[Merge] livecd-rootfs:desktop-preinstalled-fixes into livecd-rootfs:ubuntu/focal

Brian Murray mp+410949 at code.launchpad.net
Thu Oct 28 15:45:59 UTC 2021


This looks good to me and I'm fine with just doing this in Focal for now to move things forward.

Diff comments:

> diff --git a/live-build/ubuntu/hooks/099-ubuntu-image-customization.chroot b/live-build/ubuntu/hooks/099-ubuntu-image-customization.chroot
> new file mode 100644
> index 0000000..ca826f4
> --- /dev/null
> +++ b/live-build/ubuntu/hooks/099-ubuntu-image-customization.chroot
> @@ -0,0 +1,115 @@
> +#!/bin/bash -ex
> +
> +. /root/config/chroot
> +
> +# Specific ubuntu-image chroot configuration goes here.
> +if [ "$IMAGEFORMAT" == "none" ]; then
> +    if [ "$SUBPROJECT" == "desktop-preinstalled" ]; then
> +        # Create files/dirs Ubiquity requires
> +        mkdir -p /var/log/installer
> +        touch /var/log/installer/debug
> +        touch /var/log/syslog
> +        chown syslog:adm /var/log/syslog
> +
> +        # Create the oem user account
> +        if [ -e "/usr/sbin/oem-config-prepare" ] then
> +            /usr/sbin/useradd -d /home/oem -G adm,sudo -m -N -u 29999 oem
> +
> +            /usr/sbin/oem-config-prepare --quiet
> +            touch "/var/lib/oem-config/run"
> +        fi
> +
> +        # Make the writable partition grow
> +        echo "LABEL=writable    /     ext4    defaults,x-systemd.growfs    0 0" >>/etc/fstab
> +
> +        # Create a 1GB swapfile
> +        dd if=/dev/zero of=/swapfile bs=1M count=1024
> +        chmod 0600 /swapfile
> +        mkswap /swapfile
> +
> +        echo "/swapfile         none  swap    sw    0 0" >>/etc/fstab
> +
> +        if [ $(dpkg --print-architecture) == "amd64" ]; then
> +            # We need to get a grub.cfg generated for our image
> +            # This is copy-pasted from 999-cpc-fixes.chroot
> +            # TODO: Make this better. One idea would be to have this exported
> +            #  in functions or something, and then reused by both the cpc-fixes
> +            #  and here. Another possibility is to actually trim down the
> +            #  pseudo_grub_probe to only work for a regular preinstalled
> +            #  desktop.
> +            #  But short term it's safer to use a known code-base.
> +            psuedo_grub_probe() {
> +               cat <<"PSUEDO_GRUB_PROBE"
> +#!/bin/sh
> +Usage() {
> +   cat <<EOF
> +Usage: euca-psuedo-grub-probe
> +   this is a wrapper around grub-probe to provide the answers for an ec2 guest
> +EOF
> +}
> +bad_Usage() { Usage 1>&2; fail "$@"; }
> +
> +short_opts=""
> +long_opts="device-map:,target:,device"
> +getopt_out=$(getopt --name "${0##*/}" \
> +   --options "${short_opts}" --long "${long_opts}" -- "$@") &&
> +   eval set -- "${getopt_out}" ||
> +   bad_Usage
> +
> +device_map=""
> +target=""
> +device=0
> +arg=""
> +
> +while [ $# -ne 0 ]; do
> +   cur=${1}; next=${2};
> +   case "$cur" in
> +      --device-map) device_map=${next}; shift;;
> +      --device) device=1;;
> +      --target) target=${next}; shift;;
> +      --) shift; break;;
> +   esac
> +   shift;
> +done
> +arg=${1}
> +
> +case "${target}:${device}:${arg}" in
> +   device:*:/*) echo "/dev/sda1"; exit 0;;
> +   fs:*:*) echo "ext2"; exit 0;;
> +   partmap:*:*)
> +      # older versions of grub (lucid) want 'part_msdos' written

lucid? Can we drop this when the changes get updated in the main branch of livecd-rootfs?

> +      # rather than 'msdos'
> +      legacy_pre=""
> +      grubver=$(dpkg-query --show --showformat '${Version}\n' grub-pc 2>/dev/null) &&
> +         dpkg --compare-versions "${grubver}" lt 1.98+20100804-5ubuntu3 &&
> +         legacy_pre="part_"
> +      echo "${legacy_pre}msdos";
> +      exit 0;;
> +   abstraction:*:*) echo ""; exit 0;;
> +   drive:*:/dev/sda) echo "(hd0)";;
> +   drive:*:/dev/sda*) echo "(hd0,1)";;
> +   fs_uuid:*:*) exit 1;;
> +esac
> +PSUEDO_GRUB_PROBE
> +            }
> +
> +            gprobe="/usr/sbin/grub-probe"
> +            moved=0
> +            if [ -f "${gprobe}" ]; then
> +               mv "${gprobe}" "${gprobe}.dist"
> +               moved=1
> +            fi
> +            psuedo_grub_probe > "${gprobe}"
> +            chmod 755 "${gprobe}"
> +
> +            # Generate grub.cfg
> +            /usr/sbin/update-grub2
> +
> +            grub2cfg="/boot/grub/grub.cfg"
> +            [ ! -f "${grub2cfg}" ] ||
> +               sed -i -e "s,root=/dev/[hs]da1,root=LABEL=writable," "${grub2cfg}"
> +
> +            [ ${moved} -eq 0 ] || mv "${gprobe}.dist" "${gprobe}"
> +        fi
> +    fi
> +fi


-- 
https://code.launchpad.net/~ubuntu-core-dev/livecd-rootfs/+git/livecd-rootfs/+merge/410949
Your team Ubuntu Core Development Team is requested to review the proposed merge of livecd-rootfs:desktop-preinstalled-fixes into livecd-rootfs:ubuntu/focal.




More information about the Ubuntu-reviews mailing list