6. Setting up sbuild¶
sbuild
simplifies building Debian/Ubuntu binary package from source
in clean environment. It allows to try debugging packages in environment
similar (as opposed to pbuild
) to builders used by Launchpad.
It works on different architectures and allows to build packages for other releases. It needs kernel supporting overlayfs.
6.1. Installiere sbuild¶
To use sbuild, you need to install sbuild and other required packages
and add yourself to the sbuild
group:
$ sudo apt install debhelper sbuild schroot ubuntu-dev-tools
$ sudo adduser $USER sbuild
Erstelle .sbuildrc
im Home-Verzeichnis mit folgendem Inhalt:
# Name to use as override in .changes files for the Maintainer: field
# (mandatory, no default!).
$maintainer_name='Your Name <user@example.org>';
# Default distribution to build.
$distribution = "bionic";
# Build arch-all by default.
$build_arch_all = 1;
# When to purge the build directory afterwards; possible values are "never",
# "successful", and "always". "always" is the default. It can be helpful
# to preserve failing builds for debugging purposes. Switch these comments
# if you want to preserve even successful builds, and then use
# "schroot -e --all-sessions" to clean them up manually.
$purge_build_directory = 'successful';
$purge_session = 'successful';
$purge_build_deps = 'successful';
# $purge_build_directory = 'never';
# $purge_session = 'never';
# $purge_build_deps = 'never';
# Directory for writing build logs to
$log_dir=$ENV{HOME}."/ubuntu/logs";
# don't remove this, Perl needs it:
1;
Ersetzen Sie „Your Name <user@example.org>“ mit Ihrem Namen und Ihrer E-Mail-Adresse. Ändern Sie die Standarddistribution, wenn Sie wollen, aber denken Sie daran, dass Sie die Zieldistribution beim Ausführen des Befehls angeben können.
Wenn Sie Ihre Sitzung noch nicht neugestartet haben, nachdem Sie sich zur Gruppe sbuild
hinzugefügt haben, geben Sie folgendes ein:
$ sg sbuild
GPG-Schlüsselpaar für sbuild generieren und chroot für die angegebene Version erzeugen:
$ sbuild-update --keygen
$ mk-sbuild bionic
This will create chroot for your current architecture. You might want to
specify another architecture. For this, you can use --arch
option.
Example:
$ mk-sbuild xenial --arch=i386
6.2. Using schroot¶
6.2.1. in schroot wechseln¶
Sie können schroot -c <Release>-<Architektur> [-u <USER>]
verwenden, um ein neu erstelltes chroot einzugeben, aber das ist nicht genau der Grund, warum Sie sbuild: verwenden:
$ schroot -c bionic-amd64 -u root
6.2.2. schroot zum Bauen des Paketes benutzen¶
To build package using sbuild chroot, we use (surprisingly) the
sbuild
command. For example, to build hello
package from x86_64
chroot, after applying some changes:
apt source hello
cd hello-*
sed -i -- 's/Hello/Goodbye/g' src/hello.c # some
sed -i -- 's/Hello/Goodbye/g' tests/hello-1 #
dpkg-source --commit
dch -i #
update-maintainer # changes
sbuild -d bionic-amd64
To build package from source package (.dsc
), use location of the
source package as second parameter:
sbuild -d bionic-amd64 ~/packages/goodbye_*.dsc
Um die gesamte Leistung Ihrer CPU zu nutzen, können Sie die Anzahl der Threads, die für die Erstellung verwendet werden, mit dem Standard -j<threads>
angeben:
sbuild -d bionic-amd64 -j8
6.3. Maintaining schroots¶
6.3.1. Listing chroots¶
To get list of all your sbuild chroots, use schroot -l
. The
source:
chroots are used as base of new schroots. Changes here aren’t
recommended, but if you have specific reason, you can open it using
something like:
$ schroot -c source:bionic-amd64
6.3.3. Expiring active schroots¶
If because of any reason, you haven’t stopped your schroot, you can expire all active schroots using:
$ schroot -e --all-sessions
6.4. Further reading¶
There is Debian wiki page covering sbuild usage.
Ubuntu Wiki also has article about basics of sbuild.
sbuild
manpages are covering details about sbuild usage and
available features.