From 498bc9aa2b29fcc1b97cb266ccd7815e36f4a2e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20=27sil2100=27=20Zemczak?= Date: Tue, 16 Apr 2024 21:27:43 +0200 Subject: [PATCH] Clean up the code. --- live-build/auto/build | 75 +++++++++++-------- live-build/auto/config | 12 --- .../99-custom-networking.cfg | 1 - live-build/ubuntu-core-desktop/casper-enable | 3 - live-build/ubuntu-core-desktop/casper-stop | 43 ----------- live-build/ubuntu-core-desktop/casper.service | 16 ---- 6 files changed, 42 insertions(+), 108 deletions(-) delete mode 100644 live-build/ubuntu-core-desktop/99-custom-networking.cfg delete mode 100755 live-build/ubuntu-core-desktop/casper-enable delete mode 100755 live-build/ubuntu-core-desktop/casper-stop delete mode 100644 live-build/ubuntu-core-desktop/casper.service diff --git a/live-build/auto/build b/live-build/auto/build index a88905e4..8201fc55 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -86,19 +86,17 @@ fi # Link output files somewhere launchpad-buildd will be able to find them. PREFIX="livecd.$PROJECT${SUBARCH:+-$SUBARCH}" -if [ "${IMAGEFORMAT:-}" = "ubuntu-image" ]; then - # Use ubuntu-image instead of live-build +if [ "${IMAGEFORMAT:-}" = "ubuntu-image" ] \ + || [ "$PROJECT" = "ubuntu-core-desktop" ]; then + # Use ubuntu-image instead (or as part) of live-build export SNAPPY_STORE_NO_CDN=1 LB_UBUNTU_IMAGE_CHANNEL="${LB_UBUNTU_IMAGE_CHANNEL:-stable}" snap install \ --classic --channel="$LB_UBUNTU_IMAGE_CHANNEL" ubuntu-image - # TODO: eventually, this should be handled by a single ubuntu-image - # call without having to do a conditional on ubuntu-core/classic. - # We could already do that, but then we'd still have to do the - # compressing for the core images. if [ "$PROJECT" = "ubuntu-core" ]; then + # Ubuntu Core images /snap/bin/ubuntu-image snap $UBUNTU_IMAGE_ARGS \ -O output "$PREFIX".model-assertion # XXX: currently we only have one image generated, but really @@ -107,32 +105,42 @@ if [ "${IMAGEFORMAT:-}" = "ubuntu-image" ]; then mv output/*.img "$PREFIX".img xz -0 -T4 "$PREFIX".img mv output/seed.manifest "$PREFIX".manifest + + # All the builds are finished now, exit + exit 0 + elif [ "$PROJECT" = "ubuntu-core-desktop" ]; then + # Ubuntu Core Desktop payload image + # Special case for ubuntu-core-desktop - we need to call + # ubuntu-image twice, once for the core image payload and + # then for the actual image. + echo "Building the core image payload" + cd config/ + /snap/bin/ubuntu-image snap $UBUNTU_IMAGE_PAYLOAD_ARGS \ + -O output ubuntu-core-desktop*.model-assertion + mv output/*.img pc.img + xz -0 -T4 pc.img + rm -rf output/ + + # Prepare the source catalogue + cat install-sources-in.yaml | sed "s/@SIZE@/$(stat -c%s pc.img.xz)/g" > ../"$PREFIX".install-sources.yaml + + # We need to rename the image file so that it can be pulled + # by the builder. + mv pc.img.xz ../"$PREFIX".img.xz + + # We need to make sure the autoinstall file is also exported. + mv autoinstall.yaml ../"$PREFIX".autoinstall.yaml + + # Useful to have the model-assertion exported as well. + mv ubuntu-core-desktop*.model-assertion ../"$PREFIX".model-assertion + + # Important: return to the previous directory + cd ../ + + # Payload build finished, but now we need to build the rest with the + # usual live-build tools. else - if [ "$PROJECT" = "ubuntu-core-desktop" ]; then - # Special case for ubuntu-core-desktop - we need to call - # ubuntu-image twice, once for the core image payload and - # then for the actual image. - echo "Building the core image payload" - cd config/ - /snap/bin/ubuntu-image snap $UBUNTU_IMAGE_PAYLOAD_ARGS \ - -O output ubuntu-core-desktop*.model-assertion - mv output/*.img pc.img - xz -0 -T4 pc.img - rm -rf output/ - # Prepare the source catalogue - cat install-sources-in.yaml | sed "s/@SIZE@/$(stat -c%s pc.img.xz)/g" > install-sources.yaml - # Now move all of the payload to the image-definitions directory, - # so that they can be used by the image-definition effectively. - mv install-sources.yaml pc.img.xz autoinstall.yaml 99-custom-networking.cfg casper* ../image-definitions/ - cd ../ - - # Also, since we care about the model assertion to be presented, - # let's provide the payload assertion here already. - mkdir -p output/ - cp config/ubuntu-core-desktop*.model-assertion output/ - - echo "Image payload build completed, continuing" - fi + # Ubuntu classic preinstalled images /snap/bin/ubuntu-image classic --verbose $UBUNTU_IMAGE_ARGS \ -O output "$IMAGE_DEFINITION" # Since the output of the ubuntu-image call can vary based on what @@ -150,9 +158,10 @@ if [ "${IMAGEFORMAT:-}" = "ubuntu-image" ]; then mv $artifact "$PREFIX".$extension done [ -f $PREFIX.img ] && xz -0 -T4 "$PREFIX".img - fi - exit 0 + # All the builds are finished now, exit + exit 0 + fi fi if [ "$PROJECT" = "ubuntu-core-desktop" ]; then diff --git a/live-build/auto/config b/live-build/auto/config index 590ce01f..8ec65f34 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -513,18 +513,6 @@ case $IMAGEFORMAT in ubuntu-cpc) IMAGE_PROJECT="ubuntu-server" ;; - ubuntu-core-desktop) - # The ubuntu-core-desktop case is special as we need 2 ubuntu-image calls: - # one for the payload and one for the actual image - echo "Configuring for additional payload preparation" - UBUNTU_IMAGE_PAYLOAD_ARGS="--image-size 12G" - EXTRA_SNAPS="$EXTRA_SNAPS evince firefox gnome-calculator gnome-characters gnome-clocks gnome-font-viewer gnome-logs gnome-system-monitor gnome-text-editor gnome-weather loupe snapd-desktop-integration snap-store ubuntu-core-desktop-init workshops" - for snap in $EXTRA_SNAPS; do - UBUNTU_IMAGE_PAYLOAD_ARGS="$UBUNTU_IMAGE_PAYLOAD_ARGS --snap $snap" - done - echo "UBUNTU_IMAGE_PAYLOAD_ARGS=\"$UBUNTU_IMAGE_PAYLOAD_ARGS\"" >> config/common - cp -a /usr/share/livecd-rootfs/live-build/$PROJECT/* config/ - ;; esac LB_UBUNTU_IMAGES_REPO="${LB_UBUNTU_IMAGES_REPO:-git://git.launchpad.net/ubuntu-images}" diff --git a/live-build/ubuntu-core-desktop/99-custom-networking.cfg b/live-build/ubuntu-core-desktop/99-custom-networking.cfg deleted file mode 100644 index f144451d..00000000 --- a/live-build/ubuntu-core-desktop/99-custom-networking.cfg +++ /dev/null @@ -1 +0,0 @@ -network: {config: disabled} diff --git a/live-build/ubuntu-core-desktop/casper-enable b/live-build/ubuntu-core-desktop/casper-enable deleted file mode 100755 index 79191842..00000000 --- a/live-build/ubuntu-core-desktop/casper-enable +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -/usr/bin/systemctl enable casper diff --git a/live-build/ubuntu-core-desktop/casper-stop b/live-build/ubuntu-core-desktop/casper-stop deleted file mode 100755 index 1de8fe1f..00000000 --- a/live-build/ubuntu-core-desktop/casper-stop +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -# Author: Mathieu Trudel-Lapierre -# Tollef Fog Heen -# Marco Amadori -# - -PATH=/usr/sbin:/usr/bin:/sbin:/bin - -do_stop () -{ - prompt=1 - if grep -qs noprompt /proc/cmdline || [ -e /run/casper-no-prompt ]; then - prompt= - fi - - # XXX - i18n - MSG="Please press ENTER then remove the installation medium: " - MSG_FALLBACK="Please remove the installation medium, then reboot." - - if [ "$prompt" ]; then - if [ -x /bin/plymouth ] && plymouth --ping; then - chvt 63 - plymouth message --text="$MSG" - clear > /dev/tty1 - echo $MSG_FALLBACK > /dev/tty1 - else - stty sane < /dev/console - echo $MSG > /dev/console - fi - fi - - [ "$prompt" ] || return 0 - - if [ -x /bin/plymouth ] && plymouth --ping; then - plymouth watch-keystroke > /dev/null - else - read x < /dev/console - fi -} - -do_stop - diff --git a/live-build/ubuntu-core-desktop/casper.service b/live-build/ubuntu-core-desktop/casper.service deleted file mode 100644 index 01bac626..00000000 --- a/live-build/ubuntu-core-desktop/casper.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=Shuts down the "live" preinstalled system cleanly -DefaultDependencies=no -Before=final.target -After=shutdown.target umount.target plymouth-halt.service plymouth-poweroff.service plymouth-reboot.service - -[Service] -Type=oneshot -ExecStart=/sbin/casper-stop -StandardInput=tty-force -StandardOutput=inherit -StandardError=inherit -TTYReset=yes - -[Install] -WantedBy=final.target