Differences between revisions 9 and 10
Revision 9 as of 2017-02-06 09:38:10
Size: 6087
Editor: ?Afif Elghraoui
Comment: Add a "See Also" section
Revision 10 as of 2017-02-06 11:36:37
Size: 6043
Editor: PaulWise
Comment: DebianMan
Deletions are marked like this. Additions are marked like this.
Line 195: Line 195:
 * [[https://manpages.debian.org/unstable/ubuntu-dev-tools/backportpackage.1|backportpackage(1)]]  * [[DebianMan:1/backportpackage|backportpackage(1)]]

Assumptions: Architecture is amd64, stable distribution is squeeze, 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 Squeeze in a specific directory, use:

   1 sudo cowbuilder --create --distribution squeeze --basepath /var/cache/pbuilder/base-squeeze.cow

Step 2: Customize your pbuilderrc

Just copy the file /usr/share/doc/pbuilder/examples/pbuilderrc to ~/.pbuilderrc-squeeze, and alter the following entries to the values shown below:

   1 BASEPATH=/var/cache/pbuilder/base-squeeze.cow
   2 DISTRIBUTION=squeeze

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.

   1 $ gpg --gen-key
   2 ...
   3 $ gpg -K
   4 ...
   5 sec   1024D/D3D9AA84 2009-07-20
   6 uid                  Foo Bar (ARCHIVE KEY) <foo@www.example.com>
   7 ssb   2048g/6856F4A7 2009-07-20
   8 $ gpg --export -a D3D9AA84 >foo.public.key

- New Foo's archive key is 3A3CB5A6 - Publish foo.public.key file. - Create Foo's archive skeleton:

   1 $ umask 022
   2 $ mkdir -p $HOME/Backports/debian/pool/main
   3 $ mkdir -p $HOME/Backports/debian/dists/squeeze/main/binary-amd64
   4 $ mkdir -p $HOME/Backports/debian/dists/squeeze/main/source
   5 $ cd $HOME/Backports/debian
   6 $ cat > dists/squeeze/main/binary-amd64/Release << EOF
   7 Archive: unstable
   8 Version: 4.0
   9 Component: main
  10 Origin: Foo
  11 Label: Foo
  12 Architecture: amd64
  13 EOF
  14 $ cat > dists/unstable/main/source/Release << EOF
  15 Archive: unstable
  16 Version: 4.0
  17 Component: main
  18 Origin: Foo
  19 Label: Foo
  20 Architecture: source
  21 EOF
  22 $ cat >aptftp.conf <<EOF
  23 APT::FTPArchive::Release {
  24   Origin "Foo";
  25   Label "Foo";
  26   Suite "squeeze";
  27   Codename "squeeze";
  28   Architectures "amd64";
  29   Components "main";
  30   Description "Public archive for Foo";
  31 }
  32 EOF
  33 $ cat >aptgenerate.conf <<EOF
  34 Dir::ArchiveDir ".";
  35 Dir::CacheDir ".";
  36 TreeDefault::Directory "pool/";
  37 TreeDefault::SrcDirectory "pool/";
  38 Default::Packages::Extensions ".deb";
  39 Default::Packages::Compress ". gzip bzip2";
  40 Default::Sources::Compress "gzip bzip2";
  41 Default::Contents::Compress "gzip bzip2";
  42 
  43 BinDirectory "dists/squeeze/main/binary-amd64" {
  44   Packages "dists/squeeze/main/binary-amd64/Packages";
  45   Contents "dists/squeeze/Contents-amd64";
  46   SrcPackages "dists/squeeze/main/source/Sources";
  47 };
  48 
  49 Tree "dists/squeeze" {
  50   Sections "main";
  51   Architectures "amd64 source";
  52 };
  53 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/squeeze >dists/squeeze/Release;
rm -f dists/squeeze/Release.gpg ;
gpg -u D3D9AA84 -bao dists/squeeze/Release.gpg dists/squeeze/Release'|sh ;
echo 'Package archive created!'";

1;

Step 5: Add the local repository to the pbuilder options list

To ~/.pbuilderrc, add the line:

   1 BINDMOUNTS="$HOME/Backports"

And then, use sudo cowbuilder --configfile ~/.pbuilderrc-squeeze --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 squeeze 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: Add local repository to sources.list

One the main system (outside the cowbuilder chroot), add the new repository by adding the following line to /etc/apt/sources.list:

   1 deb file:///home/USER/Backports/debian squeeze main

Step 7: Build packages

To automate this task, use this script:

   1 #!/bin/sh
   2 
   3 if [ ! -n "$1" ];
   4 then
   5     echo "Usage: `basename $0` <sid_package>"
   6     exit 1;
   7 fi
   8 
   9 if [ ! -s Sources ];
  10 then
  11     wget ftp://ftp.utexas.edu/pub/debian/dists/unstable/main/source/Sources.bz2 -O - |bzcat > Sources
  12 fi
  13 
  14 FILE=$(grep-dctrl -X -S "$1" -s Directory,Files < Sources |awk '/^Directory/ { url = $NF}
  15 /\.dsc$/ { url = url "/" $NF}
  16 END { print url}')
  17 dget -d "ftp://ftp.utexas.edu/pub/debian/$FILE"
  18 sudo cowbuilder --configfile ~/.pbuilderrc-squeeze --build $(basename "$FILE")
  19 dupload -t localhost /var/cache/pbuilder/result/$(basename "${FILE%.dsc}")_amd64.changes
  20 ## Uncomment next line to automate removal post build.
  21 #dcmd rm -f $(basename "$FILE")
  22 

Now, merely running the script should build the package and put it in the archive.

See Also

Comments, corrections and suggestions for improvement welcome.