Assumptions: Architecture is amd64, stable distribution is lenny, mirror used is ftp://ftp.utexas.edu/pub/debian
Step 1: Create a build chroot
To do this, use pbuilder or cowbuilder and create a stable chroot. For example, to create a chroot for Lenny in a specific directory, use:
DIST=lenny sudo cowbuilder --create --basepath /var/cache/pbuilder/base-lenny.cow
Step 2: Customize your pbuilderrc
Just copy the file /usr/share/doc/pbuilder/examples/pbuilderrc to ~/.pbuilderrc-lenny, and alter the following entries to the values shown below:
BASEPATH=/var/cache/pbuilder/base-lenny.cow DISTRIBUTION=lenny
and any other options as needed.
Step 3: Prepare package archive
Choose a location on your system where packages can be stored and served from. For example, you can choose $HOME/Backports.
This is assuming that the packages are stored on your own machine.
- Create a public key for your repository. - Create directories for the archive.
$ gpg --gen-key ... $ gpg -K ... sec 1024D/D3D9AA84 2009-07-20 uid Foo Bar (ARCHIVE KEY) <foo@www.example.com> ssb 2048g/6856F4A7 2009-07-20 $ gpg --export -a D3D9AA84 >foo.public.key
- New Foo's archive key is 3A3CB5A6 - Publish foo.public.key file. - Create Foo's archive skeleton:
$ umask 022 $ mkdir -p $HOME/Backports/debian/pool/main $ mkdir -p $HOME/Backports/debian/dists/lenny/main/binary-amd64 $ mkdir -p $HOME/Backports/debian/dists/lenny/main/source $ cd $HOME/Backports/debian $ cat > dists/lenny/main/binary-amd64/Release << EOF Archive: unstable Version: 4.0 Component: main Origin: Foo Label: Foo Architecture: amd64 EOF $ cat > dists/unstable/main/source/Release << EOF Archive: unstable Version: 4.0 Component: main Origin: Foo Label: Foo Architecture: source EOF $ cat >aptftp.conf <<EOF APT::FTPArchive::Release { Origin "Foo"; Label "Foo"; Suite "lenny"; Codename "lenny"; Architectures "amd64"; Components "main"; Description "Public archive for Foo"; } EOF $ cat >aptgenerate.conf <<EOF Dir::ArchiveDir "."; Dir::CacheDir "."; TreeDefault::Directory "pool/"; TreeDefault::SrcDirectory "pool/"; Default::Packages::Extensions ".deb"; Default::Packages::Compress ". gzip bzip2"; Default::Sources::Compress "gzip bzip2"; Default::Contents::Compress "gzip bzip2"; BinDirectory "dists/lenny/main/binary-amd64" { Packages "dists/lenny/main/binary-amd64/Packages"; Contents "dists/lenny/Contents-amd64"; SrcPackages "dists/lenny/main/source/Sources"; }; Tree "dists/lenny" { Sections "main"; Architectures "amd64 source"; }; EOF
Step 4: For update of repository automatically
You need ssh running on your machine to do this. I haven't figured a way to avoid it, since dupload does not provide ordinary "cp" as a transport method.
Create the following ~/.dupload.conf:
package config; $preupload{'changes'} = ''; $cfg{"localhost"} = { fqdn => "localhost", method => "scpb", incoming => "/home/USER/Backports/debian/pool/main", # The dinstall on ftp-master sends emails itself dinstall_runs => 1, }; $cfg{'localhost'}{postupload}{'changes'} = " echo 'cd /home/USER/Backports/backports/debian ; apt-ftparchive generate -c=aptftp.conf aptgenerate.conf; apt-ftparchive release -c=aptftp.conf dists/lenny >dists/lenny/Release; rm -f dists/lenny/Release.gpg ; gpg -u D3D9AA84 -bao dists/lenny/Release.gpg dists/lenny/Release'|sh ; echo 'Package archive created!'"; 1;
Step 5: Add the local repository to the pbuilder options list
To ~/.pbuilderrc, add the line:
BINDMOUNTS="$HOME/Backports"
And then, use sudo cowbuilder --configfile ~/.pbuilderrc-lenny --login --save-after-login
$ sudo cowbuilder --login --save-after-login -> Copying COW directory -> Invoking pbuilder -> Running in no-targz mode -> copying local configuration -> mounting /proc filesystem -> mounting /dev/pts filesystem -> Mounting /home/USER/Backports -> policy-rc.d already exists Obtaining the cached apt archive contents -> entering the shell root@host:/# echo deb file:////home/USER/Backports/debian lenny main >> /etc/apt/sources.list root@host:/# su;apt-key add - # paste the output of "gpg -a --export D3D9AA84" here root@host:/# exit
Step 6: Build packages
To automate this task, use this script:
if [ ! -n "$1" ]; then echo "Usage: `basename $0` <sid_package>" exit 1; fi if [ ! -s Sources ]; then wget ftp://ftp.utexas.edu/pub/debian/dists/unstable/main/source/Sources.bz2 -O - |bzcat > Sources fi FILE=$(grep-dctrl -X -S "$1" -s Directory,Files < Sources |awk '/^Directory/ { url = $NF} /\.dsc$/ { url = url "/" $NF} END { print url}') dget -d "ftp://ftp.utexas.edu/pub/debian/$FILE" sudo cowbuilder --configfile ~/.pbuilderrc-lenny --build $(basename "$FILE") dupload -t localhost /var/cache/pbuilder/result/$(basename "${FILE%.dsc}")_amd64.changes ## Uncomment next line to automate removal post build. #dcmd rm -f $(basename "$FILE")