sarathonline.com/blog
Try my blog on: Ajax Version
Search

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 > \
 /var/my-local-repo/Packages

# 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.

2 comments:

flyinglizard98 said...

okay. Question: is there a simple way to get my hands on *all* deb files? Right now all I'm seeing is grabbing them one by one from http://packages.ubuntu.com/

Sarath Chandra Pandurangi said...

I dont know what you mean by *all*, because the repository would be very big (hence the division into debs)

But, say for jaunty you want all packages, you can go to http://packages.ubuntu.com/jaunty/allpackages and
use a download manager and get the ones you want. (The page itself is more than 5MB, so.. use some discretion)

Post a Comment

© SarathOnline.com 2000-'09