Merge lp:~semiosis/livecd-rootfs/fix-for-1565985 into lp:livecd-rootfs

Proposed by Louis Zuckerman
Status: Merged
Merged at revision: 1419
Proposed branch: lp:~semiosis/livecd-rootfs/fix-for-1565985
Merge into: lp:livecd-rootfs
Diff against target: 165 lines (+51/-30) (has conflicts)
2 files modified
debian/changelog (+15/-0)
live-build/ubuntu-cpc/hooks/042-vagrant.binary (+36/-30)
Text conflict in debian/changelog
To merge this branch: bzr merge lp:~semiosis/livecd-rootfs/fix-for-1565985
Reviewer Review Type Date Requested Status
Steve Langasek Needs Fixing
Dan Watkins (community) Approve
Review via email: mp+298305@code.launchpad.net

Description of the change

Several problems with the official ubuntu vagrant boxes for Xenial:

- Standard packages were missing (virtualbox-guest stuff, config management stuff)
- Box name was statically assigned, limiting to only one instance per host
- Default synced folder was disabled

This change fixes all of the above issues, except for config management.
As per discussion in #ubuntu-devel we have opened a new bug for the missing config management packages: https://bugs.launchpad.net/cloud-images/+bug/1599531

Also cleaned up some inconsistent indentation.

Last of all, had to change the shebang to not use -u. This is because clean_loops (from functions) gets called twice and the second time (by trap) has unset variables so the build would die.

As a side note, a solution to allow clean_loops to run twice under bash -u would be to use ${var_name-} instead of ${var_name} in the two variable test lines, but that was out of scope for my issues. Just FYI.

Thank you!

To post a comment you must log in.
Revision history for this message
Louis Zuckerman (semiosis) wrote :

How to use/test:

I did all my development & testing on the official xenial vagrant box (dogfooding!)

The build will exceed the space available on / on the vagrant box so I had to disable some of the other hook scripts that were unrelated.

If you have about 10 GB free on / you should be able to build all of the images in ubuntu-cpc.

Here's how...

# First, set up the build tools and workspace.
# The scripts require that you work in /build

sudo -i
apt-get install -y livecd-rootfs
mkdir -p /build/chroot
cd /build
cp -a /usr/share/livecd-rootfs/live-build/auto .

# All the hard work is done with live-build (lb command)
# and we have to configure it with environment variables

export SUITE=xenial
export ARCH=amd64
export PROJECT=ubuntu-cpc
export MIRROR=http://archive.ubuntu.com/ubuntu/

# Now we can have live-build set up the workspace

lb config

# If you're short on time or disk space you can disable
# some of the builders. Go into /build/config/hooks and
# remove these scripts which are unrelated to vagrant:
# 032-root-squashfs.binary 033-disk-image-uefi.binary
# 034-disk-image-ppc64el.binary 040-qcow2-image.binary
# 040-vmdk-image.binary 041-vmdk-ova-image.binary

# And finally, start the build

lb build

Revision history for this message
Dan Watkins (oddbloke) wrote :

Hi Louis,

I've tested this using our actual build stack, and hit some issues with package installation; I'm going to try a couple of things to get it working myself, and will let you know if I make progress.

Dan

Revision history for this message
Dan Watkins (oddbloke) wrote :

Hi Louis,

Added some comments inline; this includes the change I had to make, but also a couple of other thoughts. :)

Thanks again for looking at this!

Dan

review: Needs Fixing
1413. By Louis Zuckerman

[ Louis Zuckerman ]
* Merged the following changes from upstream
[ Łukasz 'sil2100' Zemczak ]
* Remove the ubuntu-pd project from the scripts
* Add instead an ubuntu-touch-custom project for custom re-builds of
  ubuntu-touch
[ Daniel Watkins ]
* Consolidate cloud images
  - Remove .tar.gz and .tar.xz (removed in favour of the squashfs).
  - Remove the MBR-only disk image in favour of the shared GPT/MBR UEFI
    image.
  - Remove '-disk1' from bootable image names.
