From 84da578380f39a5b394ac778e34d3f61182f406c Mon Sep 17 00:00:00 2001 From: "Gary.Wzl" Date: Mon, 28 Aug 2017 11:24:51 +0800 Subject: [PATCH 1/5] Add IMAGETYPE to support classic image creation by ubuntu-image. --- live-build/auto/build | 14 ++++++--- live-build/auto/config | 66 +++++++++++++++++++++++++----------------- 2 files changed, 50 insertions(+), 30 deletions(-) diff --git a/live-build/auto/build b/live-build/auto/build index 5c7b88ce..978d2fe0 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -16,11 +16,17 @@ if [ -z "${PROJECT:-}" ]; then fi if [ "${IMAGEFORMAT:-}" = "ubuntu-image" ]; then - # Use ubuntu-image instead of live-build - env SNAPPY_STORE_NO_CDN=1 \ - ubuntu-image -c edge \ + if [ "${IMAGETYPE:-}" = "classic" ]; then + # Use ubuntu-image instead of live-build + OPTS="${PROJECT:+--project=$PROJECT} ${SUITE:+--suite=$SUITE} ${ARCH:+--arch=$ARCH} ${SUBPROJECT:+--subproject=$SUBPROJECT} ${SUBARCH:+--subarch=$SUBARCH} ${PROPOSED:+--with-proposed=$PROPOSED} ${IMAGEFORMAT:+--image-format=$IMAGEFORMAT} ${EXTRA_PPAS:+--extra-ppas=$EXTRA_PPAS}" + ubuntu-image classic $OPTS gadget_tree + else + # Use ubuntu-image instead of live-build + env SNAPPY_STORE_NO_CDN=1 \ + ubuntu-image snap -c edge \ -o livecd."$PROJECT".img livecd."$PROJECT".model-assertion - xz -0 -T4 livecd."$PROJECT".img + xz -0 -T4 livecd."$PROJECT".img + fi exit 0 fi diff --git a/live-build/auto/config b/live-build/auto/config index 3f504463..8d350ad3 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -153,34 +153,48 @@ case $IMAGEFORMAT in ;; ubuntu-image) - case "$ARCH+${SUBARCH:-}" in - amd64+*) - MODEL=pc-amd64 ;; - i386+*) - MODEL=pc-i386 ;; - arm64+snapdragon) - MODEL=dragonboard ;; - armhf+raspi2) - MODEL=pi2 ;; - armhf+raspi3) - MODEL=pi3 ;; - armhf+cm3) - MODEL=cm3 ;; - *) - echo "Model $ARCH+${SUBARCH:-} unknown to livecd-rootfs" >&2 - exit 1 + case $IMAGETYPE in + classic) + echo "IMAGEFORMAT=$IMAGEFORMAT" >> config/common + # TODO livecd-rootfs needs to take a branch URI for the gadget as input, + # stage it, and pass it to ubuntu-image, where do we get it? + + # Fake finished configuration for lb build + mkdir -p .build + touch .build/config + exit 0 + ;; + *) # backport compatibility for core image creation. + case "$ARCH+${SUBARCH:-}" in + amd64+*) + MODEL=pc-amd64 ;; + i386+*) + MODEL=pc-i386 ;; + arm64+snapdragon) + MODEL=dragonboard ;; + armhf+raspi2) + MODEL=pi2 ;; + armhf+raspi3) + MODEL=pi3 ;; + armhf+cm3) + MODEL=cm3 ;; + *) + echo "Model $ARCH+${SUBARCH:-} unknown to livecd-rootfs" >&2 + exit 1 + ;; + esac + echo "IMAGEFORMAT=$IMAGEFORMAT" >> config/common + # Store model assertion in top dir to get it picked up later as a build artifact + env SNAPPY_STORE_NO_CDN=1 snap known --remote model series=16 model="$MODEL" brand-id=canonical > livecd."$PROJECT".model-assertion + echo "Configured ubuntu-image for the following model assertion:" + cat livecd."$PROJECT".model-assertion + echo "----------------------------------------------------------" + # Fake finished configuration for lb build + mkdir -p .build + touch .build/config + exit 0 ;; esac - echo "IMAGEFORMAT=$IMAGEFORMAT" >> config/common - # Store model assertion in top dir to get it picked up later as a build artifact - env SNAPPY_STORE_NO_CDN=1 snap known --remote model series=16 model="$MODEL" brand-id=canonical > livecd."$PROJECT".model-assertion - echo "Configured ubuntu-image for the following model assertion:" - cat livecd."$PROJECT".model-assertion - echo "----------------------------------------------------------" - # Fake finished configuration for lb build - mkdir -p .build - touch .build/config - exit 0 ;; *) From eb76178ab5698dd011ae760cc20ed10c949e6200 Mon Sep 17 00:00:00 2001 From: "Gary.Wzl" Date: Mon, 28 Aug 2017 15:14:54 +0800 Subject: [PATCH 2/5] Support to only generate rootfs via variable (GENERATE_ROOTFS_ONLY). --- live-build/auto/build | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/live-build/auto/build b/live-build/auto/build index 978d2fe0..d5b8a87e 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -235,10 +235,16 @@ EOF (cd chroot && find usr/share/doc -maxdepth 1 -type d | xargs du -s | sort -nr) echo END docdirs - lb binary "$@" - touch binary.success + if [ -z "${GENERATE_ROOTFS_ONLY:-}" ]; then + lb binary "$@" + touch binary.success + fi ) 2>&1 | tee binary.log +if [ ! -z "${GENERATE_ROOTFS_ONLY:-}" ] && [ "${GENERATE_ROOTFS_ONLY}" != "false" ]; then + exit 0 +fi + # bash has trouble with the build.sh sourcing arrangement at the top of this # file, so we use this cheap-and-cheerful approach rather than the more # correct 'set -o pipefail'. From 228ed7c87b21cfd6521aa4a83bcd41d6a995d374 Mon Sep 17 00:00:00 2001 From: "Gary.Wzl" Date: Mon, 18 Sep 2017 09:38:20 +0800 Subject: [PATCH 3/5] Remove 'IMAGETYPE' and 'IMAGEFORMAT' bits per the suggestions. --- live-build/auto/build | 14 +++------ live-build/auto/config | 66 +++++++++++++++++------------------------- 2 files changed, 30 insertions(+), 50 deletions(-) diff --git a/live-build/auto/build b/live-build/auto/build index d5b8a87e..156f7789 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -16,17 +16,11 @@ if [ -z "${PROJECT:-}" ]; then fi if [ "${IMAGEFORMAT:-}" = "ubuntu-image" ]; then - if [ "${IMAGETYPE:-}" = "classic" ]; then - # Use ubuntu-image instead of live-build - OPTS="${PROJECT:+--project=$PROJECT} ${SUITE:+--suite=$SUITE} ${ARCH:+--arch=$ARCH} ${SUBPROJECT:+--subproject=$SUBPROJECT} ${SUBARCH:+--subarch=$SUBARCH} ${PROPOSED:+--with-proposed=$PROPOSED} ${IMAGEFORMAT:+--image-format=$IMAGEFORMAT} ${EXTRA_PPAS:+--extra-ppas=$EXTRA_PPAS}" - ubuntu-image classic $OPTS gadget_tree - else - # Use ubuntu-image instead of live-build - env SNAPPY_STORE_NO_CDN=1 \ - ubuntu-image snap -c edge \ + # Use ubuntu-image instead of live-build + env SNAPPY_STORE_NO_CDN=1 \ + ubuntu-image -c edge \ -o livecd."$PROJECT".img livecd."$PROJECT".model-assertion - xz -0 -T4 livecd."$PROJECT".img - fi + xz -0 -T4 livecd."$PROJECT".img exit 0 fi diff --git a/live-build/auto/config b/live-build/auto/config index 8d350ad3..3f504463 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -153,48 +153,34 @@ case $IMAGEFORMAT in ;; ubuntu-image) - case $IMAGETYPE in - classic) - echo "IMAGEFORMAT=$IMAGEFORMAT" >> config/common - # TODO livecd-rootfs needs to take a branch URI for the gadget as input, - # stage it, and pass it to ubuntu-image, where do we get it? - - # Fake finished configuration for lb build - mkdir -p .build - touch .build/config - exit 0 - ;; - *) # backport compatibility for core image creation. - case "$ARCH+${SUBARCH:-}" in - amd64+*) - MODEL=pc-amd64 ;; - i386+*) - MODEL=pc-i386 ;; - arm64+snapdragon) - MODEL=dragonboard ;; - armhf+raspi2) - MODEL=pi2 ;; - armhf+raspi3) - MODEL=pi3 ;; - armhf+cm3) - MODEL=cm3 ;; - *) - echo "Model $ARCH+${SUBARCH:-} unknown to livecd-rootfs" >&2 - exit 1 - ;; - esac - echo "IMAGEFORMAT=$IMAGEFORMAT" >> config/common - # Store model assertion in top dir to get it picked up later as a build artifact - env SNAPPY_STORE_NO_CDN=1 snap known --remote model series=16 model="$MODEL" brand-id=canonical > livecd."$PROJECT".model-assertion - echo "Configured ubuntu-image for the following model assertion:" - cat livecd."$PROJECT".model-assertion - echo "----------------------------------------------------------" - # Fake finished configuration for lb build - mkdir -p .build - touch .build/config - exit 0 + case "$ARCH+${SUBARCH:-}" in + amd64+*) + MODEL=pc-amd64 ;; + i386+*) + MODEL=pc-i386 ;; + arm64+snapdragon) + MODEL=dragonboard ;; + armhf+raspi2) + MODEL=pi2 ;; + armhf+raspi3) + MODEL=pi3 ;; + armhf+cm3) + MODEL=cm3 ;; + *) + echo "Model $ARCH+${SUBARCH:-} unknown to livecd-rootfs" >&2 + exit 1 ;; esac + echo "IMAGEFORMAT=$IMAGEFORMAT" >> config/common + # Store model assertion in top dir to get it picked up later as a build artifact + env SNAPPY_STORE_NO_CDN=1 snap known --remote model series=16 model="$MODEL" brand-id=canonical > livecd."$PROJECT".model-assertion + echo "Configured ubuntu-image for the following model assertion:" + cat livecd."$PROJECT".model-assertion + echo "----------------------------------------------------------" + # Fake finished configuration for lb build + mkdir -p .build + touch .build/config + exit 0 ;; *) From 8fc8c6dc0050babbdd973ec07594bfa724d147f5 Mon Sep 17 00:00:00 2001 From: "Gary.Wzl" Date: Mon, 18 Sep 2017 09:54:22 +0800 Subject: [PATCH 4/5] Add a changelog entry. --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 7d11df60..d2fef2df 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +livecd-rootfs (2.457ubuntu1) UNRELEASED; urgency=medium + + * Add GENERATE_ROOTFS_ONLY to support generating a single rootfs. + + -- Gary Wang Mon, 18 Sep 2017 09:51:04 +0800 + livecd-rootfs (2.457) artful; urgency=medium * Enable systemd-networkd by default. From 8a8d203743389bb411b8ff3d2140e71bd1493ad8 Mon Sep 17 00:00:00 2001 From: "Gary.Wzl" Date: Wed, 20 Sep 2017 18:15:16 +0800 Subject: [PATCH 5/5] * Add a test for SUBPROJECT when PROJECT comes to ubuntu-server. * Use notations "0/1" instead of "false/true" as a value for GENERATE_ROOTFS_ONLY. --- debian/changelog | 3 ++- live-build/auto/build | 2 +- live-build/auto/config | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index d2fef2df..6b95a0ce 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ -livecd-rootfs (2.457ubuntu1) UNRELEASED; urgency=medium +livecd-rootfs (2.458) artful; urgency=medium * Add GENERATE_ROOTFS_ONLY to support generating a single rootfs. + * Add a test for SUBPROJECT when PROJECT comes to ubuntu-server. -- Gary Wang Mon, 18 Sep 2017 09:51:04 +0800 diff --git a/live-build/auto/build b/live-build/auto/build index 156f7789..35de4f81 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -235,7 +235,7 @@ EOF fi ) 2>&1 | tee binary.log -if [ ! -z "${GENERATE_ROOTFS_ONLY:-}" ] && [ "${GENERATE_ROOTFS_ONLY}" != "false" ]; then +if [ ! -z "${GENERATE_ROOTFS_ONLY:-}" ] && [ "${GENERATE_ROOTFS_ONLY}" = 1 ]; then exit 0 fi diff --git a/live-build/auto/config b/live-build/auto/config index 3f504463..f8515239 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -757,7 +757,7 @@ EOF ;; esac -if [ $PROJECT = ubuntu-server ] && [ $SUBPROJECT != live ]; then +if [ $PROJECT = ubuntu-server ] && [ ! -z "${SUBPROJECT:-}" ] && [ $SUBPROJECT != live ]; then cat > config/hooks/100-remove-fstab.chroot <