Why a local package repository
If you are packaging software for Debian Linux or (K)Ubuntu sometimes you need not only one package, but you have to provide a dependency like a library or whatever. When those dependencies are not in the official repositories, the only way to fulfill those dependencies is to put your package inside the repository.
But what, if you don't have the permission to upload to main/universe/multiverse? So, inject your packages to your pbuilder enviroment via a local apt-get repository.
In this document I will describe how to setup a local apt-get repository, how to upload it to your root server via rsync and how to change your pbuilders sources.list.
You might wish to also check out LocalAptGetRepositoriesTrivial for a slightly easier way to make a local repository.
Requirements
You need to install the following packages:
- pbuilder
- dput
- mini-dinstall
- rsync
Installation
The installation of pbuilder is described at PbuilderHowto, so I won't repeat it here. The other tools you can install with:
$ sudo apt-get install dput mini-dinstall rsync
Configuration
Well, you need to configure the dput and mini-dinstall tools. I will show you how my configuration looks so you can adjust it for your needs.
dput
* Create $HOME/.dput.cf with the following content:
[local] fqdn = localhost method = local incoming = ~/archive/mini-dinstall/incoming allow_unsigned_uploads = 1 post_upload_command = mini-dinstall --batch
* Create the required directories
$ mkdir -p $HOME/archive/mini-dinstall/incoming
mini-dinstall
Ok, this is something which needs some extra explanation, but first the setup:
* Create $HOME/.mini-dinstall.conf with the following content:
[DEFAULT] architectures = all, i386 archivedir = /home/shermann/archive use_dnotify = 0 verify_sigs = 0 extra_keyrings = /home/shermann/.gnupg/pubring.gpg mail_on_success = 0 archive_style = flat poll_time = 40 mail_log_level = NONE generate_release = 1 release_description = shermanns ubuntu packages [hoary] [breezy]
Explanation:
- the DEFAULT group sets
everything which is default to all repositories. If you gpg pubkey is inside the Ubuntu/Debian pub-keyring, you need to verify_sigs = 1, for me te extra_keyrings weren't working. I have to figure out why, but later
- hoary and breezy Groups
describing the two repositories, one for hoary and one for the next ubuntu generation breezy. When you upload the packages, you have to be sure, what distribution it is. For example if you set in your <app>-version/debian/changelog as distribution "hoary" the package will be moved into the hoary distribution.
Ready to Upload ?
Now, after configuring the required tools we're ready to upload the packages.
Let's say, that we build packages for Ubuntu Breezy and they are laying in $HOME/myPackages/ you should see after a ls -la the following listing:
-rw-r--r-- 1 user group 340 2005-04-12 12:42 qinx_1.4-0ubuntu1.dsc -rw-r--r-- 1 user group 765 2005-04-12 12:44 qinx_1.4-0ubuntu1_i386.changes -rw-r--r-- 1 user group 206702 2005-04-12 12:44 qinx_1.4-0ubuntu1_i386.deb -rw-r--r-- 1 user group 916 2005-04-12 12:40 qinx_1.4-0ubuntu1_source.changes -rw-r--r-- 1 user group 663497 2005-04-12 12:42 qinx_1.4-0ubuntu1.tar.gz
Now, we want to upload this source and binary package to our local repository. This package has as distribution "breezy", so it will be uploaded to the "breezy" repository. Do the following:
$ dput local qinx_1.4-0ubuntu1_i386.changes
Well, if everything went fine, you will find in $HOME/archive/breezy/ this:
-rw-r--r-- 1 user group 2150 2005-04-13 13:17 Packages -rw-r--r-- 1 user group 774 2005-04-13 13:17 Packages.gz -rw-r--r-- 1 user group 340 2005-04-13 13:17 qinx_1.4-0ubuntu1.dsc -rw------- 1 user group 765 2005-04-13 13:17 qinx_1.4-0ubuntu1_i386.changes -rw-r--r-- 1 user group 206702 2005-04-13 13:17 qinx_1.4-0ubuntu1_i386.deb -rw-r--r-- 1 user group 663497 2005-04-13 13:17 qinx_1.4-0ubuntu1.tar.gz -rw-r--r-- 1 user group 689 2005-04-13 13:17 Release -rw-r--r-- 1 user group 868 2005-04-13 13:17 Sources -rw-r--r-- 1 user group 425 2005-04-13 13:17 Sources.gz
Is it? If not, go back to the beginning and try again
Changing your systems apt-get sources.list
Now you're ready to change your local systems apt-get sources list to let it know about your local package repository.
Do this:
$ sudo vi /etc/apt/sources.list
and add the following lines to it (please replace $HOME with the correct pathname to your home):
deb file:///$HOME/archive breezy/ deb-src file:///$HOME/archive breezy/
After adding these two lines, update your local apt cache:
$ sudo apt-get update
You should see, how apt is reading your local repository.
If this is working, let's do the change for your pbuilder enviroment
Adjusting Pbuilder to use your repository
Well, if you followed the PbuilderHowto you should have a directory like /etc/pbuilder/apt.config/. In this directory there is also a copy of the old sources.list of your system.
You have to know now, pbuilder is working in a chroot enviroment, so it doesn't know anything about your $HOME directory. It means you have to setup a remote repository for your packages.
If you have your own server
I'm in the position to have a Root-Server (ok, it's running with Gentoo, but what the hell ;)) and I'm running an Apache webserver so I setup a virtualhost for my own package repository.
Say, my remote repository is in the directory /var/www/ubuntu.linux-server.org/htdocs/archive/ and I have write permissions on this directory, I have to synchronize now my local repository with the remote one.
If you know the magics of rsync now, it will be easy to do this, without having a rsync daemon running. SSH + rsync are good buddies
Ok, time to sync local with remote, try this:
$ cd $HOME/archive $ rsync -azrptL --progress --delete-after -e "ssh" breezy user@host:/var/www/ubuntu.linux-server.org/htdocs/archive/
That's it for syncing. Easy, isn't it?
If you have shared hosting
On the other hand, if you don't have access to your own server, but want to use shared hosting for your remote repo, there is a guide on Setting up your own Ubuntu repository on Dreamhost, which should be applicable, no matter what hosting service you're using.
ok, now you have your own remote package repository. It's time to adjust the pbuilder enviroment.
Changes to the pbuilder enviroment
Ok, vi the /etc/pbuilder/apt.config/sources.list
$ sudo vi /etc/pbuilder/apt.config/sources.list
and add these two lines (replace <url to repository> with your URL)
deb http://<url to repository>/ breezy/ deb-src http://<url to repository>/ breezy/
save it and now update the pbuilder:
$ sudo pbuilder update --distribution breezy --override-config
You should see, how apt-get is updating inside the pbuilders enviroment its cache.
Finally
Yeah, you did it. Now you can build your new packages with your self-made dependencies. Have fun.
If anything is not clear, please leave a comment with the comment function on this page.