[ Phil Roche ]
* Removed HWCLOCKACCESS=no from /etc/default/rcS (LP: #1581044)

1414. By Louis Zuckerman

[ Louis Zuckerman ]
* Fixes for vagrant box builder in ubuntu-cpc LP: #1565985
* Remove extra packages added on 24 Jun 2016 except virtualbox-guest stuff
* Add cloud-init config to manage /etc/hosts for localhost

1415. By Louis Zuckerman

fixed changelog

1416. By Louis Zuckerman

fix changelog

1417. By Louis Zuckerman

clean up changelog

Revision history for this message
Dan Watkins (oddbloke) wrote :

I've started the process of building a test box now (which, unfortunately, I probably won't complete before I have to head out this (BST) evening).

One thought: could we restore u to the hashbang and then just wrap the offending line in `set +u; ...; set -u`?

Revision history for this message
Louis Zuckerman (semiosis) wrote :

> One thought: could we restore u to the hashbang and then just wrap the
> offending line in `set +u; ...; set -u`?

The offending line in clean_loops is in the functions file. If we have to change that, wouldn't it be better to use ${var-} instead of ${var} like I mentioned earlier? That seems closer to the intention of the code, which wants to know if a variable contains a path or not.

http://bazaar.launchpad.net/~ubuntu-core-dev/livecd-rootfs/trunk/view/head:/live-build/ubuntu-cpc/functions#L15

I may not be catching your suggestion, since I'm not a bash expert. If the above isn't the offending line you have in mind then please help me understand better.

1418. By Louis Zuckerman

update changelog: Add cloud-init config to manage /etc/hosts LP: #1561250

1419. By Louis Zuckerman

remove comment from vagrant script

Revision history for this message
Louis Zuckerman (semiosis) wrote :

Just realized I forgot to point out where the new changed file goes! See below...

> # Now we can have live-build set up the workspace
>
> lb config
>

After running the `lb config` command above you'll have a /build/config directory. Replace /build/config/hooks/042-vagrant.binary with the version in this branch. Then continue on to run `lb build`.

Revision history for this message
Dan Watkins (oddbloke) :
review: Approve
Revision history for this message
Steve Langasek (vorlon) wrote :

Questions inline.

review: Needs Fixing
1420. By Louis Zuckerman

updated per Steve Langasek's feedback:
- put umount in trap
- wrap comment lines at 78 chars
- remove unnecessary DEBIAN_FRONTENT env var from apt-get lines

Revision history for this message
Patricia Gaughen (gaughen) :
Revision history for this message
Dan Watkins (oddbloke) :
Revision history for this message
Adam Conrad (adconrad) wrote :

Surely, virtualbox-guest-dkms isn't necessary if you're installing an Ubuntu kernel, which has the modules built in.

Revision history for this message
Adam Conrad (adconrad) wrote :

$ apt-cache show linux-image-$(uname -r) | grep ^Provides
Provides: fuse-module, ivtv-modules, kvm-api-4, linux-image, redhat-cluster-modules, spl-dkms, virtualbox-guest-modules, zfs-dkms

1421. By Louis Zuckerman

remove unnecessary virtualbox-guest-dkms package from vagrant image builder

Revision history for this message
Louis Zuckerman (semiosis) wrote :

Removed virtualbox-guest-dkms from the vagrant builder. Now the *only* extra package added to the vagrant box is virtualbox-guest-utils.

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

On Thu, Jul 21, 2016 at 10:52:49AM -0000, Dan Watkins wrote:

> > === modified file 'live-build/ubuntu-cpc/hooks/042-vagrant.binary'
> > --- live-build/ubuntu-cpc/hooks/042-vagrant.binary 2016-06-09 09:47:25 +0000
> > +++ live-build/ubuntu-cpc/hooks/042-vagrant.binary 2016-07-07 13:22:31 +0000
> > @@ -70,6 +78,7 @@
> > password: ${ubuntu_user_pass}
> > chpasswd: { expire: False }
> > ssh_pwauth: True
> > +manage_etc_hosts: localhost

