Merge lp:~mwhudson/livecd-rootfs/casper-be-gone into lp:livecd-rootfs

Proposed by Michael Hudson-Doyle
Status: Merged
Merged at revision: 1629
Proposed branch: lp:~mwhudson/livecd-rootfs/casper-be-gone
Merge into: lp:livecd-rootfs
Diff against target: 105 lines (+51/-3)
4 files modified
debian/changelog (+6/-0)
live-build/auto/config (+9/-1)
live-build/functions (+31/-0)
live-build/ubuntu-server/hooks/032-installer-squashfs.binary (+5/-2)
To merge this branch: bzr merge lp:~mwhudson/livecd-rootfs/casper-be-gone
Reviewer Review Type Date Requested Status
Steve Langasek Approve
Mathieu Trudel-Lapierre Needs Information
Review via email: mp+335127@code.launchpad.net

Description of the change

Currently casper ends up in the base filesystem (and so on the installed system) which isn't what we want. So we prevent that, by preventing lb_chroot_live-packages from running at all. Then of course, we need to install casper in the installer layer, and then regenerate the initramfs and make sure the later steps of the build pick it up (which is pretty ugly).

I haven't tested a CD built with this branch but I have run the livefs build https://launchpad.net/~mwhudson/+livefs/ubuntu/bionic/live-server-test/+build/118096 and checked that the generated initramfs is all but identical to the one generated by the default server-live livefs (only timestamps and randomly generated data differ).

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

FWIW, this doesn't work, casper probably needs to change too somehow.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Actually it does seem to work, I must have screwed up my testing before.

Revision history for this message
Steve Langasek (vorlon) wrote :

Could you factor the bulk of this code out into a couple of functions, for easy consumption of other flavor builds in the future?

review: Needs Fixing
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

I'm worried about not installing live-config as would normally be done in lb_chroot_live-packages (which is what you disabled by adding the touch command).

I have no idea if it's actually all that useful on our live images, but live-config is meant to do some late-boot "configuration" of the system, such as messing with sudoers, locale-gen, timezone, etc. for the live session. I just don't recall explicitly noticing that it was live-config rather than casper doing that work.

review: Needs Information
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

> Could you factor the bulk of this code out into a couple of functions, for
> easy consumption of other flavor builds in the future?

I've tried to do this.

1603. By Michael Hudson-Doyle

respond to some review feedback

1604. By Michael Hudson-Doyle

make another possibly more generally useful function

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

> I'm worried about not installing live-config as would normally be done in
> lb_chroot_live-packages (which is what you disabled by adding the touch
> command).

Nah, that bit of chroot_live-packages didn't fire (I guess we don't set LB_INITSYSTEM?)

> I have no idea if it's actually all that useful on our live images, but live-
> config is meant to do some late-boot "configuration" of the system, such as
> messing with sudoers, locale-gen, timezone, etc. for the live session. I just
> don't recall explicitly noticing that it was live-config rather than casper
> doing that work.

You can see that live-config is not installed in the manifest of the current livefs builds.

1605. By Michael Hudson-Doyle

move skip_lb_stage to config

1606. By Michael Hudson-Doyle

call recreate_initramfs with the argument it needs

Revision history for this message
Steve Langasek (vorlon) :
review: Needs Fixing
1607. By Michael Hudson-Doyle

remove some of the cargo culted scorpions

Revision history for this message
Steve Langasek (vorlon) :
review: Approve
1608. By Michael Hudson-Doyle

source config/binary in 032-installer-squashfs.binary

1609. By Michael Hudson-Doyle

clean up changelog

1610. By Michael Hudson-Doyle

