| Trouble viewing this page? Give Feedback .
Try my blog on: Ajax Version

Thursday, March 05, 2009

How to Make a Local (Offline) Repository in Ubuntu / Debian

If you are in a place where you dont have internet (or have a bad one) You want to download .deb packages and install them offline. Each deb file is packaged as a seperate unit but may contain dependencies (recursively). apt-get automagically solves all the dependencies and installs all that are necessary. Manually install deb files one by one resolving each dependency would be tedious.

A better approach is to make your own local repository. Before you actually make a repo, You need *all* deb files. You dont practically have to mirror all of the packages from the internet, but enough to resolve all dependencies. Also, You have to make sure, you are getting debs of the correct architecture of your system (i386 etc)

# 1. make a dir accessible (atleast by root)
sudo mkdir /var/my-local-repo
# 2. copy all the deb files to this directory.
# 3. make the directory as a 
sudo dpkg-scanpackages  /var/my-local-repo /dev/null > \

# 4. add the local repo to sources 
echo "deb file:/var/my-local-repo ./" > /tmp/my-local.list
sudo mv /tmp/my-local.list /etc/apt/sources.list.d/my-local.list
sudo apt-get update
You can now use synaptic or cli
sudo apt-get install the-package-from-local

If all dependencies are available, it will install and be done. IF not, download those deb files (dependencies) too, and repeat steps 2 and 3.

© 2000