Let's assume:

  • I have a mirror of the source repository locally.
  • I only want to build for the architecture I'm running, which is i386 in my case.
  • I'm not interested in customisation. In fact, I want the resulting binary packages to be as close to official ones as possible. From there on, I'll take care of how they are organised. I think I'll use reprepro.
  • I want it to be as easy as possible.
  • 1
    For modern RPM-based distributions, the answer is: run mock in a loop, and then deal with the fringe cases by hand. (This is how CentOS is built from RHEL source, for example.) I have no idea about the Debian/dpkg equivalent, though, which is why this is a comment rather than an answer.
    – mattdm
    Mar 7, 2011 at 21:33

2 Answers 2


Debian already does this internally, to build the binary packages that they offer for download, and most of the tools is in the distribution. (Everything except some glue scripts, I think.)

Tools that may interest you include:

  • debian-builder: rebuild packages from source code
  • buildd, buildd: automatically build some packages
  • pbuilder: personal package builder (in a chroot, mainly intended for Debian developers)
  • More generally, look at packages tagged devel::debian or works-with::software:source (aptitude search '?tag(devel::debian) | ?tag(works-with::software:source)').

Maybe something like this?


# This gets a list of all available packages
for i in $(dpkg -l \* | awk '/^[a-z]/ {print $2}')
  # This downloads and unpacks the source.
  # Any src packages already properly unpacked in the cwd won't be downloaded a second time.
  apt-get source $i
  apt-get build-dep -y $i

# This finds all buildable directories
for i in $(find . -name debian -type d | sed s/debian.*//g)
  cd $i
  debian/rules binary
  cd -

I know you said that you have the packages already, but I'm not sure what format they are in. If you already have all the packages properly unpacked in your cwd then apt will skip that package and move onto the next one. You can also pass -s to apt-get to test the commands.

Almost all packages should build in one shot like this, if you're using the same release that you're trying to build.

You will need lots of storage, and lots of time.

  • What u mean by apt will skip that package...?
    – tshepang
    Mar 8, 2011 at 18:56
  • What does dpkg -l \* | awk '/^[a-z]/ {print $2}' do exactly?
    – tshepang
    Mar 8, 2011 at 18:58
  • 1
    @tshepang when I say "apt will skip" I mean that apt will skip downloading any source package that is already properly downloaded and unpacked. The dpkg | awk command gets a unique list of all packages available in your /etc/sources.list.
    – bahamat
    Mar 8, 2011 at 21:54
  • You wanna add these clarifications to the answer itself?
    – tshepang
    Mar 8, 2011 at 21:57
  • @tshepang updated.
    – bahamat
    Mar 9, 2011 at 5:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .