From e25936cc611c36f10e13d959b52eb0335c67f976 Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Fri, 12 May 2017 21:20:22 +0200 Subject: [PATCH 1/6] Source ubuntu-cpc functions from the right place --- live-build/ubuntu-cpc/hooks/030-root-tarball.binary | 2 +- live-build/ubuntu-cpc/hooks/032-disk-image.binary | 2 +- live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary | 2 +- live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary | 2 +- live-build/ubuntu-cpc/hooks/040-qcow2-image.binary | 2 +- live-build/ubuntu-cpc/hooks/040-vmdk-image.binary | 2 +- live-build/ubuntu-cpc/hooks/042-vagrant.binary | 2 +- live-build/ubuntu-cpc/hooks/999-extras.binary | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/live-build/ubuntu-cpc/hooks/030-root-tarball.binary b/live-build/ubuntu-cpc/hooks/030-root-tarball.binary index f3e1c9e5..7571711b 100755 --- a/live-build/ubuntu-cpc/hooks/030-root-tarball.binary +++ b/live-build/ubuntu-cpc/hooks/030-root-tarball.binary @@ -5,7 +5,7 @@ if [ -n "$SUBARCH" ]; then exit 0 fi -. /build/config/functions +. config/functions mkdir binary/boot/filesystem.dir cp -a chroot/* binary/boot/filesystem.dir diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index 386fbe3b..a1f636ec 100755 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -1,6 +1,6 @@ #!/bin/bash -ex -. /build/config/functions +. config/functions BOOTPART_START= BOOTPART_END= diff --git a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary index 04a3c7df..cdef497b 100755 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -9,7 +9,7 @@ case $ARCH in ;; esac -. /build/config/functions +. config/functions apt-get -qqy install dosfstools gdisk diff --git a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary index 1f6b35a7..884626e8 100755 --- a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary +++ b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary @@ -7,7 +7,7 @@ case $ARCH in ;; esac -. /build/config/functions +. config/functions create_partitions() { disk_image="$1" diff --git a/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary b/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary index 602d871e..03ac69f1 100755 --- a/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary +++ b/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary @@ -12,7 +12,7 @@ esac apt-get install -qqy qemu-utils -. /build/config/functions +. config/functions if [ -f binary/boot/disk.ext4 ]; then convert_to_qcow2 binary/boot/disk.ext4 livecd.ubuntu-cpc.disk1.img diff --git a/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary index 80e4142c..6061298c 100755 --- a/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary +++ b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary @@ -11,7 +11,7 @@ case $ARCH in exit 0;; esac -. /build/config/functions +. config/functions if [ -e binary/boot/disk.ext4 ]; then create_vmdk binary/boot/disk.ext4 livecd.ubuntu-cpc.disk1.vmdk diff --git a/live-build/ubuntu-cpc/hooks/042-vagrant.binary b/live-build/ubuntu-cpc/hooks/042-vagrant.binary index 0471248d..90aedfdf 100755 --- a/live-build/ubuntu-cpc/hooks/042-vagrant.binary +++ b/live-build/ubuntu-cpc/hooks/042-vagrant.binary @@ -35,7 +35,7 @@ case $ARCH in exit 0;; esac -. /build/config/functions +. config/functions # Virtualbox is needed for making a small VMDK apt-get -qqy install genisoimage qemu-utils diff --git a/live-build/ubuntu-cpc/hooks/999-extras.binary b/live-build/ubuntu-cpc/hooks/999-extras.binary index e45b8e0c..2dd1dbd3 100755 --- a/live-build/ubuntu-cpc/hooks/999-extras.binary +++ b/live-build/ubuntu-cpc/hooks/999-extras.binary @@ -9,7 +9,7 @@ if [ ! -d ${my_dir}/extra ]; then fi # Export the common functions to the extras -. /build/config/functions +. config/functions # Cleaner execution /bin/run-parts --exit-on-error --regex ".*\.binary" "${extra_d}" From 95c239f301aad1211a06eba99a5a6b0a54979c01 Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Fri, 12 May 2017 21:20:22 +0200 Subject: [PATCH 2/6] Use all config hooks from the proper place, not from /build/ --- live-build/ubuntu-cpc/hooks/032-disk-image.binary | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index a1f636ec..9c7d42ea 100755 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -88,7 +88,7 @@ case $ARCH:$SUBARCH in # not the best place for this, but neither flash-kernel nor # u-boot have provisions for installing u-boot via maintainer # script - /build/config/hooks/raspi2/mkknlimg --dtok \ + config/hooks/raspi2/mkknlimg --dtok \ mountpoint/usr/lib/u-boot/rpi_2/u-boot.bin \ mountpoint/boot/firmware/uboot.bin ;; From 2685b836bd99ea607e109715df3751cd0be66c72 Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Fri, 12 May 2017 21:20:22 +0200 Subject: [PATCH 3/6] Add basic autopkgtest --- debian/tests/control | 3 + debian/tests/default-bootstraps | 97 +++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 debian/tests/control create mode 100755 debian/tests/default-bootstraps diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 00000000..a37a5d79 --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,3 @@ +Tests: default-bootstraps +Depends: @, lsb-release +Restrictions: needs-root diff --git a/debian/tests/default-bootstraps b/debian/tests/default-bootstraps new file mode 100755 index 00000000..23631d4c --- /dev/null +++ b/debian/tests/default-bootstraps @@ -0,0 +1,97 @@ +#!/bin/sh +# autopkgtest check: Build default rootfs for all supported project:subproject pairs +# (C) 2017 Canonical Ltd. +# Author: Balint Reczey + +set -e + +if [ -z "$SUITE"]; then + SUITE=$(lsb_release -c -s) +fi + +# Known project:subproject:template combinations. +# Listed subprojects can be combined with other projects as well, +# but this list gives reasonable coverage. +ALL_TRIPLETS=" + base:: + edubuntu:: + edubuntu-dvd:: + kubuntu:: + kubuntu-active:: + kubuntu-dvd:: + kubuntu-plasma5:: + lubuntu:: + lubuntu-next:: + mythbuntu:: + ubuntu:: + ubuntu-base:: + ubuntu-budgie:: + ubuntu-budgie-desktop:: + ubuntu-budgie-live:: + ubuntu-core:system-image:ubuntu-core + ubuntu-cpc::ubuntu-cpc + ubuntu-desktop-next:system-image:ubuntu-desktop-next + ubuntu-desktop-next::ubuntu-desktop-next + ubuntu-dvd:: + ubuntu-gnome:: + ubuntukylin:: + ubuntu-mate:: + ubuntu-mate-core:: + ubuntu-mate-desktop:: + ubuntu-mate-live:: + ubuntu-netbook:: + ubuntu-server:: + ubuntu-server:ubuntu-rtm: + ubuntu-server:ubuntu-rtm/foo: + ubuntu-server:wubi: + ubuntu-touch-custom::ubuntu-touch-custom + ubuntu-touch::ubuntu-touch + xubuntu::" + +if [ -z "$SELECTED_TRIPLETS" ]; then + SELECTED_TRIPLETS=" + ubuntu-base:: + ubuntu-cpc::ubuntu-cpc +" +fi + +live_build_rootfs() { + PROJECT=${1%%:*} + local SUBPROJECT_TMP=${1%:*} + SUBPROJECT=${SUBPROJECT_TMP#*:} + TEMPLATE=${1##*:} + ARCH=$(dpkg --print-architecture) + echo "Building rootfs for project: '$PROJECT' subproject: '$SUBPROJECT' template: '$TEMPLATE' in $PWD" + cp -a /usr/share/livecd-rootfs/live-build/auto . + if [ -n "$TEMPLATE" ]; then + cp -a /usr/share/livecd-rootfs/live-build/$TEMPLATE . + fi + (env PROJECT=$PROJECT \ + SUBPROJECT=$SUBPROJECT \ + SUITE=$SUITE \ + ARCH=$ARCH \ + lb config + ) + mkdir chroot + # this part needs root rights, but right now the whole script ran as root by autopkgtest + (env PROJECT=$PROJECT \ + SUBPROJECT=$SUBPROJECT \ + ARCH=$ARCH \ + lb build + ) + echo "Build results for project: '$PROJECT' subproject: '$SUBPROJECT' template: '$TEMPLATE' in $PWD" + du -sh * + echo "" +} + +WORKDIR=$(mktemp -d) +trap "RET=\$?; rm -rf $WORKDIR; exit \$RET" 0 INT QUIT ABRT PIPE TERM +cd $WORKDIR + +for i in $SELECTED_TRIPLETS; do + mkdir $i + (cd $i && live_build_rootfs $i) + # clean up after build to avoid filling the disk, needs root rights + rm -rf $i +done + From 0fcff1923c2c2b2cdd527ebfe905dcbdcf8470d9 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Fri, 12 May 2017 21:20:22 +0200 Subject: [PATCH 4/6] Mark autopkgtests isolation-machine since debootstrap won't work in a container. --- debian/tests/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/tests/control b/debian/tests/control index a37a5d79..b40640f9 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -1,3 +1,3 @@ Tests: default-bootstraps Depends: @, lsb-release -Restrictions: needs-root +Restrictions: needs-root isolation-machine From 2569995de8ca09a6b0e9dbe488a5e56bbeb8c5e8 Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Fri, 12 May 2017 21:20:22 +0200 Subject: [PATCH 5/6] Work around kpartx's nonzero exit due to "Device or resource busy" errors which still permit kpartx to finally remove loop device (LP: #1684090). Also sync before calling kpartx to let writing to loop devices finish. --- live-build/ubuntu-cpc/functions | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/live-build/ubuntu-cpc/functions b/live-build/ubuntu-cpc/functions index 6b2d69a0..7ed46906 100644 --- a/live-build/ubuntu-cpc/functions +++ b/live-build/ubuntu-cpc/functions @@ -11,9 +11,22 @@ backing_img= apt-get -qqy install dosfstools gdisk clean_loops() { + local kpartx_ret + local kpartx_stdout if [ -n "${backing_img}" ]; then - kpartx -v -d "${backing_img}" + # sync before removing loop to avoid "Device or resource busy" errors + sync + kpartx_ret="" + kpartx_stdout=$(kpartx -v -d "${backing_img}") || kpartx_ret=$? + echo "$kpartx_stdout" + if [ -n "$kpartx_ret" ]; then + if echo "$kpartx_stdout" | grep -q "loop deleted: "; then + echo "Suppressing kpartx returning error (#860894)" + else + exit $kpartx_ret + fi + fi unset backing_img fi From 8d72b588a1fd38eeca3d81ab5d45d74b3855b24e Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Fri, 12 May 2017 21:21:05 +0200 Subject: [PATCH 6/6] Update changelog --- debian/changelog | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/debian/changelog b/debian/changelog index fcd9de64..26752167 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,20 @@ +livecd-rootfs (2.408.13) UNRELEASED; urgency=medium + + [ Balint Reczey ] + * Source ubuntu-cpc functions from the right place + * Use all config hooks from the proper place, not from /build/ + * Add basic but configurable autopkgtest (LP: #1690440) + * sync before calling kpartx to let writing to loop devices finish + + [ Steve Langasek ] + * Mark autopkgtests isolation-machine since debootstrap won't work in a container. + * Resurrect Balint's fix from + lp:~rbalint/livecd-rootfs/livecd-rootfs-autopkgtest-fix to wrap kpartx + and trap spurious errors, since the problem is still being seen + intermittently on i386 despite us calling sync before kpartx. (LP: #1684090) + + -- Balint Reczey Thu, 11 May 2017 16:18:20 +0200 + livecd-rootfs (2.408.12) xenial; urgency=medium * live-build/ubuntu-cpc/hooks/999-extras.binary: Exit on first failure.