Local software repository for apt-get

We use to apt-get the packages to install in Debian derivative of Linux. The packages are mostly downloaded from internet based repositories and locally cached at /var/cache/apt/archives directory. In case we reinstall the Linux, we need to download the packages once again to install through apt-get or synaptic GUI tool. To avoid this situation we can backup the *.deb files available in /var/cache/apt/archives path in some other partition than root. After re-installation, we can create a local repository of these packages to avoid downloading again. Another advantage is that this repository can be shared with other computers too. I personally faced this with Ubuntu 5.10 and here is the step by step HOW-TO for the same.

1. Identify the backup partition and directory for downloaded *.deb files (e.g.: /home/swamytk/packages).
2. $ mkdir -p /home/swamytk/packages/archives/dists/main/mysection/binary-i386
3. $ cp /var/cache/apt/archives/*.deb /home/swamytk/packages/archives/dists/main/mysection/
4. $ cd /home/swamytk/packages/archives
5. $ apt-ftparchive packages . > ./dists/main/mysection/binary-i386/Packages
6. $ cd ./dists/main/mysection/binary-i386/
7. $ gzip Packages
8. Re-install the Linux distribution.
9. Add the following entry in /etc/apt/sources.list file.
deb file:/home/swamytk/packages/archives main mysection
10. # apt-get update

That is it. Now you have all your last downloaded files as local repository. Use apt-get or synaptic to go ahead! Enjoy the beauty of apt-get from Debian.

Share this post


  1. But this is not good. After this steps you will have not sorted repository. So can you add categorisation to those steps as apt-move?

  2. Thanks a bunch! Exactly what I was looking for! Now why hasn’t someone built in a simple local command for apt that would retreive dependancies?

Leave a Reply

Your email address will not be published. Required fields are marked *