diff --git a/debian/changelog b/debian/changelog index 2673f96c..638b7e38 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +livecd-rootfs (2.553) disco; urgency=medium + + * Add a LXD image to builds for the buildd subproject. + * Move buildd image building to binary hooks. + + -- Colin Watson Mon, 07 Jan 2019 21:23:31 +0000 + livecd-rootfs (2.552) disco; urgency=medium * Do not include curtin in the live-server installer.squashfs as the diff --git a/live-build/auto/build b/live-build/auto/build index 9648e78f..a980c26c 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -17,7 +17,7 @@ fi . config/functions -# Link output files somewhere BuildLiveCD will be able to find them. +# Link output files somewhere launchpad-buildd will be able to find them. PREFIX="livecd.$PROJECT${SUBARCH:+-$SUBARCH}" if [ "${IMAGEFORMAT:-}" = "ubuntu-image" ]; then @@ -521,16 +521,6 @@ if [ -e "binary/$INITFS/filesystem.dir" ]; then chmod 644 "$PREFIX.rootfs.tar.gz" elif [ -e binary-tar.tar.gz ]; then cp -a binary-tar.tar.gz "$PREFIX.rootfs.tar.gz" -elif [ "$SUBPROJECT" = buildd ]; then - # A few things (launchpad-buildd, sbuild-launchpad-chroot) rely on - # the top-level directory being "chroot-autobuild", so we have to do - # this ourselves. - # gzip was chosen for fastest decompression speed: it decompresses - # buildd chroots about twice as fast as xz and about five times as - # fast as bzip2. - tar --transform='s,^binary,chroot-autobuild,' \ - --sort=name --numeric-owner \ - -czf "$PREFIX.rootfs.tar.gz" binary fi if [ "$PROJECT:${SUBPROJECT:-}" = "ubuntu-core:system-image" ]; then diff --git a/live-build/auto/config b/live-build/auto/config index 496e8dea..2cafdb4e 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -707,6 +707,8 @@ case $SUBPROJECT in add_package install build-essential # Needed for LXD-based builds. add_package install init + + cp -af /usr/share/livecd-rootfs/live-build/make-lxd-metadata.py config/make-lxd-metadata ;; esac diff --git a/live-build/buildd/hooks/50-buildd-tar.binary b/live-build/buildd/hooks/50-buildd-tar.binary new file mode 100755 index 00000000..8be7b618 --- /dev/null +++ b/live-build/buildd/hooks/50-buildd-tar.binary @@ -0,0 +1,10 @@ +#! /bin/sh +# A few things (launchpad-buildd, sbuild-launchpad-chroot) rely on the +# top-level directory being "chroot-autobuild", so we have to do this +# ourselves. +set -e + +# gzip was chosen for fastest decompression speed: it decompresses buildd +# chroots about twice as fast as xz and about five times as fast as bzip2. +tar --transform='s,^binary,chroot-autobuild,' --sort=name --numeric-owner \ + -czf "livecd.$PROJECT.rootfs.tar.gz" binary diff --git a/live-build/buildd/hooks/51-buildd-lxd.binary b/live-build/buildd/hooks/51-buildd-lxd.binary new file mode 100755 index 00000000..b4b782d9 --- /dev/null +++ b/live-build/buildd/hooks/51-buildd-lxd.binary @@ -0,0 +1,16 @@ +#! /bin/sh +# Some build types prefer a LXD image over a traditional chroot tarball. +set -e + +. config/bootstrap + +TMPDIR="$(mktemp -d)" +config/make-lxd-metadata "${LB_DISTRIBUTION%-*}" "$ARCH" \ + >"$TMPDIR/metadata.yaml" +tar --numeric-owner -cf "livecd.$PROJECT.lxd.tar" -C "$TMPDIR" metadata.yaml +rm -rf "$TMPDIR" +# When using the combined metadata/rootfs form, the rootfs must be under +# rootfs/ rather than under chroot-autobuild/. +tar --transform='s,^binary,rootfs,' --sort=name --numeric-owner \ + -rf "livecd.$PROJECT.lxd.tar" binary +gzip -9 "livecd.$PROJECT.lxd.tar" diff --git a/live-build/make-lxd-metadata.py b/live-build/make-lxd-metadata.py new file mode 100755 index 00000000..896f811a --- /dev/null +++ b/live-build/make-lxd-metadata.py @@ -0,0 +1,49 @@ +#! /usr/bin/python3 + +"""Make a metadata.yaml file for a LXD image.""" + +import argparse +import json +import sys +import time + + +# Map dpkg architecture names to LXD architecture names. +lxd_arches = { + "amd64": "x86_64", + "arm64": "aarch64", + "armhf": "armv7l", + "i386": "i686", + "powerpc": "ppc", + "ppc64el": "ppc64le", + "s390x": "s390x", + } + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("series", help="Ubuntu series name") + parser.add_argument("architecture", help="Ubuntu architecture name") + args = parser.parse_args() + + metadata = { + "architecture": lxd_arches[args.architecture], + "creation_date": int(time.time()), + "properties": { + "os": "Ubuntu", + "series": args.series, + "architecture": args.architecture, + "description": "Ubuntu buildd %s %s" % ( + args.series, args.architecture), + }, + } + + # Encoding this as JSON is good enough, and saves pulling in a YAML + # library dependency. + json.dump( + metadata, sys.stdout, sort_keys=True, indent=4, separators=(",", ": "), + ensure_ascii=False) + + +if __name__ == "__main__": + main()