> OK, I've finally had time to dig in to this. We don't actually create
> user-data in 999-cpc-fixes.chroot in the general case; it's created in
> fake_cloud_init which is only called when we're creating a Raspberry Pi
> image.

Oh, of course! Sorry :)

> We _could_ investigate applying this more generally, but I think it's
> appropriate for this to be a Vagrant-only fix until such a time as we can
> investigate more fully.

Ok, fine by me.

The only remaining issue I see with this merge is that one of my earlier
review comments seems to have been misunderstood; there's still an
invocation of apt-get that's using --no-install-recommends, which I think
needs to be accounted for. Louis, you dropped the use of
DEBIAN_FRONTEND=noninteractive, which was not my concern; that should be a
no-op at this level because you shouldn't need to set it in an individual
script, but it doesn't hurt anything. The real issue is using
--no-install-recommends. I've reviewed the Recommends of
virtualbox-guest-utils, and see that it has a (reasonable by default)
Recommends: on virtualbox-guest-x11, which we definitely do not want pulled
in to our cloud image.

So this use of --no-install-recommends is appropriate, and I will include a
comment in the script when merging to this effect.

Revision history for this message
Louis Zuckerman (semiosis) wrote :

Steve, I just saw your last comment. I addressed the recommends issue in an earlier comment but I guess it got lost among all the changes I pushed. You're right, we need --no-install-recommends so that we don't pull in X11.

Thanks!

Revision history for this message
Louis Zuckerman (semiosis) wrote :

