Repository

Create folders for the package files you plan to keep in your repository. Here is an example: in your home folder, create a new folder called repository in which you will keep all your downloaded packages. If you plan to burn the package files onto a CD, I suggest you create separate folders for each disk. The naming is up to you – disk_1, disk_2, etc (I’ll assume this naming convention throughout the rest of the tutorial). This is just to ensure that you use the next folder once your cache reaches the size of a CD (usually 700MB). If you are using a local hard drive or a DVD, you obviously have higher limits to keep in mind. If you do not plan to create a CD/DVD, you may simply dump all the files in the repository folder.

The next step is to copy all your deb files (those files that end with .deb) to the repository folder(s). Open Nautilus, navigate to /var/cache/apt/archives and copy all the deb files to the appropriate folder(s). For instance, /home/<username>/repository/disk_1 – keep an eye on the size of the folders. To do it in the terminal:

cp /var/cache/apt/archives/*.deb ~/repository/disk_1

Remember to replace <username> with your real username.
If you have many files, it may take quite a while so be patient.

Change into your repository folder:

cd ~/repository/disk_1/

Now run the following command to create the Packages.gz file that is needed to for Synaptic to “see” your repository:

sudo dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

I suggest you copy and paste this to avoid any typos.
Please note that every time you add any more .deb files to this folder, you have to create a new Packages.gz file using the above command before the new file(s) will show up in Synaptic (or Aptitude).
Be sure to install the build-essential package (sudo apt-get install build-essential) before running the above command.

There are several ways of using your newly created repository.

I) Keeping the files on a local hard disk

Edit your /etc/apt/sources.list file like so:

gksudo gedit /etc/apt/sources.list

And insert this on a new line (preferably the first):

deb file:/home/<username>/repository/disk_1/ /

Remember to replace <username> with your real username.
KDE SC users, replace gksudo gedit with kdesudo kate

Reload your package index like this:

sudo apt-get update

II) Setting up a repo on your intranet (using a web server)

This method is more useful if you want access to your repo from other machines on your network.

First, follow method I) above and install the apache web server like so:

sudo apt-get install apache2

Let’s say the ip address of the web server (and the machine with the debian packages) is 192.168.4.100. We need to tell the apache server on 192.168.4.100 where to find the downloaded files:

sudo ln -s /home/<username>/repository/disk_1/ /var/www/repo

If you’ve not tinkered with apache’s configuration files, /var/www/ is usually the default virtual host.

Right, now let’s make sure another machine on the network… say 192.168.4.101, can see the repo on 192.168.4.100. Edit the sources.list file on 192.168.4.101 like so:

gksudo gedit /etc/apt/sources.list

And insert the following on a new line:

deb http://192.168.4.100/repo/ /

Update 192.168.4.101′s package index:

sudo aptitude update

I almost always forget to open up port 80 in my firewall. If you’re like me and only allow connections to port 80 on a per-machine basis, you know what to do when you start getting connection refused errors.

II) Using a CD/DVD as a repository:

Burn the repository folder onto a CD/DVD
With the disc loaded in your drive, fire up Synaptic and click through the menus like this:

Edit –> Add CD Rom.

You will be asked to type in a description for the disc; type in anything, for instance: Offline Repository Disk1.
Click Ok.

Summary

Go to /var/cache/apt/archives and copy your debian packages to a folder of your choice, for example, /home/<username>/repository/
Change into the repository directory

cd ~/repository

and generate a Packages.gz file like this:

sudo dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

Make sure build-essential is installed (sudo aptitude install build-essential) before you run the above command.

Add the following line to your sources.list file (/etc/apt/sources.list)

deb file:/home/<username>/repository/ /

Remember to replace <username> with your real username

Reload your package index like this:

sudo apt-get update

I didn't write this article originally, find the original one here

########################

Here's a procedure to create a repository on 1 machine and update the rest of the machines manually

Begin with the machine with internet connection:

apt-get install build-essential

apt-get clean

apt-get dist-upgrade

mkdir /root/repository

cd /root/repository

cp -a /var/cache/apt/archives/*.deb .

dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

On every sucessive server:

mkdir /root/repository

scp root@allIn1_IP:/root/repository/* /root/repository/

mv /etc/apt/sources.list.d/myrepo3-pro.list /etc/apt/sources.list.d/myrepo3-pro.list.disabled

mv /etc/apt/sources.list.d/myrepo3.list /etc/apt/sources.list.d/myrepo3.list.disabled

mv /etc/apt/sources.list /etc/apt/sources.list.disabled

echo "deb file:/root/repository/ /" > /etc/apt/sources.list

apt-get update

apt-get dist-upgrade

mv /etc/apt/sources.list.d/myrepo3-pro.list.disabled /etc/apt/sources.list.d/myrepo3-pro.list

mv /etc/apt/sources.list.d/myrepo3.list.disabled /etc/apt/sources.list.d/myrepo3.list

mv /etc/apt/sources.list.disabled /etc/apt/sources.list
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License