it is config/common, not config/binary, grr

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2018-02-20 21:40:04 +0000
3+++ debian/changelog 2018-02-23 01:58:51 +0000
4@@ -1,3 +1,9 @@
5+livecd-rootfs (2.505) UNRELEASED; urgency=medium
6+
7+ * Move casper from filesystem.squashfs to installer.squashfs.
8+
9+ -- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Fri, 23 Feb 2018 13:40:35 +1300
10+
11 livecd-rootfs (2.504) bionic; urgency=medium
12
13 * Override JobRunningTimeoutSec to 0s on the .device unit that
14
15=== modified file 'live-build/auto/config'
16--- live-build/auto/config 2018-02-14 20:31:07 +0000
17+++ live-build/auto/config 2018-02-23 01:58:51 +0000
18@@ -116,6 +116,12 @@
19 esac
20 fi
21
22+skip_lb_stage() {
23+ STAGE="$1"
24+ mkdir -p .build
25+ touch ".build/$STAGE"
26+}
27+
28 case $IMAGEFORMAT in
29 ext2|ext3|ext4)
30 OPTS="${OPTS:+$OPTS }--initramfs none --chroot-filesystem $IMAGEFORMAT"
31@@ -141,7 +147,9 @@
32 INITRAMFS_TYPE=none
33 case $PROJECT:${SUBPROJECT:-} in
34 ubuntu-server:live)
35- add_package live lupin-casper
36+ # Stop lp installing casper into filesystem.squashfs
37+ # by skipping lb_chroot_live-packages.
38+ skip_lb_stage chroot_live-packages
39 INITRAMFS_TYPE=auto
40 ;;
41 *)
42
43=== modified file 'live-build/functions'
44--- live-build/functions 2017-11-23 19:27:16 +0000
45+++ live-build/functions 2018-02-23 01:58:51 +0000
46@@ -329,3 +329,34 @@
47 chroot "$CHROOT_ROOT" dpkg-divert --remove --local \
48 --rename /usr/bin/systemd-detect-virt
49 }
50+
51+recreate_initramfs() {
52+ # Regenerate the initramfs by running update-initramfs in the
53+ # chroot at $1 and copying the generated initramfs
54+ # around. Beware that this was written for a single use case
55+ # (live-server) and may not work in all cases without
56+ # tweaking...
57+ # config/common must be sourced before calling this function.
58+ CHROOT="$1"
59+ # Start by cargo culting bits of lb_chroot_hacks:
60+ if [ -n "$LB_INITRAMFS_COMPRESSION" ]; then
61+ echo "COMPRESS=$LB_INITRAMFS_COMPRESSION" > "$CHROOT"/etc/initramfs-tools/conf.d/livecd-rootfs.conf
62+ fi
63+ chroot "$CHROOT" sh -c "${UPDATE_INITRAMFS_OPTIONS:-} update-initramfs -k all -t -u"
64+ rm -rf "$CHROOT"/etc/initramfs-tools/conf.d/livecd-rootfs.conf
65+ # Then bits of lb_binary_linux-image:
66+ case "${LB_INITRAMFS}" in
67+ casper)
68+ DESTDIR="binary/casper"
69+ ;;
70+
71+ live-boot)
72+ DESTDIR="binary/live"
73+ ;;
74+
75+ *)
76+ DESTDIR="binary/boot"
77+ ;;
78+ esac
79+ mv "$CHROOT"/boot/initrd.img-* $DESTDIR
80+}
81
82=== modified file 'live-build/ubuntu-server/hooks/032-installer-squashfs.binary'
83--- live-build/ubuntu-server/hooks/032-installer-squashfs.binary 2018-02-20 02:22:43 +0000
84+++ live-build/ubuntu-server/hooks/032-installer-squashfs.binary 2018-02-23 01:58:51 +0000
85@@ -22,6 +22,7 @@
86 fi
87
88 . config/functions
89+. config/common
90
91 SQUASH_ROOT=binary/boot/squashfs.dir
92 OVERLAY_ROOT=binary/overlay
93@@ -50,8 +51,10 @@
94 # Install any requirements for the installer, for things we don't want
95 # to see on the installed system
96 chroot $SQUASH_ROOT apt-get update
97-chroot $SQUASH_ROOT apt-get -y install user-setup
98-chroot $SQUASH_ROOT apt-get -y install curtin
99+chroot $SQUASH_ROOT apt-get -y install user-setup curtin lupin-casper
100+
101+# Installing casper means we need a new initramfs
102+UPDATE_INITRAMFS_OPTIONS=CASPER_GENERATE_UUID=1 recreate_initramfs $SQUASH_ROOT
103
104 # Don't let cloud-init run in the live session.
105 touch $SQUASH_ROOT/etc/cloud/cloud-init.disabled

Subscribers

People subscribed via source and target branches