Purpose: In this blog post we will learn how to create your own local Debian like package repository so that you can use apt-get install commands to install packages just like the way you install from Debian repositories. Let’s say you have created your own customized Debian packages and you would like them to install just like the Debian main packages – you can achieve this by creating your own local repository.


Before we begin, I would like to point out that there are two methods to create a local Debian repository – long (and more correct) method and the short (but quick) method. For more information, refer to the Debian Repository HOWTO. In this post, we will see the short method. I suggest that if you yourself are going to use the repository then probably short method is sufficient. But if you plan to upload your packages to a server from where a lot of people are going to download then you should setup your repository using long method.

So let’s get started…

Step 1:Prepare your system – Web-Server & dpkg-dev

Make sure you have a web-server or a FTP server running on your system on which you would like to host your packages. You can refer to the mediawiki post to see how to get a Apache web server running on a Debian system. Once you have installed the web-server, then install the following package:

# apt-get install dpkg-dev

We will require this package later on when we create a script which will scan our local packages.

Step 2: Create repository directory

By default, the directory /var/www/ is your web-server root directory which is publicly accessible. Let’s create our repository directory inside the web-server’s root directory:

# cd /var/www
# mkdir debian
# mkdir debian/binary
# mkdir debian/source

As you can see, we have created two directories – binary and source – inside “debian” directory – one for binary deb packages and the other for source deb packages.

Step 3: Create package scanning script

Now create a bash shell script, let’s say gen_packages.sh with following contents:

cd /var/www/debian
echo "Generating indexes for your binary and source packages..."
dpkg-scanpackages binary /dev/null | gzip -9c > binary/Packages.gz
dpkg-scansources source /dev/null | gzip -9c > source/Sources.gz
echo "Index generation finished!"

Make the script executable:

# chmod 755 gen_packages.sh

Step 4: Upload packages to your new repository

Now upload your own Debian packages into the binary/source directories depending on the type of the packages. For example, I have two Debian binary  packages:


which I copied/uploaded into my /var/www/debian/binary directory.

Step 5: Index the packages

Every time you add/remove/modify a package in your local repository you should run the gen_packages.sh script to regenerate the indexes.

# ./gen_packages.sh

Step 6: Add local repository to your sources file

Now you need to add the local repository into the sources.list file of your local client machines which will use apt-get to install packages on your local LAN.

# nano /etc/apt/sources.list

and add the following lines:

deb binary/
deb-src source/

Note: is the IP-address of Debian system on which we have created local repositories and uploaded packages.

and update the sources repositories.

# apt-get update

Step 7: Install packages

Finally you can start installing packages from your local clients which will fetch the packages from your server (

# apt-get install psb-firmware psb-kernel-headers

That’s it! Save a great deal of time with this method and install packages in a semi-professional way.

Happy local repositoring!

Be Sociable, Share!