From 8a36dbc115bc3d8fb5cb3d09ece0438c18734f7e Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:15 -0500 Subject: [PATCH 01/25] Add the ubuntu-cpc project base (LP: #1693018) --- debian/changelog | 6 + live-build/auto/build | 12 + live-build/auto/config | 52 +++- .../ubuntu-cpc/hooks/020-pkg-configure.chroot | 28 ++ .../ubuntu-cpc/hooks/025-create-groups.chroot | 14 + .../ubuntu-cpc/hooks/051-hwclock.chroot | 3 + .../hooks/052-ssh_authentication.chroot | 3 + live-build/ubuntu-cpc/hooks/060-ipv6.chroot | 18 ++ .../ubuntu-cpc/hooks/099-cleanup.chroot | 57 ++++ .../ubuntu-cpc/hooks/999-cpc-fixes.chroot | 281 ++++++++++++++++++ .../ubuntu-cpc/includes.chroot/etc/hostname | 1 + .../ubuntu-cpc/includes.chroot/etc/hosts | 9 + .../includes.chroot/etc/network/interfaces | 15 + .../etc/network/interfaces.d/eth0.cfg | 3 + 14 files changed, 495 insertions(+), 7 deletions(-) create mode 100644 live-build/ubuntu-cpc/hooks/020-pkg-configure.chroot create mode 100644 live-build/ubuntu-cpc/hooks/025-create-groups.chroot create mode 100644 live-build/ubuntu-cpc/hooks/051-hwclock.chroot create mode 100644 live-build/ubuntu-cpc/hooks/052-ssh_authentication.chroot create mode 100644 live-build/ubuntu-cpc/hooks/060-ipv6.chroot create mode 100644 live-build/ubuntu-cpc/hooks/099-cleanup.chroot create mode 100644 live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot create mode 100644 live-build/ubuntu-cpc/includes.chroot/etc/hostname create mode 100644 live-build/ubuntu-cpc/includes.chroot/etc/hosts create mode 100644 live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces create mode 100644 live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces.d/eth0.cfg diff --git a/debian/changelog b/debian/changelog index 2d6c19ca..834e0589 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +livecd-rootfs (2.209) trusty; urgency=medium + + * Add ubuntu-cpc project + + -- Robert C Jennings Mon, 08 May 2017 17:07:02 -0500 + livecd-rootfs (2.208.14) UNRELEASED; urgency=medium [ Balint Reczey ] diff --git a/live-build/auto/build b/live-build/auto/build index 74b702c9..71fa2de6 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -241,6 +241,18 @@ deb file:/var/lib/preinstalled-pool/ $LB_DISTRIBUTION $LB_PARENT_ARCHIVE_AREAS mkdir -p chroot/var/log/installer Chroot chroot "ln -s /etc/media-info /var/log/installer/media-info" fi + if [ "$PROJECT" = "ubuntu-cpc" ]; then + cat > chroot/etc/apt/sources.list << EOF +deb ${LB_PARENT_MIRROR_BINARY} ${LB_DISTRIBUTION} main restricted universe multiverse +deb ${LB_PARENT_MIRROR_BINARY} ${LB_DISTRIBUTION}-updates main restricted universe multiverse +deb ${LB_PARENT_MIRROR_BINARY_SECURITY} ${LB_DISTRIBUTION}-security main restricted universe multiverse +EOF + lb chroot_hosts install + lb chroot_resolv install + Chroot chroot "apt-get update" + lb chroot_resolv remove + lb chroot_hosts remove + fi echo "===== Checking size of /usr/share/doc =====" echo BEGIN docdirs diff --git a/live-build/auto/config b/live-build/auto/config index dacc156c..52a9d61e 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -121,9 +121,15 @@ case $IMAGEFORMAT in COMPONENTS='main restricted universe multiverse' ;; *) - add_package live jasper - OPTS="${OPTS:+$OPTS }--swap-file-path SWAP.swap" - OPTS="${OPTS:+$OPTS }--swap-file-size 512" + case $PROJECT in + ubuntu-cpc) + ;; + *) + add_package live jasper + OPTS="${OPTS:+$OPTS }--swap-file-path SWAP.swap" + OPTS="${OPTS:+$OPTS }--swap-file-size 512" + ;; + esac ;; esac ;; @@ -164,7 +170,7 @@ if [ "$PREINSTALLED" = "true" ] && [ "$SUBPROJECT" != "wubi" ]; then ubuntu-server) add_package live oem-config-debconf ubiquity-frontend-debconf ;; - ubuntu-core|ubuntu-base|base|ubuntu-touch) + ubuntu-core|ubuntu-base|base|ubuntu-touch|ubuntu-cpc) ;; *) add_package live oem-config-gtk ubiquity-frontend-gtk @@ -381,6 +387,9 @@ case $PROJECT in OPTS="${OPTS:+$OPTS }--zsync false" ;; + ubuntu-cpc) + ;; + *) echo "unknown project $PROJECT" >&2 exit 2 @@ -458,6 +467,35 @@ case $PROJECT in ;; esac +if [ "$PROJECT" = "ubuntu-cpc" ]; then + BINARY_REMOVE_LINUX=false + OPTS="${OPTS:+$OPTS }--linux-packages=none --initramfs=none" + KERNEL_FLAVOURS=none + case $ARCH in + armhf) + add_package install flash-kernel linux-generic-lpae + add_task install server + ;; + arm64) + add_package install flash-kernel linux-generic + add_task install server + ;; + ppc64el) + add_package install linux-virtual + add_task install server + ;; + *) + add_package install linux-virtual + ;; + esac + OPTS="${OPTS:+$OPTS }--system=normal" + OPTS="${OPTS:+$OPTS }--hdd-label=cloudimg-rootfs" + OPTS="${OPTS:+$OPTS }--ext-resize-blocks=536870912 --ext-block-size=4096" + OPTS="${OPTS:+$OPTS }--ext-fudge-factor=15" + add_task install minimal standard cloud-image + add_package install landscape-client ubuntu-minimal +fi + add_chroot_hook update-apt-file-cache add_chroot_hook update-apt-xapian-index add_chroot_hook update-mlocate-database @@ -466,7 +504,7 @@ add_chroot_hook remove-openssh-server-host-keys add_chroot_hook remove-udev-persistent-rules case $PROJECT in - ubuntu-server) + ubuntu-server|ubuntu-cpc) ;; *) @@ -556,8 +594,8 @@ EOF fi ;; - ubuntu-touch) - cp -af /usr/share/livecd-rootfs/live-build/ubuntu-touch/* \ + ubuntu-touch|ubuntu-cpc) + cp -af /usr/share/livecd-rootfs/live-build/${PROJECT}/* \ config/ ;; esac diff --git a/live-build/ubuntu-cpc/hooks/020-pkg-configure.chroot b/live-build/ubuntu-cpc/hooks/020-pkg-configure.chroot new file mode 100644 index 00000000..5aee6ae5 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/020-pkg-configure.chroot @@ -0,0 +1,28 @@ +#!/bin/bash +# Configure certain packages + +## console-setup + +# Select the fontface +printf "%s\t%s\t%s\t%s\n" \ + console-setup console-setup/console-setup/fontface47 string "Fixed" debconf-set-selections || + { echo "FAILED to setup console fontface"; exit 1; } + +# Select the code page for font +printf "%s\t%s\t%s\t%s\n" \ + console-setup console-setup/codesetcode string "Uni2" | debconf-set-selections || + { echo "FAILED to setup console code page to Uni2"; exit 1; } + +# Set Language string for codepage 47 +printf "%s\t%s\t%s\t%s\n" \ + console-setup console-setup/codeset47 string ". Combined - Latin; Slavic Cyrillic; Greek" | debconf-set-selections || + { echo "FAILED to setup codeset47 to proper string"; exti 1; } + +# Replace the console font and typ ein /etc/default/console-setup +sed -i -e 's,^CODESET.*,CODESET="Uni2",g' \ + -e 's,^FONTFACE.*,FONTFACE="Fixed",g' \ + /etc/default/console-setup + +# Configure the console-setup +dpkg-reconfigure --frontend=noninteractive console-setup || + { echo "FAILED to recofigure console-setup"; exit 1; } diff --git a/live-build/ubuntu-cpc/hooks/025-create-groups.chroot b/live-build/ubuntu-cpc/hooks/025-create-groups.chroot new file mode 100644 index 00000000..031cbfef --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/025-create-groups.chroot @@ -0,0 +1,14 @@ +#!/bin/bash +# +# Create the necessary users and set their passwords. If needed, +# make sure they belong to the proper groups +# +# Author: Ben Howard +# Date: 29 Jun 2011 +# + +echo "Adding admin group..." +addgroup --system --quiet admin + +echo "Adding netdev group..." +addgroup --system --quiet netdev diff --git a/live-build/ubuntu-cpc/hooks/051-hwclock.chroot b/live-build/ubuntu-cpc/hooks/051-hwclock.chroot new file mode 100644 index 00000000..946b1cbc --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/051-hwclock.chroot @@ -0,0 +1,3 @@ +#!/bin/bash + +printf "HWCLOCKACCESS=no" >> /etc/default/rcS diff --git a/live-build/ubuntu-cpc/hooks/052-ssh_authentication.chroot b/live-build/ubuntu-cpc/hooks/052-ssh_authentication.chroot new file mode 100644 index 00000000..6b0a34ea --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/052-ssh_authentication.chroot @@ -0,0 +1,3 @@ +#!/bin/bash + +sed -i "s|#PasswordAuthentication yes|PasswordAuthentication no|g" /etc/ssh/sshd_config diff --git a/live-build/ubuntu-cpc/hooks/060-ipv6.chroot b/live-build/ubuntu-cpc/hooks/060-ipv6.chroot new file mode 100644 index 00000000..3d4a0be2 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/060-ipv6.chroot @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Disable IPv6 privacy extensions on Utopic and later +# + +codename=$(sh -c 'lsb_release --short --codename') +dist_ge() { [[ "$1" > "$2" || "$1" == "$2" ]]; } + +if ! dist_ge "${codename}" "trusty"; then + exit 0 +fi + +cat << EOF > /etc/sysctl.d/99-cloudimg-ipv6.conf +# Written by the Cloud Image build process +# See https://bugs.launchpad.net/ubuntu/+source/procps/+bug/1068756 +net.ipv6.conf.all.use_tempaddr = 0 +net.ipv6.conf.default.use_tempaddr = 0 +EOF diff --git a/live-build/ubuntu-cpc/hooks/099-cleanup.chroot b/live-build/ubuntu-cpc/hooks/099-cleanup.chroot new file mode 100644 index 00000000..cf2b7dd1 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/099-cleanup.chroot @@ -0,0 +1,57 @@ +#!/bin/bash + +# Clean up extraneous log files that may be left around +rm /etc/ssh/ssh_host*key* || echo "No SSH keys to remove" + +# Fix LP: #1047707, 1019338 +# Truncate logs that are owned, otherwise remove +whitelisted_logs=(/var/log/btmp /var/log/lastlog /var/log/wtmp /var/log/fsck/checkfs /var/log/fsck/checkroot) + +for log in $(find /var/log -type f) +do + whitelisted=$(echo "${whitelisted_logs[@]}" | grep -o ${log}) + + if [ -n "${whitelisted}" ]; then + : > ${log} && + echo "Truncated whitelisted log ${log}" || + echo "Failed to truncate whitelisted log ${log}" + else + + dpkg -S ${log} > /dev/null 2>&1 && + { : > ${log} || + echo "Failed to truncate $f"; } || + { rm ${log} && + echo "Removed ${log} as an orphaned log file" || + echo "Failed to remove unnecessary log $f"; } + fi +done + +# Remove un-owned log directories +whitelisted_dirs=(/var/log/fsck) + +for log_d in $(find /var/log/* -type d) +do + whitelisted=$(echo "${whitelisted_dirs[@]}" | grep -o "${log_d}") + if [ -z "${whitelisted}" ]; then + dpkg -S ${log_d} > /dev/null 2>&1 && + echo "Preserving log directory ${log_d}" || + { rm -rf ${log_d} && + echo "Removed log directory ${log_d} as orphaned log dir" || + echo "Failed to remove unnessasary log dir ${log_d}"; } + + else + echo "Preserving whitelisted directory ${log_d}" + fi + +done + + +rm -rf /var/run/* || echo "Failed to clean /var/run/*" +rm /etc/passwd- || echo "No spare passwd file to cleanup" +rm /etc/shadow- || echo "No spare shadow file to cleanup" +rm /etc/gshadow- || echo "No spare gshadow file to cleanup" +rm /etc/group- || echo "No spare group file to clenaup" +rm -f /etc/apt/conf.d/00secure || echo "No apt cache to cleanup" + +# Truncate instead of delete, LP: #707311 +truncate --size=0 -c /etc/popularity-contest.conf diff --git a/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot new file mode 100644 index 00000000..28534971 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot @@ -0,0 +1,281 @@ +#!/bin/bash +rootd="${1:-/}" +root_fs_label=cloudimg-rootfs +set -ex + +CLOUD_IMG_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" + +LANG=C + +_xchroot() { + # Prevent multiple chroots + if [ "$1" = "/" ]; then + shift; + "$@" + else + chroot "$@" + fi +} + +#### COMMON architecture independent functions +arch=$(_xchroot "${rootd}" dpkg --print-architecture) + +add_serial_console() { + condev=$1 + idir="$rootd/etc/init" + cat << EOF > "${idir}/${condev}.conf" +# CONDEV - getty +# +# This service maintains a getty on CONDEV from the point the system is +# started until it is shut down again. + +start on stopped rc RUNLEVEL=[2345] and ( + not-container or + container CONTAINER=lxc or + container CONTAINER=lxc-libvirt) + +stop on runlevel [!2345] + +pre-start script + # getty will not be started if the serial console is not present + stty -F /dev/CONDEV -a 2> /dev/null > /dev/null || { stop ; exit 0; } +end script + +respawn +script + exec /sbin/getty -L CONDEV 115200 vt102 +end script +${CLOUD_IMG_STR} +EOF + sed -i "s/CONDEV/${condev}/g" "$idir/${condev}.conf" +} + +## -------------- +# remove 127.0.1.1 entry (LP: #440757) +_xchroot "${rootd}" sh -c 'sed -i "/^127.0.1.1/d" /etc/hosts' + +## -------------- +# remove ssh pregenerated keys (LP: #512377) + +_xchroot "${rootd}" sh -c 'rm -f /etc/ssh/ssh_host_[rd]sa_key*' + +## -------------- +_xchroot "${rootd}" locale-gen en_US.utf8 + +## -------------- +# set cloud-init to be on +values="NoCloud, ConfigDrive, AltCloud, OVF, MAAS, Ec2, None" +printf "%s\t%s\t%s\t%s\n" \ + cloud-init cloud-init/datasources multiselect "$values" | + _xchroot "${rootd}" debconf-set-selections +_xchroot "${rootd}" dpkg-reconfigure --frontend=noninteractive cloud-init + +## -------------- +# write some build information to the guest +# the idea is that given runtime info and this info, the instance +# can at least determine if there is a newer build available +# these variables are passed in in environment from cloudimg-build-launcher +if [ -n "${build_name}" -o -n "${serial}" ]; then + d="${rootd}/etc/cloud" + [ -d "$d" ] || mkdir -p "${d}" + { + [ -n "${build_name}" ] && echo "build_name: ${build_name}" + [ -n "${serial}" ] && echo "serial: ${serial}" + } > "$d/build.info" +fi + +## -------------- +# for maverick and newer, use LABEL= for the '/' entry in fstab +if [ -n "${root_fs_label}" ]; then + bl="[:blank:]" + lstr="LABEL=${root_fs_label}" + sed -i "s,^[^#${bl}]*\([${bl}]*/[${bl}].*\),${lstr}\1," "${rootd}/etc/fstab" +fi +cat > /etc/fstab << EOM +LABEL=cloudimg-rootfs / ext4 defaults 0 0 +EOM + +## Make sure that the update-motd.d directory exists +[ ! -e "${rootd}/etc/update-motd.d" ] && + mkdir -p "${rootd}/etc/update-motd.d" + +## write a MOTD file advertising support for images +cat > "${rootd}/etc/update-motd.d/51-cloudguest" << EOF +#!/bin/sh +# +${CLOUD_IMG_STR} +# This file is not managed by a package. If you no longer want to +# see this message you can safely remove the file. +echo "" +echo " Get cloud support with Ubuntu Advantage Cloud Guest:" +echo " http://www.ubuntu.com/business/services/cloud" +EOF + +chmod +x "${rootd}/etc/update-motd.d/51-cloudguest" + +# for quantal and newer, add /etc/overlayroot.local.conf +# but do not overwrite anything that somehow got there +if [ -f "${rootd}/etc/overlayroot.conf" ] && + [ ! -f "${rootd}/etc/overlayroot.local.conf" ]; then + { + echo "${CLOUD_IMG_STR}" + echo "overlayroot_cfgdisk=LABEL=OROOTCFG" + } > "${rootd}/etc/overlayroot.local.conf" +fi + + +#### END COMMON ARCH FUNCTIONS + +if [ "$arch" = "ppc64el" ]; then + add_serial_console hvc0 + exit 0 +fi + +# ARM images are special +if [[ "$arch" =~ (arm|arm64|aarch64) ]]; then + + echo "Configuring ARM Serial Port" + add_serial_console ttyAMA0 + + echo "Image architecture is ARM. Existing vmbuilder-fixups" + + exit 0 +fi + +## Add ttyS0 for i386/amd64 for Trusty and newer +if [ "$arch" = "i386" -o "$arch" = "amd64" ]; then + add_serial_console ttyS0 +fi + + +psuedo_grub_probe() { + cat <<"PSUEDO_GRUB_PROBE" +#!/bin/sh +Usage() { + cat <&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 + # 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 +} + +## install / setup grub2 +gprobe="${rootd}/usr/sbin/grub-probe" +moved=0 +if [ -f "${gprobe}" ]; then + mv "${gprobe}" "${gprobe}.dist" + moved=1 +fi +psuedo_grub_probe > "${gprobe}" +chmod 755 "${gprobe}" + +# for Quantal and later, use /etc/default/grub.d functionality +# rather than modifying the grub configuration itself. +# This avoids the mess of having to do dpkg stuff +# LP: 1179940 +mkdir -p "${rootd}/etc/default/grub.d" +cat << EOF > "${rootd}/etc/default/grub.d/50-cloudimg-settings.cfg" +# Cloud Image specific Grub settings for Generic Cloud Images +${CLOUD_IMG_STR} + +# Set the recordfail timeout +GRUB_RECORDFAIL_TIMEOUT=0 + +# Do not wait on grub prompt +GRUB_TIMEOUT=0 + +# Set the default commandline +GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0" + +# Set the grub console type +GRUB_TERMINAL=console +EOF +_xchroot "${rootd}" update-grub2 + +# since this is a disk image, we technically don't need to install all the +# grub modules, as the image itself is not bootable. This makes for a small +# disk image +_xchroot "${rootd}" update-grub + +# reconfigure grub so that upgrades to grub-pc do not force a debconf config +# changed prompt (LP: #1009294). This re-runs update-grub +_xchroot "${rootd}" env DEBIAN_FRONTEND=noninteractive \ + dpkg-reconfigure grub-pc + +grub2cfg="${rootd}/boot/grub/grub.cfg" +[ ! -f "${grub2cfg}" ] || + sed -i -e "s,root=/dev/sda1,root=LABEL=${root_fs_label}," "${grub2cfg}" + +[ ${moved} -eq 0 ] || mv "${gprobe}.dist" "${gprobe}" + +## modify /boot/grub/menu.lst if it exists +## this is generated at install time by grub-legacy-ec2, but will have +## devices as found from the _xchroot. Here we write what it will be on ec2 +if [ -f "${rootd}/boot/grub/menu.lst" ]; then + grub_root="(hd0)" + linux_root=/dev/sda1 + [ -n "${root_fs_label}" ] && linux_root="LABEL=${root_fs_label}" + # the sed code below basically fixes/sets the following lines in a + # /boot/grub/menu.lst file: + # # kopt=root=xxxxxxx ro + # kernel /boot/vmlinuz-... root=xxxxxx .... + # # groot=xxxxx + # root xxxxx + # uuuid xxxxx + sed -i "${rootd}/boot/grub/menu.lst" \ + -e "s|^\(# kopt=root=\)[^ ]*|\1${linux_root}|" \ + -e "s|^\(kernel.*root=\)[^ ]*|\1${linux_root}|" \ + -e "s|^\(# groot=\)[^ ]*|\1${grub_root}|" \ + -e "s|^\(root\|uuid\)\([[:space:]]*\).*|root\2${grub_root}|" + + # grub-legacy-ec2 writes this ucf entry. since we've modified + # /boot/grub/menu.lst, we have to remove it, or the user will + # get prompted for a 3 way merge of the changes the first time this runs + _xchroot "${rootd}" /usr/bin/ucfr --purge grub /var/run/grub/menu.lst +fi + +# vi: ts=3 expandtab diff --git a/live-build/ubuntu-cpc/includes.chroot/etc/hostname b/live-build/ubuntu-cpc/includes.chroot/etc/hostname new file mode 100644 index 00000000..e9e5f7ce --- /dev/null +++ b/live-build/ubuntu-cpc/includes.chroot/etc/hostname @@ -0,0 +1 @@ +ubuntu diff --git a/live-build/ubuntu-cpc/includes.chroot/etc/hosts b/live-build/ubuntu-cpc/includes.chroot/etc/hosts new file mode 100644 index 00000000..56e7c15b --- /dev/null +++ b/live-build/ubuntu-cpc/includes.chroot/etc/hosts @@ -0,0 +1,9 @@ +127.0.0.1 localhost + +# The following lines are desirable for IPv6 capable hosts +::1 ip6-localhost ip6-loopback +fe00::0 ip6-localnet +ff00::0 ip6-mcastprefix +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters +ff02::3 ip6-allhosts diff --git a/live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces b/live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces new file mode 100644 index 00000000..a3e1bad7 --- /dev/null +++ b/live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces @@ -0,0 +1,15 @@ +# This file describes the network interfaces available on your system +# and how to activate them. For more information, see interfaces(5). + +# The loopback network interface +auto lo +iface lo inet loopback + +# Source interfaces +# Please check /etc/network/interfaces.d before changing this file +# as interfaces may have been defined in /etc/network/interfaces.d +# NOTE: the primary ethernet device is defined in +# /etc/network/interfaces.d/eth0 +# See LP: #1262951 +source /etc/network/interfaces.d/*.cfg + diff --git a/live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces.d/eth0.cfg b/live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces.d/eth0.cfg new file mode 100644 index 00000000..d117f4b2 --- /dev/null +++ b/live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces.d/eth0.cfg @@ -0,0 +1,3 @@ +# The primary network interface +auto eth0 +iface eth0 inet dhcp From 38c87ca9af581aa6b15067225011990ef3c5cab4 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:16 -0500 Subject: [PATCH 02/25] Move building of all architecture-specific CPC artifacts into Launchpad (LP: #1513754) --- debian/changelog | 8 + live-build/auto/build | 8 + live-build/auto/config | 14 +- live-build/ubuntu-cpc/functions | 61 ++++++++ .../hooks/010-write-etc-ec2-version.chroot | 4 + .../ubuntu-cpc/hooks/030-root-tarball.binary | 25 ++++ .../ubuntu-cpc/hooks/031-root-xz.binary | 3 + .../ubuntu-cpc/hooks/032-disk-image.binary | 60 ++++++++ .../hooks/033-disk-image-uefi.binary | 141 ++++++++++++++++++ .../hooks/034-disk-image-ppc64el.binary | 64 ++++++++ .../ubuntu-cpc/hooks/040-qcow2-image.binary | 16 ++ .../ubuntu-cpc/hooks/999-cpc-fixes.chroot | 5 +- 12 files changed, 398 insertions(+), 11 deletions(-) create mode 100644 live-build/ubuntu-cpc/functions create mode 100644 live-build/ubuntu-cpc/hooks/010-write-etc-ec2-version.chroot create mode 100644 live-build/ubuntu-cpc/hooks/030-root-tarball.binary create mode 100644 live-build/ubuntu-cpc/hooks/031-root-xz.binary create mode 100644 live-build/ubuntu-cpc/hooks/032-disk-image.binary create mode 100644 live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary create mode 100644 live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary create mode 100644 live-build/ubuntu-cpc/hooks/040-qcow2-image.binary diff --git a/debian/changelog b/debian/changelog index 834e0589..783fd3c2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +livecd-rootfs (2.209.1) trusty; urgency=medium + + [Daniel Watkins] + * Move building of all architecture-specific CPC artifacts into Launchpad + (LP: #1513754). + + -- Robert C Jennings Tue, 23 May 2017 16:33:44 -0500 + livecd-rootfs (2.209) trusty; urgency=medium * Add ubuntu-cpc project diff --git a/live-build/auto/build b/live-build/auto/build index 71fa2de6..8853da29 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -242,6 +242,10 @@ deb file:/var/lib/preinstalled-pool/ $LB_DISTRIBUTION $LB_PARENT_ARCHIVE_AREAS Chroot chroot "ln -s /etc/media-info /var/log/installer/media-info" fi if [ "$PROJECT" = "ubuntu-cpc" ]; then + cat > chroot/etc/cloud/build.info << EOF +build_name: server +serial: $BUILDSTAMP +EOF cat > chroot/etc/apt/sources.list << EOF deb ${LB_PARENT_MIRROR_BINARY} ${LB_DISTRIBUTION} main restricted universe multiverse deb ${LB_PARENT_MIRROR_BINARY} ${LB_DISTRIBUTION}-updates main restricted universe multiverse @@ -341,6 +345,10 @@ for FLAVOUR in $LB_LINUX_FLAVOURS; do continue fi FLAVOUR=${FLAVOUR%%-lts-*} + if [ "$FLAVOUR" = "virtual" ]; then + # The virtual kernel is named generic in /boot + FLAVOUR="generic" + fi KVERS="$( (cd "binary/$INITFS"; ls vmlinu?-* 2>/dev/null || true) | (fgrep -v .efi || true) | sed -n "s/^vmlinu.-\\([^-]*-[^-]*-$FLAVOUR\\)$/\\1/p" )" if [ -z "$KVERS" ]; then if [ -e "binary/$INITFS/vmlinuz" ]; then diff --git a/live-build/auto/config b/live-build/auto/config index 52a9d61e..72e0a0ff 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -469,24 +469,22 @@ esac if [ "$PROJECT" = "ubuntu-cpc" ]; then BINARY_REMOVE_LINUX=false - OPTS="${OPTS:+$OPTS }--linux-packages=none --initramfs=none" - KERNEL_FLAVOURS=none + OPTS="${OPTS:+$OPTS }--initramfs=none" + KERNEL_FLAVOURS=virtual case $ARCH in armhf) - add_package install flash-kernel linux-generic-lpae + KERNEL_FLAVOURS=generic-lpae + add_package install flash-kernel add_task install server ;; arm64) - add_package install flash-kernel linux-generic + KERNEL_FLAVOURS=generic + add_package install flash-kernel add_task install server ;; ppc64el) - add_package install linux-virtual add_task install server ;; - *) - add_package install linux-virtual - ;; esac OPTS="${OPTS:+$OPTS }--system=normal" OPTS="${OPTS:+$OPTS }--hdd-label=cloudimg-rootfs" diff --git a/live-build/ubuntu-cpc/functions b/live-build/ubuntu-cpc/functions new file mode 100644 index 00000000..3c082ff2 --- /dev/null +++ b/live-build/ubuntu-cpc/functions @@ -0,0 +1,61 @@ +CLOUD_IMG_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" +IMAGE_SIZE=$((2252*1024**2)) # 2.2G (the current size we ship) + +rootfs_dev_mapper= +loop_device= +loop_raw= + +clean_loops() { + [ -z "${rootfs_dev_mapper}" ] || { + udevadm settle + find /dev/mapper -iname "${loop_device///dev\//}*" | \ + xargs -n1 -I DEVICE dmsetup remove DEVICE || + kpartx -d "${rootfs_dev_mapper}" + losetup -d "${loop_device}" || echo "Failed to detach disk" + unset loop_raw + } +} + +create_empty_disk_image() { + # Prepare an empty disk image + dd if=/dev/zero of="$1" bs=1 count=0 seek="${IMAGE_SIZE}" +} + +make_ext4_partition() { + device="$1" + + mkfs.ext4 -F -b 4096 -i 8192 -m 0 -L cloudimg-rootfs -E resize=536870912 "$device" +} + +mount_image() { + apt-get install -qqy kpartx + trap clean_loops EXIT + loop_raw="$(kpartx -s -v -a "$1" )" + loop_device="$(echo -e "${loop_raw}" | head -n1 | awk '{print($(NF-1))}')" + rootfs_dev_mapper="/dev/mapper${loop_device///dev/}p1" + [ ! -b "${rootfs_dev_mapper}" ] && + echo "${rootfs_dev_mapper} is not a block device" && exit 1 + return 0 +} + +mount_partition() { + partition="$1" + mountpoint="$2" + + mount "$partition" "$mountpoint" + mount --bind /dev "$mountpoint/dev" + mount proc-live -t proc "$mountpoint/proc" + mount sysfs-live -t sysfs "$mountpoint/sys" + mv "$mountpoint/etc/resolv.conf" resolv.conf.tmp + cp /etc/resolv.conf "$mountpoint/etc/resolv.conf" +} + +umount_partition() { + mountpoint="$1" + + mv resolv.conf.tmp "$mountpoint/etc/resolv.conf" + umount "$mountpoint/proc" + umount "$mountpoint/sys" + umount "$mountpoint/dev" + umount "$mountpoint" +} diff --git a/live-build/ubuntu-cpc/hooks/010-write-etc-ec2-version.chroot b/live-build/ubuntu-cpc/hooks/010-write-etc-ec2-version.chroot new file mode 100644 index 00000000..daa18de7 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/010-write-etc-ec2-version.chroot @@ -0,0 +1,4 @@ +#!/bin/bash -eux + +. /etc/os-release +echo "Ubuntu $VERSION" > /etc/ec2_version diff --git a/live-build/ubuntu-cpc/hooks/030-root-tarball.binary b/live-build/ubuntu-cpc/hooks/030-root-tarball.binary new file mode 100644 index 00000000..22556399 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/030-root-tarball.binary @@ -0,0 +1,25 @@ +#!/bin/bash -ex +mkdir binary/boot/filesystem.dir + +cp -a chroot/* binary/boot/filesystem.dir + +mount --bind /dev "binary/boot/filesystem.dir/dev" +mount proc-live -t proc "binary/boot/filesystem.dir/proc" +mount sysfs-live -t sysfs "binary/boot/filesystem.dir/sys" +mv "binary/boot/filesystem.dir/etc/resolv.conf" resolv.conf.tmp +cp /etc/resolv.conf "binary/boot/filesystem.dir/etc/resolv.conf" + +chroot binary/boot/filesystem.dir dpkg-divert --local --rename /usr/sbin/grub-probe +chroot binary/boot/filesystem.dir touch /usr/sbin/grub-probe +chroot binary/boot/filesystem.dir chmod +x /usr/sbin/grub-probe + +env DEBIAN_FRONTEND=noninteractive chroot binary/boot/filesystem.dir apt-get --purge remove --assume-yes '^linux-.*' +env DEBIAN_FRONTEND=noninteractive chroot binary/boot/filesystem.dir apt-get --purge remove --assume-yes '^grub-.*' + +chroot binary/boot/filesystem.dir rm /usr/sbin/grub-probe +chroot binary/boot/filesystem.dir dpkg-divert --remove --local --rename /usr/sbin/grub-probe + +mv resolv.conf.tmp "binary/boot/filesystem.dir/etc/resolv.conf" +umount "binary/boot/filesystem.dir/proc" +umount "binary/boot/filesystem.dir/sys" +umount "binary/boot/filesystem.dir/dev" diff --git a/live-build/ubuntu-cpc/hooks/031-root-xz.binary b/live-build/ubuntu-cpc/hooks/031-root-xz.binary new file mode 100644 index 00000000..b2503adb --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/031-root-xz.binary @@ -0,0 +1,3 @@ +#!/bin/bash -ex +(cd "binary/boot/filesystem.dir/" && tar -c *) | \ + xz > "livecd.ubuntu-cpc.rootfs.tar.xz" diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary new file mode 100644 index 00000000..99514de4 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -0,0 +1,60 @@ +#!/bin/bash -eux +architecture=$(chroot chroot dpkg --print-architecture) +if [ "$architecture" = "ppc64el" ]; then + echo "ppc64el disk images are handled separately" + exit 0 +fi + +. /build/config/functions + +create_empty_partition() { + apt-get install -qqy parted + parted_prefix="parted $1 --script --" + + ${parted_prefix} mklabel msdos + ${parted_prefix} mkpart primary 1 -1 + ${parted_prefix} set 1 B + ${parted_prefix} print + ${parted_prefix} align-check opt 1 +} + +disk_image=binary/boot/disk.ext4 + +create_empty_disk_image "${disk_image}" +create_empty_partition "${disk_image}" +mount_image "${disk_image}" + +# Copy the chroot in to the disk +make_ext4_partition "${rootfs_dev_mapper}" +mkdir mountpoint +mount "${rootfs_dev_mapper}" mountpoint +cp -a chroot/* mountpoint/ +umount mountpoint +rmdir mountpoint + +should_install_grub() { + case $architecture in + armhf|arm64) + return 1 + ;; + *) + return 0 + ;; + esac +} + +if should_install_grub; then + mkdir mountpoint + mount_partition "${rootfs_dev_mapper}" mountpoint + + echo "(hd0) ${loop_device}" > mountpoint/tmp/device.map + chroot mountpoint grub-install ${loop_device} + chroot mountpoint grub-bios-setup --boot-image=i386-pc/boot.img --core-image=i386-pc/core.img --skip-fs-probe --device-map=/tmp/device.map ${loop_device} + + rm mountpoint/tmp/device.map + umount_partition mountpoint + rmdir mountpoint +fi + +clean_loops +trap - EXIT diff --git a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary new file mode 100644 index 00000000..ccc6cca9 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -0,0 +1,141 @@ +#!/bin/bash -eux + +architecture=$(chroot chroot dpkg --print-architecture) +case $architecture in + amd64|arm64) + ;; + *) + echo "We don't create EFI images for $architecture." + exit 0 + ;; +esac + +. /build/config/functions + +create_partitions() { + disk_image="$1" + apt-get install -qqy gdisk + sgdisk "${disk_image}" --zap-all + case $architecture in + arm64) + sgdisk "${disk_image}" \ + --new=15:0:204800 \ + --typecode=15:ef00 \ + --new=1: + ;; + amd64) + sgdisk "${disk_image}" \ + --new=14::+4M \ + --new=15::+106M \ + --new=1:: + sgdisk "${disk_image}" \ + -t 14:ef02 \ + -t 15:ef00 + ;; + esac + sgdisk "${disk_image}" \ + --print +} + +create_and_mount_uefi_partition() { + uefi_dev="/dev/mapper${loop_device///dev/}p15" + apt-get -qqy install dosfstools + mountpoint="$1" + mkfs.vfat -F 32 -n UEFI "${uefi_dev}" + + mkdir -p "${mountpoint}"/boot/efi + mount "${uefi_dev}" "$mountpoint"/boot/efi + + cat << EOF >> "mountpoint/etc/fstab" +LABEL=UEFI /boot/efi vfat defaults 0 0 +EOF +} + +install_grub() { + mkdir mountpoint + mount_partition "${rootfs_dev_mapper}" mountpoint + + create_and_mount_uefi_partition mountpoint + + echo "(hd0) ${loop_device}" > mountpoint/tmp/device.map + mkdir -p mountpoint/etc/default/grub.d + efi_boot_dir="/boot/efi/EFI/BOOT" + chroot mountpoint mkdir -p "${efi_boot_dir}" + + case $architecture in + arm64) + chroot mountpoint apt-get -qqy install --no-install-recommends grub-efi-arm64 grub-efi-arm64-bin + grub_modules="part_gpt fat gzio ext2 normal chain boot configfile linux search_fs_uuid search_label terminal serial video video_fb efi_gop" + efi_target=arm64-efi + ;; + amd64) + chroot mountpoint apt-get install -qqy grub-efi-amd64-signed grub-efi-amd64 shim-signed + grub_modules="part_gpt fat ext2 normal chain boot configfile linux multiboot search_fs_uuid search_label terminal serial video video_fb video_bochs usb usb_keyboard efi_gop efi_uga" + chroot mountpoint cp /usr/lib/shim/shim.efi.signed "${efi_boot_dir}/shimx64.efi" + chroot mountpoint cp /usr/lib/shim/MokManager.efi.signed "${efi_boot_dir}/MokManager.efi" + chroot mountpoint cp /usr/lib/grub/x86_64-efi-signed/grubx64.efi.signed "${efi_boot_dir}/grubx64.efi" + efi_target=x86_64-efi + ;; + esac + + cat << EOF >> mountpoint/etc/default/grub.d/50-cloudimg-settings.cfg +${CLOUD_IMG_STR} +# For Cloud Image compatability +GRUB_PRELOAD_MODULES="${grub_modules}" +EOF + chroot mountpoint grub-install "${loop_device}" \ + --boot-directory=/boot \ + --efi-directory=/boot/efi \ + --target=${efi_target} \ + --removable \ + --uefi-secure-boot \ + --no-nvram \ + --modules="${grub_modules}" + + if [ -f mountpoint/boot/efi/EFI/BOOT/grub.cfg ]; then + sed -i "s| root| root hd0,gpt1|" mountpoint/boot/efi/EFI/BOOT/grub.cfg + sed -i "1i${CLOUD_IMG_STR}" mountpoint/boot/efi/EFI/BOOT/grub.cfg + # For some reason the grub disk is looking for /boot/grub/grub.cfg on + # part 15.... + chroot mountpoint mkdir -p /boot/efi/boot/grub + chroot mountpoint cp /boot/efi/EFI/BOOT/grub.cfg /boot/efi/boot/grub + fi + + if [ $architecture = "amd64" ]; then + # Install the BIOS/GPT bits. Since GPT boots from the ESP partition, + # it means that we just run this simple command and we're done + chroot mountpoint grub-install --target=i386-pc "${loop_device}" + fi + + chroot mountpoint dpkg-divert --local --rename /etc/grub.d/30_os-prober + chroot mountpoint update-grub + sed -i "s,root=.* ,root=LABEL=cloudimg-rootfs ,g" mountpoint/boot/grub/grub.cfg + chroot mountpoint dpkg-divert --remove --local --rename /etc/grub.d/30_os-prober + + chroot mountpoint apt-get -y clean + chroot mountpoint apt-get -y update + + rm mountpoint/tmp/device.map + umount mountpoint/boot/efi + umount_partition mountpoint + rmdir mountpoint +} + +disk_image=binary/boot/disk-uefi.ext4 + +create_empty_disk_image "${disk_image}" +create_partitions "${disk_image}" +mount_image "${disk_image}" + +# Copy the chroot in to the disk +make_ext4_partition "${rootfs_dev_mapper}" +mkdir mountpoint +mount "${rootfs_dev_mapper}" mountpoint +cp -a chroot/* mountpoint/ +umount mountpoint +rmdir mountpoint + +install_grub + +clean_loops +trap - EXIT diff --git a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary new file mode 100644 index 00000000..239f29f8 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary @@ -0,0 +1,64 @@ +#!/bin/bash -eux +architecture=$(chroot chroot dpkg --print-architecture) +if [ "$architecture" != "ppc64el" ]; then + exit 0 +fi + +. /build/config/functions + +create_partitions() { + disk_image="$1" + apt-get install -qqy gdisk + sgdisk "${disk_image}" \ + --zap-all + sgdisk "${disk_image}" \ + --new=2::+8M \ + --new=1: + sgdisk "${disk_image}" -t 2:4100 + sgdisk "${disk_image}" \ + --print +} + +install_grub() { + mkdir mountpoint + mount_partition "${rootfs_dev_mapper}" mountpoint + + chroot mountpoint apt-get -qqy install grub2 + chroot mountpoint apt-get -qqy remove --purge grub-legacy-ec2 + + # set the kernel commandline to use hvc0 + mkdir -p mountpoint/etc/default/grub.d + cat << EOF > mountpoint/etc/default/grub.d/50-cloudimg-settings.cfg +${CLOUD_IMG_STR} +# +# Set the default commandline +GRUB_CMDLINE_LINUX_DEFAULT="console=hvc0 earlyprintk" +EOF + prep_partition="/dev/mapper${loop_device///dev/}p2" + chroot mountpoint grub-install "${prep_partition}" \ + --no-nvram \ + --boot-directory=/boot \ + --target=powerpc-ieee1275 + + umount_partition mountpoint + rmdir mountpoint +} + +disk_image=binary/boot/disk.ext4 + +create_empty_disk_image "${disk_image}" +create_partitions "${disk_image}" +mount_image "${disk_image}" + +# Copy the chroot in to the disk +make_ext4_partition "${rootfs_dev_mapper}" +mkdir mountpoint +mount "${rootfs_dev_mapper}" mountpoint +cp -a chroot/* mountpoint/ +umount mountpoint +rmdir mountpoint + +install_grub + +clean_loops +trap - EXIT diff --git a/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary b/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary new file mode 100644 index 00000000..b90aabd0 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary @@ -0,0 +1,16 @@ +#!/bin/bash -ex + +apt-get install -qqy qemu-utils + +convert_image() { + src="$1" + destination="$2" + qemu-img convert -c -O qcow2 -o compat=0.10 "$src" "$destination" + qemu-img info "$destination" +} + +convert_image binary/boot/disk.ext4 livecd.ubuntu-cpc.disk1.img + +if [ -f binary/boot/disk-uefi.ext4 ]; then + convert_image binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.uefi1.img +fi diff --git a/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot index 28534971..501d09d6 100644 --- a/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot +++ b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -x rootd="${1:-/}" root_fs_label=cloudimg-rootfs set -ex @@ -147,7 +147,6 @@ if [ "$arch" = "i386" -o "$arch" = "amd64" ]; then add_serial_console ttyS0 fi - psuedo_grub_probe() { cat <<"PSUEDO_GRUB_PROBE" #!/bin/sh @@ -248,7 +247,7 @@ _xchroot "${rootd}" env DEBIAN_FRONTEND=noninteractive \ grub2cfg="${rootd}/boot/grub/grub.cfg" [ ! -f "${grub2cfg}" ] || - sed -i -e "s,root=/dev/sda1,root=LABEL=${root_fs_label}," "${grub2cfg}" + sed -i -e "s,root=/dev/[hs]da1,root=LABEL=${root_fs_label}," "${grub2cfg}" [ ${moved} -eq 0 ] || mv "${gprobe}.dist" "${gprobe}" From f4331844165a5eb2e77f224a646d22e1d1bc9c7b Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:17 -0500 Subject: [PATCH 03/25] Added additional CPC build targets - added manifest generation for squashfs and root.tar.gz - added VMDK generation - added OVA generation from VMDK's --- debian/changelog | 11 ++ live-build/ubuntu-cpc/functions | 68 +++++++ .../ubuntu-cpc/hooks/031-root-xz.binary | 6 + .../ubuntu-cpc/hooks/032-root-squashfs.binary | 15 ++ .../hooks/033-disk-image-uefi.binary | 4 +- .../ubuntu-cpc/hooks/040-vmdk-image.binary | 22 +++ .../hooks/041-vmdk-ova-image.binary | 88 +++++++++ .../ubuntu-cpc/hooks/042-vagrant.binary | 185 ++++++++++++++++++ live-build/ubuntu-cpc/hooks/999-extras.binary | 15 ++ .../ovf/ubuntu-ova-v1-cloudcfg-vmdk.tmpl | 179 +++++++++++++++++ .../hooks/ovf/ubuntu-ova-v1-vmdk.tmpl | 177 +++++++++++++++++ .../hooks/ovf/ubuntu-ovf-v1-img.tmpl | 130 ++++++++++++ 12 files changed, 898 insertions(+), 2 deletions(-) create mode 100644 live-build/ubuntu-cpc/hooks/032-root-squashfs.binary create mode 100644 live-build/ubuntu-cpc/hooks/040-vmdk-image.binary create mode 100644 live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary create mode 100644 live-build/ubuntu-cpc/hooks/042-vagrant.binary create mode 100644 live-build/ubuntu-cpc/hooks/999-extras.binary create mode 100644 live-build/ubuntu-cpc/hooks/ovf/ubuntu-ova-v1-cloudcfg-vmdk.tmpl create mode 100644 live-build/ubuntu-cpc/hooks/ovf/ubuntu-ova-v1-vmdk.tmpl create mode 100644 live-build/ubuntu-cpc/hooks/ovf/ubuntu-ovf-v1-img.tmpl diff --git a/debian/changelog b/debian/changelog index 783fd3c2..58657354 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +livecd-rootfs (2.209.2) trusty; urgency=medium + + [Oliver Grawert] + * added additional CPC build targets: + - added manifest generation for squashfs and root.tar.gz + - added VMDK generation + - added OVA generation from VMDK's + - added generic Vagrant image generation + + -- Robert C Jennings Tue, 23 May 2017 16:40:29 -0500 + livecd-rootfs (2.209.1) trusty; urgency=medium [Daniel Watkins] diff --git a/live-build/ubuntu-cpc/functions b/live-build/ubuntu-cpc/functions index 3c082ff2..b5500e70 100644 --- a/live-build/ubuntu-cpc/functions +++ b/live-build/ubuntu-cpc/functions @@ -1,3 +1,5 @@ +# vi: ts=4 expandtab syntax=sh + CLOUD_IMG_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" IMAGE_SIZE=$((2252*1024**2)) # 2.2G (the current size we ship) @@ -59,3 +61,69 @@ umount_partition() { umount "$mountpoint/dev" umount "$mountpoint" } + +modify_vmdk_header() { + # Modify the VMDK headers so that both VirtualBox _and_ VMware can + # read the vmdk and import them. The vodoo here is _not_ documented + # anywhere....so this will have to do. This is undocumented vodoo + # that has been learned by the Cloud Image team. + + vmdk_name="${1}" + descriptor=$(mktemp) + newdescriptor=$(mktemp) + + # Extract the vmdk header for manipulation + dd if="${vmdk_name}" of="${descriptor}" bs=1 skip=512 count=1024 + + # The sed lines below is where the magic is. Specifically: + # ddb.toolsVersion: sets the open-vm-tools so that VMware shows + # the tooling as current + # ddb.virtualHWVersion: set the version to 7, which covers most + # current versions of VMware + # createType: make sure its set to stream Optimized + # remove the vmdk-stream-converter comment and replace with + # # Disk DescriptorFile. This is needed for Virtualbox + # remove the comments from vmdk-stream-converter which causes + # VirtualBox and others to fail VMDK validation + + sed -e 's|# Description file.*|# Disk DescriptorFile|' \ + -e '/# Believe this is random*/d' \ + -e '/# Indicates no parent/d' \ + -e '/# The Disk Data Base/d' \ + -e 's|ddb.comment.*|ddb.toolsVersion = "2147483647"|' \ + "${descriptor}" > "${newdescriptor}" + + # The header is cannot be bigger than 1024 + expr $(stat --format=%s ${newdescriptor}) \< 1024 > /dev/null 2>&1 || { + echo "descriptor is too large, VMDK will be invalid!"; exit 1; } + + # Overwrite the vmdk header with our new, modified one + dd conv=notrunc,nocreat \ + if="${newdescriptor}" of="${vmdk_name}" \ + bs=1 seek=512 count=1024 + + rm ${descriptor} ${newdescriptor} +} + +create_vmdk() { + # There is no real good way to create a _compressed_ VMDK using open source + # tooling that works across multiple VMDK-capable platforms. This functions + # uses vmdk-stream-converter and then calls modify_vmdk_header to produce a + # compatible VMDK. + + src="$1" + destination="$2" + size="${3:-10240}" + + apt-get install -qqy qemu-utils vmdk-stream-converter + streamconverter="/usr/share/pyshared/VMDKstream.py" + scratch_d=$(mktemp -d) + cp ${src} ${scratch_d}/resize.img + + truncate --size=${size}M ${scratch_d}/resize.img + python ${streamconverter} ${scratch_d}/resize.img ${destination} + modify_vmdk_header ${destination} + + qemu-img info ${destination} + rm -rf ${scratch_d} +} diff --git a/live-build/ubuntu-cpc/hooks/031-root-xz.binary b/live-build/ubuntu-cpc/hooks/031-root-xz.binary index b2503adb..a3ee963d 100644 --- a/live-build/ubuntu-cpc/hooks/031-root-xz.binary +++ b/live-build/ubuntu-cpc/hooks/031-root-xz.binary @@ -1,3 +1,9 @@ #!/bin/bash -ex +# vi: ts=4 noexpandtab +# +# Generate the rootfs.tar.gz and manifest + +dpkg-query --admindir=binary/boot/filesystem.dir/var/lib/dpkg -W > livecd.ubuntu-cpc.rootfs.manifest + (cd "binary/boot/filesystem.dir/" && tar -c *) | \ xz > "livecd.ubuntu-cpc.rootfs.tar.xz" diff --git a/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary b/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary new file mode 100644 index 00000000..37d612f9 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary @@ -0,0 +1,15 @@ +#!/bin/bash -eux +# vi: ts=4 noexpandtab +# +# Generate a squashfs root and manifest + +apt-get -qqy install squashfs-tools + +squashfs_f="${PWD}/livecd.ubuntu-cpc.squashfs" +squashfs_f_manifest="${squashfs_f}.manifest" + +dpkg-query --admindir=binary/boot/filesystem.dir/var/lib/dpkg -W > ${squashfs_f_manifest} + +(cd "binary/boot/filesystem.dir/" && + mksquashfs . ${squashfs_f} \ + -no-progress -xattrs -comp xz ) 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 ccc6cca9..e0e90c18 100644 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -12,9 +12,10 @@ esac . /build/config/functions +apt-get -qqy install dosfstools gdisk + create_partitions() { disk_image="$1" - apt-get install -qqy gdisk sgdisk "${disk_image}" --zap-all case $architecture in arm64) @@ -39,7 +40,6 @@ create_partitions() { create_and_mount_uefi_partition() { uefi_dev="/dev/mapper${loop_device///dev/}p15" - apt-get -qqy install dosfstools mountpoint="$1" mkfs.vfat -F 32 -n UEFI "${uefi_dev}" diff --git a/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary new file mode 100644 index 00000000..44f876dc --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary @@ -0,0 +1,22 @@ +#!/bin/bash -eux +# vi: ts=4 expandtab +# +# Generate VMDK files + +architecture=$(chroot chroot dpkg --print-architecture) + +extension="disk1.vmdk" +case ${architecture} in + i386) image_target="binary/boot/disk.ext4";; + amd64) image_target="binary/boot/disk-uefi.ext4"; extension="uefi1.vmdk";; + *) echo "VMDK images are not supported for ${architecture} yet."; + exit 0;; +esac + +. /build/config/functions + +create_vmdk binary/boot/disk.ext4 livecd.ubuntu-cpc.disk1.vmdk + +if [ -e binary/boot/disk-uefi.ext4 ]; then + create_vmdk binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.uefi.vmdk +fi diff --git a/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary b/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary new file mode 100644 index 00000000..84134c42 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary @@ -0,0 +1,88 @@ +#!/bin/bash -eux +# vi: ts=4 expandtab +# +# Generate OVA images +# +# OVA images are, by defintiion a tarball consisting of a disk image, OVF file +# and checksums. This step produces an OVA that is suitable for use with +# Cloud's that support the OVF specification. +# +# For this step, we re-use the VMDK's made in 040-vmdk-image.binary + +cur_d=${PWD} +my_d=$(dirname $(readlink -f ${0})) + +architecture=$(chroot chroot dpkg --print-architecture) + +base_vmdk="livecd.ubuntu-cpc.disk1.vmdk" +case ${architecture} in + amd64) base_vmdk="livecd.ubuntu-cpc.uefi.vmdk";; + *) echo "OVA images are not supported for ${architecture} yet."; + exit 0;; +esac + +if [ ! -e ${base_vmdk} ]; then + find . | grep vmdk + exit 0 +fi + +# Lets be safe about this +scratch_d=$(mktemp -d) +trap "rm -rf ${scratch_d}" EXIT + +# Used to identify bits +suite=$(chroot chroot lsb_release -c -s) +version=$(chroot chroot lsb_release --release --short) +distro=$(chroot chroot lsb_release --id --short | tr [:upper:] [:lower:]) + +# Put our vmdk in place for OVA conversion +prefix="${distro}-${suite}-${version}-cloudimg" +vmdk_f="${scratch_d}/${prefix}.vmdk" +cp ${base_vmdk} ${vmdk_f} + +# Get information about the VMDK +vmdk_size=$(du -b "${vmdk_f}" | cut -f1) +vmdk_capacity=$(qemu-img info "${vmdk_f}" | awk '-F[\( ]' '$1 ~ /virtual/ && $NF ~ /bytes.*/ {print$(NF-1)}') + +# Populate the OVF template +ovf="${scratch_d}/${prefix}.ovf" +cp ${my_d}/ovf/ubuntu-ova-v1-vmdk.tmpl ${ovf} +serial_stamp=$(date +%Y%m%d) +sed -i "${ovf}" \ + -e "s/@@NAME@@/${prefix}-${serial_stamp}/g" \ + -e "s/@@FILENAME@@/${vmdk_f##*/}/g" \ + -e "s/@@VMDK_FILE_SIZE@@/${vmdk_size}/g" \ + -e "s/@@VMDK_CAPACITY@@/${vmdk_capacity}/g" \ + -e "s/@@NUM_CPUS@@/2/g" \ + -e "s/@@VERSION@@/${version}/g" \ + -e "s/@@DATE@@/${serial_stamp}/g" \ + -e "s/@@MEM_SIZE@@/1024/g" + +# Get the checksums +vmdk_sha256=$(sha256sum ${vmdk_f} | cut -d' ' -f1) +ovf_sha256=$(sha256sum ${ovf} | cut -d' ' -f1) + +# Generate the manifest +manifest="${scratch_d}/${prefix}.mf" +cat > "${manifest}" < ${seed_d}/user-data < ${seed_d}/meta-data < ${box_d}/Vagrantfile < ${box_d}/metadata.json < "${manifest}" < + + + + + + + Virtual disk information + + + + + The list of logical networks + + The VM Network network + + + + A virtual machine + @@NAME@@ + + The kind of installed guest operating system + + + + Cloud-Init customization + Ubuntu @@VERSION@@ Server (@@DATE@@) + + + Specifies the instance id. This is required and used to determine if the machine should take "first boot" actions + + + Specifies the hostname for the appliance + + + + This field is optional, but indicates that the instance should 'seed' user-data and meta-data from the given url. If set to 'http://tinyurl.com/sm-' is given, meta-data will be pulled from http://tinyurl.com/sm-meta-data and user-data from http://tinyurl.com/sm-user-data. Leave this empty if you do not want to seed from a url. + + + + This field is optional, but indicates that the instance should populate the default user's 'authorized_keys' with this value + + + + In order to fit into a xml attribute, this value is base64 encoded . It will be decoded, and then processed normally as user-data. + + + + + If set, the default user's password will be set to this value to allow password based login. The password will be good for only a single login. If set to the string 'RANDOM' then a random password will be generated, and written to the console. + + + + + Virtual hardware requirements + + Virtual Hardware Family + 0 + @@NAME@@ + vmx-10 + + + hertz * 10^6 + Number of Virtual CPUs + @@NUM_CPUS@@ virtual CPU(s) + 1 + 3 + @@NUM_CPUS@@ + + + byte * 2^20 + Memory Size + @@MEM_SIZE@@MB of memory + 2 + 4 + @@MEM_SIZE@@ + + + 0 + SCSI Controller + SCSI Controller 0 + 3 + VirtualSCSI + 6 + + + 1 + IDE Controller + VirtualIDEController 1 + 4 + 5 + + + 0 + IDE Controller + VirtualIDEController 0 + 5 + 5 + + + false + VirtualVideoCard + 6 + 24 + + + + + + + + false + VirtualVMCIDevice + 7 + vmware.vmci + 1 + + + + 0 + false + CD-ROM 1 + 8 + 4 + vmware.cdrom.remotepassthrough + 15 + + + + 0 + Hard Disk 1 + ovf:/disk/vmdisk1 + 9 + 3 + 17 + + + + 1 + ConfigDriveDisk + ovf:/disk/vmdisk2 + 10 + 3 + 17 + + + + 7 + true + VM Network + VmxNet3 ethernet adapter on "VM Network" + Ethernet 1 + 11 + VmxNet3 + 10 + + + + + + + + + + + + + + + + + + + + + + diff --git a/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ova-v1-vmdk.tmpl b/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ova-v1-vmdk.tmpl new file mode 100644 index 00000000..0eaa85a4 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ova-v1-vmdk.tmpl @@ -0,0 +1,177 @@ + + + + + + + Virtual disk information + + + + The list of logical networks + + The VM Network network + + + + A virtual machine + @@NAME@@ + + The kind of installed guest operating system + + + + Cloud-Init customization + Ubuntu @@VERSION@@ Server (@@DATE@@) + + + Specifies the instance id. This is required and used to determine if the machine should take "first boot" actions + + + Specifies the hostname for the appliance + + + + This field is optional, but indicates that the instance should 'seed' user-data and meta-data from the given url. If set to 'http://tinyurl.com/sm-' is given, meta-data will be pulled from http://tinyurl.com/sm-meta-data and user-data from http://tinyurl.com/sm-user-data. Leave this empty if you do not want to seed from a url. + + + + This field is optional, but indicates that the instance should populate the default user's 'authorized_keys' with this value + + + + In order to fit into a xml attribute, this value is base64 encoded . It will be decoded, and then processed normally as user-data. + + + + + If set, the default user's password will be set to this value to allow password based login. The password will be good for only a single login. If set to the string 'RANDOM' then a random password will be generated, and written to the console. + + + + + Virtual hardware requirements + + Virtual Hardware Family + 0 + @@NAME@@ + vmx-10 + + + hertz * 10^6 + Number of Virtual CPUs + @@NUM_CPUS@@ virtual CPU(s) + 1 + 3 + @@NUM_CPUS@@ + + + byte * 2^20 + Memory Size + @@MEM_SIZE@@MB of memory + 2 + 4 + @@MEM_SIZE@@ + + + 0 + SCSI Controller + SCSI Controller 0 + 3 + VirtualSCSI + 6 + + + 1 + IDE Controller + VirtualIDEController 1 + 4 + 5 + + + 0 + IDE Controller + VirtualIDEController 0 + 5 + 5 + + + false + VirtualVideoCard + 6 + 24 + + + + + + + + false + VirtualVMCIDevice + 7 + vmware.vmci + 1 + + + + 0 + false + CD-ROM 1 + 8 + 4 + vmware.cdrom.remotepassthrough + 15 + + + + 0 + Hard Disk 1 + ovf:/disk/vmdisk1 + 9 + 3 + 17 + + + + 0 + false + Floppy Drive + Floppy 1 + 10 + vmware.floppy.remotedevice + 14 + + + 7 + true + VM Network + VmxNet3 ethernet adapter on "VM Network" + Ethernet 1 + 11 + VmxNet3 + 10 + + + + + + + + + + + + + + + + + + + + + + diff --git a/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ovf-v1-img.tmpl b/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ovf-v1-img.tmpl new file mode 100644 index 00000000..161b8f61 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ovf-v1-img.tmpl @@ -0,0 +1,130 @@ + + + + + + + Virtual disk information + + + + The list of logical networks + + The bridged network + + + + A virtual machine + $VIRTUAL_SYSTEM_NAME + + $VIRTUAL_SYSTEM_OS_INFO + + + Cloud-Init customization + $VIRTUAL_SYSTEM_OS_INFO + + + Specifies the instance id. This is required and used to determine if the machine should take "first boot" actions + + + Specifies the hostname for the appliance + + + + This field is optional, but indicates that the instance should 'seed' user-data and meta-data from the given url. If set to 'http://tinyurl.com/sm-' is given, meta-data will be pulled from http://tinyurl.com/sm-meta-data and user-data from http://tinyurl.com/sm-user-data. Leave this empty if you do not want to seed from a url. + + + + This field is optional, but indicates that the instance should populate the default user's 'authorized_keys' with this value + + + + In order to fit into a xml attribute, this value is base64 encoded . It will be decoded, and then processed normally as user-data. + + + + + If set, the default user's password will be set to this value to allow password based login. The password will be good for only a single login. If set to the string 'RANDOM' then a random password will be generated, and written to the console. + + + + Virtual hardware requirements + + Virtual Hardware Family + 0 + $VIRTUAL_SYSTEM_IDENTIFIER + $VIRTUAL_SYSTEM_TYPES + + + hertz * 10^6 + Number of Virtual CPUs + 1 virtual CPU(s) + 1 + 3 + 1 + + + byte * 2^20 + Memory Size + 256MB of memory + 2 + 4 + 256 + + + 0 + USB Controller + usb + 3 + 23 + + + 0 + SCSI Controller + scsiController0 + 4 + lsilogic + 6 + + + 1 + IDE Controller + ideController1 + 5 + 5 + + + 0 + false + cdrom1 + 6 + 5 + 15 + + + 0 + disk1 + ovf:/disk/vmdisk1 + 7 + 4 + 17 + + + 2 + true + bridged + ethernet adapter on "bridged" + ethernet0 + 8 + E1000 + 10 + + + + $ANNOTATION_INFO + $ANNOTATION + + + From 323da962e5188c1f28bd3cda030e463676a573c0 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:19 -0500 Subject: [PATCH 04/25] Fix typo in ubuntu-cpc preventing non-intel builds --- debian/changelog | 7 +++++++ live-build/ubuntu-cpc/hooks/042-vagrant.binary | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 58657354..220fa4ef 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +livecd-rootfs (2.209.3) trusty; urgency=medium + + [Ben Howard] + * Fix typo in ubuntu-cpc preventing non-intel builds. + + -- Robert C Jennings Tue, 23 May 2017 16:46:04 -0500 + livecd-rootfs (2.209.2) trusty; urgency=medium [Oliver Grawert] diff --git a/live-build/ubuntu-cpc/hooks/042-vagrant.binary b/live-build/ubuntu-cpc/hooks/042-vagrant.binary index 0aebde7a..22d359e7 100644 --- a/live-build/ubuntu-cpc/hooks/042-vagrant.binary +++ b/live-build/ubuntu-cpc/hooks/042-vagrant.binary @@ -19,7 +19,7 @@ architecture=$(chroot chroot dpkg --print-architecture) base_vmdk="livecd.ubuntu-cpc.disk1.vmdk" if [[ ! "${architecture}" =~ (amd64|i386) ]]; then - echo "Vagrant images are not supported for ${architecutre}" + echo "Vagrant images are not supported for ${architecture}" exit 0 elif [ ! -e ${base_vmdk} ]; then echo "Did not find VMDK to produce Vagrant images." From 004ee17e1f59490ee92f23ad6ea5a9d05163f406 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:20 -0500 Subject: [PATCH 05/25] ubuntu-cpc: Add /dev/pts to hook env, also settle disks after UEFI builds --- debian/changelog | 9 +++++++++ live-build/ubuntu-cpc/functions | 2 ++ live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/debian/changelog b/debian/changelog index 220fa4ef..610520bc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +livecd-rootfs (2.209.4) trusty; urgency=medium + + [Ben Howard] + * ubuntu-cpc: + - add devpts-live to hook builds + - add logic to settle the disks after UEFI builds + + -- Robert C Jennings Tue, 23 May 2017 20:12:47 -0500 + livecd-rootfs (2.209.3) trusty; urgency=medium [Ben Howard] diff --git a/live-build/ubuntu-cpc/functions b/live-build/ubuntu-cpc/functions index b5500e70..a966840f 100644 --- a/live-build/ubuntu-cpc/functions +++ b/live-build/ubuntu-cpc/functions @@ -46,6 +46,7 @@ mount_partition() { mount "$partition" "$mountpoint" mount --bind /dev "$mountpoint/dev" + mount devpts-live -t devpts "$mountpoint/dev/pts" mount proc-live -t proc "$mountpoint/proc" mount sysfs-live -t sysfs "$mountpoint/sys" mv "$mountpoint/etc/resolv.conf" resolv.conf.tmp @@ -58,6 +59,7 @@ umount_partition() { mv resolv.conf.tmp "$mountpoint/etc/resolv.conf" umount "$mountpoint/proc" umount "$mountpoint/sys" + umount "$mountpoint/dev/pts" umount "$mountpoint/dev" umount "$mountpoint" } 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 e0e90c18..88530c6e 100644 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -116,7 +116,11 @@ EOF chroot mountpoint apt-get -y update rm mountpoint/tmp/device.map + sync umount mountpoint/boot/efi + sleep 5 + udevadm settle + mount umount_partition mountpoint rmdir mountpoint } From 65bb92f3a666394cdc6372ff5eb6f370cefea1f6 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:21 -0500 Subject: [PATCH 06/25] ubunutu-cpc: Improvements for derivative image creation * ubunutu-cpc: - extended hooks/functions to support creation of derivative images including mounting images. - added the ability to create qcow2 images in hooks/functions - simplified loop clean-up in hooks/functions - removed assumption that disk1.img would be built - switched qcow2 generation to use hooks/functions function --- debian/changelog | 13 ++ live-build/ubuntu-cpc/functions | 126 +++++++++++++++--- .../ubuntu-cpc/hooks/040-qcow2-image.binary | 13 +- .../ubuntu-cpc/hooks/040-vmdk-image.binary | 12 +- live-build/ubuntu-cpc/hooks/999-extras.binary | 7 +- 5 files changed, 141 insertions(+), 30 deletions(-) diff --git a/debian/changelog b/debian/changelog index 610520bc..aa784239 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +livecd-rootfs (2.209.5) trusty; urgency=medium + + [Ben Howard] + * ubuntu-cpc: + - extended hooks/functions to support creation of derivative images + including mounting images. + - added the ability to create qcow2 images in hooks/functions + - simplified loop clean-up in hooks/functions + - removed assumption that disk1.img would be built + - switched qcow2 generation to use hooks/functions function + + -- Robert C Jennings Tue, 23 May 2017 20:21:47 -0500 + livecd-rootfs (2.209.4) trusty; urgency=medium [Ben Howard] diff --git a/live-build/ubuntu-cpc/functions b/live-build/ubuntu-cpc/functions index a966840f..79b02c4c 100644 --- a/live-build/ubuntu-cpc/functions +++ b/live-build/ubuntu-cpc/functions @@ -6,16 +6,23 @@ IMAGE_SIZE=$((2252*1024**2)) # 2.2G (the current size we ship) rootfs_dev_mapper= loop_device= loop_raw= +backing_img= + +apt-get -qqy install dosfstools gdisk clean_loops() { - [ -z "${rootfs_dev_mapper}" ] || { - udevadm settle - find /dev/mapper -iname "${loop_device///dev\//}*" | \ - xargs -n1 -I DEVICE dmsetup remove DEVICE || - kpartx -d "${rootfs_dev_mapper}" - losetup -d "${loop_device}" || echo "Failed to detach disk" - unset loop_raw - } + if [ -z "${rootfs_dev_mapper}" ]; then + return 0 + fi + + if [ -n "${backing_img}" ]; then + kpartx -v -d "${backing_img}" + fi + + unset backing_img + unset loop_device + unset loop_raw + unset rootfs_dev_mapper } create_empty_disk_image() { @@ -32,6 +39,7 @@ make_ext4_partition() { mount_image() { apt-get install -qqy kpartx trap clean_loops EXIT + backing_img="$1" loop_raw="$(kpartx -s -v -a "$1" )" loop_device="$(echo -e "${loop_raw}" | head -n1 | awk '{print($(NF-1))}')" rootfs_dev_mapper="/dev/mapper${loop_device///dev/}p1" @@ -46,22 +54,80 @@ mount_partition() { mount "$partition" "$mountpoint" mount --bind /dev "$mountpoint/dev" - mount devpts-live -t devpts "$mountpoint/dev/pts" + mount devpts-live -t proc "$mountpoint/dev/pts" mount proc-live -t proc "$mountpoint/proc" mount sysfs-live -t sysfs "$mountpoint/sys" + mount -t tmpfs none "$mountpoint/tmp" mv "$mountpoint/etc/resolv.conf" resolv.conf.tmp cp /etc/resolv.conf "$mountpoint/etc/resolv.conf" } + +mount_disk_image() { + local disk_image=${1} + local mountpoint=${2} + mount_image ${disk_image} + mount_partition "${rootfs_dev_mapper}" $mountpoint + + local uefi_dev="/dev/mapper${loop_device///dev/}p15" + if [ -b ${uefi_dev} -a -e $mountpoint/boot/efi ]; then + mount "${uefi_dev}" $mountpoint/boot/efi + fi + + # This is needed to allow for certain operations + # such as updating grub and installing software + cat > $mountpoint/usr/sbin/policy-rc.d << EOF +#!/bin/sh +# ${CLOUD_IMG_STR} +echo "All runlevel operations denied by policy" >&2 +exit 101 +EOF + chmod 0755 $mountpoint/usr/sbin/policy-rc.d + +} + +umount_settle() { + # Unmount device, and let it settle + umount $1 + udevadm settle + sleep 3 +} + umount_partition() { + local mountpoint=${1} + mv resolv.conf.tmp "$mountpoint/etc/resolv.conf" + for submnt in proc sys dev/pts dev tmp; + do + umount_settle $mountpoint/$submnt + done + umount_settle $mountpoint + + if [ -n "${rootfs_dev_mapper}" -a -b "${rootfs_dev_mapper}" ]; then + # buildd's don't have /etc/mtab symlinked + # /etc/mtab is needed in order zerofree space for ext4 filesystems + [ -e /etc/mtab ] || ln -s /proc/mounts /etc/mtab + + # both of these are likely overkill, but it does result in slightly + # smaller ext4 filesystem + apt-get -qqy install zerofree + e2fsck -y -E discard ${rootfs_dev_mapper} + zerofree ${rootfs_dev_mapper} + fi +} + +umount_disk_image() { mountpoint="$1" - mv resolv.conf.tmp "$mountpoint/etc/resolv.conf" - umount "$mountpoint/proc" - umount "$mountpoint/sys" - umount "$mountpoint/dev/pts" - umount "$mountpoint/dev" - umount "$mountpoint" + local uefi_dev="/dev/mapper${loop_device///dev/}p15" + if [ -e "$mountpoint/boot/efi" -a -b "$uefi_dev" ]; then + umount --detach-loop "$mountpoint/boot/efi" + fi + + if [ -e $mountpoint/usr/sbin/policy-rc.d ]; then + rm $mountpoint/usr/sbin/policy-rc.d + fi + umount_partition $mountpoint + clean_loops } modify_vmdk_header() { @@ -129,3 +195,33 @@ create_vmdk() { qemu-img info ${destination} rm -rf ${scratch_d} } + +create_derivative() { + # arg1 is the disk type + # arg2 is the new name + unset derivative_img + case ${1} in + uefi) disk_image="binary/boot/disk-uefi.ext4"; + dname="${disk_image//-uefi/-$2-uefi}";; + *) disk_image="binary/boot/disk.ext4"; + dname="${disk_image//.ext4/-$2.ext4}";; + esac + + if [ ! -e ${disk_image} ]; then + echo "Did not find ${disk_image}!"; exit 1; + fi + + cp ${disk_image} ${dname} + export derivative_img=${dname} +} + +convert_to_qcow2() { + apt-get install -qqy qemu-utils + + src="$1" + destination="$2" + qemu-img convert -c -O qcow2 -o compat=0.10 "$src" "$destination" + qemu-img info "$destination" +} + + diff --git a/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary b/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary index b90aabd0..e8b9fbd5 100644 --- a/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary +++ b/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary @@ -2,15 +2,12 @@ apt-get install -qqy qemu-utils -convert_image() { - src="$1" - destination="$2" - qemu-img convert -c -O qcow2 -o compat=0.10 "$src" "$destination" - qemu-img info "$destination" -} +. /build/config/functions -convert_image binary/boot/disk.ext4 livecd.ubuntu-cpc.disk1.img +if [ -f binary/boot/disk.ext4 ]; then + convert_to_qcow2 binary/boot/disk.ext4 livecd.ubuntu-cpc.disk1.img +fi if [ -f binary/boot/disk-uefi.ext4 ]; then - convert_image binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.uefi1.img + convert_to_qcow2 binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.uefi1.img fi diff --git a/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary index 44f876dc..7345bf4e 100644 --- a/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary +++ b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary @@ -6,16 +6,18 @@ architecture=$(chroot chroot dpkg --print-architecture) extension="disk1.vmdk" + case ${architecture} in - i386) image_target="binary/boot/disk.ext4";; - amd64) image_target="binary/boot/disk-uefi.ext4"; extension="uefi1.vmdk";; - *) echo "VMDK images are not supported for ${architecture} yet."; - exit 0;; + i386|amd64) ;; + *) echo "VMDK images are not supported for ${architecture} yet."; + exit 0;; esac . /build/config/functions -create_vmdk binary/boot/disk.ext4 livecd.ubuntu-cpc.disk1.vmdk +if [ -e binary/boot/disk.ext4 ]; then + create_vmdk binary/boot/disk.ext4 livecd.ubuntu-cpc.disk1.vmdk +fi if [ -e binary/boot/disk-uefi.ext4 ]; then create_vmdk binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.uefi.vmdk diff --git a/live-build/ubuntu-cpc/hooks/999-extras.binary b/live-build/ubuntu-cpc/hooks/999-extras.binary index 4e6c7e81..155a3b12 100644 --- a/live-build/ubuntu-cpc/hooks/999-extras.binary +++ b/live-build/ubuntu-cpc/hooks/999-extras.binary @@ -8,8 +8,11 @@ if [ ! -d ${my_dir}/extra ]; then exit 0 fi +# Export the common functions to the extras +. /build/config/functions + # Execute extra binary hooks -for recipe in $(find ${extra_d} -type f -executable); +for recipe in $(find ${extra_d} -type f -executable -maxdepth 1); do - bash ${recipe} + bash -xue ${recipe} done From d8704008514ce4524ce32c3618226ebbca53943a Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:22 -0500 Subject: [PATCH 07/25] ubuntu-cpc: Produce OVA files for i386 cloud builds --- debian/changelog | 7 +++++++ .../hooks/041-vmdk-ova-image.binary | 19 +++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index aa784239..55d56e26 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +livecd-rootfs (2.209.6) trusty; urgency=medium + + [Daniel Watkins] + * Produce OVA files for i386 cloud builds. + + -- Robert C Jennings Tue, 23 May 2017 20:34:47 -0500 + livecd-rootfs (2.209.5) trusty; urgency=medium [Ben Howard] diff --git a/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary b/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary index 84134c42..4123a501 100644 --- a/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary +++ b/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary @@ -9,20 +9,23 @@ # # For this step, we re-use the VMDK's made in 040-vmdk-image.binary -cur_d=${PWD} -my_d=$(dirname $(readlink -f ${0})) - architecture=$(chroot chroot dpkg --print-architecture) -base_vmdk="livecd.ubuntu-cpc.disk1.vmdk" case ${architecture} in - amd64) base_vmdk="livecd.ubuntu-cpc.uefi.vmdk";; - *) echo "OVA images are not supported for ${architecture} yet."; - exit 0;; + amd64|i386) ;; + *) echo "OVA images are not supported for ${architecture} yet."; + exit 0;; esac +cur_d=${PWD} +my_d=$(dirname $(readlink -f ${0})) + +base_vmdk="livecd.ubuntu-cpc.disk1.vmdk" +if [ $architecture = "amd64" ]; then + base_vmdk="livecd.ubuntu-cpc.uefi.vmdk" +fi if [ ! -e ${base_vmdk} ]; then - find . | grep vmdk + find . | grep vmdk exit 0 fi From fd9a4dc0ba3e1a0d46c70a9804f52bca69724315 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:22 -0500 Subject: [PATCH 08/25] ubuntu-cpc: Remove unneeded packages from the root.tar.{gz,xz} (LP: #1534764) --- debian/changelog | 8 ++++++++ live-build/ubuntu-cpc/hooks/030-root-tarball.binary | 1 + live-build/ubuntu-cpc/hooks/999-extras.binary | 7 ++----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index 55d56e26..b82f5ddf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +livecd-rootfs (2.209.7) trusty; urgency=medium + + [Ben Howard] + * Remove unneeded packages from the root.tar.{gz,xz} cloud image targets + (LP: #1534764). + + -- Robert C Jennings Tue, 23 May 2017 20:45:47 -0500 + livecd-rootfs (2.209.6) trusty; urgency=medium [Daniel Watkins] diff --git a/live-build/ubuntu-cpc/hooks/030-root-tarball.binary b/live-build/ubuntu-cpc/hooks/030-root-tarball.binary index 22556399..6e6f183a 100644 --- a/live-build/ubuntu-cpc/hooks/030-root-tarball.binary +++ b/live-build/ubuntu-cpc/hooks/030-root-tarball.binary @@ -15,6 +15,7 @@ chroot binary/boot/filesystem.dir chmod +x /usr/sbin/grub-probe env DEBIAN_FRONTEND=noninteractive chroot binary/boot/filesystem.dir apt-get --purge remove --assume-yes '^linux-.*' env DEBIAN_FRONTEND=noninteractive chroot binary/boot/filesystem.dir apt-get --purge remove --assume-yes '^grub-.*' +env DEBIAN_FRONTEND=noninteractive chroot binary/boot/filesystem.dir apt-get autoremove --purge --assume-yes chroot binary/boot/filesystem.dir rm /usr/sbin/grub-probe chroot binary/boot/filesystem.dir dpkg-divert --remove --local --rename /usr/sbin/grub-probe diff --git a/live-build/ubuntu-cpc/hooks/999-extras.binary b/live-build/ubuntu-cpc/hooks/999-extras.binary index 155a3b12..dad116a0 100644 --- a/live-build/ubuntu-cpc/hooks/999-extras.binary +++ b/live-build/ubuntu-cpc/hooks/999-extras.binary @@ -11,8 +11,5 @@ fi # Export the common functions to the extras . /build/config/functions -# Execute extra binary hooks -for recipe in $(find ${extra_d} -type f -executable -maxdepth 1); -do - bash -xue ${recipe} -done +# Cleaner execution +/bin/run-parts ${extra_d} From 009aca99d8555d957be65d32704244f80c901a51 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:23 -0500 Subject: [PATCH 09/25] ubuntu-cpc: Install grub in ppc64el images so they are bootable (LP: #1538610) --- debian/changelog | 7 +++++++ live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/debian/changelog b/debian/changelog index b82f5ddf..75a82967 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +livecd-rootfs (2.209.8) trusty; urgency=medium + + [Daniel Watkins] + * Install grub in ppc64el cloud images so they are bootable (LP: #1538610) + + -- Robert C Jennings Tue, 23 May 2017 20:51:47 -0500 + livecd-rootfs (2.209.7) trusty; urgency=medium [Ben Howard] 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 239f29f8..54d1ad03 100644 --- a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary +++ b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary @@ -40,6 +40,11 @@ EOF --boot-directory=/boot \ --target=powerpc-ieee1275 + chroot mountpoint dpkg-divert --local --rename /etc/grub.d/30_os-prober + chroot mountpoint update-grub + sed -i "s,root=.* ,root=LABEL=cloudimg-rootfs ,g" mountpoint/boot/grub/grub.cfg + chroot mountpoint dpkg-divert --remove --local --rename /etc/grub.d/30_os-prober + umount_partition mountpoint rmdir mountpoint } From 3bab68711901912ee1e7eecf5ff400f6c356346a Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:24 -0500 Subject: [PATCH 10/25] ubuntu-cpc: Fix ppc64el grub timeout. Also run extras correctly. * Set timeout options so ppc64el cloud images don't display a grub boot menu (matching the behaviour of other cloud images). * Specify a regex to run-parts so that cloud image extra scripts are found and executed. --- debian/changelog | 10 ++++++++++ .../ubuntu-cpc/hooks/034-disk-image-ppc64el.binary | 8 +++++++- live-build/ubuntu-cpc/hooks/999-extras.binary | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 75a82967..c274207d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +livecd-rootfs (2.209.9) trusty; urgency=medium + + [Daniel Watkins] + * Set timeout options so ppc64el cloud images don't display a grub boot + menu (matching the behaviour of other cloud images). + * Specify a regex to run-parts so that cloud image extra scripts are found + and executed. + + -- Robert C Jennings Tue, 23 May 2017 20:57:47 -0500 + livecd-rootfs (2.209.8) trusty; urgency=medium [Daniel Watkins] 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 54d1ad03..59ae62b6 100644 --- a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary +++ b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary @@ -30,7 +30,13 @@ install_grub() { mkdir -p mountpoint/etc/default/grub.d cat << EOF > mountpoint/etc/default/grub.d/50-cloudimg-settings.cfg ${CLOUD_IMG_STR} -# + +# Set the recordfail timeout +GRUB_RECORDFAIL_TIMEOUT=0 + +# Do not wait on grub prompt +GRUB_TIMEOUT=0 + # Set the default commandline GRUB_CMDLINE_LINUX_DEFAULT="console=hvc0 earlyprintk" EOF diff --git a/live-build/ubuntu-cpc/hooks/999-extras.binary b/live-build/ubuntu-cpc/hooks/999-extras.binary index dad116a0..ffc7c691 100644 --- a/live-build/ubuntu-cpc/hooks/999-extras.binary +++ b/live-build/ubuntu-cpc/hooks/999-extras.binary @@ -12,4 +12,4 @@ fi . /build/config/functions # Cleaner execution -/bin/run-parts ${extra_d} +/bin/run-parts --regex ".*\.binary" "${extra_d}" From 9cf7b2278f06f432d1caf4054f49498f668beb8f Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:24 -0500 Subject: [PATCH 11/25] ubuntu-cpc: Refactor for consistency & fix grub-install logic [ Steve Langasek ] * Refactor/reorder ubuntu-cpc support for consistency with other flavors, so that subarch overrides can be applied correctly. [ Ben Howard ] * ubuntu-cpc: - fixed loop setup due to change of kpartx output - only use grub-install logic for Intel architectures --- debian/changelog | 13 +++++ live-build/auto/config | 52 +++++++++---------- live-build/ubuntu-cpc/functions | 35 +++++++++---- .../ubuntu-cpc/hooks/032-disk-image.binary | 23 ++++---- 4 files changed, 75 insertions(+), 48 deletions(-) diff --git a/debian/changelog b/debian/changelog index c274207d..ef3c9db6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +livecd-rootfs (2.209.10) trusty; urgency=medium + + [ Steve Langasek ] + * Refactor/reorder ubuntu-cpc support for consistency with other flavors, + so that subarch overrides can be applied correctly. + + [ Ben Howard ] + * ubuntu-cpc: + - fixed loop setup due to change of kpartx output + - only use grub-install logic for Intel architectures + + -- Robert C Jennings Tue, 23 May 2017 21:01:47 -0500 + livecd-rootfs (2.209.9) trusty; urgency=medium [Daniel Watkins] diff --git a/live-build/auto/config b/live-build/auto/config index 72e0a0ff..eea3b37f 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -388,6 +388,31 @@ case $PROJECT in ;; ubuntu-cpc) + add_task install minimal standard cloud-image + add_package install ubuntu-minimal + + BINARY_REMOVE_LINUX=false + OPTS="${OPTS:+$OPTS }--initramfs=none" + KERNEL_FLAVOURS=virtual + case $ARCH in + armhf) + KERNEL_FLAVOURS=generic-lpae + add_package install flash-kernel + add_task install server + ;; + arm64) + KERNEL_FLAVOURS=generic + add_package install flash-kernel + add_task install server + ;; + ppc64el) + add_task install server + ;; + esac + OPTS="${OPTS:+$OPTS }--system=normal" + OPTS="${OPTS:+$OPTS }--hdd-label=cloudimg-rootfs" + OPTS="${OPTS:+$OPTS }--ext-resize-blocks=536870912 --ext-block-size=4096" + OPTS="${OPTS:+$OPTS }--ext-fudge-factor=15" ;; *) @@ -467,33 +492,6 @@ case $PROJECT in ;; esac -if [ "$PROJECT" = "ubuntu-cpc" ]; then - BINARY_REMOVE_LINUX=false - OPTS="${OPTS:+$OPTS }--initramfs=none" - KERNEL_FLAVOURS=virtual - case $ARCH in - armhf) - KERNEL_FLAVOURS=generic-lpae - add_package install flash-kernel - add_task install server - ;; - arm64) - KERNEL_FLAVOURS=generic - add_package install flash-kernel - add_task install server - ;; - ppc64el) - add_task install server - ;; - esac - OPTS="${OPTS:+$OPTS }--system=normal" - OPTS="${OPTS:+$OPTS }--hdd-label=cloudimg-rootfs" - OPTS="${OPTS:+$OPTS }--ext-resize-blocks=536870912 --ext-block-size=4096" - OPTS="${OPTS:+$OPTS }--ext-fudge-factor=15" - add_task install minimal standard cloud-image - add_package install landscape-client ubuntu-minimal -fi - add_chroot_hook update-apt-file-cache add_chroot_hook update-apt-xapian-index add_chroot_hook update-mlocate-database diff --git a/live-build/ubuntu-cpc/functions b/live-build/ubuntu-cpc/functions index 79b02c4c..f4557c9e 100644 --- a/live-build/ubuntu-cpc/functions +++ b/live-build/ubuntu-cpc/functions @@ -11,15 +11,16 @@ backing_img= apt-get -qqy install dosfstools gdisk clean_loops() { - if [ -z "${rootfs_dev_mapper}" ]; then - return 0 - fi if [ -n "${backing_img}" ]; then kpartx -v -d "${backing_img}" + unset backing_img + fi + + if [ -z "${rootfs_dev_mapper}" ]; then + return 0 fi - unset backing_img unset loop_device unset loop_raw unset rootfs_dev_mapper @@ -40,11 +41,27 @@ mount_image() { apt-get install -qqy kpartx trap clean_loops EXIT backing_img="$1" - loop_raw="$(kpartx -s -v -a "$1" )" - loop_device="$(echo -e "${loop_raw}" | head -n1 | awk '{print($(NF-1))}')" - rootfs_dev_mapper="/dev/mapper${loop_device///dev/}p1" - [ ! -b "${rootfs_dev_mapper}" ] && - echo "${rootfs_dev_mapper} is not a block device" && exit 1 + kpartx_mapping="$(kpartx -s -v -a ${backing_img})" + + # Find the loop device + loop_p1="$(echo -e ${kpartx_mapping} | head -n1 | awk '{print$3}')" + loop_device="/dev/loop$(echo ${loop_p1} | cut -b5)" + if [ ! -b ${loop_device} ]; then + echo "unable to find loop device for ${backing_img}" + exit 1 + fi + + # Find the rootfs location + rootfs_dev_mapper="/dev/mapper/${loop_p1}" + if [ ! -b "${rootfs_dev_mapper}" ]; then + echo "${rootfs_dev_mapper} is not a block device"; + exit 1 + fi + + # Add some information to the debug logs + echo "Mounted disk image ${backing_img} to ${rootfs_dev_mapper}" + blkid ${rootfs_dev_mapper} + return 0 } diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index 99514de4..1eefd13c 100644 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -32,24 +32,23 @@ cp -a chroot/* mountpoint/ umount mountpoint rmdir mountpoint -should_install_grub() { - case $architecture in - armhf|arm64) - return 1 - ;; - *) - return 0 - ;; - esac -} +case $architecture in + amd64|i386) should_install_grub=1;; + *) should_install_grub=0;; +esac -if should_install_grub; then +if [ "${should_install_grub}" -eq 1 ]; then mkdir mountpoint mount_partition "${rootfs_dev_mapper}" mountpoint echo "(hd0) ${loop_device}" > mountpoint/tmp/device.map chroot mountpoint grub-install ${loop_device} - chroot mountpoint grub-bios-setup --boot-image=i386-pc/boot.img --core-image=i386-pc/core.img --skip-fs-probe --device-map=/tmp/device.map ${loop_device} + chroot mountpoint grub-bios-setup \ + --boot-image=i386-pc/boot.img \ + --core-image=i386-pc/core.img \ + --skip-fs-probe \ + --device-map=/tmp/device.map \ + ${loop_device} rm mountpoint/tmp/device.map umount_partition mountpoint From 4a65c41a5e1f8877520176ce44b7ed4f1cf758b2 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:25 -0500 Subject: [PATCH 12/25] ubuntu-cpc: Mask blkid failure in mount_image On trusty parted does not create the FS based on the type passed to it. As a result, calling mount_image for a newly created image will not have an FS on the root partition. Calling blkid in mount_image to provide additional debug output will fail when the root partition has no FS. The root FS is created after mount_image is called in the hook that creates the base.ext4 image. We can ignore the blkid failure as it is used for debug output; the base image will not have output but derivative images already have a formatted partition and we'll have handy info. --- live-build/ubuntu-cpc/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/live-build/ubuntu-cpc/functions b/live-build/ubuntu-cpc/functions index f4557c9e..9aa64d14 100644 --- a/live-build/ubuntu-cpc/functions +++ b/live-build/ubuntu-cpc/functions @@ -60,7 +60,7 @@ mount_image() { # Add some information to the debug logs echo "Mounted disk image ${backing_img} to ${rootfs_dev_mapper}" - blkid ${rootfs_dev_mapper} + blkid ${rootfs_dev_mapper} || true return 0 } From cb8ede888fc2ff45ec02457d9bf280e2fd5238e9 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:26 -0500 Subject: [PATCH 13/25] ubuntu-cpc: Refactor arch handling to fix armhf [ Steve Langasek ] * Refactor some non-idiomatic architecture handling in live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot that also misidentifies the architecture name for armhf. --- debian/changelog | 9 +++++ .../ubuntu-cpc/hooks/999-cpc-fixes.chroot | 38 +++++++++---------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/debian/changelog b/debian/changelog index ef3c9db6..9c69e930 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +livecd-rootfs (2.209.11) trusty; urgency=medium + + [ Steve Langasek ] + * Refactor some non-idiomatic architecture handling in + live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot that also misidentifies + the architecture name for armhf. + + -- Robert C Jennings Tue, 23 May 2017 21:38:47 -0500 + livecd-rootfs (2.209.10) trusty; urgency=medium [ Steve Langasek ] diff --git a/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot index 501d09d6..34964ca7 100644 --- a/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot +++ b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot @@ -126,26 +126,26 @@ fi #### END COMMON ARCH FUNCTIONS -if [ "$arch" = "ppc64el" ]; then - add_serial_console hvc0 - exit 0 -fi - -# ARM images are special -if [[ "$arch" =~ (arm|arm64|aarch64) ]]; then - - echo "Configuring ARM Serial Port" - add_serial_console ttyAMA0 - - echo "Image architecture is ARM. Existing vmbuilder-fixups" - exit 0 -fi - -## Add ttyS0 for i386/amd64 for Trusty and newer -if [ "$arch" = "i386" -o "$arch" = "amd64" ]; then - add_serial_console ttyS0 -fi +case $arch in + # ARM images are special + armhf|arm64) + echo "Configuring ARM Serial Port" + add_serial_console ttyAMA0 + + echo "Image architecture is ARM. Existing vmbuilder-fixups" + + exit 0 + ;; + ## Add ttyS0 for i386/amd64 for Trusty and newer + i386|amd64) + add_serial_console ttyS0 + ;; + ppc64el) + add_serial_console hvc0 + exit 0 + ;; +esac psuedo_grub_probe() { cat <<"PSUEDO_GRUB_PROBE" From 742985bb4dc5bd84caaaa2bc8a6af9e9edf34271 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:26 -0500 Subject: [PATCH 14/25] Clean/refactor to add raspi2, plus ubuntu-cpc fixes [ Steve Langasek ] * Add hooks to ubuntu-cpc to divert /bin/sync in the chroot and undivert it at the end. This is a general-purpose change that should be applied to all flavors and archs, but at the moment it's only needed on armhf+raspi2 to work around the raspberrypi2-firmware postinst calling sync, which is actually warranted in the normal case. * If a subarch is specified for a cloud image build, don't build rootfs artifacts; these should come from the 'generic' build. * Fix architecture handling in hooks. We know we're always being invoked from a launchpad-buildd-like setup, which passes ARCH and SUBARCH in the environment, because auto/config and auto/build both rely on this. So don't scatter dpkg --print-architecture calls throughout, especially when many of these are not cross-build-aware. * Refactor ubuntu-cpc hooks to allow us to handle images where the root partition should not be partition 1. [ Ben Howard ] * ubuntu-cpc: fix hooks/032-disk-image.binary call to create_empty_partition, which requires five args due to "-u" * ubuntu-cpc: in hooks/030-root-tarball.binary create /lib/modules to fix (LP: 1543204). [ Steve Langasek ] * Refactor ubuntu-cpc hooks to always produce a 'plain' rootfs via live-build and reuse this for the tarball, instead of lb_binary_rootfs creating some artifact that we ignore / throw away. * Initial support for raspi2 subarch. * Import live-build/ubuntu-cpc/hooks/raspi2/mkknlimg from https://github.com/raspberrypi/linux/blob/rpi-4.1.y/scripts/mkknlimg and use it to install a bootable uboot.bin. --- debian/changelog | 35 +++ debian/copyright | 6 +- live-build/auto/config | 85 ++++++ live-build/ubuntu-cpc/functions | 20 +- .../hooks/001-divert-sync.chroot_early | 11 + .../ubuntu-cpc/hooks/030-root-tarball.binary | 17 +- .../ubuntu-cpc/hooks/031-root-xz.binary | 4 + .../ubuntu-cpc/hooks/032-disk-image.binary | 109 ++++++-- .../ubuntu-cpc/hooks/032-root-squashfs.binary | 6 +- .../hooks/033-disk-image-uefi.binary | 13 +- .../hooks/034-disk-image-ppc64el.binary | 5 +- .../ubuntu-cpc/hooks/040-qcow2-image.binary | 10 + .../ubuntu-cpc/hooks/040-vmdk-image.binary | 6 +- .../hooks/041-vmdk-ova-image.binary | 8 +- .../ubuntu-cpc/hooks/042-vagrant.binary | 13 +- .../ubuntu-cpc/hooks/999-undivert-sync.chroot | 5 + live-build/ubuntu-cpc/hooks/raspi2/mkknlimg | 244 ++++++++++++++++++ 17 files changed, 536 insertions(+), 61 deletions(-) create mode 100644 live-build/ubuntu-cpc/hooks/001-divert-sync.chroot_early create mode 100644 live-build/ubuntu-cpc/hooks/999-undivert-sync.chroot create mode 100644 live-build/ubuntu-cpc/hooks/raspi2/mkknlimg diff --git a/debian/changelog b/debian/changelog index 9c69e930..f3df49d1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,38 @@ +livecd-rootfs (2.209.12) trusty; urgency=medium + + [ Steve Langasek ] + * Add hooks to ubuntu-cpc to divert /bin/sync in the chroot and undivert it + at the end. This is a general-purpose change that should be applied to + all flavors and archs, but at the moment it's only needed on armhf+raspi2 + to work around the raspberrypi2-firmware postinst calling sync, which is + actually warranted in the normal case. + * If a subarch is specified for a cloud image build, don't build rootfs + artifacts; these should come from the 'generic' build. + * Fix architecture handling in hooks. We know we're always being invoked + from a launchpad-buildd-like setup, which passes ARCH and SUBARCH in the + environment, because auto/config and auto/build both rely on this. So + don't scatter dpkg --print-architecture calls throughout, especially + when many of these are not cross-build-aware. + * Refactor ubuntu-cpc hooks to allow us to handle images where the root + partition should not be partition 1. + + [ Ben Howard ] + * ubuntu-cpc: fix hooks/032-disk-image.binary call to + create_empty_partition, which requires five args due to "-u" + * ubuntu-cpc: in hooks/030-root-tarball.binary create /lib/modules to fix + (LP: 1543204). + + [ Steve Langasek ] + * Refactor ubuntu-cpc hooks to always produce a 'plain' rootfs via + live-build and reuse this for the tarball, instead of lb_binary_rootfs + creating some artifact that we ignore / throw away. + * Initial support for raspi2 subarch. + * Import live-build/ubuntu-cpc/hooks/raspi2/mkknlimg from + https://github.com/raspberrypi/linux/blob/rpi-4.1.y/scripts/mkknlimg + and use it to install a bootable uboot.bin. + + -- Robert C Jennings Tue, 23 May 2017 22:29:47 -0500 + livecd-rootfs (2.209.11) trusty; urgency=medium [ Steve Langasek ] diff --git a/debian/copyright b/debian/copyright index 0a2a7189..3d267162 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,4 +1,4 @@ -live-build/* is copyright (c) 2004-2013 by Canonical Ltd. +live-build/* is copyright (c) 2004-2016 by Canonical Ltd. These programs are free software; you can redistribute and/or modify them under the terms of the GNU General Public License as published by @@ -16,3 +16,7 @@ livecd-rootfs source package as the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +Files: live-build/ubuntu-cpc/hooks/raspi2/mkknlimg +Copyright: 2009,2010 Dick Streefland + 2014,2015 Raspberry Pi (Trading) Limited +License: GPL-2+ diff --git a/live-build/auto/config b/live-build/auto/config index eea3b37f..64be2cc4 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -111,6 +111,12 @@ add_binary_hook () BINARY_HOOKS="${BINARY_HOOKS:+$BINARY_HOOKS }$1" } +case $PROJECT in + ubuntu-cpc) + IMAGEFORMAT=plain + ;; +esac + case $IMAGEFORMAT in ext2|ext3|ext4) OPTS="${OPTS:+$OPTS }--initramfs none --chroot-filesystem $IMAGEFORMAT" @@ -480,6 +486,11 @@ case $ARCH in echo "linux-firmware-nexus7 shared/nexus7_notice_accepted boolean true" >config/preseed/linux-firmware-nexus7.preseed.chroot echo "d-i passwd/auto-login boolean true" >config/preseed/autologin.preseed.chroot ;; + raspi2) + COMPONENTS='main restricted universe' + add_package install raspberrypi2-firmware u-boot-rpi flash-kernel u-boot-tools + BINARY_REMOVE_LINUX=false + ;; esac ;; esac @@ -536,6 +547,80 @@ echo "LB_CHROOT_HOOKS=\"$CHROOT_HOOKS\"" >> config/chroot echo "LB_BINARY_HOOKS=\"$BINARY_HOOKS\"" >> config/binary echo "BUILDSTAMP=\"$NOW\"" >> config/binary +case $ARCH+$SUBARCH in + armhf+raspi2) + cat > config/hooks/01-firmware-directory.chroot_early < config/hooks/999-raspi2-fixes.chroot <> /etc/fstab << EOM +LABEL=system-boot /boot/firmware vfat defaults 0 1 +EOM + +cat > /boot/firmware/cmdline.txt << EOM +dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait +EOM + +cat > /boot/firmware/config.txt << EOM +# For more options and information see +# http://www.raspberrypi.org/documentation/configuration/config-txt.md +# Some settings may impact device functionality. See link above for details + +kernel=uboot.bin + +# enable i2c +dtparam=i2c_arm=on +dtparam=spi=on + +# uncomment if you get no picture on HDMI for a default "safe" mode +#hdmi_safe=1 + +# uncomment this if your display has a black border of unused pixels visible +# and your display can output without overscan +#disable_overscan=1 + +# uncomment the following to adjust overscan. Use positive numbers if console +# goes off screen, and negative if there is too much border +#overscan_left=16 +#overscan_right=16 +#overscan_top=16 +#overscan_bottom=16 + +# uncomment to force a console size. By default it will be display's size minus +# overscan. +#framebuffer_width=1280 +#framebuffer_height=720 + +# uncomment if hdmi display is not detected and composite is being output +#hdmi_force_hotplug=1 + +# uncomment to force a specific HDMI mode (this will force VGA) +#hdmi_group=1 +#hdmi_mode=1 + +# uncomment to force a HDMI mode rather than DVI. This can make audio work in +# DMT (computer monitor) modes +#hdmi_drive=2 + +# uncomment to increase signal to HDMI, if you have interference, blanking, or +# no display +#config_hdmi_boost=4 + +# uncomment for composite PAL +#sdtv_mode=2 + +#uncomment to overclock the arm. 700 MHz is the default. +#arm_freq=800 + +EOM +EOF + ;; + *) + ;; +esac + case $PROJECT in ubuntu-server) cat > config/hooks/100-remove-fstab.chroot < /bin/sync <<'EOF' +#! /bin/sh +echo "$0: diverted by livecd-rootfs" >&2 +exit 0 +EOF + +chmod +x /bin/sync diff --git a/live-build/ubuntu-cpc/hooks/030-root-tarball.binary b/live-build/ubuntu-cpc/hooks/030-root-tarball.binary index 6e6f183a..eff30ec1 100644 --- a/live-build/ubuntu-cpc/hooks/030-root-tarball.binary +++ b/live-build/ubuntu-cpc/hooks/030-root-tarball.binary @@ -1,13 +1,13 @@ #!/bin/bash -ex -mkdir binary/boot/filesystem.dir -cp -a chroot/* binary/boot/filesystem.dir +if [ -n "$SUBARCH" ]; then + echo "Skipping rootfs build for subarch flavor build" + exit 0 +fi -mount --bind /dev "binary/boot/filesystem.dir/dev" -mount proc-live -t proc "binary/boot/filesystem.dir/proc" -mount sysfs-live -t sysfs "binary/boot/filesystem.dir/sys" -mv "binary/boot/filesystem.dir/etc/resolv.conf" resolv.conf.tmp -cp /etc/resolv.conf "binary/boot/filesystem.dir/etc/resolv.conf" +. /build/config/functions + +setup_mountpoint binary/boot/filesystem.dir chroot binary/boot/filesystem.dir dpkg-divert --local --rename /usr/sbin/grub-probe chroot binary/boot/filesystem.dir touch /usr/sbin/grub-probe @@ -16,6 +16,7 @@ chroot binary/boot/filesystem.dir chmod +x /usr/sbin/grub-probe env DEBIAN_FRONTEND=noninteractive chroot binary/boot/filesystem.dir apt-get --purge remove --assume-yes '^linux-.*' env DEBIAN_FRONTEND=noninteractive chroot binary/boot/filesystem.dir apt-get --purge remove --assume-yes '^grub-.*' env DEBIAN_FRONTEND=noninteractive chroot binary/boot/filesystem.dir apt-get autoremove --purge --assume-yes +chroot binary/boot/filesystem.dir mkdir /lib/modules chroot binary/boot/filesystem.dir rm /usr/sbin/grub-probe chroot binary/boot/filesystem.dir dpkg-divert --remove --local --rename /usr/sbin/grub-probe @@ -23,4 +24,6 @@ chroot binary/boot/filesystem.dir dpkg-divert --remove --local --rename /usr/sbi mv resolv.conf.tmp "binary/boot/filesystem.dir/etc/resolv.conf" umount "binary/boot/filesystem.dir/proc" umount "binary/boot/filesystem.dir/sys" +umount "binary/boot/filesystem.dir/dev/pts" umount "binary/boot/filesystem.dir/dev" +umount "binary/boot/filesystem.dir/tmp" diff --git a/live-build/ubuntu-cpc/hooks/031-root-xz.binary b/live-build/ubuntu-cpc/hooks/031-root-xz.binary index a3ee963d..33489e92 100644 --- a/live-build/ubuntu-cpc/hooks/031-root-xz.binary +++ b/live-build/ubuntu-cpc/hooks/031-root-xz.binary @@ -3,6 +3,10 @@ # # Generate the rootfs.tar.gz and manifest +if [ -n "$SUBARCH" ]; then + exit 0 +fi + dpkg-query --admindir=binary/boot/filesystem.dir/var/lib/dpkg -W > livecd.ubuntu-cpc.rootfs.manifest (cd "binary/boot/filesystem.dir/" && tar -c *) | \ diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index 1eefd13c..cebf681a 100644 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -1,46 +1,106 @@ -#!/bin/bash -eux -architecture=$(chroot chroot dpkg --print-architecture) -if [ "$architecture" = "ppc64el" ]; then - echo "ppc64el disk images are handled separately" - exit 0 -fi +#!/bin/bash -ex . /build/config/functions -create_empty_partition() { +BOOTPART_START= +BOOTPART_END= +BOOT_MOUNTPOINT= +ROOTPART_START=1 + +case $ARCH:$SUBARCH in + ppc64el:*) + echo "ppc64el disk images are handled separately" + exit 0 + ;; + armhf:raspi2) + # matches the size of the snappy image + IMAGE_SIZE=$((4*1000*1000*1000)) + + BOOTPART_START=8192s + BOOTPART_END=138M + BOOT_MOUNTPOINT=/boot/firmware + ;; + *) + ;; +esac + +create_empty_partition_table() { apt-get install -qqy parted - parted_prefix="parted $1 --script --" - ${parted_prefix} mklabel msdos - ${parted_prefix} mkpart primary 1 -1 - ${parted_prefix} set 1 B + parted "$1" --script -- mklabel msdos +} + +create_empty_partition() { + local disk="$1" + local part="$2" + local start="$3" + local end="$4" + local type="$5" + local bootable="$6" + + parted_prefix="parted $disk --script --" + ${parted_prefix} mkpart primary "$type" "$start" "$end" + if [ -n "$bootable" ]; then + ${parted_prefix} set "$part" B + fi ${parted_prefix} print - ${parted_prefix} align-check opt 1 + ${parted_prefix} align-check opt "$part" } disk_image=binary/boot/disk.ext4 create_empty_disk_image "${disk_image}" -create_empty_partition "${disk_image}" -mount_image "${disk_image}" +create_empty_partition_table "${disk_image}" + +ROOTPART=1 +ROOT_BOOTABLE=1 +if [ -n "$BOOTPART_START" ]; then + ROOTPART=2 + ROOTPART_START="$BOOTPART_END" + ROOT_BOOTABLE= + create_empty_partition "$disk_image" 1 "$BOOTPART_START" "$BOOTPART_END" fat32 1 +fi +create_empty_partition "${disk_image}" "$ROOTPART" "$ROOTPART_START" -1 ext2 "$ROOT_BOOTABLE" + +mount_image "${disk_image}" "$ROOTPART" # Copy the chroot in to the disk make_ext4_partition "${rootfs_dev_mapper}" mkdir mountpoint mount "${rootfs_dev_mapper}" mountpoint + +if [ -n "$BOOT_MOUNTPOINT" ]; then + boot_dev_mapper="${rootfs_dev_mapper%%[0-9]}1" + # assume fat32 for now + mkfs.vfat -n system-boot "$boot_dev_mapper" + mkdir -p "mountpoint/$BOOT_MOUNTPOINT" + mount "$boot_dev_mapper" "mountpoint/$BOOT_MOUNTPOINT" +fi + cp -a chroot/* mountpoint/ -umount mountpoint -rmdir mountpoint -case $architecture in +setup_mountpoint mountpoint + +case $ARCH:$SUBARCH in + armhf:raspi2) + chroot mountpoint flash-kernel \ + --machine "Raspberry Pi 2 Model B" + # 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 \ + mountpoint/usr/lib/u-boot/rpi_2/u-boot.bin \ + mountpoint/boot/firmware/uboot.bin + ;; + *) ;; +esac + +case $ARCH in amd64|i386) should_install_grub=1;; *) should_install_grub=0;; esac if [ "${should_install_grub}" -eq 1 ]; then - mkdir mountpoint - mount_partition "${rootfs_dev_mapper}" mountpoint - echo "(hd0) ${loop_device}" > mountpoint/tmp/device.map chroot mountpoint grub-install ${loop_device} chroot mountpoint grub-bios-setup \ @@ -51,9 +111,14 @@ if [ "${should_install_grub}" -eq 1 ]; then ${loop_device} rm mountpoint/tmp/device.map - umount_partition mountpoint - rmdir mountpoint fi +if [ -n "$BOOT_MOUNTPOINT" ]; then + umount "mountpoint/$BOOT_MOUNTPOINT" +fi + +umount_partition mountpoint +rmdir mountpoint + clean_loops trap - EXIT diff --git a/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary b/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary index 37d612f9..9e3bb61e 100644 --- a/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary +++ b/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary @@ -1,8 +1,12 @@ -#!/bin/bash -eux +#!/bin/bash -ex # vi: ts=4 noexpandtab # # Generate a squashfs root and manifest +if [ -n "$SUBARCH" ]; then + exit 0 +fi + apt-get -qqy install squashfs-tools squashfs_f="${PWD}/livecd.ubuntu-cpc.squashfs" 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 88530c6e..8599ea8d 100644 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -1,11 +1,10 @@ #!/bin/bash -eux -architecture=$(chroot chroot dpkg --print-architecture) -case $architecture in +case $ARCH in amd64|arm64) ;; *) - echo "We don't create EFI images for $architecture." + echo "We don't create EFI images for $ARCH." exit 0 ;; esac @@ -17,7 +16,7 @@ apt-get -qqy install dosfstools gdisk create_partitions() { disk_image="$1" sgdisk "${disk_image}" --zap-all - case $architecture in + case $ARCH in arm64) sgdisk "${disk_image}" \ --new=15:0:204800 \ @@ -62,7 +61,7 @@ install_grub() { efi_boot_dir="/boot/efi/EFI/BOOT" chroot mountpoint mkdir -p "${efi_boot_dir}" - case $architecture in + case $ARCH in arm64) chroot mountpoint apt-get -qqy install --no-install-recommends grub-efi-arm64 grub-efi-arm64-bin grub_modules="part_gpt fat gzio ext2 normal chain boot configfile linux search_fs_uuid search_label terminal serial video video_fb efi_gop" @@ -101,7 +100,7 @@ EOF chroot mountpoint cp /boot/efi/EFI/BOOT/grub.cfg /boot/efi/boot/grub fi - if [ $architecture = "amd64" ]; then + if [ "$ARCH" = "amd64" ]; then # Install the BIOS/GPT bits. Since GPT boots from the ESP partition, # it means that we just run this simple command and we're done chroot mountpoint grub-install --target=i386-pc "${loop_device}" @@ -129,7 +128,7 @@ disk_image=binary/boot/disk-uefi.ext4 create_empty_disk_image "${disk_image}" create_partitions "${disk_image}" -mount_image "${disk_image}" +mount_image "${disk_image}" 1 # Copy the chroot in to the disk make_ext4_partition "${rootfs_dev_mapper}" 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 59ae62b6..6a7c85a2 100644 --- a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary +++ b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary @@ -1,6 +1,5 @@ #!/bin/bash -eux -architecture=$(chroot chroot dpkg --print-architecture) -if [ "$architecture" != "ppc64el" ]; then +if [ "$ARCH" != "ppc64el" ]; then exit 0 fi @@ -59,7 +58,7 @@ disk_image=binary/boot/disk.ext4 create_empty_disk_image "${disk_image}" create_partitions "${disk_image}" -mount_image "${disk_image}" +mount_image "${disk_image}" 1 # Copy the chroot in to the disk make_ext4_partition "${rootfs_dev_mapper}" diff --git a/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary b/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary index e8b9fbd5..602d871e 100644 --- a/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary +++ b/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary @@ -1,5 +1,15 @@ #!/bin/bash -ex +case $ARCH:$SUBARCH in + # Not sure if any other cloud images use subarch for something that + # should take qcow2 format, so only skipping this on raspi2 for now. + armhf:raspi2) + apt-get install -qqy pxz + pxz -T4 -c binary/boot/disk.ext4 > livecd.ubuntu-cpc.disk1.img.xz + exit 0 + ;; +esac + apt-get install -qqy qemu-utils . /build/config/functions diff --git a/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary index 7345bf4e..80e4142c 100644 --- a/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary +++ b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary @@ -3,13 +3,11 @@ # # Generate VMDK files -architecture=$(chroot chroot dpkg --print-architecture) - extension="disk1.vmdk" -case ${architecture} in +case $ARCH in i386|amd64) ;; - *) echo "VMDK images are not supported for ${architecture} yet."; + *) echo "VMDK images are not supported for $ARCH yet."; exit 0;; esac diff --git a/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary b/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary index 4123a501..c48ca75b 100644 --- a/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary +++ b/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary @@ -9,18 +9,16 @@ # # For this step, we re-use the VMDK's made in 040-vmdk-image.binary -architecture=$(chroot chroot dpkg --print-architecture) - -case ${architecture} in +case $ARCH in amd64|i386) ;; - *) echo "OVA images are not supported for ${architecture} yet."; + *) echo "OVA images are not supported for $ARCH yet."; exit 0;; esac cur_d=${PWD} my_d=$(dirname $(readlink -f ${0})) base_vmdk="livecd.ubuntu-cpc.disk1.vmdk" -if [ $architecture = "amd64" ]; then +if [ "$ARCH" = "amd64" ]; then base_vmdk="livecd.ubuntu-cpc.uefi.vmdk" fi diff --git a/live-build/ubuntu-cpc/hooks/042-vagrant.binary b/live-build/ubuntu-cpc/hooks/042-vagrant.binary index 22d359e7..6bf40dc3 100644 --- a/live-build/ubuntu-cpc/hooks/042-vagrant.binary +++ b/live-build/ubuntu-cpc/hooks/042-vagrant.binary @@ -15,13 +15,16 @@ cur_d=${PWD} my_d=$(dirname $(readlink -f ${0})) -architecture=$(chroot chroot dpkg --print-architecture) base_vmdk="livecd.ubuntu-cpc.disk1.vmdk" -if [[ ! "${architecture}" =~ (amd64|i386) ]]; then - echo "Vagrant images are not supported for ${architecture}" - exit 0 -elif [ ! -e ${base_vmdk} ]; then +case $ARCH in + amd64|i386) ;; + *) + echo "Vagrant images are not supported for $ARCH" + exit 0 +esac + +if [ ! -e ${base_vmdk} ]; then echo "Did not find VMDK to produce Vagrant images." exit 0 fi diff --git a/live-build/ubuntu-cpc/hooks/999-undivert-sync.chroot b/live-build/ubuntu-cpc/hooks/999-undivert-sync.chroot new file mode 100644 index 00000000..8a97432d --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/999-undivert-sync.chroot @@ -0,0 +1,5 @@ +#! /bin/sh +set -e + +rm -f /bin/sync +dpkg-divert --quiet --remove --rename /bin/sync diff --git a/live-build/ubuntu-cpc/hooks/raspi2/mkknlimg b/live-build/ubuntu-cpc/hooks/raspi2/mkknlimg new file mode 100644 index 00000000..3998d43b --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/raspi2/mkknlimg @@ -0,0 +1,244 @@ +#!/usr/bin/env perl +# ---------------------------------------------------------------------- +# mkknlimg by Phil Elwell for Raspberry Pi +# based on extract-ikconfig by Dick Streefland +# +# (c) 2009,2010 Dick Streefland +# (c) 2014,2015 Raspberry Pi (Trading) Limited +# +# Licensed under the terms of the GNU General Public License. +# ---------------------------------------------------------------------- + +use strict; +use warnings; +use integer; + +my $trailer_magic = 'RPTL'; + +my $tmpfile1 = "/tmp/mkknlimg_$$.1"; +my $tmpfile2 = "/tmp/mkknlimg_$$.2"; + +my $dtok = 0; +my $is_283x = 0; + +while (@ARGV && ($ARGV[0] =~ /^-/)) +{ + my $arg = shift(@ARGV); + if ($arg eq '--dtok') + { + $dtok = 1; + } + elsif ($arg eq '--283x') + { + $is_283x = 1; + } + else + { + print ("* Unknown option '$arg'\n"); + usage(); + } +} + +usage() if (@ARGV != 2); + +my $kernel_file = $ARGV[0]; +my $out_file = $ARGV[1]; + +if (! -r $kernel_file) +{ + print ("* File '$kernel_file' not found\n"); + usage(); +} + +my @wanted_strings = +( + 'bcm2708_fb', + 'brcm,bcm2835-mmc', + 'brcm,bcm2835-sdhost', + 'brcm,bcm2708-pinctrl', + 'brcm,bcm2835-gpio', + 'brcm,bcm2835', + 'brcm,bcm2836' +); + +my $res = try_extract($kernel_file, $tmpfile1); +$res = try_decompress('\037\213\010', 'xy', 'gunzip', 0, + $kernel_file, $tmpfile1, $tmpfile2) if (!$res); +$res = try_decompress('\3757zXZ\000', 'abcde', 'unxz --single-stream', -1, + $kernel_file, $tmpfile1, $tmpfile2) if (!$res); +$res = try_decompress('BZh', 'xy', 'bunzip2', 0, + $kernel_file, $tmpfile1, $tmpfile2) if (!$res); +$res = try_decompress('\135\0\0\0', 'xxx', 'unlzma', 0, + $kernel_file, $tmpfile1, $tmpfile2) if (!$res); +$res = try_decompress('\211\114\132', 'xy', 'lzop -d', 0, + $kernel_file, $tmpfile1, $tmpfile2) if (!$res); +$res = try_decompress('\002\041\114\030', 'xy', 'lz4 -d', 1, + $kernel_file, $tmpfile1, $tmpfile2) if (!$res); + +my $append_trailer; +my $trailer; +my $kver = '?'; + +$append_trailer = $dtok; + +if ($res) +{ + $kver = $res->{''} || '?'; + print("Version: $kver\n"); + + $append_trailer = $dtok; + if (!$dtok) + { + if (config_bool($res, 'bcm2708_fb') || + config_bool($res, 'brcm,bcm2835-mmc') || + config_bool($res, 'brcm,bcm2835-sdhost')) + { + $dtok ||= config_bool($res, 'brcm,bcm2708-pinctrl'); + $dtok ||= config_bool($res, 'brcm,bcm2835-gpio'); + $is_283x ||= config_bool($res, 'brcm,bcm2835'); + $is_283x ||= config_bool($res, 'brcm,bcm2836'); + $dtok ||= $is_283x; + $append_trailer = 1; + } + else + { + print ("* This doesn't look like a Raspberry Pi kernel. In pass-through mode.\n"); + } + } +} +elsif (!$dtok) +{ + print ("* Is this a valid kernel? In pass-through mode.\n"); +} + +if ($append_trailer) +{ + printf("DT: %s\n", $dtok ? "y" : "n"); + printf("283x: %s\n", $is_283x ? "y" : "n"); + + my @atoms; + + push @atoms, [ $trailer_magic, pack('V', 0) ]; + push @atoms, [ 'KVer', $kver ]; + push @atoms, [ 'DTOK', pack('V', $dtok) ]; + push @atoms, [ '283x', pack('V', $is_283x) ]; + + $trailer = pack_trailer(\@atoms); + $atoms[0]->[1] = pack('V', length($trailer)); + + $trailer = pack_trailer(\@atoms); +} + +my $ofh; +my $total_len = 0; + +if ($out_file eq $kernel_file) +{ + die "* Failed to open '$out_file' for append\n" + if (!open($ofh, '>>', $out_file)); + $total_len = tell($ofh); +} +else +{ + die "* Failed to open '$kernel_file'\n" + if (!open(my $ifh, '<', $kernel_file)); + die "* Failed to create '$out_file'\n" + if (!open($ofh, '>', $out_file)); + + my $copybuf; + while (1) + { + my $bytes = sysread($ifh, $copybuf, 64*1024); + last if (!$bytes); + syswrite($ofh, $copybuf, $bytes); + $total_len += $bytes; + } + close($ifh); +} + +if ($trailer) +{ + # Pad to word-alignment + syswrite($ofh, "\x000\x000\x000", (-$total_len & 0x3)); + syswrite($ofh, $trailer); +} + +close($ofh); + +exit($trailer ? 0 : 1); + +END { + unlink($tmpfile1) if ($tmpfile1); + unlink($tmpfile2) if ($tmpfile2); +} + + +sub usage +{ + print ("Usage: mkknlimg [--dtok] [--283x] \n"); + exit(1); +} + +sub try_extract +{ + my ($knl, $tmp) = @_; + + my $ver = `strings "$knl" | grep -a -E "^Linux version [1-9]"`; + + return undef if (!$ver); + + chomp($ver); + + my $res = { ''=>$ver }; + my $string_pattern = '^('.join('|', @wanted_strings).')$'; + + my @matches = `strings \"$knl\" | grep -E \"$string_pattern\"`; + foreach my $match (@matches) + { + chomp($match); + $res->{$match} = 1; + } + + return $res; +} + + +sub try_decompress +{ + my ($magic, $subst, $zcat, $idx, $knl, $tmp1, $tmp2) = @_; + + my $pos = `tr "$magic\n$subst" "\n$subst=" < "$knl" | grep -abo "^$subst"`; + if ($pos) + { + chomp($pos); + $pos = (split(/[\r\n]+/, $pos))[$idx]; + return undef if (!defined($pos)); + $pos =~ s/:.*[\r\n]*$//s; + my $cmd = "tail -c+$pos \"$knl\" | $zcat > $tmp2 2> /dev/null"; + my $err = (system($cmd) >> 8); + return undef if (($err != 0) && ($err != 2)); + + return try_extract($tmp2, $tmp1); + } + + return undef; +} + +sub pack_trailer +{ + my ($atoms) = @_; + my $trailer = pack('VV', 0, 0); + for (my $i = $#$atoms; $i>=0; $i--) + { + my $atom = $atoms->[$i]; + $trailer .= pack('a*x!4Va4', $atom->[1], length($atom->[1]), $atom->[0]); + } + return $trailer; +} + +sub config_bool +{ + my ($configs, $wanted) = @_; + my $val = $configs->{$wanted} || 'n'; + return (($val eq 'y') || ($val eq '1')); +} From 02340e2480b2e2e1ed7163f41c9b1ba895b303cd Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:27 -0500 Subject: [PATCH 15/25] ubuntu-cpc: nocloud data source for non-cloud cloud images (armhf+raspi2) --- debian/changelog | 9 ++++++ .../ubuntu-cpc/hooks/999-cpc-fixes.chroot | 32 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/debian/changelog b/debian/changelog index f3df49d1..b434fe39 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +livecd-rootfs (2.209.13) trusty; urgency=medium + + [Adam Conrad] + * live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot: Add fake_cloud_init + function to create a nocloud data source for cloud images that aren't + meant to be used on real clouds and use it by default on armhf+raspi2 + + -- Robert C Jennings Tue, 23 May 2017 22:35:47 -0500 + livecd-rootfs (2.209.12) trusty; urgency=medium [ Steve Langasek ] diff --git a/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot index 34964ca7..b8c8f9d0 100644 --- a/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot +++ b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot @@ -50,6 +50,33 @@ EOF sed -i "s/CONDEV/${condev}/g" "$idir/${condev}.conf" } +fake_cloud_init() { + # If the cloud does not provide a meta-data service this should be run + # This will setup a nocloud datasource. + + seed_d="${rootd}/var/lib/cloud/seed/nocloud-net" + mkdir -p "${seed_d}" + + # fake instance-id + cat << EOF > "${seed_d}/meta-data" +instance_id: cloud-image +EOF + + # fake user-data to create the default user/password + cat << EOF > "${seed_d}/user-data" +#cloud-config +password: ubuntu +chpasswd: ubuntu +ssh_pwauth: True +EOF + + # tell cloud-init not to look for meta-data sources + cat << EOF > ${rootd}/etc/cloud/cloud.cfg.d/99-fake_cloud.cfg +# configure cloud-init for NoCloud +datasource_list: [ NoCloud, None ] +EOF +} + ## -------------- # remove 127.0.1.1 entry (LP: #440757) _xchroot "${rootd}" sh -c 'sed -i "/^127.0.1.1/d" /etc/hosts' @@ -132,6 +159,11 @@ case $arch in armhf|arm64) echo "Configuring ARM Serial Port" add_serial_console ttyAMA0 + # Dirty hack because SUBARCH doesn't exist when running chroot hooks, + # and we don't want raspi2 images to depend on a cloud data source: + if _xchroot "${rootd}" dpkg -l linux-image-raspi2 2>/dev/null | grep -q '^.i'; then + fake_cloud_init + fi echo "Image architecture is ARM. Existing vmbuilder-fixups" From 2229a1a754a97c1016c27eb564b8c4a0886e949f Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:28 -0500 Subject: [PATCH 16/25] ubuntu-cpc: Add serial device in Vagrant images and refactor ext4 rootfs [ Ben Howard ] * live-build/ubuntu-cpc/hooks/042-vagrant.binary: add serial device for Vagrant images (LP: #1546108). [ Daniel Watkins ] * Refactor ubuntu-cpc hooks to hard-code producing an 'ext4' rootfs, which is used outside of the livecd-rootfs build process (specifically for EC2 publication). --- debian/changelog | 13 +++++++++++++ live-build/auto/config | 2 +- live-build/ubuntu-cpc/hooks/030-root-tarball.binary | 3 +++ live-build/ubuntu-cpc/hooks/042-vagrant.binary | 5 +++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index b434fe39..86590520 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +livecd-rootfs (2.209.14) trusty; urgency=medium + + [ Ben Howard ] + * live-build/ubuntu-cpc/hooks/042-vagrant.binary: add serial device for + Vagrant images (LP: #1546108). + + [ Daniel Watkins ] + * Refactor ubuntu-cpc hooks to hard-code producing an 'ext4' rootfs, which + is used outside of the livecd-rootfs build process (specifically for EC2 + publication). + + -- Robert C Jennings Tue, 24 May 2017 14:08:47 -0500 + livecd-rootfs (2.209.13) trusty; urgency=medium [Adam Conrad] diff --git a/live-build/auto/config b/live-build/auto/config index 64be2cc4..a827450c 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -113,7 +113,7 @@ add_binary_hook () case $PROJECT in ubuntu-cpc) - IMAGEFORMAT=plain + IMAGEFORMAT=ext4 ;; esac diff --git a/live-build/ubuntu-cpc/hooks/030-root-tarball.binary b/live-build/ubuntu-cpc/hooks/030-root-tarball.binary index eff30ec1..8856cf56 100644 --- a/live-build/ubuntu-cpc/hooks/030-root-tarball.binary +++ b/live-build/ubuntu-cpc/hooks/030-root-tarball.binary @@ -7,6 +7,9 @@ fi . /build/config/functions +mkdir binary/boot/filesystem.dir +cp -a chroot/* binary/boot/filesystem.dir + setup_mountpoint binary/boot/filesystem.dir chroot binary/boot/filesystem.dir dpkg-divert --local --rename /usr/sbin/grub-probe diff --git a/live-build/ubuntu-cpc/hooks/042-vagrant.binary b/live-build/ubuntu-cpc/hooks/042-vagrant.binary index 6bf40dc3..618d3f9c 100644 --- a/live-build/ubuntu-cpc/hooks/042-vagrant.binary +++ b/live-build/ubuntu-cpc/hooks/042-vagrant.binary @@ -112,6 +112,11 @@ Vagrant.configure("2") do |config| config.ssh.username = "ubuntu" config.ssh.password = "${ubuntu_user_pass}" config.vm.synced_folder '.', '/vagrant', disabled: true + + # Needed due to the default commandline, which expects a console. + config.customize [ "modifyvm", :id, "--uart1", "0x3F8", "4" ] + config.customize [ "modifyvm", :id, "--uartmode1", "file", "console.log" ] + end EOF From b0453f87e85231d00bb5151f08ee030e8a2b02bd Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:28 -0500 Subject: [PATCH 17/25] ubuntu-cpc: Vagrant config for serial device must be scoped for Virtualbox only [ Ben Howard ] * live-build/ubuntu-cpc/hooks/042-vagrant.binary: scope serial device for Virtualbox only. --- debian/changelog | 8 ++++++++ live-build/ubuntu-cpc/hooks/042-vagrant.binary | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 86590520..124a8f3c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +livecd-rootfs (2.209.15) trusty; urgency=medium + + [ Ben Howard ] + * live-build/ubuntu-cpc/hooks/042-vagrant.binary: scope serial device for + Virtualbox only. + + -- Robert C Jennings Tue, 24 May 2017 14:22:47 -0500 + livecd-rootfs (2.209.14) trusty; urgency=medium [ Ben Howard ] diff --git a/live-build/ubuntu-cpc/hooks/042-vagrant.binary b/live-build/ubuntu-cpc/hooks/042-vagrant.binary index 618d3f9c..bb9f8db1 100644 --- a/live-build/ubuntu-cpc/hooks/042-vagrant.binary +++ b/live-build/ubuntu-cpc/hooks/042-vagrant.binary @@ -113,9 +113,12 @@ Vagrant.configure("2") do |config| config.ssh.password = "${ubuntu_user_pass}" config.vm.synced_folder '.', '/vagrant', disabled: true - # Needed due to the default commandline, which expects a console. - config.customize [ "modifyvm", :id, "--uart1", "0x3F8", "4" ] - config.customize [ "modifyvm", :id, "--uartmode1", "file", "console.log" ] + config.vm.provider "virtualbox" do |vb| + vb.name = "${prefix}" + vb.customize [ "modifyvm", :id, "--uart1", "0x3F8", "4" ] + vb.customize [ "modifyvm", :id, "--uartmode1", "file", File.join(Dir.pwd, "%s-console.log" % vb.name) ] + end + end EOF From bfcc963d8bec6226ea6d5fe159e5d196743a51f3 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:29 -0500 Subject: [PATCH 18/25] ubuntu-cpc: Enable building of powerpc cloud images. --- debian/changelog | 7 +++++++ live-build/auto/config | 4 ++++ live-build/ubuntu-cpc/hooks/032-disk-image.binary | 4 ++-- .../ubuntu-cpc/hooks/034-disk-image-ppc64el.binary | 10 +++++++--- live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot | 2 +- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index 124a8f3c..9d6ada68 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +livecd-rootfs (2.209.16) trusty; urgency=medium + + [ Daniel Watkins ] + * Enable building of powerpc cloud images. + + -- Robert C Jennings Tue, 24 May 2017 14:31:47 -0500 + livecd-rootfs (2.209.15) trusty; urgency=medium [ Ben Howard ] diff --git a/live-build/auto/config b/live-build/auto/config index a827450c..3889e49d 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -414,6 +414,10 @@ case $PROJECT in ppc64el) add_task install server ;; + powerpc) + KERNEL_FLAVOURS=powerpc64-smp + add_task install server + ;; esac OPTS="${OPTS:+$OPTS }--system=normal" OPTS="${OPTS:+$OPTS }--hdd-label=cloudimg-rootfs" diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index cebf681a..a17f5631 100644 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -8,8 +8,8 @@ BOOT_MOUNTPOINT= ROOTPART_START=1 case $ARCH:$SUBARCH in - ppc64el:*) - echo "ppc64el disk images are handled separately" + ppc64el:*|powerpc:*) + echo "POWER disk images are handled separately" exit 0 ;; armhf:raspi2) 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 6a7c85a2..d085ba38 100644 --- a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary +++ b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary @@ -1,7 +1,11 @@ #!/bin/bash -eux -if [ "$ARCH" != "ppc64el" ]; then - exit 0 -fi +case $ARCH in + ppc64el|powerpc) + ;; + *) + exit 0 + ;; +esac . /build/config/functions diff --git a/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot index b8c8f9d0..815d946d 100644 --- a/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot +++ b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot @@ -173,7 +173,7 @@ case $arch in i386|amd64) add_serial_console ttyS0 ;; - ppc64el) + powerpc|ppc64el) add_serial_console hvc0 exit 0 ;; From d94c09e109e39447b277c31ba421672dd38ffa0e Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:29 -0500 Subject: [PATCH 19/25] ubuntu-cpc: Fixes for vagrant box builder (LP: #1565985) [ Louis Zuckerman ] * Fixes for vagrant box builder in ubuntu-cpc LP: #1565985 - Install virtualbox-guest-utils - Don't disable default synced folder - Don't set vm name - Add cloud-init config to manage /etc/hosts LP: #1561250 --- debian/changelog | 11 ++++ .../ubuntu-cpc/hooks/042-vagrant.binary | 64 +++++++++++-------- 2 files changed, 47 insertions(+), 28 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9d6ada68..a08c43f0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +livecd-rootfs (2.209.17) trusty; urgency=medium + + [ Louis Zuckerman ] + * Fixes for vagrant box builder in ubuntu-cpc LP: #1565985 + - Install virtualbox-guest-utils + - Don't disable default synced folder + - Don't set vm name + - Add cloud-init config to manage /etc/hosts LP: #1561250 + + -- Robert C Jennings Tue, 24 May 2017 14:41:47 -0500 + livecd-rootfs (2.209.16) trusty; urgency=medium [ Daniel Watkins ] diff --git a/live-build/ubuntu-cpc/hooks/042-vagrant.binary b/live-build/ubuntu-cpc/hooks/042-vagrant.binary index bb9f8db1..6fd02d9c 100644 --- a/live-build/ubuntu-cpc/hooks/042-vagrant.binary +++ b/live-build/ubuntu-cpc/hooks/042-vagrant.binary @@ -1,22 +1,23 @@ -#!/bin/bash -eux +#!/bin/bash -ex # vi: ts=4 noexpandtab # # Generate a generic Vagrant Box. # -# Vagrant images are essentially nothing more than OVA's with extra-metadata. +# Vagrant images are essentially nothing more than OVA's with extra-metadata +# and some preinstalled packages. # -# We can't use the OVA's for Vagrant since Vagrant uses SSH to modify the instance. -# This build step creates a cloud-config ISO so that Cloud-Init will configure -# the initial user, creates meta-data that tells Vagrant how to interact with -# the cloud-init created users, and finally create the OVA. +# We can't use the OVA's for Vagrant since Vagrant uses SSH to modify the +# instance. This build step creates a cloud-config ISO so that Cloud-Init +# will configure the initial user, creates meta-data that tells Vagrant how +# to interact with the cloud-init created users, and finally create the OVA. # -# For this step, we re-use the VMDK's made in 040-vmdk-image.binary +# For this step, we make a deriviative of binary/boot/disk.ext4 and install +# some packages in it, convert it to a vmdk, and then assemble the vagrant +# box. cur_d=${PWD} my_d=$(dirname $(readlink -f ${0})) -base_vmdk="livecd.ubuntu-cpc.disk1.vmdk" - case $ARCH in amd64|i386) ;; *) @@ -24,11 +25,6 @@ case $ARCH in exit 0 esac -if [ ! -e ${base_vmdk} ]; then - echo "Did not find VMDK to produce Vagrant images." - exit 0 -fi - . /build/config/functions # Virtualbox is needed for making a small VMDK @@ -37,7 +33,22 @@ apt-get -qqy install genisoimage qemu-utils # Lets be safe about this box_d=$(mktemp -d) seed_d=$(mktemp -d) -trap "rm -rf ${box_d} ${seed_d}" EXIT +mount_d=$(mktemp -d) + +create_derivative "disk" "vagrant" #sets ${derivative_img} +mount_disk_image ${derivative_img} ${mount_d} + +cleanup_vagrant() { + umount_disk_image ${mount_d} + rm -rf ${box_d} ${seed_d} ${mount_d} ${derivative_img} +} +trap cleanup_vagrant EXIT + +chroot ${mount_d} apt-get update +# virtualbox-guest-utils Recommends: virtualbox-guest-x11, which we want to +# avoid pulling into a cloud image. +chroot ${mount_d} apt-get install --no-install-recommends -y virtualbox-guest-utils +chroot ${mount_d} apt-get clean # Used to identify bits suite=$(chroot chroot lsb_release -c -s) @@ -47,7 +58,7 @@ distro=$(chroot chroot lsb_release --id --short | tr [:upper:] [:lower:]) # Get the VMDK in place prefix="${distro}-${suite}-${version}-cloudimg" vmdk_f="${box_d}/${prefix}.vmdk" -cp ${base_vmdk} ${vmdk_f} +create_vmdk ${derivative_img} ${vmdk_f} # Vagrant needs a base user. We either inject the well-known SSH key # or use password authentication. Both are ugly. So we'll use a password @@ -70,6 +81,7 @@ cat > ${seed_d}/user-data < Date: Thu, 25 May 2017 20:35:30 -0500 Subject: [PATCH 20/25] ubuntu-cpc: Fix unmount handling (LP: #1621393) [Steve Langasek] * live-build/ubuntu-cpc/hooks/042-vagrant.binary: fix unmount handling so that the teardown is done properly /before/ we try to make an image from our filesystem, since otherwise /etc/resolv.conf is broken. LP: #1621393. --- debian/changelog | 10 ++++++++++ live-build/ubuntu-cpc/hooks/042-vagrant.binary | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index a08c43f0..7bcd8f12 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +livecd-rootfs (2.209.18) trusty; urgency=medium + + [Steve Langasek] + * live-build/ubuntu-cpc/hooks/042-vagrant.binary: fix unmount handling + so that the teardown is done properly /before/ we try to make an + image from our filesystem, since otherwise /etc/resolv.conf is broken. + LP: #1621393. + + -- Robert C Jennings Tue, 24 May 2017 14:44:47 -0500 + livecd-rootfs (2.209.17) trusty; urgency=medium [ Louis Zuckerman ] diff --git a/live-build/ubuntu-cpc/hooks/042-vagrant.binary b/live-build/ubuntu-cpc/hooks/042-vagrant.binary index 6fd02d9c..ca08e44e 100644 --- a/live-build/ubuntu-cpc/hooks/042-vagrant.binary +++ b/live-build/ubuntu-cpc/hooks/042-vagrant.binary @@ -39,7 +39,9 @@ create_derivative "disk" "vagrant" #sets ${derivative_img} mount_disk_image ${derivative_img} ${mount_d} cleanup_vagrant() { - umount_disk_image ${mount_d} + if [ -d "$mount_d" ]; then + umount_disk_image "$mount_d" + fi rm -rf ${box_d} ${seed_d} ${mount_d} ${derivative_img} } trap cleanup_vagrant EXIT @@ -49,6 +51,8 @@ chroot ${mount_d} apt-get update # avoid pulling into a cloud image. chroot ${mount_d} apt-get install --no-install-recommends -y virtualbox-guest-utils chroot ${mount_d} apt-get clean +umount_disk_image "$mount_d" +rmdir "$mount_d" # Used to identify bits suite=$(chroot chroot lsb_release -c -s) From f0b2591de516cfa849a9f6680ac420bc718b6623 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:31 -0500 Subject: [PATCH 21/25] ubuntu-cpc: apt sources.list fixes, OVA manifest fixes [ Daniel Watkins ] * Don't overwrite the default sources.list in cloud images. * Replace sources.list generated using COMPONENTS with the sources.list from an Ubuntu Server installation (i.e. with all components enabled, and all deb-src lines commented). LP: #1513529. [ Chris Glass ] * Fix the manifest generation in OVA files so that ovf files don't have double extensions. (LP: #1627931) * Fix the OVF's metadata to include Ubuntu specific identifiers and descriptions instead of the generic Linux ones. (LP: #1656293) [ Daniel Watkins ] * Add replace_grub_root_with_label function thereby consolidating multiple uses of the same calls to sed. [ Robert C Jennings ] * ubuntu-cpc: Remove redundant copy of grub files. (LP: #1637290) --- debian/changelog | 23 +++ live-build/auto/build | 134 +++++------------- live-build/ubuntu-cpc/functions | 7 + .../hooks/033-disk-image-uefi.binary | 5 +- .../hooks/034-disk-image-ppc64el.binary | 2 +- .../hooks/041-vmdk-ova-image.binary | 26 +++- .../ubuntu-cpc/hooks/042-vagrant.binary | 25 +++- .../ovf/ubuntu-ova-v1-cloudcfg-vmdk.tmpl | 3 +- .../hooks/ovf/ubuntu-ova-v1-vmdk.tmpl | 3 +- 9 files changed, 108 insertions(+), 120 deletions(-) diff --git a/debian/changelog b/debian/changelog index 7bcd8f12..3f2e8188 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,26 @@ +livecd-rootfs (2.209.19) trusty; urgency=medium + + [ Daniel Watkins ] + * Don't overwrite the default sources.list in cloud images. + * Replace sources.list generated using COMPONENTS with the sources.list from + an Ubuntu Server installation (i.e. with all components enabled, and all + deb-src lines commented). LP: #1513529. + + [ Chris Glass ] + * Fix the manifest generation in OVA files so that ovf files don't have + double extensions. (LP: #1627931) + * Fix the OVF's metadata to include Ubuntu specific identifiers and + descriptions instead of the generic Linux ones. (LP: #1656293) + + [ Daniel Watkins ] + * Add replace_grub_root_with_label function thereby consolidating multiple + uses of the same calls to sed. + + [ Robert C Jennings ] + * ubuntu-cpc: Remove redundant copy of grub files. (LP: #1637290) + + -- Robert C Jennings Tue, 24 May 2017 15:09:47 -0500 + livecd-rootfs (2.209.18) trusty; urgency=medium [Steve Langasek] diff --git a/live-build/auto/build b/live-build/auto/build index 8853da29..dcfcc8cf 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -55,116 +55,56 @@ EOF # preinstalled being slightly different in what it doesn't ask) from # debian-installer's apt-setup: -codename=$LB_DISTRIBUTION -file="chroot/etc/apt/sources.list" -dists="main" -alldists="main" -if echo "$LB_PARENT_ARCHIVE_AREAS" | grep -q restricted; then - dists="$dists restricted" - alldists="$alldists restricted" -fi -if echo "$LB_PARENT_ARCHIVE_AREAS" | grep -q universe; then - UNIVERSE=true -else - UNIVERSE=false -fi -if echo "$LB_PARENT_ARCHIVE_AREAS" | grep -q multiverse; then - MULTIVERSE=true -else - MULTIVERSE=false -fi - -cat > $file < chroot/etc/apt/sources.list << EOF # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. - -deb $LB_PARENT_MIRROR_BINARY $codename $dists -deb-src $LB_PARENT_MIRROR_BINARY $codename $dists +deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION main restricted +# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION main restricted ## Major bug fix updates produced after the final release of the ## distribution. -deb $LB_PARENT_MIRROR_BINARY $codename-updates $dists -deb-src $LB_PARENT_MIRROR_BINARY $codename-updates $dists -EOF +deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates main restricted +# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates main restricted -# Even if universe isn't enabled, we write example lines for it. -echo >> $file -if [ "$UNIVERSE" = true ]; then - alldists="$alldists universe" - COMMENT= -else - cat >> $file <> $file <> $file <> $file <> $file <> $file <> $file < chroot/etc/apt/sources.list << EOF -deb ${LB_PARENT_MIRROR_BINARY} ${LB_DISTRIBUTION} main restricted universe multiverse -deb ${LB_PARENT_MIRROR_BINARY} ${LB_DISTRIBUTION}-updates main restricted universe multiverse -deb ${LB_PARENT_MIRROR_BINARY_SECURITY} ${LB_DISTRIBUTION}-security main restricted universe multiverse -EOF - lb chroot_hosts install - lb chroot_resolv install - Chroot chroot "apt-get update" - lb chroot_resolv remove - lb chroot_hosts remove fi echo "===== Checking size of /usr/share/doc =====" diff --git a/live-build/ubuntu-cpc/functions b/live-build/ubuntu-cpc/functions index f6e5836e..8010c4dd 100644 --- a/live-build/ubuntu-cpc/functions +++ b/live-build/ubuntu-cpc/functions @@ -249,4 +249,11 @@ convert_to_qcow2() { qemu-img info "$destination" } +replace_grub_root_with_label() { + # When update-grub is run, it will detect the disks in the build system. + # Instead, we want grub to use the cloudimg-rootfs labelled disk + CHROOT_ROOT="$1" + sed -i -e "s,root=[^ ]\+,root=LABEL=cloudimg-rootfs," \ + "$CHROOT_ROOT/boot/grub/grub.cfg" +} 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 8599ea8d..04a3c7df 100644 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -70,9 +70,6 @@ install_grub() { amd64) chroot mountpoint apt-get install -qqy grub-efi-amd64-signed grub-efi-amd64 shim-signed grub_modules="part_gpt fat ext2 normal chain boot configfile linux multiboot search_fs_uuid search_label terminal serial video video_fb video_bochs usb usb_keyboard efi_gop efi_uga" - chroot mountpoint cp /usr/lib/shim/shim.efi.signed "${efi_boot_dir}/shimx64.efi" - chroot mountpoint cp /usr/lib/shim/MokManager.efi.signed "${efi_boot_dir}/MokManager.efi" - chroot mountpoint cp /usr/lib/grub/x86_64-efi-signed/grubx64.efi.signed "${efi_boot_dir}/grubx64.efi" efi_target=x86_64-efi ;; esac @@ -108,7 +105,7 @@ EOF chroot mountpoint dpkg-divert --local --rename /etc/grub.d/30_os-prober chroot mountpoint update-grub - sed -i "s,root=.* ,root=LABEL=cloudimg-rootfs ,g" mountpoint/boot/grub/grub.cfg + replace_grub_root_with_label mountpoint chroot mountpoint dpkg-divert --remove --local --rename /etc/grub.d/30_os-prober chroot mountpoint apt-get -y clean 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 d085ba38..d4539594 100644 --- a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary +++ b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary @@ -51,7 +51,7 @@ EOF chroot mountpoint dpkg-divert --local --rename /etc/grub.d/30_os-prober chroot mountpoint update-grub - sed -i "s,root=.* ,root=LABEL=cloudimg-rootfs ,g" mountpoint/boot/grub/grub.cfg + replace_grub_root_with_label mountpoint chroot mountpoint dpkg-divert --remove --local --rename /etc/grub.d/30_os-prober umount_partition mountpoint diff --git a/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary b/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary index c48ca75b..cc8ed5d3 100644 --- a/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary +++ b/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary @@ -9,11 +9,24 @@ # # For this step, we re-use the VMDK's made in 040-vmdk-image.binary + +# Switch on $ARCH to determine which ID and description to use in the produced +# OVF. We have fancy Ubuntu-specific IDs in the OVF specification, we might as +# well use them. case $ARCH in - amd64|i386) ;; - *) echo "OVA images are not supported for $ARCH yet."; - exit 0;; + amd64) + ovf_id=94 + ovf_os_type="ubuntu64Guest" + ovf_desc_bits=64 ;; + i386) + ovf_id=93 + ovf_os_type="ubuntu32Guest" + ovf_desc_bits=32 ;; + *) + echo "OVA images are not supported for $ARCH yet."; + exit 0;; esac + cur_d=${PWD} my_d=$(dirname $(readlink -f ${0})) @@ -57,7 +70,10 @@ sed -i "${ovf}" \ -e "s/@@NUM_CPUS@@/2/g" \ -e "s/@@VERSION@@/${version}/g" \ -e "s/@@DATE@@/${serial_stamp}/g" \ - -e "s/@@MEM_SIZE@@/1024/g" + -e "s/@@MEM_SIZE@@/1024/g" \ + -e "s/@@OVF_ID@@/${ovf_id}/g" \ + -e "s/@@OVF_OS_TYPE@@/${ovf_os_type}/g" \ + -e "s/@@OVF_DESC_BITS@@/${ovf_desc_bits}/g" # Get the checksums vmdk_sha256=$(sha256sum ${vmdk_f} | cut -d' ' -f1) @@ -67,7 +83,7 @@ ovf_sha256=$(sha256sum ${ovf} | cut -d' ' -f1) manifest="${scratch_d}/${prefix}.mf" cat > "${manifest}" < "${manifest}" < A virtual machine @@NAME@@ - + The kind of installed guest operating system + Ubuntu Linux (@@OVF_DESC_BITS@@-bit) diff --git a/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ova-v1-vmdk.tmpl b/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ova-v1-vmdk.tmpl index 0eaa85a4..7f0b85e0 100644 --- a/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ova-v1-vmdk.tmpl +++ b/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ova-v1-vmdk.tmpl @@ -16,8 +16,9 @@ A virtual machine @@NAME@@ - + The kind of installed guest operating system + Ubuntu Linux (@@OVF_DESC_BITS@@-bit) From 5fed3097d2a0fe44810b96fa4041a6ea1015d5b9 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:31 -0500 Subject: [PATCH 22/25] ubuntu-cpc: Add `apt-get update` to ppc64el build so it uses new sources --- debian/changelog | 8 ++++++++ live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary | 1 + 2 files changed, 9 insertions(+) diff --git a/debian/changelog b/debian/changelog index 3f2e8188..6555420d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +livecd-rootfs (2.209.20) trusty; urgency=medium + + [Daniel Watkins] + * Add `apt-get update` to ubuntu-cpc ppc64el builds so they use the new + sources. + + -- Robert C Jennings Tue, 24 May 2017 15:13:47 -0500 + livecd-rootfs (2.209.19) trusty; urgency=medium [ Daniel Watkins ] 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 d4539594..1f6b35a7 100644 --- a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary +++ b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary @@ -26,6 +26,7 @@ install_grub() { mkdir mountpoint mount_partition "${rootfs_dev_mapper}" mountpoint + chroot mountpoint apt-get -qqy update chroot mountpoint apt-get -qqy install grub2 chroot mountpoint apt-get -qqy remove --purge grub-legacy-ec2 From 4d4a0b11dba3ca18a30eefe84dc4b051270ee6af Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:40:57 -0500 Subject: [PATCH 23/25] Coalesce changelog for ubuntu-cpc commits (LP: #1693018) --- debian/changelog | 367 ++++++++++++++++++----------------------------- 1 file changed, 140 insertions(+), 227 deletions(-) diff --git a/debian/changelog b/debian/changelog index 6555420d..be0c010a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,232 +1,145 @@ -livecd-rootfs (2.209.20) trusty; urgency=medium - - [Daniel Watkins] - * Add `apt-get update` to ubuntu-cpc ppc64el builds so they use the new - sources. - - -- Robert C Jennings Tue, 24 May 2017 15:13:47 -0500 - -livecd-rootfs (2.209.19) trusty; urgency=medium - - [ Daniel Watkins ] - * Don't overwrite the default sources.list in cloud images. - * Replace sources.list generated using COMPONENTS with the sources.list from - an Ubuntu Server installation (i.e. with all components enabled, and all - deb-src lines commented). LP: #1513529. - - [ Chris Glass ] - * Fix the manifest generation in OVA files so that ovf files don't have - double extensions. (LP: #1627931) - * Fix the OVF's metadata to include Ubuntu specific identifiers and - descriptions instead of the generic Linux ones. (LP: #1656293) - - [ Daniel Watkins ] - * Add replace_grub_root_with_label function thereby consolidating multiple - uses of the same calls to sed. - - [ Robert C Jennings ] - * ubuntu-cpc: Remove redundant copy of grub files. (LP: #1637290) - - -- Robert C Jennings Tue, 24 May 2017 15:09:47 -0500 - -livecd-rootfs (2.209.18) trusty; urgency=medium - - [Steve Langasek] - * live-build/ubuntu-cpc/hooks/042-vagrant.binary: fix unmount handling - so that the teardown is done properly /before/ we try to make an - image from our filesystem, since otherwise /etc/resolv.conf is broken. - LP: #1621393. - - -- Robert C Jennings Tue, 24 May 2017 14:44:47 -0500 - -livecd-rootfs (2.209.17) trusty; urgency=medium - - [ Louis Zuckerman ] - * Fixes for vagrant box builder in ubuntu-cpc LP: #1565985 - - Install virtualbox-guest-utils - - Don't disable default synced folder - - Don't set vm name - - Add cloud-init config to manage /etc/hosts LP: #1561250 - - -- Robert C Jennings Tue, 24 May 2017 14:41:47 -0500 - -livecd-rootfs (2.209.16) trusty; urgency=medium - - [ Daniel Watkins ] - * Enable building of powerpc cloud images. - - -- Robert C Jennings Tue, 24 May 2017 14:31:47 -0500 - -livecd-rootfs (2.209.15) trusty; urgency=medium - - [ Ben Howard ] - * live-build/ubuntu-cpc/hooks/042-vagrant.binary: scope serial device for - Virtualbox only. - - -- Robert C Jennings Tue, 24 May 2017 14:22:47 -0500 - -livecd-rootfs (2.209.14) trusty; urgency=medium - - [ Ben Howard ] - * live-build/ubuntu-cpc/hooks/042-vagrant.binary: add serial device for - Vagrant images (LP: #1546108). - - [ Daniel Watkins ] - * Refactor ubuntu-cpc hooks to hard-code producing an 'ext4' rootfs, which - is used outside of the livecd-rootfs build process (specifically for EC2 - publication). - - -- Robert C Jennings Tue, 24 May 2017 14:08:47 -0500 - -livecd-rootfs (2.209.13) trusty; urgency=medium - - [Adam Conrad] - * live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot: Add fake_cloud_init - function to create a nocloud data source for cloud images that aren't - meant to be used on real clouds and use it by default on armhf+raspi2 - - -- Robert C Jennings Tue, 23 May 2017 22:35:47 -0500 - -livecd-rootfs (2.209.12) trusty; urgency=medium - - [ Steve Langasek ] - * Add hooks to ubuntu-cpc to divert /bin/sync in the chroot and undivert it - at the end. This is a general-purpose change that should be applied to - all flavors and archs, but at the moment it's only needed on armhf+raspi2 - to work around the raspberrypi2-firmware postinst calling sync, which is - actually warranted in the normal case. - * If a subarch is specified for a cloud image build, don't build rootfs - artifacts; these should come from the 'generic' build. - * Fix architecture handling in hooks. We know we're always being invoked - from a launchpad-buildd-like setup, which passes ARCH and SUBARCH in the - environment, because auto/config and auto/build both rely on this. So - don't scatter dpkg --print-architecture calls throughout, especially - when many of these are not cross-build-aware. - * Refactor ubuntu-cpc hooks to allow us to handle images where the root - partition should not be partition 1. - - [ Ben Howard ] - * ubuntu-cpc: fix hooks/032-disk-image.binary call to - create_empty_partition, which requires five args due to "-u" - * ubuntu-cpc: in hooks/030-root-tarball.binary create /lib/modules to fix - (LP: 1543204). - - [ Steve Langasek ] - * Refactor ubuntu-cpc hooks to always produce a 'plain' rootfs via - live-build and reuse this for the tarball, instead of lb_binary_rootfs - creating some artifact that we ignore / throw away. - * Initial support for raspi2 subarch. - * Import live-build/ubuntu-cpc/hooks/raspi2/mkknlimg from - https://github.com/raspberrypi/linux/blob/rpi-4.1.y/scripts/mkknlimg - and use it to install a bootable uboot.bin. - - -- Robert C Jennings Tue, 23 May 2017 22:29:47 -0500 - -livecd-rootfs (2.209.11) trusty; urgency=medium - - [ Steve Langasek ] - * Refactor some non-idiomatic architecture handling in - live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot that also misidentifies - the architecture name for armhf. - - -- Robert C Jennings Tue, 23 May 2017 21:38:47 -0500 - -livecd-rootfs (2.209.10) trusty; urgency=medium - - [ Steve Langasek ] - * Refactor/reorder ubuntu-cpc support for consistency with other flavors, - so that subarch overrides can be applied correctly. - - [ Ben Howard ] - * ubuntu-cpc: - - fixed loop setup due to change of kpartx output - - only use grub-install logic for Intel architectures - - -- Robert C Jennings Tue, 23 May 2017 21:01:47 -0500 - -livecd-rootfs (2.209.9) trusty; urgency=medium - - [Daniel Watkins] - * Set timeout options so ppc64el cloud images don't display a grub boot - menu (matching the behaviour of other cloud images). - * Specify a regex to run-parts so that cloud image extra scripts are found - and executed. - - -- Robert C Jennings Tue, 23 May 2017 20:57:47 -0500 - -livecd-rootfs (2.209.8) trusty; urgency=medium - - [Daniel Watkins] - * Install grub in ppc64el cloud images so they are bootable (LP: #1538610) - - -- Robert C Jennings Tue, 23 May 2017 20:51:47 -0500 - -livecd-rootfs (2.209.7) trusty; urgency=medium - - [Ben Howard] - * Remove unneeded packages from the root.tar.{gz,xz} cloud image targets - (LP: #1534764). - - -- Robert C Jennings Tue, 23 May 2017 20:45:47 -0500 - -livecd-rootfs (2.209.6) trusty; urgency=medium - - [Daniel Watkins] - * Produce OVA files for i386 cloud builds. - - -- Robert C Jennings Tue, 23 May 2017 20:34:47 -0500 - -livecd-rootfs (2.209.5) trusty; urgency=medium - - [Ben Howard] - * ubuntu-cpc: - - extended hooks/functions to support creation of derivative images - including mounting images. - - added the ability to create qcow2 images in hooks/functions - - simplified loop clean-up in hooks/functions - - removed assumption that disk1.img would be built - - switched qcow2 generation to use hooks/functions function - - -- Robert C Jennings Tue, 23 May 2017 20:21:47 -0500 - -livecd-rootfs (2.209.4) trusty; urgency=medium - - [Ben Howard] - * ubuntu-cpc: - - add devpts-live to hook builds - - add logic to settle the disks after UEFI builds - - -- Robert C Jennings Tue, 23 May 2017 20:12:47 -0500 - -livecd-rootfs (2.209.3) trusty; urgency=medium - - [Ben Howard] - * Fix typo in ubuntu-cpc preventing non-intel builds. - - -- Robert C Jennings Tue, 23 May 2017 16:46:04 -0500 - -livecd-rootfs (2.209.2) trusty; urgency=medium - - [Oliver Grawert] - * added additional CPC build targets: - - added manifest generation for squashfs and root.tar.gz - - added VMDK generation - - added OVA generation from VMDK's - - added generic Vagrant image generation - - -- Robert C Jennings Tue, 23 May 2017 16:40:29 -0500 - -livecd-rootfs (2.209.1) trusty; urgency=medium - - [Daniel Watkins] - * Move building of all architecture-specific CPC artifacts into Launchpad - (LP: #1513754). - - -- Robert C Jennings Tue, 23 May 2017 16:33:44 -0500 - livecd-rootfs (2.209) trusty; urgency=medium - * Add ubuntu-cpc project + * Add ubuntu-cpc project (LP: #1693018) + + [ Daniel Watkins ] + * Move building of all architecture-specific CPC artifacts into Launchpad + (LP: #1513754). + + [ Oliver Grawert ] + * added additional CPC build targets: + - added manifest generation for squashfs and root.tar.gz + - added VMDK generation + - added OVA generation from VMDK's + - added generic Vagrant image generation + + [ Ben Howard ] + * Fix typo in ubuntu-cpc preventing non-intel builds. + * add devpts-live to hook builds + * add logic to settle the disks after UEFI builds + * extended hooks/functions to support creation of derivative images + * including mounting images. + * added the ability to create qcow2 images in hooks/functions + * simplified loop clean-up in hooks/functions + * removed assumption that disk1.img would be built + * switched qcow2 generation to use hooks/functions function + + [ Daniel Watkins ] + * Produce OVA files for i386 cloud builds. + + [ Ben Howard ] + * Remove unneeded packages from the root.tar.{gz,xz} cloud image targets + (LP: #1534764). + + [ Daniel Watkins ] + * Install grub in ppc64el cloud images so they are bootable (LP: #1538610) + + [ Daniel Watkins ] + * Set timeout options so ppc64el cloud images don't display a grub boot + menu (matching the behaviour of other cloud images). + * Specify a regex to run-parts so that cloud image extra scripts are found + and executed. + + [ Steve Langasek ] + * Refactor/reorder ubuntu-cpc support for consistency with other flavors, + so that subarch overrides can be applied correctly. + + [ Ben Howard ] + * fixed loop setup due to change of kpartx output + * only use grub-install logic for Intel architectures + + [ Steve Langasek ] + * Refactor some non-idiomatic architecture handling in + live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot that also misidentifies + the architecture name for armhf. + + [ Steve Langasek ] + * Add hooks to ubuntu-cpc to divert /bin/sync in the chroot and undivert it + at the end. This is a general-purpose change that should be applied to + all flavors and archs, but at the moment it's only needed on armhf+raspi2 + to work around the raspberrypi2-firmware postinst calling sync, which is + actually warranted in the normal case. + * If a subarch is specified for a cloud image build, don't build rootfs + artifacts; these should come from the 'generic' build. + * Fix architecture handling in hooks. We know we're always being invoked + from a launchpad-buildd-like setup, which passes ARCH and SUBARCH in the + environment, because auto/config and auto/build both rely on this. So + don't scatter dpkg --print-architecture calls throughout, especially + when many of these are not cross-build-aware. + * Refactor ubuntu-cpc hooks to allow us to handle images where the root + partition should not be partition 1. + + [ Ben Howard ] + * ubuntu-cpc: fix hooks/032-disk-image.binary call to + create_empty_partition, which requires five args due to "-u" + * ubuntu-cpc: in hooks/030-root-tarball.binary create /lib/modules to fix + (LP: 1543204). + + [ Steve Langasek ] + * Refactor ubuntu-cpc hooks to always produce a 'plain' rootfs via + live-build and reuse this for the tarball, instead of lb_binary_rootfs + creating some artifact that we ignore / throw away. + * Initial support for raspi2 subarch. + * Import live-build/ubuntu-cpc/hooks/raspi2/mkknlimg from + https://github.com/raspberrypi/linux/blob/rpi-4.1.y/scripts/mkknlimg + and use it to install a bootable uboot.bin. + + [ Adam Conrad ] + * live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot: Add fake_cloud_init + function to create a nocloud data source for cloud images that aren't + meant to be used on real clouds and use it by default on armhf+raspi2 + + [ Ben Howard ] + * live-build/ubuntu-cpc/hooks/042-vagrant.binary: add serial device for + Vagrant images (LP: #1546108). + + [ Daniel Watkins ] + * Refactor ubuntu-cpc hooks to hard-code producing an 'ext4' rootfs, which + is used outside of the livecd-rootfs build process (specifically for EC2 + publication). + + [ Ben Howard ] + * live-build/ubuntu-cpc/hooks/042-vagrant.binary: scope serial device for + Virtualbox only. + + [ Daniel Watkins ] + * Enable building of powerpc cloud images. + + [ Louis Zuckerman ] + * Fixes for vagrant box builder in ubuntu-cpc LP: #1565985 + - Install virtualbox-guest-utils + - Don't disable default synced folder + - Don't set vm name + - Add cloud-init config to manage /etc/hosts LP: #1561250 + + [ Steve Langasek ] + * live-build/ubuntu-cpc/hooks/042-vagrant.binary: fix unmount handling + so that the teardown is done properly /before/ we try to make an + image from our filesystem, since otherwise /etc/resolv.conf is broken. + LP: #1621393. + + [ Daniel Watkins ] + * Don't overwrite the default sources.list in cloud images. + * Replace sources.list generated using COMPONENTS with the sources.list from + an Ubuntu Server installation (i.e. with all components enabled, and all + deb-src lines commented). LP: #1513529. + + [ Chris Glass ] + * Fix the manifest generation in OVA files so that ovf files don't have + double extensions. (LP: #1627931) + * Fix the OVF's metadata to include Ubuntu specific identifiers and + descriptions instead of the generic Linux ones. (LP: #1656293) + + [ Daniel Watkins ] + * Add replace_grub_root_with_label function thereby consolidating multiple + uses of the same calls to sed. + + [ Robert C Jennings ] + * ubuntu-cpc: Remove redundant copy of grub files. (LP: #1637290) + + [ Daniel Watkins ] + * Add `apt-get update` to ubuntu-cpc ppc64el builds so they use the new + sources. -- Robert C Jennings Mon, 08 May 2017 17:07:02 -0500 From 54fd57be7b024e0a220da94fd190c2ba665429c5 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 1 Jun 2017 14:22:08 -0500 Subject: [PATCH 24/25] Remove old bug references from backport --- debian/changelog | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/debian/changelog b/debian/changelog index be0c010a..7d1ea6b4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,7 +4,6 @@ livecd-rootfs (2.209) trusty; urgency=medium [ Daniel Watkins ] * Move building of all architecture-specific CPC artifacts into Launchpad - (LP: #1513754). [ Oliver Grawert ] * added additional CPC build targets: @@ -29,10 +28,9 @@ livecd-rootfs (2.209) trusty; urgency=medium [ Ben Howard ] * Remove unneeded packages from the root.tar.{gz,xz} cloud image targets - (LP: #1534764). [ Daniel Watkins ] - * Install grub in ppc64el cloud images so they are bootable (LP: #1538610) + * Install grub in ppc64el cloud images so they are bootable [ Daniel Watkins ] * Set timeout options so ppc64el cloud images don't display a grub boot @@ -73,7 +71,6 @@ livecd-rootfs (2.209) trusty; urgency=medium * ubuntu-cpc: fix hooks/032-disk-image.binary call to create_empty_partition, which requires five args due to "-u" * ubuntu-cpc: in hooks/030-root-tarball.binary create /lib/modules to fix - (LP: 1543204). [ Steve Langasek ] * Refactor ubuntu-cpc hooks to always produce a 'plain' rootfs via @@ -91,7 +88,7 @@ livecd-rootfs (2.209) trusty; urgency=medium [ Ben Howard ] * live-build/ubuntu-cpc/hooks/042-vagrant.binary: add serial device for - Vagrant images (LP: #1546108). + Vagrant images [ Daniel Watkins ] * Refactor ubuntu-cpc hooks to hard-code producing an 'ext4' rootfs, which @@ -106,36 +103,35 @@ livecd-rootfs (2.209) trusty; urgency=medium * Enable building of powerpc cloud images. [ Louis Zuckerman ] - * Fixes for vagrant box builder in ubuntu-cpc LP: #1565985 + * Fixes for vagrant box builder in ubuntu-cpc - Install virtualbox-guest-utils - Don't disable default synced folder - Don't set vm name - - Add cloud-init config to manage /etc/hosts LP: #1561250 + - Add cloud-init config to manage /etc/hosts [ Steve Langasek ] * live-build/ubuntu-cpc/hooks/042-vagrant.binary: fix unmount handling so that the teardown is done properly /before/ we try to make an image from our filesystem, since otherwise /etc/resolv.conf is broken. - LP: #1621393. [ Daniel Watkins ] * Don't overwrite the default sources.list in cloud images. * Replace sources.list generated using COMPONENTS with the sources.list from an Ubuntu Server installation (i.e. with all components enabled, and all - deb-src lines commented). LP: #1513529. + deb-src lines commented). [ Chris Glass ] * Fix the manifest generation in OVA files so that ovf files don't have - double extensions. (LP: #1627931) + double extensions. * Fix the OVF's metadata to include Ubuntu specific identifiers and - descriptions instead of the generic Linux ones. (LP: #1656293) + descriptions instead of the generic Linux ones. [ Daniel Watkins ] * Add replace_grub_root_with_label function thereby consolidating multiple uses of the same calls to sed. [ Robert C Jennings ] - * ubuntu-cpc: Remove redundant copy of grub files. (LP: #1637290) + * ubuntu-cpc: Remove redundant copy of grub files. [ Daniel Watkins ] * Add `apt-get update` to ubuntu-cpc ppc64el builds so they use the new From 1343885b3de4b92903251b95c5016046fefe8878 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 1 Jun 2017 14:32:08 -0500 Subject: [PATCH 25/25] Add changelog entry for mapping of virual flavor to generic kernel --- debian/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/changelog b/debian/changelog index 7d1ea6b4..073df172 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,7 @@ livecd-rootfs (2.209) trusty; urgency=medium [ Daniel Watkins ] * Move building of all architecture-specific CPC artifacts into Launchpad + - Fixup virtual FLAVOUR kernel name [ Oliver Grawert ] * added additional CPC build targets: