There are 4 steps to setting up your own repository
- Install
dpkg-dev
- Put the packages in a directory
- Create a script that will scan the packages and create a file
apt-get update
can read
- Add a line to your
sources.list
pointing at your repository
Install dpkg-dev
Open a terminal:
sudo apt-get install dpkg-dev
The Directory
Create a directory to keep your packages. For this example, we'll be using /usr/local/lan-repo
.
sudo mkdir -p /usr/local/lan-repo
Now move all your packages into that new directory.
Packages that have been downloaded already are usually stored on your system in /var/cache/apt/archives
. If you have installed apt-cacher
you will most likely have additional packages stored in the apt-cacher/packages
directory.
Create a script named update-lan-repo
It's a very simple three line script:
#! /bin/bash
cd /usr/local/lan-repo
sudo dpkg-scanpackages . /dev/null | gzip -9c > packages.gz
Copy and paste the above into your favorite text editor, and save it as update-lan-repo
in ~/bin
. (~
means the home directory. If ~/bin
doesn't exist already then create it. Ubuntu will automatically put that directory in your PATH. This makes it a good place to put personal scripts.)
Now let's make the script executable:
chmod u+x ~/bin/update-lan-repo
Here's how the script works:
dpkg-scanpackages
looks at all the packages in lan-repo
, and the output is compressed and written to the file packages.gz
, which apt-get update
can read (see below for a reference that explains this in full detail). /dev/null
is an empty file - that is - it's a makeshift for an override file which holds some additional information about the packages, which in our case is not really needed. See deb-override(5)
if you want to find out more about it.
We need to add your local repo to your sources.list file
echo "deb file:/usr/local/lan-repo ./" >> /etc/apt/sources.list
and that's it you're done.
CD/DVD Option
You can store the directory containing the .deb file to a CD/DVD and use that as a repository as well (good for sharing between computers). To use the CD as a repository:
simply run the command:
sudo apt-cdrom add
using the new repository.
Then whenever you store a new debian package in the lan-repo directory, run:
sudo update-lan-repo
sudo apt-get update
Now your local packages can be manipulated with Synaptic, aptitude and the apt commands: apt-get
, apt-cache
, etc. When you attempt to apt-get install, any dependencies will be resolved for you, as long as they can be met.