Ir para o conteúdo
ou

Software livre Brasil

 Voltar a Blog
Tela cheia

Pbuilder and pdebuild to sign deb package automagically

20 de Setembro de 2013, 22:21 , por Software Livre Brasil - 0sem comentários ainda | Ninguém está seguindo este artigo ainda.
Visualizado 58 vezes

To create a deb package (debian way) it is hard work. After spending some time working on that, you will feel more comfortable but the package building still is a little bit complex. Mainly if you add tests.

A good tool to create a deb package automatically is pbuilder. It creates a chroot jail and it allows to build deb packages for Debian and Ubuntu.

Create chroot jails environment

Debian Sid/Unstable em AMD64

1
2
$sudo pbuilder create --basetgz /var/cache/pbuilder/base-sid-amd64.tgz \
    --distribution sid

Debian Wheezy (Stable) I386 (ia32)

1
2
$sudo pbuilder create --basetgz /var/cache/pbuilder/base-stable-i386.tgz \
    --distribution stable --architecture i386

If you are using Debian and you want to build a deb package to Ubuntu. It can be done adding the Ubuntu repository public key in apt keyring before pbuilder use. Bellow is an example with Ubuntu Raring Ringtail (13.04).

1
2
3
4
5
$sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32

$sudo pbuilder create --basetgz /var/cache/pbuilder/base-raring-amd64.tgz \
    --distribution raring --mirror http://ftp.ubuntu.com/ubuntu \
    --debootstrapopts --keyring=/etc/apt/trusted.gpg

Building packages

pbuilder

1
2
3
4
5
6
7
8
9
10
11
#Debian Sid
$sudo pbuilder build --basetgz /var/cache/pbuilder/base-sid-amd64.tgz \
    --distribution sid foobar*.dsc

#Debian Stable 
$sudo pbuilder build --basetgz /var/cache/pbuilder/base-stable-i386.tgz \
    --distribution stable foobar*.dsc

#Ubuntu Raring
$sudo pbuilder build --basetgz /var/cache/pbuilder/base-raring-amd64.tgz \
    --distribution raring foobar*.dsc

When you try to use pbuilder is very common to sign .dsc and .changes files automatically.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Sid
$sudo pdebuild --auto-debsign --debsign-k XXXXXXXX --  \
    --basetgz /var/cache/pbuilder/base-sid-amd64.tgz --distribution sid \
    foobar*.dsc

# Stable i386
$sudo pdebuild --auto-debsign --debsign-k XXXXXXXX --  \
    --basetgz /var/cache/pbuilder/base-stable-i386.tgz \
    --distribution stable --architecture i386 foobar*.dsc

# Ubuntu Raring
$sudo pdebuild --auto-debsign --debsign-k XXXXXXXX --  \
    --basetgz /var/cache/pbuilder/base-raring-amd64.tgz \
    --distribution raring  --mirror http://ftp.ubuntu.com/ubuntu \
    foobar*.dsc

Updating chroot environment

If one needs to update these created chroots, it can be done as the examples bellow.

1
2
3
4
5
6
7
8
9
10
11
# Debian Sid
$pbuilder update --basetgz /var/cache/pbuilder/base-sid-amd64.tgz \
    --distribution sid

# Debian Stable i386
$pbuilder update --basetgz /var/cache/pbuilder/base-stable-i386.tgz \
    --distribution stable --architecture i386

# Ubuntu Raring
$pbuilder update --basetgz /var/cache/pbuilder/base-raring-amd64.tgz \
    --distribution raring

The files and deb packages built are at ”/var/cache/pbuilder/result/”. But it can easly be changed using –buildresult option, take a look at pbuilder manual for more details.

Conclusion

Pbuilder and pdebuild are good tools that can be used in many ways, mainly to build tests automation. If you want to know more, take a look at manuals ($man pbuilder, man pdebuild) and you can find good tips about automation building in Debian and Ubuntu wiki.


Fonte: http://www.fernandoike.com/2013/09/20/pbuilder-and-pdebuild-to-sign-deb-package-automagically/

0sem comentários ainda

Enviar um comentário

Os campos são obrigatórios.

Se você é um usuário registrado, pode se identificar e ser reconhecido automaticamente.