SBUILD(1)
๐ SBUILD โ the Debian sbuild manual, bestie edition โจ
okay so you're here because you want to build Debian packages from source, and sbuild is the girl for the job. Welcome to the Debian sbuild manual, rewritten for your reading pleasure ๐ซถ
๐ NAME
sbuild โ build debian packages from source โจ
๐ธ SYNOPSIS
sbuild [-h|--help | -V|--version] [-v|--verbose | -q|--quiet]
[-D|--debug] [-A|--arch-all] [--archive=archive]
[-d|--dist=distribution] [-c|--chroot=chroot]
[--chroot-mode=schroot|sudo|autopkgtest|unshare] [--arch=architecture]
[--arch-any | --no-arch-any] [--build=architecture]
[--host=architecture] [--profiles=profile[,...]] [-s|--source]
[--force-orig-source] [--make-binNMU=changelog-entry] [--binNMU=NMU-
version] [--append-to-version=string] [--binNMU-timestamp=timestamp]
[--binNMU-changelog=changelog] [--build-dir=directory]
[--add-depends=dependency] [--add-conflicts=dependency]
[--add-depends-arch=dependency] [--add-conflicts-arch=dependency]
[--add-depends-indep=dependency] [--add-conflicts-indep=dependency]
[-m|--maintainer=maintainer] [-e|--uploader=uploader] [-k|--keyid=key-
id] [--source-only-changes] [--no-source-only-changes] [-j|--jobs=n]
[--enable-network] [--no-enable-network] [--debbuildopt=option]
[--debbuildopts=options] [--dpkg-source-opt=options]
[--dpkg-source-opts=options] [--dpkg-file-suffix=suffix]
[-p|--purge=purge-mode] [--purge-build=purge-mode] [--purge-deps=purge-
mode] [--purge-session=purge-mode] [-b|--batch] [-n|--nolog] [--hide-
log-sections=sections] [--clean-source] [--no-clean-source]
[--run-lintian] [--no-run-lintian] [--lintian-opt=options]
[--lintian-opts=options] [--run-piuparts] [--no-run-piuparts]
[--piuparts-opt=options] [--piuparts-opts=options]
[--piuparts-root-arg=options] [--piuparts-root-args=options]
[--run-autopkgtest] [--no-run-autopkgtest] [--autopkgtest-opt=options]
[--autopkgtest-opts=options] [--autopkgtest-root-arg=options]
[--autopkgtest-root-args=options] [--pre-build-commands=string]
[--chroot-setup-commands=string]
[--chroot-update-failed-commands=string]
[--build-deps-failed-commands=string] [--starting-build-commands=string]
[--finished-build-commands=string] [--build-failed-commands=string]
[--chroot-cleanup-commands=string] [--post-build-commands=string]
[--post-build-failed-commands=string]
[--anything-failed-commands=string] [--log-external-command-output]
[--log-external-command-error] [--setup-hook=hook-script]
[--build-dep-resolver=resolver]
[--resolve-alternatives|--no-resolve-alternatives]
[--extra-package=package.deb|directory] [--extra-repository=spec]
[--extra-repository-key=file.asc] [--build-path=string]
[--dsc-dir=string] [--autopkgtest-virt-server=string]
[--autopkgtest-virt-server-opt=string]
[--autopkgtest-virt-server-opts=options] [--purge-extra-packages]
[--bd-uninstallable-explainer=dose3|apt|none] [PACKAGE[.dsc]]
๐ฆ DESCRIPTION
so basically ๐ sbuild rebuilds Debian binary packages from the corresponding Debian source, and it installs any missing source dependencies for you. no cap. The build happens inside a dedicated clean build environment, not on your host system โ which is the whole point, bestie. If you wanna know about all the chroot backends it supports, go peek at the section CHROOT MODES ๐
sbuild can fetch the Debian source over a network ๐, or it can use sources you already have locally. Your call.
You hand sbuild stuff to process via the argument PACKAGE[.dsc]. That argument can be any of these:
- a debianized package source directory,
- a source package name plus a version, in the form
package_version, - a source package name,
- or a
.dscfile.
And if you give it no arguments at all? Then the current working directory gets passed as the argument. iconic default behaviour honestly ๐
Here's the tea on how each argument type gets handled โ:
- For arguments given as source directories,
dpkg-sourceis first run to produce a source.dscfile. Then the package is built using the.dscproduced. - For arguments in the form
package_versionorpackage,aptis used to download the source package. - For arguments given as a
.dscfile,sbuildbuilds the source packages directly. - For
.dscfiles in remote locations, the source packages are downloaded first, then built.
It's also possible to run external commands with sbuild. See EXTERNAL COMMANDS for more on that. ๐ฅ
sbuild mails the build logs to a user ๐ฌ. It gets configured by the configuration files /etc/sbuild/sbuild.conf and $XDG_CONFIG_HOME/sbuild/config.pl (which is preferred over ~/.sbuildrc). If $XDG_CONFIG_HOME is either not set or empty, ~/.config/sbuild/config.pl will be used instead. An example sbuildrc is available in /usr/share/doc/sbuild/examples/example.sbuildrc. And if you want a custom config path? Just set the SBUILD_CONFIG environment variable to the path of an additional configuration file. slay ๐
You can build either using a local package with its .dsc file, or a remote one by specifying an explicit dpkg version. simple as that โจ
โจ OPTIONS โจ
heads up bestie: options set on the command line overwrite settings made in the configuration file. command line eats first, periodt ๐
-h,--helpโ Display this manual. ๐-V,--versionโ Print version information. ๐ท๏ธ--add-depends=dependency--add-conflicts=dependency--add-depends-arch=dependency--add-conflicts-arch=dependency--add-depends-indep=dependency--add-conflicts-indep=dependency
These options add a build dependency to the source package being built, on top of the build dependency info already specified in debian/control. These dependencies get concatenated directly to Build-Depends, Build-Conflicts, Build-Depends-Arch, Build-Conflicts-Arch, Build-Depends-Indep and Build-Conflicts-Indep respectively. You can use these options any number of times to stack up multiple dependencies ๐ฅ. The format is identical to the format used in debian/control. These command line options append to the MANUAL_DEPENDS, MANUAL_CONFLICTS, MANUAL_DEPENDS_ARCH, MANUAL_CONFLICTS_ARCH, MANUAL_DEPENDS_INDEP and MANUAL_CONFLICTS_INDEP configuration variables, respectively. See sbuild.conf(5) for more information. ๐ซถ
--arch=architectureโ Build using the architecture specified. A chroot named$distribution-$arch-sbuildor$distribution-archis searched for, in that order of preference. The chroot must be installed and configured appropriately to build as that architecture, e.g. usingpersonality=linux32to buildi386packages on anamd64system. Note that this option is equivalent to--host=architecture --build=architecture. If you specify an architecture that your CPU cannot execute, make sure that you haveqemu-userwithbinfmtsupport installed to emulate the foreign architecture ๐ง. Since build and host architecture are equivalent, this option will result in a native compilation, even if the native compilation is being emulated transparently using qemu. This command line option sets theHOST_ARCHandBUILD_ARCHconfiguration variables. Seesbuild.conf(5)for more information.--host=architectureโ Build using the host architecture specified. Defaults to the native architecture. The host architecture is the architecture thatsbuildwill build packages for. If the specified architecture is different from the build architecture, then a cross-build is being performed ๐. If$hostand$builddon't match, a chroot named$distribution-$build-$host-sbuildor$distribution-$build-$hostis searched for, falling back to$distribution-$build-sbuildor$distribution-$build, in that order of preference. This command line option sets theHOST_ARCHconfiguration variable. Seesbuild.conf(5)for more information.--build=architectureโ Build using the build architecture specified. Defaults to the native architecture. The build architecture is the architecture of the chroot that the package will be built in. If you want to perform a native build, set the host architecture to the same value or just use the--archoption. This command line option sets theBUILD_ARCHconfiguration variable. Seesbuild.conf(5)for more information.-A,--arch-allโ Also buildArchitecture: allpackages. This is the default behaviour for native builds. This option is the opposite of--no-arch-all. See the section BUILD ARTIFACTS for more information. This command line option sets theBUILD_ARCH_ALLconfiguration variable. Seesbuild.conf(5)for more information.--no-arch-allโ Do not buildArchitecture: allpackages. This is the default behaviour for cross builds. This option is the opposite of--arch-all. See the section BUILD ARTIFACTS for more information. This command line option sets theBUILD_ARCH_ALLconfiguration variable. Seesbuild.conf(5)for more information.--arch-anyโ BuildArchitecture: anypackages. This is the default behavior. This option is the opposite of--no-arch-any. See the section BUILD ARTIFACTS for more information. This command line option sets theBUILD_ARCH_ANYconfiguration variable. Seesbuild.conf(5)for more information.--no-arch-anyโ Do not buildArchitecture: anypackages. This option is the opposite of--arch-anyand only useful when used together with--arch-allor--source. See the section BUILD ARTIFACTS for more information. This command line option sets theBUILD_ARCH_ANYconfiguration variable. Seesbuild.conf(5)for more information.-b,--batchโ Operate in batchmode, i.e. write a build-progress file during execution and files on shutdown to facilitate a clean restart ๐. This command line option sets theBATCH_MODEconfiguration variable. Seesbuild.conf(5)for more information.-c,--chroot=chrootโ okay so this one tells sbuild which chroot to use, but bestie, what that even means depends entirely on which chroot mode you're in. Buckle up:- schroot mode: this is the schroot name or alias you want. Don't specify it and sbuild defaults to the first schroot name or alias that actually exists, checking in this order:
$distribution-$arch-sbuild,$distribution-sbuild,$distribution-$arch, then$distribution. - sudo mode: now it's the chroot directory to use. That directory is expected either in
/etc/sbuild/chroot(when you're in buildd sbuild mode) or in the build directory (see--build-dir), prefixed withchroot-(this is user sbuild mode, which is the default). Leave it unspecified and sbuild searches for a directory in those respective locations, named the exact same way as the schroot mode naming above. - unshare mode: if the value is a path, that's the location of the chroot tarball, directly, no middleman. Otherwise, a tarball with an equal basename from
~/.cache/sbuildgets used. Unspecified? sbuild searches for a tarball named the schroot-mode way under~/.cache/sbuild. - autopkgtest mode: this option literally does nothing here ๐. The
--autopkgtest-virt-server-optsare what pick the chroot in autopkgtest mode.
- schroot mode: this is the schroot name or alias you want. Don't specify it and sbuild defaults to the first schroot name or alias that actually exists, checking in this order:
This command line option sets the CHROOT configuration variable. See sbuild.conf(5) for more information.
--chroot-mode=schroot|sudo|autopkgtest|unshareโ pick your chroot mode, four choices on the menu: schroot (the default, the classic), sudo (which uses sudo to execute chroot in a directory from/etc/sbuild/chrootor./chroot), autopkgtest which uses theautopkgtest-virt-*binaries (selectable via the--autopkgtest-virt-serveroption), and unshare (which uses linux namespaces for chroot and doesn't require superuser privileges โ yes, no root, iconic). See the section CHROOT MODES for more information. This command line option sets theCHROOT_MODEconfiguration variable. Seesbuild.conf(5)for more information.-d,--dist=distributionโ explicitly set the distribution for the package build. This selects the correct chroot to use and sets the value of theDistributionfield in the created.changesfile. You kinda need this when you hand sbuild a.dscfile or a plain source package name to build. In that second case it's the distribution the source package gets fetched from. This command line option sets theDISTRIBUTIONconfiguration variable. Seesbuild.conf(5)for more information.--archive=archiveโ communicate with the specified archive. Talk to it. Gossip with it. This command line option sets theARCHIVEconfiguration variable. Seesbuild.conf(5)for more information.-D,--debugโ enable debug output. Turn the volume up on the logs ๐.--apt-clean,--no-apt-cleanโ run (or do not run)apt-get cleanin the chroot before executing the build, overriding the default setting. This command line option sets theAPT_CLEANconfiguration variable. Seesbuild.conf(5)for more information.--apt-update,--no-apt-updateโ run (or do not run)apt-get updatein the chroot before executing the build. This only applies to the default repositories of the chroot: the internal sbuild apt repository, the repository for extra packages (see--extra-package) and any repositories set via--extra-repositoryare always updated, no exceptions.
It is not recommended to use--no-apt-updatebecause you should build using the latest available packages in each distribution. If you do disable updates you need to ensure that the chroot contains downloaded package lists or apt will be unable to install any packages and the build is likely to fail. If you are using the unshare chroot mode you can add--skip=cleanup/apt/liststo$unshare_mmdebstrap_extra_argsto retain the package lists inside the chroot tarball.
This command line option sets the APT_UPDATE configuration variable. See sbuild.conf(5) for more information.
--apt-upgrade,--no-apt-upgradeโ run (or do not run)apt-get upgradein the chroot before executing the build, overriding the default setting. This command line option sets theAPT_UPGRADEconfiguration variable. Seesbuild.conf(5)for more information.--apt-distupgrade,--no-apt-distupgradeโ run (or do not run)apt-get distupgradein the chroot before executing the build, overriding the default setting. This command line option sets theAPT_DISTUPGRADEconfiguration variable. Seesbuild.conf(5)for more information.-m,--maintainer=maintainerโ specify the identity used for GPG signing packages, and also used as the maintainer for binary NMUs. You don't normally need to set this (it defaults to the uploader). This command line option sets theMAINTAINER_NAMEconfiguration variable. Seesbuild.conf(5)for more information.-e,--uploader=uploaderโ passed todpkg-genchangesand used to set theChanged-by:field in the.changesfile(s). This command line option sets theUPLOADER_NAMEconfiguration variable. Seesbuild.conf(5)for more information.-k,--keyid=key-idโ passed todebsignand used to set the key for signing the.changesfile(s). Default is not using any key and not signing the.changesfile(s) โ so the default is just vibes, unsigned. This command line option sets theKEY_IDconfiguration variable. Seesbuild.conf(5)for more information.--source-only-changes,--no-source-only-changesโ in addition to the.changesfile generated bydpkg-buildpackage, also produce (or don't produce) a.changesfile suitable for a source-only upload. If requested by--keyid, this.changesfile will also be signed bydebsign. This command line option sets theSOURCE_ONLY_CHANGESconfiguration variable. Seesbuild.conf(5)for more information.-j,--jobs=nโ number of jobs to run simultaneously. Passed through todpkg-buildpackage. Parallelism, we love to see it โจ. This command line option appends the appropriate-joption to theDPKG_BUILDPACKAGE_USER_OPTIONSconfiguration variable. Seesbuild.conf(5)for more information.--enable-networkโ enable network access during build. This command line option sets theENABLE_NETWORKconfiguration variable. Seesbuild.conf(5)for more information.--no-enable-networkโ don't enable network access during build (only implemented for the unshare mode) (this is the default). This command line option sets theENABLE_NETWORKconfiguration variable. Seesbuild.conf(5)for more information.--debbuildopt=optionโ pass the specified option directly todpkg-buildpackagein addition to the options already passed by sbuild. You can pass this multiple times (once perdpkg-buildpackageoption) and freely mix it with the--debbuildoptsoption. Options get passed todpkg-buildpackagein the order that the--debbuildoptand--debbuildoptsoptions are given on the command line. This command line option appends to theDPKG_BUILDPACKAGE_USER_OPTIONSconfiguration variable. Seesbuild.conf(5)for more information.--debbuildopts=optionsโ pass the specified options directly todpkg-buildpackagein addition to the options already passed by sbuild. The argument gets split by whitespaces and the resulting array is passed to thedpkg-buildpackageinvocation. If any options contain spaces, use--debbuildoptfor them instead. You can pass this multiple times and freely mix it with the--debbuildoptoption. Options get passed todpkg-buildpackagein the order that the--debbuildoptand--debbuildoptsoptions are given on the command line. This command line option appends to theDPKG_BUILDPACKAGE_USER_OPTIONSconfiguration variable. Seesbuild.conf(5)for more information.--dpkg-source-opt=optionsโ pass the specified option directly todpkg-sourcein addition to the options already passed by sbuild. This is only used when creating a source package from a Debianized source directory. You can pass this multiple times (once perdpkg-sourceoption) and freely mix it with the--dpkg-source-optsoption. Options get passed todpkg-sourcein the order that the--dpkg-source-optand--dpkg-source-optsoptions are given on the command line. This command line option appends to theDPKG_SOURCE_OPTIONSconfiguration variable. Seesbuild.conf(5)for more information.
NOTE: The-b,--before-buildand--after-buildoptions will always be passed todpkg-source, respectively.
--dpkg-source-opts=optionsโ pass the specified options directly todpkg-sourcein addition to the options already passed by sbuild. The argument gets split by whitespaces and the resulting array is passed to thedpkg-sourceinvocation. This is only used when creating a source package from a Debianized source directory. If any options contain spaces, use--dpkg-source-optfor them instead. You can pass this multiple times and freely mix it with the--dpkg-source-optoption. Options get passed todpkg-sourcein the order that the--dpkg-source-optand--dpkg-source-optsoptions are given on the command line. This command line option appends to theDPKG_SOURCE_OPTIONSconfiguration variable. Seesbuild.conf(5)for more information.
NOTE: The-b,--before-buildand--after-buildoptions will always be passed todpkg-source, respectively.
--dpkg-file-suffix=suffixโ add the suffix to the filename of the changes and buildinfo files generated by dpkg. Cute little name tag for your files ๐.
NOTE: This option is ignored ifdpkg-devin the build environment is too old to support it. At leastdpkg-dev1.18.11 is required.
--mail-log-to=email-addressโ send the build log to the specified email address. This command line option sets theMAILTOconfiguration variable. Seesbuild.conf(5)for more information.--mailfrom=email-addressโ email address used as the sender address for build logs. This command line option sets theMAILFROMconfiguration variable. Seesbuild.conf(5)for more information.-n,--nologโ bestie, this one is the anti-log. No package log file in$log_dir, no build log file, nope, nada, not a single one ๐ everything just gets printed straight to stdout instead. And no log mails either, we're not emailing anybody. This sets theNOLOGconfig variable. Peepsbuild.conf(5)for the deets.--hide-log-sections=section1,section2,...โ hides specific log sections from standard output so your terminal isn't giving chaos energy. The section names you're allowed to hide are:postbuild,cleanup,changes,buildinfo,contentsandsummary. Separate multiple names with commas, and yes you can pass this option multiple times. This sets theLOG_HIDDEN_SECTIONSconfig variable.sbuild.conf(5)has more.--log-filename-ts-format=formatโ sets the format of the timestamp in the build log filename, using the same format asstrftime. Customize your filenames, slay โจ--profiles=profile[,...]โ tells sbuild which profile(s) we're building, comma-separated list style. Defaults to the space-separated list of profiles in theDEB_BUILD_PROFILESenvironment variable when building natively, or thecrossandnocheckprofiles when cross-building. This sets theBUILD_PROFILESconfig variable.sbuild.conf(5), you know the drill.-p,--purge=purge-modeโ the convenience queen ๐ setspurge-modefor the build directory, the build dependencies and the session, all in one go. It sets thePURGE_BUILD_DEPS,PURGE_BUILD_DIRECTORYandPURGE_SESSIONconfig variables all at once.sbuild.conf(5)for more.--purge-build=purge-modeโ does the build directory get deleted after a build or not?purge-modedecides. Possible values arealways(the default),never, andsuccessful. Sets thePURGE_BUILD_DIRECTORYconfig variable.sbuild.conf(5)babes.--purge-deps=purge-modeโ same energy but for the build dependencies: do they get removed after a build? Possible values arealways(default),never, andsuccessful. Sets thePURGE_BUILD_DEPSconfig variable.sbuild.conf(5).--purge-session=purge-modeโ purges the schroot session after a build. This one is lowkey a baddie when you pair it with the--purge-buildand--purge-depsoptions and you're using snapshot chroots, because by default that snapshot will get deleted. Possible values arealways(default),never, andsuccessful. Sets thePURGE_SESSIONconfig variable.sbuild.conf(5)has the tea.-s,--sourceโ builds the source package on top of the other build artifacts you asked for. By default thedscwill not be rewritten, because the source package is the input to sbuild, not its output. Even when you run it from an unpacked source tree, sbuild will first build the source package usingdpkg-sourceand then hand that off to the sbuild machinery. Use this option only when you know what you are doing โ it will rewrite the originaldscyou passed to sbuild ๐ญ See the BUILD ARTIFACTS section for more. Sets theBUILD_SOURCEconfig variable.sbuild.conf(5).--no-sourceโ don't rebuild the source package. This is the default, and it's the opposite of--source. See the BUILD ARTIFACTS section. Sets theBUILD_SOURCEconfig variable.sbuild.conf(5).--force-orig-sourceโ when used together with-s, this forces the inclusion of theorig.tar.gzfile in the generated.changesfile, even in cases where it wouldn't normally be included, i.e.dpkg-buildpackage -saenergy. Sets theFORCE_ORIG_SOURCEconfig variable.sbuild.conf(5)for more.--use-snapshotโ installs the latest snapshot gcc compiler from thegcc-snapshotpackage and alters the build environment to use that snapshot compiler for the build. Specifically, it appends/usr/lib/gcc-snapshot/libto the value of theLD_LIBRARY_PATHconfig variable and/usr/lib/gcc-snapshot/binto the value of thePATHconfig variable. It also sets theGCC_SNAPSHOTconfig variable.sbuild.conf(5)if you want more.-v,--verboseโ be verbose, i.e. all the information goes to stdout as well as to the log files. Spill the tea everywhere ๐-q,--quietโ be quiet. This is the opposite of--verbose. Not a peep ๐คซ--make-binNMU=changelog-entryโ with this one, sbuild creates a brand new changelog entry indebian/changelogof every package built. The version number will be in the format for binary-only NMUs (peep--binNMU); the maintainer is set to the maintainer name configured for sbuild.changelog-entrywill be used as the changelog entry following โBinary-only non-maintainer upload for ARCH -- no source changesโ. Heads up bestie: the versions in thePACKAGE_VERSION[.dsc]arguments still have to be the unmodified (non-NMU) ones so the sources can actually be found. The version number in log files and mails will get modified by sbuild automatically. The--append-to-versionoption has a similar effect but lets you specify an arbitrary version suffix instead of a custom changelog entry. If you want a custom version suffix and a custom changelog entry, use--make-binNMUand--append-to-versionat the same time with--binNMU=0. This option is incompatible with--binNMU-changelog. It implies--no-arch-all. This sets theBIN_NMUconfig variable and sets theBIN_NMU_VERSIONconfig variable to1if it wasn't set yet, for example by the--binNMUoption.sbuild.conf(5)for more.--binNMU=NMU-versionโ the version number of the binary NMU. This option only does anything if it's combined with--make-binNMUand/or with--append-to-version.versionis a single number for the(+bn)format used for binary NMUs. If the argument is the empty string or zero, then the+bnsuffix will not be appended. The+bnsuffix gets appended after the string given via--append-to-version. This option is incompatible with--binNMU-changelog. Sets theBIN_NMU_VERSIONconfig variable.sbuild.conf(5)for more.--append-to-version=stringโ similar to--make-binNMUexcept it lets you specify an arbitrary string to be appended to the version number (immediately before the+in the Debian revision, if--make-binNMUis also provided). To pass an arbitrary changelog text as well, combine this option with--make-binNMU, but be aware that this will also add the+bnsuffix unless you also pass--binNMU=0to disable it ๐ This option is incompatible with--binNMU-changelog. It implies--no-arch-all. Sets theAPPEND_TO_VERSIONconfig variable.sbuild.conf(5).--binNMU-timestamp=timestampโ sets the timestamp of the new binNMU changelog entry. By default the time of the build is used to generate the binNMU changelog timestamp, but this option lets you use a custom one instead. The timestamp is either an integer in Unix time, or a string in the format compatible with Debian changelog entries (i.e. as generated bydate -R). This option is incompatible with--binNMU-changelog. Sets theBIN_NMU_TIMESTAMPconfig variable.sbuild.conf(5).--binNMU-changelog=changelogโ sets the complete content of a binary-only changelog entry, so you get full customization of the new changelog entry. It's up to you to make sure the changelog entry is well-formed, no pressure ๐ The argument has to include all necessary newlines. Leading and trailing newlines will be stripped. Sbuild will not interpret any backslash escapes. This option is incompatible with--make-binNMU,--binNMU,--append-to-versionand--binNMU-timestamp. Sets theBIN_NMU_CHANGELOGconfig variable.sbuild.conf(5).--build-dir=directoryโ sets the output directory for the build artifacts created bydpkg-buildpackageand the log file. By default the current directory is used, or โ when sbuild is executed from within an unpacked source directory โ the parent directory. Sets theBUILD_DIRconfig variable.sbuild.conf(5)if you want more.--clean-sourceโ when executing sbuild from within an unpacked source tree, this executes thedebian/rules cleantarget. This is the default, and it might require some of the build dependencies installed on the host. Sets theCLEAN_SOURCEconfig variable.sbuild.conf(5).--no-clean-sourceโ when executing sbuild from within an unpacked source tree, this does not run thedebian/rules cleantarget before building the source package. Only set this if you start from a clean checkout and you know what you are doing โ ๏ธ Sets theCLEAN_SOURCEconfig variable.sbuild.conf(5).--run-lintianโ runs lintian after a successful build. Sets theRUN_LINTIANconfig variable.sbuild.conf(5)for more.--no-run-lintianโ doesn't run lintian after a successful build. If sbuild is configured to run lintian by default, this option will prevent lintian from being run at all. Sets theRUN_LINTIANconfig variable.sbuild.conf(5).
--lintian-opt=optionsโ okay so this one yeets your option directly at lintian, on top of all the options sbuild already hands over, bestie ๐ . Pass it as many times as you want (like, once per lintian option, no cap) and mix it freely with--lintian-opts, they don't fight ๐ซถ. The order they land on the command line? That's literally the order lintian gets them in โจ. This one appends to theLINTIAN_OPTIONSconfiguration variable. Go readsbuild.conf(5)for the tea ๐--lintian-opts=optionsโ same energy, except the argument gets split on whitespaces first and the resulting array gets passed to the lintian invocation ๐ธ. So if any of your options have spaces in them, use--lintian-optfor those instead, fr fr. Pass it multiple times, mix it freely with the--lintian-optsoption, and order stays exactly as given on the command line ๐. This one also appends to theLINTIAN_OPTIONSconfiguration variable.sbuild.conf(5)has the deets ๐--run-piupartsโ run piuparts after a successful build ๐. Yes queen, extra testing. This sets theRUN_PIUPARTSconfiguration variable.sbuild.conf(5)for more ๐--no-run-piupartsโ don't run piuparts after a successful build ๐. If your sbuild is configured to run piuparts by default, this here is the veto โ piuparts will not run. This sets theRUN_PIUPARTSconfiguration variable.sbuild.conf(5), you know the drill ๐--piuparts-opt=optionsโ passes the option straight to piuparts, directly, on top of whatever sbuild already sends ๐ฆ. Multiple times? Absolutely. Mixed with--piuparts-opts? Freely. Order given on the command line = order piuparts receives them โจ. Certain percent escapes are supported in here, and to write a literal percent sign you escape it with another percent sign (the drama of it all ๐ญ) โ see the OPTION STRING PERCENT ESCAPES section. This one appends to thePIUPARTS_OPTIONSconfiguration variable.sbuild.conf(5)๐--piuparts-opts=optionsโ same vibe, but the argument gets split by whitespaces and the array goes to the piuparts invocation ๐ธ. Options with spaces in them? Use--piuparts-optfor those, bestie. Pass it multiple times, mix freely with--piuparts-opts, order preserved like a queen ๐. Certain percent escapes are supported, and a literal percent sign needs another percent sign as its escape โ see OPTION STRING PERCENT ESCAPES. This one appends to thePIUPARTS_OPTIONSconfiguration variable.sbuild.conf(5)๐--piuparts-root-arg=optionsโ adds an argument used to launch piuparts as root ๐ . Without it, the default is to use"sudo --"to launch piuparts. Supply an empty string and piuparts is launched with no prefixed command at all โ iconic, unbothered, no middleman โจ. Can be specified multiple times. This one appends to thePIUPARTS_ROOT_ARGSconfiguration variable.sbuild.conf(5)๐--piuparts-root-args=optionsโ adds arguments used to launch piuparts as root ๐ซถ. Without it, default is"sudo --"to launch piuparts; empty string means no prefixed command whatsoever. The argument gets split by whitespaces, so to pass options that contain whitespaces use--piuparts-root-arginstead, okay? This one appends to thePIUPARTS_ROOT_ARGSconfiguration variable.sbuild.conf(5)๐--run-autopkgtestโ run autopkgtest after a successful build ๐ฅ. This sets theRUN_AUTOPKGTESTconfiguration variable.sbuild.conf(5)for the full story ๐ฆ--no-run-autopkgtestโ don't run autopkgtest after a successful build ๐. If sbuild is configured to run autopkgtest by default, this right here stops it in its tracks. This sets theRUN_AUTOPKGTESTconfiguration variable.sbuild.conf(5)๐--autopkgtest-opt=optionsโ tosses the option directly at autopkgtest, on top of the ones sbuild already passes ๐ธ. Multiple times (once per autopkgtest option), freely mixed with--autopkgtest-opts, and the order on the command line is exactly the order autopkgtest sees them in โจ. Certain percent escapes are supported โ literal percent sign? Escape it with another percent sign. See OPTION STRING PERCENT ESCAPES. This one appends to theAUTOPKGTEST_OPTIONSconfiguration variable.sbuild.conf(5)๐--autopkgtest-opts=optionsโ argument gets split by whitespaces, resulting array goes to the autopkgtest invocation ๐. Options containing spaces belong in--autopkgtest-opt, not here, bestie. Pass multiple times, mix freely with--autopkgtest-opts, order preserved ๐. Certain percent escapes are supported; write a literal percent sign by escaping it with another percent sign. See OPTION STRING PERCENT ESCAPES. This one appends to theAUTOPKGTEST_OPTIONSconfiguration variable.sbuild.conf(5)๐--autopkgtest-root-arg=optionsโ adds an argument used to launch autopkgtest as root ๐ . Without it, default ="sudo --"to launch autopkgtest. Empty string = autopkgtest launches with no prefixed command, periodt โจ. Can be specified multiple times. This one appends to theAUTOPKGTEST_ROOT_ARGSconfiguration variable.sbuild.conf(5)๐ซถ--autopkgtest-root-args=optionsโ adds arguments used to launch autopkgtest as root ๐ธ. Without it, default ="sudo --"to launch autopkgtest; empty string = no prefixed command. The argument gets split by whitespaces, so for options with whitespaces use--autopkgtest-root-arginstead. This one appends to theAUTOPKGTEST_ROOT_ARGSconfiguration variable.sbuild.conf(5)๐
lowkey this next batch is the external-commands squad, and they are so useful when stuff goes sideways ๐ญ. Obsessed.
--pre-build-commands=stringโ this is the earliest external command, running right after the chroot session has been initialized and before literally anything else happens (yes, before installing the build dependencies) ๐ฅ. It runs outside of the chroot. Can be used multiple times to add multiple commands. Certain percent escapes are supported โ literal percent sign, escape it with another percent sign. See the EXTERNAL COMMANDS section for the full lore. This one appends to theEXTERNAL_COMMANDSconfiguration variable.sbuild.conf(5)โจ--chroot-setup-commands=stringโ runs these commands after the chroot and variables have been set up, but before dependencies get installed ๐. This one runs as root inside the chroot. Can be used multiple times to stack up commands. Certain percent escapes supported; a literal percent sign needs another percent sign to escape it. See EXTERNAL COMMANDS. This one appends to theEXTERNAL_COMMANDSconfiguration variable.sbuild.conf(5)๐--chroot-update-failed-commands=stringโ these run after any of'apt-get update','apt-get upgrade'or'apt-get dist-upgrade'failed ๐ญ. Important caveat, bestie: this hook does not run for updates of the internal sbuild apt repository, the repository for extra packages (see--extra-package) and the repositories given via--extra-repository. The environment is intact and the failure can be investigated โ and especially%SBUILD_SHELLis useful here ๐. Can be used multiple times to add multiple commands. Certain percent escapes are supported; to write a literal percent sign, escape it with another percent sign. See the EXTERNAL COMMANDS section for more. This one appends to theEXTERNAL_COMMANDSconfiguration variable.sbuild.conf(5)๐--build-deps-failed-commands=stringโ these commands run if installing the build dependencies has failed, directly after the failed attempt ๐. The environment is intact, so you can actually go investigate the mess โ and especially%SBUILD_SHELLis useful here ๐ . The command runs as root inside the chroot. Can be used multiple times to add multiple commands. Certain percent escapes are supported; to write a literal percent sign, escape it with another percent sign. See the EXTERNAL COMMANDS section. This one appends to theEXTERNAL_COMMANDSconfiguration variable.sbuild.conf(5)๐ฆ--starting-build-commands=string โ bestie, these are the commands that get run right after your dependencies are installed and just before the actual package build withdpkg-buildpackagekicks off. They run as the root user inside the chroot (yes, root root ๐). Drop this flag multiple times to stack up multiple commands. Certain percent escapes are supported โ and if you want a literal percent sign, escape it with another percent sign (yeah,%%, it's giving very "escape the escape chased the escape" energy ๐). Peep theEXTERNAL COMMANDSsection for the deets. This flag appends to theEXTERNAL_COMMANDSconfiguration variable, so go readsbuild.conf(5)if you want more.--finished-build-commands=string โ run these immediately after the timed package build finishes. Also run as the root user inside the chroot. Also stackable (hit it multiple times, add as many commands as your heart desires ๐). Also supports those percent escapes, and yes, literal percent sign = escape it with another percent sign. SeeEXTERNAL COMMANDSfor more. This flag appends toEXTERNAL_COMMANDS. Seesbuild.conf(5)for more.--build-failed-commands=string โ these ones run ifdpkg-buildpackagehas failed, directly after that failed attempt ๐ญ. The environment is left intact, meaning you can actually go investigate what went wrong โ and ngl,%SBUILD_SHELLis especially useful here (it's the moment, fr). Runs as the root user inside the chroot. Use it multiple times for multiple commands. Percent escapes supported; literal percent sign gets escaped with another percent sign. See theEXTERNAL COMMANDSsection. This flag appends toEXTERNAL_COMMANDS. Seesbuild.conf(5)for more.--chroot-cleanup-commands=string โ these run when a chroot gets cleaned up, and importantly, before the build directory is purged ๐งนโจ. Run as root inside the chroot. Multiple uses = multiple commands. Percent escapes supported; literal percent sign โ escape it with another percent sign.EXTERNAL COMMANDSsection has the lore. This flag appends toEXTERNAL_COMMANDS. Seesbuild.conf(5)for more.--post-build-commands=string โ these run after a successful build ๐ and they run outside of the chroot (plot twist, bestie โ not inside this time). Hit it multiple times to add multiple commands. Percent escapes supported; literal percent sign gets escaped with another percent sign. See the sectionEXTERNAL COMMANDSfor more info. This flag appends toEXTERNAL_COMMANDS. Seesbuild.conf(5)for more.--post-build-failed-commands=string โ exactly like the one above, but when a build fails ๐. See theEXTERNAL COMMANDSsection for more information. This flag appends toEXTERNAL_COMMANDS. Seesbuild.conf(5)for more.--anything-failed-commands=string โ the catch-all queen ๐: these run for all the--xxx-failed-commandsoptions. And once again,%SBUILD_SHELLis especially useful here. Multiple uses = multiple commands. Percent escapes supported; literal percent sign gets escaped with another percent sign. See theEXTERNAL COMMANDSsection. This flag appends toEXTERNAL_COMMANDS. Seesbuild.conf(5)for more.--log-external-command-outputโ write the output from external commands straight into the build log ๐. This flag sets theLOG_EXTERNAL_COMMAND_OUTPUTconfiguration variable. Seesbuild.conf(5)for more.--log-external-command-errorโ same vibe, but for the error output from external commands, also into the build log. This flag sets theLOG_EXTERNAL_COMMAND_ERRORconfiguration variable. Seesbuild.conf(5)for more.--setup-hook=hook-script DEPRECATED โ okay so this option is deprecated, like, do not build your whole personality around it bestie ๐ญ. Using it will add hook-script to the external commands that get run viachroot-setup-commands. This flag sets theCHROOT_SETUP_SCRIPTconfiguration variable and appends to theEXTERNAL_COMMANDSconfiguration variable. Seesbuild.conf(5)for more.--build-dep-resolver=resolver โ pick which resolver handles selecting your build dependencies. Supported resolvers areapt(the default โจ),aptitude,aspcud,xapt, andnull. Let's break it down ๐ซถ:aptโ the most appropriate resolver for most users, for building for unstable, stable and other distributions. Heads up: if alternative build dependencies are used (excluding architecture restrictions), only the first alternative will be used and the others get ignored ๐.aptitudeโ very similar, but smarter and slower ๐ , and it will consider all alternatives by default. Suited to more complex situations, like building packages for the experimental distribution where packages need installing from multiple suites (unstable and experimental). Due to performance issues, it's not recommended for use by default.aspcudโ for when the dependency situation is so complex that neitheraptnoraptitudecan find a solution. It usesapt-cudfto askaspcud, a real solver (and we mean solver in the math sense ๐งฎ), to find a solution to the installation problem. Sinceaspcuduses a real solver (an ASP solver), it will always find a solution if one exists. You can refine the solution it finds by changing the default optimization criteria through the--aspcud-criteriaoption.xaptโ intended only for cross-building, and it's a temporary transitional feature which will be removed following the complete introduction of multi-arch support. So like, don't get attached ๐ฅฒ.nullโ a dummy solver that does not install, upgrade or remove any packages. This lets you completely control package installation via hooks.
This flag sets the BUILD_DEP_RESOLVER configuration variable. See sbuild.conf(5) for more.
--aspcud-criteria=criteria โ optimization criteria in extended MISC 2012 syntax passed toaspcudthroughapt-cudf. Criteria are separated by commas, sorted by decreasing order of priority, and prefixed with a polarity (+to maximize and-to minimize). The default criteria is-removed,-changed,-new, which first minimizes the number of removed packages, then the number of changed packages (up or downgrades), and then the number of new packages. A common task is minimizing the number of packages installed from experimental โ to do this you can add a criteria like-count(changed,APT-Release:=/a=experimental/)to the default criteria. This will then minimize the number of changed packages which contain the stringa=experimentalin theAPT-Releasefield of the EDSP output created by apt. For more help on writing optimization criteria, see theapt-cudf(1)man page โ specifically the help on the--criteriaoption. This flag sets theASPCUD_CRITERIAconfiguration variable. Seesbuild.conf(5)for more.--resolve-alternativesโ allow the use of alternatives inBuild-Depends,Build-Depends-ArchandBuild-Depends-Indep. This is the default for theaptitudedependency resolver. This flag sets theRESOLVE_ALTERNATIVESconfiguration variable. Seesbuild.conf(5)for more.--no-resolve-alternativesโ do not allow the use of alternatives inBuild-Depends,Build-Depends-ArchandBuild-Depends-Indep. Note that alternatives for the same package (e.g. different versions) are still allowed ๐ซก. This is the default for theaptandxaptdependency resolvers. This flag sets theRESOLVE_ALTERNATIVESconfiguration variable. Seesbuild.conf(5)for more.--extra-package=package.deb|directory โ make package.deb available for build-dependency resolution by adding it to a temporary archive created by sbuild. This makes it way easier to build packages against locally-built build dependencies โ no waiting for those packages to hit the main archive, no going through the hassle of maintaining a local archive and making it accessible inside the chroot ๐. package.deb gets copied into the chroot, so it can refer to any path on the host system. And if you pass a directory instead of a regular file, then all regular files inside that directory with a filename ending in.debwill get added in the same fashion as individual packages. This option can be specified multiple times. This flag appends to theEXTRA_PACKAGESconfiguration variable. Seesbuild.conf(5)for more.--extra-repository=spec โ add a repository to the list of apt sources during the package build. The repository specification is a line suitable for anaptsources.list(5)file. Like, for instance, you might use:
--extra-repository="deb http://deb.debian.org/debian experimental main"
to allow packages in the experimental distribution to fulfil build-dependencies. Note that the build chroot must already trust the key of this repository, or a key must be given with the --extra-repository-key flag (see apt-secure(8)). This flag appends to the EXTRA_REPOSITORIES configuration variable. See sbuild.conf(5) for more.
--extra-repository-key=file.asc โ add file.asc to the list of trusted keys inside the chroot ๐. The key is read from the filename given, and added to the trusted keys. For more information, seeapt-secure(8). This flag is particularly useful if the target in--extra-repositoryisn't signed with a key that's trusted by the base chroot. This flag appends to theEXTRA_REPOSITORY_KEYSconfiguration variable. Seesbuild.conf(5)for more.
--build-path=stringโ okay so by default your package gets built under/build/reproducible-path/packagename-version/, but this option lets you pick a custom path where the package is built inside the chroot ๐ . The catch? Thesbuilduser in the chroot has to have permissions to create that path, so pick somewhere writable โ common choices are subdirectories of/tmpor/build.
โ ๏ธ Using/tmpmight be dangerous, because (depending on the chroot mode) the/tmpinside the chroot might be a world writable location that processes outside the chroot can access. Not it. The directory/buildcan only be accessed by thesbuilduser and group and should be a safe location. ๐ซถ
Also, the buildpath must be an empty directory, because the last component of the path will be removed after the build is finished. Cleanup slay, but keep that in mind.
And notice โ depending on the chroot mode (see --chroot-mode), some locations inside the chroot might be bind mounts that are shared with other sbuild instances ๐ญ. You must avoid using these shared locations as the build path, otherwise concurrent runs of sbuild will likely fail. With the default schroot chroot mode, /build is shared between multiple schroot sessions. You can change this behaviour in /etc/schroot/sbuild/fstab. The behaviour of other chroot modes will vary.
Want sbuild to pick a random build location for you, in the format /build/packagename-XXXXXX/packagename-version/ where XXXXXX is a random ascii string? Just pass the empty string to this option, bestie โจ.
This command line option sets the BUILD_PATH configuration variable. See sbuild.conf(5) for more info.
--dsc-dir=stringโ by default the package is built in a path of the following format,/build/packagename-XXXXXX/packagename-version/, wherepackagename-versiongets replaced by the values indebian/changelog. This option lets you specify a custompackagename-versionpath where the package is built inside the chroot ๐. Super useful when you want a static path for different versions โ for example forccache๐.
This command line option sets the DSC_DIR configuration variable. See sbuild.conf(5) for more information.
--autopkgtest-virt-server=schroot|lxc|chroot|qemu|ssh|lxd|podman|docker|incus|unshareโ the autopkgtest virtualization server ๐ฆ. You can specify it with or without theautopkgtest-virt-prefix. For instance, this set of command line options will use theautopkgtest-virt-schrootchroot mode for a package build:
--chroot-mode=autopkgtest --autopkgtest-virt-server=schroot --autopkgtest-virt-server-opt=unstable-amd64-sbuild
Some autopkgtest backends require access to the user's $HOME, but sbuild unsets that environment variable for the commands it runs ๐. Workaround? Add the appropriate $XDG_*_HOME to $environment_filter and set them to their respective values in the environment that you start sbuild with. Lowkey genius.
This command line option sets the AUTOPKGTEST_VIRT_SERVER configuration variable. See sbuild.conf(5) for more information.
--autopkgtest-virt-server-opt=stringโ passes the specified option directly to the respectiveautopkgtest-virt-*virtualization server, on top of the options sbuild already passes ๐. This option can be passed multiple times (once perautopkgtest-virt-*option) and can be freely mixed with the--autopkgtest-virt-server-optsoption. Options will be passed to the respectiveautopkgtest-virt-*virtualization server in the order that the--autopkgtest-virt-server-optand--autopkgtest-virt-server-optsoptions are given on the command line โญ. See the manual pages of the respectiveautopkgtest-virt-*commands for more info.
Certain percent escapes are supported โจ. To write a literal percent sign, escape it with another percent sign. See the section OPTION STRING PERCENT ESCAPES for more information.
This command line option appends to the AUTOPKGTEST_VIRT_SERVER_OPTIONS configuration variable. See sbuild.conf(5) for more information.
--autopkgtest-virt-server-opts=optionsโ passes the specified options directly to the respectiveautopkgtest-virt-*virtualization server, again on top of what sbuild already passes. The argument gets split by whitespaces and the resulting array is passed to theautopkgtest-virt-*invocation ๐ธ. If any options contain spaces, use--autopkgtest-virt-server-optfor them instead. This option can be passed multiple times and can be freely mixed with the--autopkgtest-virt-server-optsoption โ yes, the text says so, and yes, it's a little iconic that way ๐คญ. Options will be passed to the respectiveautopkgtest-virt-*virtualization server in the order that the--autopkgtest-virt-server-optand--autopkgtest-virt-server-optsoptions are given on the command line. See the manual pages of the respectiveautopkgtest-virt-*commands for more info.
Certain percent escapes are supported ๐. To write a literal percent sign, escape it with another percent sign. See the section OPTION STRING PERCENT ESCAPES for more information.
This command line option appends to the AUTOPKGTEST_VIRT_SERVER_OPTIONS configuration variable. See sbuild.conf(5) for more information.
--sbuild-mode=modeโ behaviour changes for use in a buildd environment ๐ง. This command line option sets theSBUILD_MODEconfiguration variable. Seesbuild.conf(5)for more information.--stats-dir=directoryโ the directory for writing build statistics to ๐. This command line option sets theSTATS_DIRconfiguration variable. Seesbuild.conf(5)for more information.--purge-extra-packagesโ ๐จ this is an experimental option. Only use when you know what you are doing, fr fr. Source packages must be buildable with only their build dependencies, all packages marked asEssential:yes, thebuild-essentialpackage and their transitive dependencies installed. But by default, most chroots will also includePriority:requiredpackages andaptas well as their transitive dependencies. This option will try to remove all additional packages that are not strictly required for the build right after build dependencies were installed ๐ฅ. It currently works best with theaspcudresolver. Theaptresolver will not make as much effort to remove all unneeded packages and will keep all providers of a virtual package and all packages from any dependency alternative that happen to be installed. Theaptitudeandxaptresolver do not implement this feature yet ๐ญ.
The removed packages are not (yet) added again after the build finished. This can have undesirable side effects like lintian not working (because there is no apt to install its dependencies) or bare chroots becoming totally unusable after apt was removed from them ๐. So this option should only be used with throw-away chroots, like schroot provides them, where the original state is automatically restored after each build. This command line option sets the PURGE_EXTRA_PACKAGES configuration variable. See sbuild.conf(5) for more information.
--bd-uninstallable-explainer=dose3|apt|noneโ if the build dependencies cannot be satisfied by the chosen resolver, sbuild will run the selected method to give a better explanation of why the build dependencies cannot be installed ๐ต๏ธโ๏ธ. Possible arguments for this option aredose3(the default),aptandnone. To disable this feature, passnoneor the empty string.
Depending on the resolver, the dose3 explainer might report a dependency situation as satisfiable even if the chosen resolver found it to be unsatisfiable. This is especially likely to happen if the apt resolver (the default) is used. Such disparities can have two reasons: either the understanding of the involved dependency situation of the apt and dose3 solver differs (this is a bug ๐) or the apt solver was unable to find a solution if the dependency situation is not trivial (for example if it involves packages from multiple repositories).
In the former case, please report the disparity as a bug against the resolvers. In the latter case, use a resolver that is more likely to find a solution like the aptitude or aspcud resolvers โจ. Especially the aspcud resolver should find a solution if and only if the dose3 solver also finds one ๐.
This command line option sets the BD_UNINSTALLABLE_EXPLAINER configuration variable. See sbuild.conf(5) for more information.
๐ CHROOT MODES ๐
okay bestie, here's the whole โจpointโจ of sbuild: it builds Debian packages inside a clean chroot environment. But โ plot twist โ sbuild does not go around provisioning and managing those chroots itself. Nope. That's a whole other job, done by multiple backends. ๐ซถ
The default backend (a.k.a. the chroot mode) is schroot, which is an suid binary that lets regular users wander into a chroot environment. But sbuild also lets you build packages in a qemu virtual machine, lxc, lxd, docker, podman, or on a remote host reached by ssh using the autopkgtest backend. ๐
Which backend you get is chosen with the --chroot-mode command line argument or the $chroot_mode configuration parameter. easy.
๐ธ unshare
The default and recommended chroot mode, no cap. It's also what's used on Debian buildd machines. ๐
This backend lets you build packages inside chroots without superuser privileges. Which means you can set up an arbitrary build environment without having to become root, bestie. Building packages with unshare also doesn't require sudo (schroot is suid root, fyi). The unshare backend only makes use of two small suid binaries: newuidmap and newgidmap. ๐ง
This backend allows arbitrary tarballs containing chroot environments to be used for package building. The default tarball location is in ~/.cache/sbuild/. The expected names are resolved in the same order as for the schroot chroot mode, and can be overridden using the -c or --chroot options.
๐ schroot
Use sbuild-createchroot to set up sbuild for use with the schroot backend โ it will also write out the necessary schroot configuration files in /etc. To actually use the chroots, the current user has to be added to the sbuild group, for example by running sbuild-adduser. ๐
Updating these schroot backends can be done using sbuild-update. See the respective man pages for more info about how to use these programs. ๐
Schroot supports chroots from directories, tarballs, filesystem images and block devices. It provides ephemeral chroots either by unpacking a tarball into a temporary directory, by using an overlay filesystem for directory chroots, or by using btrfs or lvm snapshots. ๐
Chroots usable by schroot are defined by configuration files in /etc/schroot/chroot.d/. When building for a specific distribution and architecture, sbuild will choose the chroot that is named (or has the alias) $distribution-$arch-sbuild, $distribution-sbuild, $distribution-$arch or $distribution โ in that order of preference. The used chroot name can be overridden using the -c or --chroot options.
๐ฅ sudo
It operates by plainly entering the chosen chroot directory using sudo chroot. So yeah, this backend also does not provide ephemeral chroots. ๐ญ
The sudo chroot mode searches for a symlink or directory located at /etc/sbuild/chroot/ or in the current directory, prefixed with chroot-. The expected names are resolved in the same order as for the schroot chroot mode, and can be overridden using the -c or --chroot options.
โญ autopkgtest
This one is experimental, girlies, so hold on tight. ๐ข It's a chroot mode that lets you build packages in any chroot supported by autopkgtest. Which means you can build in lxc, lxd, docker or podman containers, a qemu virtual machine, or on a remote host via ssh. ๐
Which autopkgtest server to use is determined via the --autopkgtest-virt-server option. And since autopkgtest (unlike schroot) does not maintain a registry of available containers or (virtual) machines, you have to manually specify them using the --autopkgtest-virt-server-opts= command line argument. To avoid having to manually type the right container or machine name every single time sbuild is executed, percent escapes are permitted. ๐
Note that theunsharebackend does not support the session concept, so you can't use--purge-sessionwith it. Use the options listed below under EXTERNAL COMMANDS instead. ๐ซก
Onbusterand earlier Debian releases, unprivileged userns clones (/proc/sys/kernel/unprivileged_userns_clone) were disabled by default by means of a Debian-specific kernel patch. On these systems, root is required for enabling them. This can also be done permanently by settingkernel.unprivileged_userns_clone=1in/etc/sysctl.d/. ๐ ๏ธ
๐ BUILD ARTIFACTS ๐
Everything the build produces gets saved into the directory specified by the --build-dir command-line parameter or the BUILD_DIR configuration variable. ๐ฆ
Sbuild is meant to be used to build architecture specific binary packages from a given source package. But plot twist, it's also able to generate architecture independent binary packages and to rebuild the original source package that was used as input. In summary, sbuild can build architecture specific binary packages, architecture independent binary packages and source packages. ๐
What ends up actually being built is determined by the configuration variables BUILD_ARCH_ANY, BUILD_ARCH_ALL and BUILD_SOURCE, respectively. See sbuild.conf(5) for a detailed explanation of these configuration variables. ๐
By default, during native compilation, BUILD_ARCH_ANY and BUILD_ARCH_ALL are set to true while BUILD_SOURCE is set to false. During cross-compilation, BUILD_ARCH_ALL defaults to false. ๐ฆ
This behaviour can be changed either by using command line options or by modifying the configuration variables in your ~/.sbuildrc. The relevant command line options to change the values of BUILD_ARCH_ANY, BUILD_ARCH_ALL and BUILD_SOURCE are --arch-any/--no-arch-any, --arch-all/--no-arch-all and --source/--no-source, respectively. ๐
The values of BUILD_ARCH_ANY, BUILD_ARCH_ALL and BUILD_SOURCE change the parameter that dpkg-buildpackage is called with. Here's the whole mapping โ what gets passed to dpkg-buildpackage depending on the three config options, in order. ๐งพ
BUILD_ARCH_ANY=false,BUILD_ARCH_ALL=false,BUILD_SOURCE=falseโdpkg-buildpackageflag:invalid๐BUILD_ARCH_ANY=false,BUILD_ARCH_ALL=false,BUILD_SOURCE=trueโdpkg-buildpackageflag:-SBUILD_ARCH_ANY=false,BUILD_ARCH_ALL=true,BUILD_SOURCE=falseโdpkg-buildpackageflag:-ABUILD_ARCH_ANY=false,BUILD_ARCH_ALL=true,BUILD_SOURCE=trueโdpkg-buildpackageflag:-gBUILD_ARCH_ANY=true,BUILD_ARCH_ALL=false,BUILD_SOURCE=falseโdpkg-buildpackageflag:-BBUILD_ARCH_ANY=true,BUILD_ARCH_ALL=false,BUILD_SOURCE=trueโdpkg-buildpackageflag:-GBUILD_ARCH_ANY=true,BUILD_ARCH_ALL=true,BUILD_SOURCE=falseโdpkg-buildpackageflag:-bBUILD_ARCH_ANY=true,BUILD_ARCH_ALL=true,BUILD_SOURCE=trueโdpkg-buildpackageflag: no option
aaaand the log file describing the build? It's named in the form:
package_version_arch-YYYY-MM-DDTHH:MM:SSZ.build
and saved in the --build-dir, usually defaulting to the current working directory. ๐
As a special case: if sbuild is in buildd mode, the default log directory is$HOME/logsand the.buildextension is omitted. ๐จ
The version is omitted if it is not known at the start of the build โ for example when the package is specified as a package name without version and downloaded from the apt archive during build. โจ
- Initialise chroot session
--pre-build-commandsโ root: no ยท runs outside (on the host) ๐ ยท%c: no ยท%e: yes ยท%r: yes ยท%d,%p: maybe
- Setup the chroot and variables
--chroot-setup-commandsโ root: yes ๐ ยท runs inside the chroot ยท%c: no ยท%e: no ยท%r: no ยท%d,%p: maybe
- Update and upgrade packages
--chroot-update-failed-commandsโ root: yes ยท runs inside ยท%c: no ยท%e: no ยท%r: no ยท%d,%p: maybe
- Fetch and unpack source package ๐ฆ
- Install Dependencies
--build-deps-failed-commandsโ root: yes ยท runs inside ยท%c: no ยท%e: no ยท%r: no ยท%d,%p: yes--starting-build-commandsโ root: yes ยท runs inside ยท%c: no ยท%e: no ยท%r: no ยท%d,%p: yes
- Run dpkg-buildpackage
--build-failed-commandsโ root: yes ยท runs inside ยท%c: no ยท%e: no ยท%r: no ยท%d,%p: yes--finished-build-commandsโ root: yes ยท runs inside ยท%c: no ยท%e: no ยท%r: no ยท%d,%p: yes
- Run lintian (if configured)
--chroot-cleanup-commandsโ root: yes ยท runs inside ยท%c: yes โ ยท%e: no ยท%r: no ยท%d,%p: yes
- Cleanup build files and dependencies
- Run piuparts (if configured)
- Run autopkgtest (if configured)
- Close schroot session
--post-build-commandsโ root: no ยท runs outside ๐ ยท%c: yes ยท%e: yes ยท%r: yes ยท%d,%p: yes--post-build-failed-commandsโ root: no ยท runs outside ๐ ยท%c: yes ยท%e: yes ยท%r: yes ยท%d,%p: yes
๐ Defining hooks in the config file ๐
So you've got two ways to write these in the configuration file: as strings, or as a list of arguments. Both are valid, bestie, pick your fighter. ๐
Like, say you wanna run foo and bar with some arguments before a build kicks off โ you'd write:
$external_commands = {
"pre-build-commands" => [
['foo', 'arg1', 'arg2'],
'bar arg1 arg2 arg3',
],
};
The hash keys for commands that run at other stages are literally the same name as their matching command-line option, minus the leading --. iykyk โจ
Here's how you do the exact same thing, but using the --pre-build-commands option instead:
$ sbuild \
--pre-build-commands='foo arg1 arg2' \
--pre-build-commands='bar arg1 arg2 arg3'
โ ๏ธ Okay so important: all of these commands get run through/bin/sh. If you write your command as a list in the config file, only very few shell facilities work โ no redirection, no command concatenation with;, none of that. But if you pass a string (in the config file or on the command line), the string gets handed to the shell as-is. Which means all the shell facilities are yours ๐ โ and also you must escape everything properly, exactly like you would in an interactive shell. No shortcuts, sorry babe ๐ญ
External commands are processed in the order they're given. First the ones from the configuration file, then any that came in through the command-line options. Order matters, no cap. ๐ฅ
๐ PERCENT ESCAPES FOR HOOKS ๐
sbuild supports a bunch of percent escapes inside hook commands, so you can feed useful arguments straight into your external command. Like, if you wanna run something on the .changes, you just reach for %c. Iconic. ๐
These are the escapes it supports:
%%โ escapes a%. Classic. ๐ซถ%d,%SBUILD_DSCโ the absolute path (on the host) of the.dscfile being built.%c,%SBUILD_CHANGESโ the absolute path to a package's source.changesfile. And listen, this is the.changesfile generated by thedpkg-buildpackageinvocation, not the source-only.changesfile that might also have been produced via--source-only-changes. This variable is only set after the build is finished, i.e. in--chroot-cleanup-commands,--post-build-commands, and--post-build-failed-commands.%a,%SBUILD_HOST_ARCHโ the debian name of the architecture the package is being built for (e.g.,amd64,armhf).%e,%SBUILD_CHROOT_EXECโ these escapes turn into a prefix command that runs the subsequent command and arguments inside the chroot. So like,"%SBUILD_CHROOT_EXEC cat /etc/hostname"will list the hostname of the chroot, slay ๐ Standard input and output of the process started inside the chroot are connected to the program running on the host. Which means โ yes babe โ this command can also be used to copy data into the chroot and out of the chroot. ๐ฆ The working directory of the process started inside the chroot is the root directory of the chroot, and the process is started as the root user in the chroot. This escape is only available for--pre-build-commands,--post-build-commands, and--post-build-failed-commands, because all the other hooks are already running everything inside the chroot.%r,%SBUILD_CHROOT_DIRโ these escapes turn into the absolute path on the host to the root directory of the chroot. This variable isn't set if the external command runs inside the chroot. So this escape is only available for--pre-build-commandsand--post-build-commands.%b,%SBUILD_BUILD_DIRโ the absolute path of the build directory inside the chroot.%p,%SBUILD_PKGBUILD_DIRโ the absolute path of the package build directory inside the chroot.%s,%SBUILD_SHELLโ this converts into a command that spawns an interactivebashshell. It'll either be running in the chroot or on the host, depending on which hook it's run from. Bestie gets her own little shell ๐โจ%SBUILD_BUILD_ARCHโ the Debian name of the architecture the build is being run on (e.gamd64,armhf).%SRCPACKAGEโ the name of the source package being built.%SRCPACKAGE_VERSIONโ the name and version of the source package being built, separated by an underscore. This may not be available if you ran sbuild passing just a source package name. ๐%SBUILD_LOG_PATHโ the absolute path to the sbuild log (on the host). This is defined even if--nologwas used, so it may reference a file that doesn't exist. It's equivalent to%SBUILD_LOG_DIR/%SBUILD_LOG_BASENAME.%SBUILD_LOG_DIRโ the absolute path to the directory (on the host) holding the sbuild log file.%SBUILD_LOG_BASENAMEโ the filename of the sbuild log file. This is (usually) equivalent to%SRCPACKAGE_VERSION_%SBUILD_HOST_ARCH-STARTTIME.buildwhereSTARTTIMEis when the build started:%SRCPACKAGEis used if the version isn't defined, and the.buildsuffix is omitted in buildd mode.
โ ๏ธ Percent escapes are only defined when an appropriate value is defined for them. At other times, they get left unchanged. For example%cand%eare not always defined in every hook. Like, a.changesfile is only defined at the end of a build, so using%cwill only be available in post-build-commands and post-build-failed-commands. ๐
Here's an example of using an escape to run a program foo on a .changes file after a build is done:
$ sbuild --post-build-commands \
'foo %SBUILD_CHANGES'
And here's one that'll spawn an interactive shell so you can go investigate the problem whenever the build failed. Main character detective energy ๐๐
$ sbuild --build-failed-commands '%SBUILD_SHELL'
And this one would copy a file from the host into the chroot:
$ sbuild --pre-build-commands \
'cat blub.txt | %SBUILD_CHROOT_EXEC sh -c "cat > blub.txt"'
โญ OPTION STRING PERCENT ESCAPES โญ
sbuild also recognises some percent escapes in options passed to piuparts, autopkgtest and the autopkgtest-virt server. Super handy for communicating the right chroot backend to piuparts or autopkgtest, depending on the distribution or architecture the source package was built for. Vibe check passed โ
Here's the rundown of these keywords and what each one turns into:
%%โ used to escape a%.%a,%SBUILD_HOST_ARCHโ these escapes turn into the debian name of the architecture the build is being built for (e.gamd64,armhf).%r,%SBUILD_DISTRIBUTIONโ the distribution that the source package was built for. This is the value recorded indebian/changelogor the value passed via the--distoption. Mnemonic: theris the first letter in "release". ๐ง โจ
Here's an example that'll run piuparts with the right schroot chroot:
$ sbuild --run-piuparts \
--piuparts-opts="--schroot=%r-%a-sbuild"
Or, running autopkgtest with the right schroot chroot:
$ sbuild --run-autopkgtest --autopkgtest-root-args= \
--autopkgtest-opts="-- schroot %r-%a-sbuild"
Wanna achieve the same effect through the configuration file instead? Add this, bestie:
$autopkgtest_root_args = '';
$piuparts_opts = [ '--schroot=%r-%a-sbuild' ];
$autopkgtest_opts = [ '--', 'schroot', '%r-%a-sbuild' ];
The --autopkgtest-root-args option and the $autopkgtest_root_args configuration variable are both set to the empty string, because the default is to run autopkgtest with sudo -- in front of it โ which you don't need with the schroot autopkgtest backend. No unnecessary sudo around here, we're not doing that ๐
๐ซ
๐๏ธ LOCAL ARCHIVE
okay so bestie, when the apt and aptitude resolvers do their thing, they spin up a local archive for installing build dependencies. and here's the tea: this is a purely internal implementation detail of the build dependency resolver. it is not user configurable, and it's meant to be entirely transparent to you โ like it's not even there. ๐ป
the local archive exists only transiently, during the package build. it does not persist across builds, and its one and only job is storing the dummy dependency packages created for a single build. so don't get attached, she's not staying. ๐
what the dependency resolvers actually do (step by step, iconic behavior)
the dependency resolvers do the following:
- Create a dummy dependency package. this lil guy contains the
Build-Depends(and optionallyBuild-Depends-ArchandBuild-Depends-Indep) asDepends, andBuild-Conflicts(and optionallyBuild-Conflicts-ArchandBuild-Conflicts-Indep) asConflicts. - Install the dummy dependency package into the local archive,
- Generate the
Packages,SourcesandReleasefiles. - Write a
sources.listfile for the local archive into/etc/apt/sources.list.d. - Inject the lists directly into
/var/lib/apt/lists. this step is to save running updating all apt sources, which is undesirable during a build;aptandaptitudedo not support updating a single source at present. (rip, no single-source updates yet ๐ญ) - Regenerate the apt caches to ensure everything is in sync. โจ
- Install the dummy dependency package with
aptoraptitude; the dummy package is pulled from the local apt archive, while all its dependencies are pulled from the regular configured apt sources.
and at the end of the build? the local archive gets removed, along with the rest of the build tree. poof. gone. ๐ซถ
๐ EXAMPLES ๐
before you use sbuild for the very first time, you gotta do some setup depending on the chroot mode you're using. the default chroot mode is schroot. to use sbuild with the schroot backend, you need to add your user to the sbuild group and create a schroot chroot. that second part can be accomplished by using sbuild-createchroot(8). ๐ธ
after this one-time setup, you can now use sbuild to build packages like this:
% sbuild -d unstable bash
or on a .dsc:
% sbuild -d unstable bash.dsc
or from within an unpacked source package (heads up: the -d parameter is not necessary here because the distribution is inferred from debian/changelog) โ look at her, so smart:
% sbuild
๐ ENVIRONMENT VARIABLES ๐
the following environment variables are used by sbuild:
HOMEโ the home directory of the user. ๐LOGNAMEโ used in lockfiles. ๐SBUILD_CONFIGโ path to an additional configuration file, layered on top of the system-wide and user-specific ones.
๐ FILES ๐
/etc/sbuild/sbuild.confโ Configuration, maintained by the system administrator. this may be used to override the defaults./etc/sbuild/chrootโ Directory containing symbolic links to chroots. this is only used forsudochroot access;schrootaccess uses the schroot chroot configuration.$XDG_CONFIG_HOME/sbuild/config.plor~/.config/sbuild/config.pl(alternatively:~/.sbuildrc) โ User-specific configuration. If$XDG_CONFIG_HOMEis either not set or empty,~/.config/sbuild/config.plwill be used. If noconfig.plwas found,~/.sbuildrcis used, but that path is deprecated and users should switch to a location under$XDG_CONFIG_HOMEor~/.config. > a custom path to a configuration file can also be specified through setting theSBUILD_CONFIGenvironment variable to the path of an additional configuration file. โ ๏ธ/var/lib/sbuildโ Build trees, archive signing keys, build statistics and lock files.
๐ AUTHORS ๐
Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>.
sbuild is based on debbuild, written by James Troup <james@nocrew.org> and has been modified by Ben Collins <bcollins@debian.org>, Ryan Murray <rmurray@debian.org>, Francesco Paolo Lovergine <frankie@debian.org>, Michael Banck <mbanck@debian.org>, and Roger Leigh <rleigh@debian.org>
๐ COPYRIGHT ๐
Copyright ยฉ 1998-2000 Roman Hodek <roman@hodek.net> Copyright ยฉ 1998-1999 James Troup <troup@debian.org> Copyright ยฉ 2003-2006 Ryan Murray <rmurray@debian.org> Copyright ยฉ 2001-2003 Rick Younie <younie@debian.org> Copyright ยฉ 2003-2004 Francesco Paolo Lovergine <frankie@debian.org> Copyright ยฉ 2005 Michael Banck <mbanck@debian.org> Copyright ยฉ 2005-2009 Roger Leigh <rleigh@debian.org>
๐ฆ SEE ALSO ๐ฆ
sbuild.conf(5), sbuild-abort(1), sbuild-adduser(8), sbuild-apt(1), sbuild-checkpackages(1), sbuild-createchroot(8), sbuild-distupgrade(1), sbuild-hold(1), sbuild-setup(7). sbuild-shell(1), sbuild-unhold(1), sbuild-update(1), sbuild-upgrade(1), schroot(1),
and that's the whole page bestie, we made it to the end ๐ slay. this was Version 0.91.10ubuntu1, dated 29 June 2026 โ go build something iconic, you've got this. ๐โจ
๐ฆ where this page comes from
- ubuntu stonking: sbuild 0.91.10ubuntu1 ยท GPL-2.0-or-later
- Copyright ยฉ 1998 James Troup <james@nocrew.org>
- Copyright ยฉ 2005-2009 Roger Leigh <rleigh@debian.org>
- Copyright ยฉ 2008 Simon McVittie <smcv@debian.org>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms