I leave notes here that I find particularly worth remembering myself.
Howto build your own Debian repository
Posted 06-01-2010 at 05:04 AM by bittner
Updated 06-07-2010 at 07:08 AM by bittner (added reference (background reading))
Updated 06-07-2010 at 07:08 AM by bittner (added reference (background reading))
Tags administration, debian, packages
If you write software for Linux and you write them for Debian systems (Debian, Ubuntu, and others) you may want to provide your software as .deb installation packages. And one day eventually you will want to set up a repository so others can download and install your software without fuzz.
If you look at a Debian mirror (e.g. http://ftp.debian.org/debian/) you will find out one day that packages and meta information is split up into two main directories on the root level:
To build our repository we need to
Directory Structure
If you have it simple your directory structure will look like this:
Your .deb Files
For each software you will eventually add directories in pool, if you love hierarchical order. But those subdirectories are optional. If you provide packages for different architectures give them distict names (e.g. mysoftware-common_0.1.0-4_i386.deb, mysoftware-common_0.1.0-4_amd64.deb, etc.) and put them into the same directory in the pool subtree.
Metadata Generation
For the last step we need to prepare a configuration file for apt-ftparchive, let's call it personal-archive.conf:
You can use this configuration almost right away, the only unfortunate thing here is the ArchiveDir option (= your repository root): This must be an absolute path name. So, unless you're also called bittner change it.
Then run the following two commands to generate the metadata files of your repository:
Now you have all your files in place in the dists subtree as well (check for Release and the Packages* files, and see what is in there!). Running these commands will be necessary again each time you copy an updated version of any .deb file into the pool tree of your repository.
Providing Web Access To Your Repository
If you want others to access your repository over the web you can set up an Apache web server and place your personal repository in a Virtual Host in there. But that's another story... (a rather simple one)
P.S.: It's interesting to note that apt-ftparchive will not descend your pool subtree if you forget about the Tree section in the configuration file. Also, the --contents=off shouldn't be necessary, but the APT::FTPArchive::Contents directive seems to be ignored. I believe these are bugs of the tool, correct me if I'm wrong...
References
If you look at a Debian mirror (e.g. http://ftp.debian.org/debian/) you will find out one day that packages and meta information is split up into two main directories on the root level:
- dists ... contains meta information split up in releases, target platforms (architecture), etc.
- pool ... contains the actual pool of software installation packages (.deb files)
To build our repository we need to
- set up the necessary directory structure
- put our (updated) .deb files into the pool tree
- run two commands using the apt-ftparchive tool to generate the repository meta data files (Release file, and Packages files for each architecture)
Directory Structure
If you have it simple your directory structure will look like this:
Code:
(repository root) + dists | + stable (= suite) | + main (= section) | + binary-i386 (= architecture) + pool + main (= section) + m (= first letter of your software's name) + mysoftware (= umbrella name of your packages)
For each software you will eventually add directories in pool, if you love hierarchical order. But those subdirectories are optional. If you provide packages for different architectures give them distict names (e.g. mysoftware-common_0.1.0-4_i386.deb, mysoftware-common_0.1.0-4_amd64.deb, etc.) and put them into the same directory in the pool subtree.
Metadata Generation
For the last step we need to prepare a configuration file for apt-ftparchive, let's call it personal-archive.conf:
Code:
APT::FTPArchive::Release { Version "1.0"; Origin "Peter Bittner Linux Hacking"; Label "Personal Debian Repository"; Suite "personal"; Codename "personal"; Architectures "i386"; Components "main"; Description "My personal repository for Debian/Lenny"; } APT::FTPArchive::Contents "no"; Default { Packages::Extensions ".deb"; Packages::Compress ". gzip bzip2"; Sources::Compress ". gzip bzip2"; MaxContentsChange 25000; }; Dir { ArchiveDir "/home/bittner/Development/debian/mirror"; }; Tree "dists/personal" { Sections "main"; Architectures "i386"; }; TreeDefault { Directory "pool/personal/main"; }; BinDirectory "pool/personal" { Packages "dists/personal/main/binary-i386/Packages"; };
Then run the following two commands to generate the metadata files of your repository:
Code:
$ apt-ftparchive generate --contents=off personal-archive.conf $ apt-ftparchive -c personal-archive.conf release dists/personal > dists/personal/Release
Providing Web Access To Your Repository
If you want others to access your repository over the web you can set up an Apache web server and place your personal repository in a Virtual Host in there. But that's another story... (a rather simple one)
P.S.: It's interesting to note that apt-ftparchive will not descend your pool subtree if you forget about the Tree section in the configuration file. Also, the --contents=off shouldn't be necessary, but the APT::FTPArchive::Contents directive seems to be ignored. I believe these are bugs of the tool, correct me if I'm wrong...
References
- http://hausheer.osola.com/docs/14
- http://www.debian.org/doc/debian-policy/ch-archive.html (background reading)
Total Comments 1
Comments
-
"generate" silently fails sometimes (workaround)
Sometimes, for some reason I have not yet fully figured out apt-ftparchive generate puts old (probably cached) data into the Packages file. You only note this problem when, e.g., the .deb file size has changed and the old size doesn't match the new size anymore. In this special case apt-get will then complain:
Code:E: Failed to fetch http://.... Size mismatch
Code:$ cd /home/bittner/Development/debian/mirror $ apt-ftparchive -c personal-archive.conf packages \ pool/personal/main > dists/personal/main/binary-i386/Packages $ apt-ftparchive -c personal-archive.conf release \ dists/personal > dists/personal/Release
Posted 08-06-2010 at 08:22 AM by bittner