I'm setting up an apt repository to manage dependencies for servers that I build. I'm doing this because I want to be able to repeatably build the exact same server over and over again.

There are certainly tools (apt-get) to analyze a running system and download packages needed to satisfy a given requirement. For example, that's exactly what happens when I run

sudo apt-get install --download-only vim

In this case apt-get analyzes the state of the system and downloads the packages needed to install vim on my system.

I'm looking for a similar tool that would allow me to download packages to add to my own apt repository. It should do the same type of dependency analysis on the repository as apt-get does on my system, and only download packages not already in the repository. So when I run apt-get install ... on a system that points to my repository it will be able to install the package and all of its dependencies. Are there any tools available to analyze what packages I already have in my repository and then download additional packages needed?

  • Seems to me like you could do something with approx, apt-proxy, or one of the many other apt caches. Simply get everything via the proxy initially. Then adjust the proxy config so that the upstream proxies are not longer used, and instead it only uses the local cache.
    – Zoredache
    Jan 18, 2013 at 20:53
  • Thanks for the suggestion @Zoredache. However, using a proxy requires running system(s) on which packages are installed to maintain the repository. I am hoping to manage the repository and its contents independent of any system on which the packages are installed. Also, your suggestion requires changing the proxy configuration for some period of time to add new packages; during that time the proxy/repository cannot be used concurrently by existing systems in the field without the possibility of them getting undesired updates (causing undesired changes to the proxy/repository).
    – Daniel
    Jan 21, 2013 at 20:27

4 Answers 4


As @Andrea De Palo said theoretically you can just use puppet and after you install your master distro just run puppet resource package which will lists all the installed packages with the exact version, etc.

After that just create an module with all the packages listed. Moreover you can use also use puppet to customize the config files, etc.

Worth a try.

  • I'm using SaltStack, which is similar to Puppet, to build the servers. This is an interesting idea. The server will need to use public repositories during the build phase and then change to my private one once it's working. I suppose that could all be automated with Salt...
    – Daniel
    Feb 6, 2013 at 15:57

I have a trivial Makefile I use to do this, but here's the same thing in shell:

rm -f Release* Packages* new-release
dpkg-scanpackages . /dev/null > Packages
gzip -c -9 <Packages >Packages.gz
apt-ftparchive release . > new-release
mv new-release Release
gpg -abs -o Release.gpg Release

The GPG step is not needed if you don't want to sign your repository, but the effort to do so is minimal (and these days the alternate is a configuration change to disable signature checking, so you need to do something).

You then refer to the directory in your client's /etc/apt/sources.list like this:

# Local directory
deb file:///var/local/debs ./ 
# Via http(s)
deb http://foo.bar.com/debian ./

HTTPS can be a nice way to allow updates from servers across the globe without needing a VPN, I did this at a previous job piggy-backing on the CA inside our puppet deployment so it was fully automatic.


I have never used it myself, not sure it fits your needs. But you may be interested by http://wiki.debian.org/DebPartialMirror


What about using Puppet to automate package management?


You must log in to answer this question.

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