Oh ok, I now see that my comments weren't saved. I'll try to save them now. Better late than never, right?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2016-07-21 08:11:04 +0000
+++ debian/changelog 2016-07-21 13:25:32 +0000
@@ -1,4 +1,19 @@
1<<<<<<< TREE
1livecd-rootfs (2.420) yakkety; urgency=medium2livecd-rootfs (2.420) yakkety; urgency=medium
3=======
4livecd-rootfs (2.420ubuntu1) UNRELEASED; urgency=medium
5
6 [ Louis Zuckerman ]
7 * Fixes for vagrant box builder in ubuntu-cpc LP: #1565985
8 - Install virtualbox-guest-utils & virtualbox-guest-dkms
9 - Don't disable default synced folder
10 - Don't set vm name
11 - Add cloud-init config to manage /etc/hosts LP: #1561250
12
13 -- Louis Zuckerman <me@louiszuckerman.com> Wed, 06 Jul 2016 09:51:20 -0400
14
15livecd-rootfs (2.420) UNRELEASED; urgency=medium
16>>>>>>> MERGE-SOURCE
217
3 [ Łukasz 'sil2100' Zemczak ]18 [ Łukasz 'sil2100' Zemczak ]
4 * Remove the ubuntu-pd project from the scripts19 * Remove the ubuntu-pd project from the scripts
520
=== modified file 'live-build/ubuntu-cpc/hooks/042-vagrant.binary'
--- live-build/ubuntu-cpc/hooks/042-vagrant.binary 2016-06-09 09:47:25 +0000
+++ live-build/ubuntu-cpc/hooks/042-vagrant.binary 2016-07-21 13:25:32 +0000
@@ -1,22 +1,23 @@
1#!/bin/bash -eux1#!/bin/bash -ex
2# vi: ts=4 noexpandtab2# vi: ts=4 noexpandtab
3#3#
4# Generate a generic Vagrant Box.4# Generate a generic Vagrant Box.
5#5#
6# Vagrant images are essentially nothing more than OVA's with extra-metadata.6# Vagrant images are essentially nothing more than OVA's with extra-metadata
7#7# and some preinstalled packages.
8# We can't use the OVA's for Vagrant since Vagrant uses SSH to modify the instance.8#
9# This build step creates a cloud-config ISO so that Cloud-Init will configure9# We can't use the OVA's for Vagrant since Vagrant uses SSH to modify the
10# the initial user, creates meta-data that tells Vagrant how to interact with10# instance. This build step creates a cloud-config ISO so that Cloud-Init
11# the cloud-init created users, and finally create the OVA.11# will configure the initial user, creates meta-data that tells Vagrant how
12#12# to interact with the cloud-init created users, and finally create the OVA.
13# For this step, we re-use the VMDK's made in 040-vmdk-image.binary13#
14# For this step, we make a deriviative of binary/boot/disk.ext4 and install
15# some packages in it, convert it to a vmdk, and then assemble the vagrant
16# box.
1417
15cur_d=${PWD}18cur_d=${PWD}
16my_d=$(dirname $(readlink -f ${0}))19my_d=$(dirname $(readlink -f ${0}))
1720
18base_vmdk="livecd.ubuntu-cpc.vmdk"
19
20case $ARCH in21case $ARCH in
21 amd64|i386) ;;22 amd64|i386) ;;
22 *)23 *)
@@ -24,11 +25,6 @@
24 exit 025 exit 0
25esac26esac
2627
27if [ ! -e ${base_vmdk} ]; then
28 echo "Did not find VMDK to produce Vagrant images."
29 exit 0
30fi
31
32. /build/config/functions28. /build/config/functions
3329
34# Virtualbox is needed for making a small VMDK30# Virtualbox is needed for making a small VMDK
@@ -37,7 +33,20 @@
37# Lets be safe about this33# Lets be safe about this
38box_d=$(mktemp -d)34box_d=$(mktemp -d)
39seed_d=$(mktemp -d)35seed_d=$(mktemp -d)
40trap "rm -rf ${box_d} ${seed_d}" EXIT36mount_d=$(mktemp -d)
37
38create_derivative "disk" "vagrant" #sets ${derivative_img}
39mount_disk_image ${derivative_img} ${mount_d}
40
41cleanup_vagrant() {
42 umount_disk_image ${mount_d}
43 rm -rf ${box_d} ${seed_d} ${mount_d} ${derivative_img}
44}
45trap cleanup_vagrant EXIT
46
47chroot ${mount_d} apt-get update
48chroot ${mount_d} apt-get install --no-install-recommends -y virtualbox-guest-utils
49chroot ${mount_d} apt-get clean
4150
42# Used to identify bits51# Used to identify bits
43suite=$(chroot chroot lsb_release -c -s)52suite=$(chroot chroot lsb_release -c -s)
@@ -47,7 +56,7 @@
47# Get the VMDK in place56# Get the VMDK in place
48prefix="${distro}-${suite}-${version}-cloudimg"57prefix="${distro}-${suite}-${version}-cloudimg"
49vmdk_f="${box_d}/${prefix}.vmdk"58vmdk_f="${box_d}/${prefix}.vmdk"
50cp ${base_vmdk} ${vmdk_f}59create_vmdk ${derivative_img} ${vmdk_f}
5160
52# Vagrant needs a base user. We either inject the well-known SSH key61# Vagrant needs a base user. We either inject the well-known SSH key
53# or use password authentication. Both are ugly. So we'll use a password62# or use password authentication. Both are ugly. So we'll use a password
@@ -70,6 +79,7 @@
70password: ${ubuntu_user_pass}79password: ${ubuntu_user_pass}
71chpasswd: { expire: False }80chpasswd: { expire: False }
72ssh_pwauth: True81ssh_pwauth: True
82manage_etc_hosts: localhost
73END83END
7484
75# Create the fake meta-data85# Create the fake meta-data
@@ -111,15 +121,11 @@
111 config.vm.base_mac = "${macaddr}"121 config.vm.base_mac = "${macaddr}"
112 config.ssh.username = "ubuntu"122 config.ssh.username = "ubuntu"
113 config.ssh.password = "${ubuntu_user_pass}"123 config.ssh.password = "${ubuntu_user_pass}"
114 config.vm.synced_folder '.', '/vagrant', disabled: true
115124
116 config.vm.provider "virtualbox" do |vb|125 config.vm.provider "virtualbox" do |vb|
117 vb.name = "${prefix}"
118 vb.customize [ "modifyvm", :id, "--uart1", "0x3F8", "4" ]126 vb.customize [ "modifyvm", :id, "--uart1", "0x3F8", "4" ]
119 vb.customize [ "modifyvm", :id, "--uartmode1", "file", File.join(Dir.pwd, "%s-console.log" % vb.name) ]127 vb.customize [ "modifyvm", :id, "--uartmode1", "file", File.join(Dir.pwd, "${prefix}-console.log") ]
120 end128 end
121
122
123end129end
124EOF130EOF
125131
@@ -151,10 +157,10 @@
151serial_stamp=$(date +%Y%m%d)157serial_stamp=$(date +%Y%m%d)
152sed -i "${ovf}" \158sed -i "${ovf}" \
153 -e "s/@@NAME@@/${prefix}-${serial_stamp}/g" \159 -e "s/@@NAME@@/${prefix}-${serial_stamp}/g" \
154 -e "s/@@FILENAME1@@/${vmdk_f##*/}/g" \160 -e "s/@@FILENAME1@@/${vmdk_f##*/}/g" \
155 -e "s/@@VMDK_FILE_SIZE@@/${vmdk_size}/g" \161 -e "s/@@VMDK_FILE_SIZE@@/${vmdk_size}/g" \
156 -e "s/@@VMDK_CAPACITY@@/${vmdk_capacity}/g" \162 -e "s/@@VMDK_CAPACITY@@/${vmdk_capacity}/g" \
157 -e "s/@@FILENAME2@@/${cdrom_vmdk_f##*/}/g" \163 -e "s/@@FILENAME2@@/${cdrom_vmdk_f##*/}/g" \
158 -e "s/@@VMDK_FILE_SIZE2@@/${cdrom_size}/g" \164 -e "s/@@VMDK_FILE_SIZE2@@/${cdrom_size}/g" \
159 -e "s/@@VMDK_CAPACITY2@@/${cdrom_capacity}/g" \165 -e "s/@@VMDK_CAPACITY2@@/${cdrom_capacity}/g" \
160 -e "s/@@NUM_CPUS@@/2/g" \166 -e "s/@@NUM_CPUS@@/2/g" \
@@ -181,16 +187,16 @@
181 VMDK Name: ${vmdk_f##*/}187 VMDK Name: ${vmdk_f##*/}
182 VMDK Capacity: ${vmdk_capacity}188 VMDK Capacity: ${vmdk_capacity}
183 VMDK SHA256: ${vmdk_sha256}189 VMDK SHA256: ${vmdk_sha256}
184 CDROM Name: ${cdrom_vmdk_f##*/}190 CDROM Name: ${cdrom_vmdk_f##*/}
185 CDROM Capacity: ${cdrom_capacity}191 CDROM Capacity: ${cdrom_capacity}
186 CDROM SHA256: ${cdrom_sha256}192 CDROM SHA256: ${cdrom_sha256}
187EOM193EOM
188194
189tar -C ${box_d} \195tar -C ${box_d} \
190 -cf ${cur_d}/livecd.ubuntu-cpc.vagrant.box \196 -cf ${cur_d}/livecd.ubuntu-cpc.vagrant.box \
191 box.ovf \197 box.ovf \
192 Vagrantfile \198 Vagrantfile \
193 metadata.json \199 metadata.json \
194 ${prefix}.mf \200 ${prefix}.mf \
195 ${vmdk_f##*/} \201 ${vmdk_f##*/} \
196 ${cdrom_vmdk_f##*/}202 ${cdrom_vmdk_f##*/}

Subscribers

People subscribed via source and target branches