Debian sbuild setup
The following article will detail the install and basic setup of sbuild for Debian package building.
Install and Configuration
Install sbuild-debian-developer-setup.
Note: I do not use apt caching and select No when prompted during install. See the References section at the bottom for further details regarding apt caching.
sudo apt install sbuild-debian-developer-setup
Install devscripts.
sudo apt install devscripts
Optional (not required, but recommended) install piuparts.
sudo apt install piuparts
Add yourself to the sbuild group and then reboot your system.
sudo adduser $USER sbuild
Create the sbuild configuration file.
nano ~/.sbuildrc
Insert the text below, save and exit your editor.
# Name to use as override in .changes files for the Maintainer: field # (mandatory, no default!). Uncomment the lines below if required. #$maintainer_name='Your Name <your_email_address@domain.tld>'; #$uploader_name = 'Your Name <your_email_address@domain.tld>'; # Default distribution to build. $distribution = "unstable"; # Default chroot (defaults to distribution[-arch][-sbuild]) $chroot = 'unstable-amd64-sbuild'; # Build arch-all by default. $build_arch_all = 1; $build_source = 1; # --source-only-changes (applicable for dput. irrelevant for dgit push-source). $source_only_changes = 1; # By default, the -s option only includes the .orig.tar.gz when needed # (i.e. when the Debian revision is 0 or 1). By setting this option # to 1, the .orig.tar.gz will always be included when -s is used. # This is equivalent to --force-orig-source. $force_orig_source = 0; # Verbose (-v) $verbose = 1; # Parallel build $ENV{'DEB_BUILD_OPTIONS'} = 'parallel=4'; # Time to wait for a source dependency lock. The default is 1 minute. my $srcdep_lock_wait = 1; # 1 minute $run_lintian = 1; $lintian_opts = ['-v', '-i', '-I']; $run_piuparts = 1; $piuparts_opts = ['--schroot', '%r-%a-sbuild', '--no-eatmydata']; $run_autopkgtest = 1; $autopkgtest_root_args = ''; $autopkgtest_opts = [ '--', 'schroot', '%r-%a-sbuild' ]; # 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'; # Directory for writing build logs to $log_dir=$ENV{HOME}."/Development/builder/debian/sbuild_logs"; # don't remove this, Perl needs it: 1;
Please read through the configuration file and edit to fit your needs i.e. for $maintainer_name, $uploader_name, $ENV{'DEB_BUILD_OPTIONS'} = 'parallel=4';, $log_dir etc.
Create your unstable build chroot.
sudo sbuild-createchroot unstable /srv/chroot/unstable-amd64-sbuild
Building Packages
With a properly configured '~/.sbuildrc' as above, you can simply run the following to build a package from the source directory of a debianized package.
sbuild
Alternatively, you may pass in the '.dsc' file of a package generated by dpkg-buildpackage, git-buildpackage, and so forth so that it may be built with sbuild.
sbuild <package_name>_<package_version>-<debian_revision>.dsc
Updating your chroot
To update your unstable chroot with the latest packages.
sudo sbuild-update -udcar unstable
Cleaning up chroot sessions
Finding any dangling chroot sessions.
schroot -l --all
Clean up dangling sessions.
sudo schroot --end-session --all-sessions
Delete a chroot
To delete a chroot.
sudo rm -r /srv/chroot/unstable-amd64-sbuild/
sudo rm /etc/schroot/chroot.d/unstable-amd64-sbuild-* /etc/sbuild/chroot/unstable-amd64-sbuild
References
Donations
If you choose to do so, you can donate to me by clicking on the image below. Any donations are greatly appreciated and go towards hosting and hardware so I can continue contribution across a wide range of Free and Open Source projects.