diff --git a/BuildLiveCD b/BuildLiveCD deleted file mode 100755 index 4938d7e0..00000000 --- a/BuildLiveCD +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash -BUILD_LOG=~/public_html/BuildLive.out -ALWAYS_SEND_LOG=yes -LANG=C - -finish() { - [ $? != "0" ] && STATUS="Failed" || STATUS="Successful" - if [ "$STATUS" = "Failed" ] || [ "$ALWAYS_SEND_LOG" = "yes" ]; then - SEND_LOG=yes - fi - if [ -e "$LOG" ]; then - echo "======================= Log of livefs.sh output follows =======================" - cat $LOG - fi - if [ "$SEND_LOG" = "yes" ]; then - exec >/dev/null 2>&1 - mailx -s "LiveCD: $STATUS $STE:$FS${SUBPROJECT:+-$SUBPROJECT}${SUBARCH:+-$SUBARCH}${UBUNTU_DEFAULTS_LOCALE:+-$UBUNTU_DEFAULTS_LOCALE} build on ${ARCH}" buildd+porters < "$BUILD_LOG" - fi - rm -f ~/buildLiveCD.lock - nohup ~/bin/pruneLiveCD >/dev/null 2>&1 & -} - -if [ -n "$SSH_ORIGINAL_COMMAND" ]; then - set -- $SSH_ORIGINAL_COMMAND - [ ${1##*/} != 'BuildLiveCD' ] && echo bad command >&2 && exit 2 - shift -fi -ARCH=$(dpkg --print-architecture) -SUBARCH="" -NEWSUITE="precise" -SUITES="" -PROPOSED="" -IMAGEFORMAT="" -LIVE_BUILD=false -UBUNTU_DEFAULTS_LOCALE="" - -while getopts :A:s:r:d:f:plu:t: name; do case $name in - A) ARCH="$OPTARG";; - s) SUBARCH="$OPTARG";; - r) SUBPROJECT="$OPTARG";; - d) NEWSUITE="$OPTARG";; - f) IMAGEFORMAT="$OPTARG";; - p) PROPOSED="-p";; - l) LIVE_BUILD=:;; - u) UBUNTU_DEFAULTS_LOCALE="$OPTARG";; - t) UBUNTU_TOUCH_ANDROID="$OPTARG";; -esac; done; -shift $((OPTIND-1)) - -for s in $NEWSUITE; do - if [ -d build-${s}-live/chroot-${s} ]; then SUITES="$SUITES $s"; fi -done -if [ -z "$SUITES" ]; then - echo "No valid suites to build for" >&2 && exit 1 -fi -for s in $SUITES; do - case $s in - dapper|edgy|feisty|gutsy|hardy) - old_suite="yes" - ;; - *) - new_suite="yes" - ;; - esac -done -if [ "$new_suite" = "yes" ] && [ "$old_suite" = "yes" ]; then - echo "Can't build images for suites older than intrepid and suites" >&2 - echo "greater than hardy at the same time, please use two invocations" >&2 - exit 1 -fi -if ([ $# = 0 ] || [ "X$1" = "Xall" ]) && ! $LIVE_BUILD; then - set -- ubuntu kubuntu kubuntu-active edubuntu xubuntu mythbuntu base - if [ "$ARCH" = "i386" ]; then - set -- ubuntu ubuntu-dvd ubuntu-lpia ubuntu-netbook kubuntu kubuntu-dvd kubuntu-active edubuntu edubuntu-dvd xubuntu mythbuntu base - fi -fi - -case ${ARCH} in - hppa|sparc|powerpc) LINUX32=linux32;; - *) LINUX32="";; -esac - -if [ "`echo $@ | wc -w`" -gt "1" ]; then - for arg in "$@"; do - $0 $arg - done - exit 0 -fi -FS="$1" -shift - -# 12 hours should be enough for even the longest build queue to clear. -lockfile -8 -r$((12 * 60 * 60 / 8)) ~/buildLiveCD.lock || exit 1 -trap "finish" 0 -trap "rm -f ~/buildLiveCD.lock; exit 1" 1 2 3 15 -exec > $BUILD_LOG 2>&1 -set -e - -for STE in $SUITES; do - if [ -d ~/build-${STE}-live/chroot-${STE} ]; then - sudo chroot ~/build-${STE}-live/chroot-${STE} apt-get -qq update || true - sudo chroot ~/build-${STE}-live/chroot-${STE} apt-get -y dist-upgrade || true - sudo chroot ~/build-${STE}-live/chroot-${STE} apt-get -y install livecd-rootfs eatmydata || true - sudo chroot ~/build-${STE}-live/chroot-${STE} apt-get -y --install-recommends install ubuntu-defaults-builder || true - fi -done -for STE in $SUITES; do - if cd ~/build-${STE}-live 2>/dev/null; then - DIR=~/build-${STE}-live/chroot-${STE}/./build/ - else - cd ~/build.live - DIR=~/build.live/chroot-${STE}/./build/ - fi - - PUBDIR=~/public_html/LiveCD/${STE}/${FS}${SUBPROJECT:+-$SUBPROJECT}${SUBARCH:+-$SUBARCH}${UBUNTU_DEFAULTS_LOCALE:+-$UBUNTU_DEFAULTS_LOCALE}/ - mkdir -p ${PUBDIR} - - NOW=$(date +%Y%m%d) - if [ -d ${PUBDIR}${NOW} ]; then - typeset -i n=1; while [ -d ${PUBDIR}${NOW}.$n ]; do n=n+1; done - NOW=${NOW}.$n - fi - LOG=${PUBDIR}${NOW}/livecd-${NOW}-${ARCH}.out - - rm -f ${PUBDIR}latest - ln -sf ${PUBDIR}${NOW} ${PUBDIR}latest - mkdir -p ${PUBDIR}${NOW} - > ${LOG} - ln -sf livecd-${NOW}-${ARCH}.out ${PUBDIR}${NOW}/livecd-${ARCH}.out - if $LIVE_BUILD; then - $LINUX32 sudo chroot ${DIR%/./*} sh -c "cd /${DIR#*/./} && rm -rf auto && mkdir -p auto && for f in config build clean; do ln -s /usr/share/livecd-rootfs/live-build/auto/\$f auto/; done" >> ${LOG} 2>&1 || true - $LINUX32 sudo chroot ${DIR%/./*} sh -c "cd /${DIR#*/./} && lb clean --purge" >> ${LOG} 2>&1 || true - if ! $LINUX32 sudo chroot ${DIR%/./*} sh -c "cd /${DIR#*/./} && NOW=${NOW} SUITE=${STE} PROJECT=${FS} SUBPROJECT=${SUBPROJECT} ARCH=${ARCH} SUBARCH=${SUBARCH} IMAGEFORMAT=${IMAGEFORMAT} PROPOSED=${PROPOSED:+1} lb config" >> ${LOG} 2>&1; then - exit 1 - fi - COMMAND="PROJECT=${FS} SUBPROJECT=${SUBPROJECT} ARCH=${ARCH} SUBARCH=${SUBARCH} lb build" - elif [ "$UBUNTU_DEFAULTS_LOCALE" ]; then - COMMAND="ubuntu-defaults-image --locale ${UBUNTU_DEFAULTS_LOCALE} --arch ${ARCH} --release ${STE}" - else - echo "Must pass either -l or -u." - exit 1 - fi - if $LINUX32 sudo chroot ${DIR%/./*} sh -c "cd /${DIR#*/./} && eatmydata -- $COMMAND" >> ${LOG} 2>&1; then - rm -f ${PUBDIR}current - ln -sf ${NOW} ${PUBDIR}current - - for file in ${DIR}livecd.*; do - if [ -f ${file} ]; then - ext=${file##*.} - base=${file%.*}; base=${base##*/} - sudo chown buildd ${file} - sudo mv ${file} ${PUBDIR}${NOW}/${base}-${NOW}-${ARCH}.${ext} - ln -sf ${base}-${NOW}-${ARCH}.${ext} ${PUBDIR}${NOW}/${base}.${ext} - fi - done - - for f in ${PUBDIR}${NOW}/livecd.*.cloop-*; do - if [ -f ${f} ]; then - target=${f%-*} - if [ ! -f ${target} ]; then - for fsbs in 4096:4096 1024:65536; do - if [ -f ${target}-${fsbs} ]; then - ln -sf ${target##*/}-${fsbs} ${target} - break - fi - done - if [ ! -f ${target} ]; then - best=$(ls -ld ${target}-* | sort -k5,5n| awk '{print $NF; quit}') - ln -sf ${best##*/} ${target} - fi - fi - fi - done - else - exit 1 - fi -done diff --git a/debian/changelog b/debian/changelog index 8876769e..8b9d5b74 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,51 @@ +livecd-rootfs (2.376) xenial; urgency=medium + + [ Michael Terry ] + * Change real name for phablet user to "Ubuntu" in ubuntu-touch. + + [ Steve Langasek ] + * Drop BuildLiveCD from the examples; we now use launchpad-buildd to drive + livefs builds, so BuildLiveCD is obsolete and misleading. + * 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). + + [ Dimitri John Ledkov ] + * Do not remove linux-base, when purging all the linux-*, in the tarball + build. Otherwise ubuntu-minimal is removed, and things get crazy. + * Correct initrd.img symlink, kernel/hooks should actually produce the + right thing here, but meh. + * Chroot to execute zipl, because it's nice. + * Use the right loop device to install zipl onto. + + [ 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. + + -- Steve Langasek Fri, 12 Feb 2016 21:14:49 +0000 + livecd-rootfs (2.375) xenial; 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/debian/examples b/debian/examples deleted file mode 100644 index 202be4c9..00000000 --- a/debian/examples +++ /dev/null @@ -1 +0,0 @@ -BuildLiveCD diff --git a/live-build/auto/config b/live-build/auto/config index 05692012..03a41393 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -101,6 +101,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" @@ -111,13 +117,7 @@ case $IMAGEFORMAT in COMPONENTS='main restricted universe multiverse' ;; *) - case $PROJECT in - ubuntu-cpc) - ;; - *) - add_package live jasper - ;; - esac + add_package live jasper ;; esac ;; @@ -562,6 +562,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 @@ -625,6 +630,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..28d920ce 100755 --- a/live-build/ubuntu-cpc/hooks/030-root-tarball.binary +++ b/live-build/ubuntu-cpc/hooks/030-root-tarball.binary @@ -1,21 +1,22 @@ #!/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 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 '^linux-.*' 'linux-base+' 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 100755 --- 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 fe6f1c71..045add8b 100755 --- 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,14 +111,10 @@ if [ "${should_install_grub}" -eq 1 ]; then ${loop_device} rm mountpoint/tmp/device.map - umount_partition mountpoint - rmdir mountpoint fi -if [ "$architecture" = "s390x" ]; then +if [ "$ARCH" = "s390x" ]; then # Do ZIPL install bits - mkdir mountpoint - mount_partition "${rootfs_dev_mapper}" mountpoint # Write out cloudy zipl.conf for future kernel updates cat << EOF > mountpoint/etc/zipl.conf @@ -73,20 +129,31 @@ ramdisk = /boot/initrd.img parameters = root=LABEL=cloudimg-rootfs EOF + # Kernel initramfs hooks end up creating a copy + # rather than a symlink FIXME + pushd mountpoint/boot + ln -sf initrd.img-* initrd.img + popd + # Create bootmap file - mountpoint/sbin/zipl -V \ - --image=mountpoint/boot/vmlinuz \ - --ramdisk=mountpoint/boot/initrd.img \ + chroot mountpoint /sbin/zipl -V \ + --image=/boot/vmlinuz \ + --ramdisk=/boot/initrd.img \ --parameters='root=LABEL=cloudimg-rootfs' \ - --target=mountpoint/boot/ \ - --targetbase=/dev/loop0 \ + --target=/boot/ \ + --targetbase=$loop_device \ --targettype=SCSI \ --targetblocksize=512 \ --targetoffset=2048 - 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 100755 --- 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 100755 --- 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 107dfd3d..6647c9ec 100755 --- 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 100755 --- 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 100755 --- 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 100755 --- 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 100755 --- 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 100755 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 100755 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')); +} diff --git a/live-build/ubuntu-desktop-next/hooks/500-move-kernel-to-device-tar.binary b/live-build/ubuntu-desktop-next/hooks/500-move-kernel-to-device-tar.binary index 9afe61db..33e70ab4 100644 --- a/live-build/ubuntu-desktop-next/hooks/500-move-kernel-to-device-tar.binary +++ b/live-build/ubuntu-desktop-next/hooks/500-move-kernel-to-device-tar.binary @@ -8,7 +8,6 @@ echo "I: Moving kernel into device tarball" HERE="$(pwd)" TMPDIR="$(mktemp -d)" -ARCH=$(dpkg --print-architecture) mkdir -p $TMPDIR/system/ mkdir -p $TMPDIR/assets/ diff --git a/live-build/ubuntu-touch/hooks/01-setup_user.chroot b/live-build/ubuntu-touch/hooks/01-setup_user.chroot index 1be0534d..3232ef56 100755 --- a/live-build/ubuntu-touch/hooks/01-setup_user.chroot +++ b/live-build/ubuntu-touch/hooks/01-setup_user.chroot @@ -1,10 +1,11 @@ #!/bin/sh -x USER=phablet +GECOS=Ubuntu UGID=32011 echo "I: creating default user $USER" -adduser --gecos $USER --disabled-login $USER --uid $UGID +adduser --gecos $GECOS --disabled-login $USER --uid $UGID echo "I: set user $USER password to blank" passwd -d $USER