HOWTO: Create your own local Debian repository
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.
Basics
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:
#!/bin/bash
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:
psb-firmware_0.30-1lenny1_all.deb
psb-kernel-headers_4.41.1-1lenny1_all.deb
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 http://192.168.0.100/debian/ binary/
deb-src http://192.168.0.100/debian/ source/
Note: 192.168.0.100 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 (192.168.0.100)
# 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!


Email Subscription









September 21st, 2009 at 6:57 am
[...] the original post: how to set-up or create your own local Debian repository to … By admin | category: directory script | tags: package, publicly-accessible, will-require, [...]
September 22nd, 2009 at 10:54 am
[...] install commands to install packages just like the way you install from Debian repositories. More here Before we begin, I would like to point out that there are two methods to create a local Debian [...]
September 23rd, 2009 at 1:26 pm
Another simple solution for creating small repositories is reprepro:
* http://packages.debian.org/reprepro
:-)
Reply to this comment
Admin Reply:
September 23rd, 2009 at 10:35 pm
Hi Adam,
That is an interesting package. I will try it out soon. Never found about it when I was researching on this topic.
Reply to this comment
July 16th, 2010 at 9:08 am
Awesome post! I’m using your script to regenerate the indexes after uploading the files, but I get this since I have updated my package a few times:
sudo cp ./../../vipre-2.1-4.deb /var/www/debian/binary/
sudo /usr/sbin/gen_packages.sh
Generating indexes for your binary and source packages…
! Package vipre (filename binary/vipre-2.1-2.deb) is repeat;
ignored that one and using data from binary/vipre-2.1-4.deb !
! Package vipre (filename binary/vipre-2.1-3.deb) is repeat;
ignored that one and using data from binary/vipre-2.1-4.deb !
** Packages in archive but missing from override file: **
vipre
Wrote 1 entries to output Packages file.
Index generation finished!
===================================================
This is where the files are being “uploaded” to:
nblade@ubuntu:~/vipreblade/build$ tree /var/www/debian/
/var/www/debian/
|– binary
| |– Packages.gz
| |– vipre-2.1-2.deb
| |– vipre-2.1-3.deb
| `– vipre-2.1-4.deb
`– source
`– Sources.gz
2 directories, 5 files
==================================
How do I get rid of the warnings regarding the “repeat” files and the “missing from override”?
Thanks!
Reply to this comment
September 24th, 2010 at 2:34 pm
[...] then no need to process the packages in Suse. Just set up a local repository in your Mint OS. http://linux.koolsolutions.com/2009/09/21/…an-repository/ ( Found with : Google .. local debian repo .. ) [...]
November 16th, 2010 at 6:38 am
Nice post, but apt-mirror would be much more simple.
Reply to this comment
August 12th, 2011 at 9:13 pm
[...] you already have it all set up, then the steps outlined in this blog post will probably be enough to get you going in the right [...]
June 28th, 2012 at 8:55 am
I tried reprepro and had no luck for what I am doing, but this article worked the first time. Yes, I get warnings when running the script but the end result is that my update manager tells me when I have updated the repo, and it installs the new version correctly. I love having my own repo! Thanks much!!!
Reply to this comment