How to build systemd

J Fernyhough j.fernyhough at
Fri Aug 5 10:48:46 UTC 2016

On 04/08/16 15:45, Alex Lyakas wrote:
> Greetings,
> I have downloaded the systemd package for trusty
> ( with “apt-get source
> systemd”.
> Which commands should I issue to build it? Specifically I need to build
> udev and its accompanying tools (like scsi_id).

The easiest way (I've found) to build packages from source is with
`debuild`, e.g.:

$> apt-get source systemd
$> cd systemd-204
$systemd-204> debuild

This will probably complain about missing dependencies. You can go
through the list and install manually, use `apt-get build-dep systemd`,
or install `equivs` and use `mk-build-deps` (which is what I would do as
it's then easy to remove the deps afterwards), e.g.:

$> mk-build-deps systemd
$> sudo gdebi systemd-build-deps_204-5ubuntu20.19_all.deb

(`gdebi` will automatically install dependencies, `dpkg -i` will not.
`mk-build-deps` will also run without an argument from within a source
directory, the above command makes it explicit and means there's not a
deb file created in the source directory.)

So, putting this together:

$~> sudo apt-get install equivs
$~> apt-get source systemd
$~> mk-build-deps systemd
$~> sudo gdebi systemd-build-deps_204-5ubuntu20.19_all.deb
$~> cd systemd-204
$systemd-204> debuild
$systemd-204> cd ..
$~> ls
[newly created package files]
$~> sudo apt-get purge systemd-build-deps
$~> sudo apt-get autoremove --purge

Be aware that this build will depend on the packages currently installed
on your system. A better approach (which is also used by e.g. Launchpad)
is to build in a chroot, probably using pbuilder:

Once you have this set up you only need to use `pdebuild` instead of

$~> apt-get source systemd
$~> cd systemd-204
$systemd-204> sudo pdebuild
$systemd-204> ls /var/cache/pbuilder/result/
[newly created package files]

This should automatically install all necessary buildeps within the
chroot and produce the debs (and other package files) in
/var/cache/pbuilder/result by default. To specify a target location use
`pbuilder --buildresult /target/location` (see `man pdebuild`).

There's an awful lot of documentation on the web to wade through for
package maintenance, and quite a bit is contradictory (or at least
inconsistent), but this should at least get you started.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 851 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the Ubuntu-devel-discuss mailing list