Merge lp:~ubuntu-on-ec2/livecd-rootfs/cpc into lp:livecd-rootfs

Proposed by Dan Watkins
Status: Rejected
Rejected by: Steve Langasek
Proposed branch: lp:~ubuntu-on-ec2/livecd-rootfs/cpc
Merge into: lp:livecd-rootfs
Diff against target: 665 lines (+538/-4) (has conflicts)
14 files modified
live-build/auto/build (+12/-0)
live-build/auto/config (+42/-4)
live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot (+52/-0)
live-build/ubuntu-cpc/hooks/020-pkg-configure.chroot (+28/-0)
live-build/ubuntu-cpc/hooks/025-create-groups.chroot (+14/-0)
live-build/ubuntu-cpc/hooks/051-hwclock.chroot (+3/-0)
live-build/ubuntu-cpc/hooks/052-ssh_authentication.chroot (+3/-0)
live-build/ubuntu-cpc/hooks/060-ipv6.chroot (+18/-0)
live-build/ubuntu-cpc/hooks/099-cleanup.chroot (+57/-0)
live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot (+281/-0)
live-build/ubuntu-cpc/includes.chroot/etc/hostname (+1/-0)
live-build/ubuntu-cpc/includes.chroot/etc/hosts (+9/-0)
live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces (+15/-0)
live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces.d/eth0.cfg (+3/-0)
Conflict adding file live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot.  Moved existing file to live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot.moved.
To merge this branch: bzr merge lp:~ubuntu-on-ec2/livecd-rootfs/cpc
Reviewer Review Type Date Requested Status
Steve Langasek Needs Fixing
Michael Vogt Pending
Review via email: mp+255346@code.launchpad.net

Description of the change

This merge proposal contains the changes required to use livecd-rootfs to build our base cloud images. We are currently using it in a PPA for building the vivid cloud images using the Launchpad buildds.

(Resubmitting because LP seems to have got unhappy about diffs/conflicts)

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) wrote :

This MP still shows a conflict over the live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot file, and wants to move the existing file aside and replace it. Could you please resolve this conflict (probably requires a fresh branch and a new MP)?

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

On 07/04/15 20:58, Steve Langasek wrote:
> This MP still shows a conflict over the live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot file, and wants to move the existing file aside and replace it. Could you please resolve this conflict (probably requires a fresh branch and a new MP)?

Blurgh, sorry. Have opened a new MP for a new branch at
https://code.launchpad.net/~ubuntu-on-ec2/livecd-rootfs/cpc2/+merge/255468.

Unmerged revisions

1106. By Dan Watkins

Don't try to install acpiphp any more (LP: #1430323).

1105. By Dan Watkins

Set ext image options.

1104. By Dan Watkins

Get the right package sets for arm* and ppc64el.

1103. By Dan Watkins

Install the correct kernels on each arch.

1102. By Dan Watkins

Put our fstab in place.

1101. By Dan Watkins

Set the root_fs_label correctly.

1100. By Dan Watkins

Ensure we ship results of apt-get update.

1099. By Dan Watkins

Put correct apt sources in place.

1098. By Dan Watkins

Add hooks and includes.

1097. By Dan Watkins

Add our own hook.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'live-build/auto/build'
2--- live-build/auto/build 2015-03-13 10:13:11 +0000
3+++ live-build/auto/build 2015-04-07 11:57:34 +0000
4@@ -241,6 +241,18 @@
5 mkdir -p chroot/var/log/installer
6 Chroot chroot "ln -s /etc/media-info /var/log/installer/media-info"
7 fi
8+ if [ "$PROJECT" = "ubuntu-cpc" ]; then
9+ cat > chroot/etc/apt/sources.list << EOF
10+deb ${LB_PARENT_MIRROR_BINARY} ${LB_DISTRIBUTION} main restricted universe multiverse
11+deb ${LB_PARENT_MIRROR_BINARY} ${LB_DISTRIBUTION}-updates main restricted universe multiverse
12+deb ${LB_PARENT_MIRROR_BINARY_SECURITY} ${LB_DISTRIBUTION}-security main restricted universe multiverse
13+EOF
14+ lb chroot_hosts install
15+ lb chroot_resolv install
16+ Chroot chroot "apt-get update"
17+ lb chroot_resolv remove
18+ lb chroot_hosts remove
19+ fi
20
21 echo "===== Checking size of /usr/share/doc ====="
22 echo BEGIN docdirs
23
24=== modified file 'live-build/auto/config'
25--- live-build/auto/config 2015-03-25 09:27:51 +0000
26+++ live-build/auto/config 2015-04-07 11:57:34 +0000
27@@ -111,7 +111,13 @@
28 COMPONENTS='main restricted universe multiverse'
29 ;;
30 *)
31- add_package live jasper
32+ case $PROJECT in
33+ ubuntu-cpc)
34+ ;;
35+ *)
36+ add_package live jasper
37+ ;;
38+ esac
39 ;;
40 esac
41 ;;
42@@ -156,7 +162,7 @@
43 ubuntu-server)
44 add_package live oem-config-debconf ubiquity-frontend-debconf
45 ;;
46- ubuntu-core|base|ubuntu-touch)
47+ ubuntu-core|base|ubuntu-touch|ubuntu-cpc)
48 ;;
49 *)
50 add_package live oem-config-gtk ubiquity-frontend-gtk
51@@ -440,6 +446,9 @@
52 esac
53 ;;
54
55+ ubuntu-cpc)
56+ ;;
57+
58 *)
59 echo "unknown project $PROJECT" >&2
60 exit 2
61@@ -523,6 +532,35 @@
62 esac
63 esac
64
65+if [ "$PROJECT" = "ubuntu-cpc" ]; then
66+ BINARY_REMOVE_LINUX=false
67+ OPTS="${OPTS:+$OPTS }--linux-packages=none --initramfs=none"
68+ KERNEL_FLAVOURS=none
69+ case $ARCH in
70+ armhf)
71+ add_package install flash-kernel linux-generic-lpae
72+ add_task install server
73+ ;;
74+ arm64)
75+ add_package install flash-kernel linux-generic
76+ add_task install server
77+ ;;
78+ ppc64el)
79+ add_package install linux-virtual
80+ add_task install server
81+ ;;
82+ *)
83+ add_package install linux-virtual
84+ ;;
85+ esac
86+ OPTS="${OPTS:+$OPTS }--system=normal"
87+ OPTS="${OPTS:+$OPTS }--hdd-label=cloudimg-rootfs"
88+ OPTS="${OPTS:+$OPTS }--ext-resize-blocks=536870912 --ext-block-size=4096"
89+ OPTS="${OPTS:+$OPTS }--ext-fudge-factor=15"
90+ add_task install minimal standard cloud-image
91+ add_package install landscape-client ubuntu-minimal
92+fi
93+
94 add_chroot_hook update-apt-file-cache
95 add_chroot_hook update-apt-xapian-index
96 add_chroot_hook update-mlocate-database
97@@ -531,7 +569,7 @@
98 add_chroot_hook remove-udev-persistent-rules
99
100 case $PROJECT in
101- ubuntu-server)
102+ ubuntu-server|ubuntu-cpc)
103 ;;
104
105 *)
106@@ -622,7 +660,7 @@
107 fi
108 ;;
109
110- ubuntu-touch:*|ubuntu-core:system-image)
111+ ubuntu-touch:*|ubuntu-core:system-image|ubuntu-cpc:*)
112 cp -af /usr/share/livecd-rootfs/live-build/${PROJECT}/* \
113 config/
114 ;;
115
116=== added file 'live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot'
117--- live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot 1970-01-01 00:00:00 +0000
118+++ live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot 2015-04-07 11:57:34 +0000
119@@ -0,0 +1,52 @@
120+#!/bin/sh -eu
121+
122+ERRCNT=""
123+
124+passwd_hash=$(set -- $(md5sum /etc/passwd) && echo $1)
125+shadow_hash=$(set -- $(cat /etc/shadow | sed "s/:.*:0:99999:/:0:99999:/g" | md5sum) && echo $1)
126+group_length=$(cat /etc/group | wc -l)
127+gshadow_length=$(cat /etc/gshadow | wc -l)
128+
129+passwd_orig_hash=$(set -- $(md5sum /etc/passwd.orig) && echo $1)
130+shadow_orig_hash=$(set -- $(cat /etc/shadow.orig | sed "s/:.*:0:99999:/:0:99999:/g" | md5sum) && echo $1)
131+group_orig_length=$(cat /etc/group.orig | wc -l)
132+gshadow_orig_length=$(cat /etc/gshadow.orig | wc -l)
133+
134+if [ "$passwd_hash" != "$passwd_orig_hash" ]; then
135+ echo "/etc/passwd has changed during setup." >&2
136+ echo "The new /etc/passwd md5sum is: $passwd_hash" >&2
137+ diff -Nrup /etc/passwd.orig /etc/passwd >&2 || true
138+ ERRCNT=1
139+fi
140+
141+if [ "$shadow_hash" != "$shadow_orig_hash" ]; then
142+ echo "/etc/shadow has changed during setup." >&2
143+ echo "The new /etc/shadow md5sum is: $shadow_hash" >&2
144+ diff -Nrup /etc/shadow.orig /etc/shadow >&2 || true
145+ ERRCNT=1
146+fi
147+
148+if [ "$group_length" != "$group_orig_length" ]; then
149+ echo "/etc/group has changed during setup." >&2
150+ diff -Nrup /etc/group.orig /etc/group >&2 || true
151+ ERRCNT=1
152+fi
153+
154+if [ "$gshadow_length" != "$gshadow_orig_length" ]; then
155+ echo "/etc/gshadow has changed during setup." >&2
156+ diff -Nrup /etc/gshadow.orig /etc/gshadow >&2 || true
157+ ERRCNT=1
158+fi
159+
160+if [ -n "$ERRCNT" ]; then
161+ echo "There were changes to the password database," >&2
162+ echo "please adjust the values in the livecd-rootfs source in the file:" >&2
163+ echo "live-build/ubuntu-core/hooks/00-uid-gid-fix.chroot_early" >&2
164+ echo >&2
165+ echo "Please check also if a maintainer script of the package" >&2
166+ echo "that added these entries perhaps created a home directory and," >&2
167+ echo "if needed, add code for creation of it to the above hook" >&2
168+ exit 1
169+fi
170+
171+rm /etc/passwd.orig /etc/shadow.orig /etc/group.orig /etc/gshadow.orig
172
173=== renamed file 'live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot' => 'live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot.moved'
174=== added directory 'live-build/ubuntu-cpc'
175=== added directory 'live-build/ubuntu-cpc/hooks'
176=== added file 'live-build/ubuntu-cpc/hooks/020-pkg-configure.chroot'
177--- live-build/ubuntu-cpc/hooks/020-pkg-configure.chroot 1970-01-01 00:00:00 +0000
178+++ live-build/ubuntu-cpc/hooks/020-pkg-configure.chroot 2015-04-07 11:57:34 +0000
179@@ -0,0 +1,28 @@
180+#!/bin/bash
181+# Configure certain packages
182+
183+## console-setup
184+
185+# Select the fontface
186+printf "%s\t%s\t%s\t%s\n" \
187+ console-setup console-setup/console-setup/fontface47 string "Fixed" debconf-set-selections ||
188+ { echo "FAILED to setup console fontface"; exit 1; }
189+
190+# Select the code page for font
191+printf "%s\t%s\t%s\t%s\n" \
192+ console-setup console-setup/codesetcode string "Uni2" | debconf-set-selections ||
193+ { echo "FAILED to setup console code page to Uni2"; exit 1; }
194+
195+# Set Language string for codepage 47
196+printf "%s\t%s\t%s\t%s\n" \
197+ console-setup console-setup/codeset47 string ". Combined - Latin; Slavic Cyrillic; Greek" | debconf-set-selections ||
198+ { echo "FAILED to setup codeset47 to proper string"; exti 1; }
199+
200+# Replace the console font and typ ein /etc/default/console-setup
201+sed -i -e 's,^CODESET.*,CODESET="Uni2",g' \
202+ -e 's,^FONTFACE.*,FONTFACE="Fixed",g' \
203+ /etc/default/console-setup
204+
205+# Configure the console-setup
206+dpkg-reconfigure --frontend=noninteractive console-setup ||
207+ { echo "FAILED to recofigure console-setup"; exit 1; }
208
209=== added file 'live-build/ubuntu-cpc/hooks/025-create-groups.chroot'
210--- live-build/ubuntu-cpc/hooks/025-create-groups.chroot 1970-01-01 00:00:00 +0000
211+++ live-build/ubuntu-cpc/hooks/025-create-groups.chroot 2015-04-07 11:57:34 +0000
212@@ -0,0 +1,14 @@
213+#!/bin/bash
214+#
215+# Create the necessary users and set their passwords. If needed,
216+# make sure they belong to the proper groups
217+#
218+# Author: Ben Howard <ben.howard@canonical.com>
219+# Date: 29 Jun 2011
220+#
221+
222+echo "Adding admin group..."
223+addgroup --system --quiet admin
224+
225+echo "Adding netdev group..."
226+addgroup --system --quiet netdev
227
228=== added file 'live-build/ubuntu-cpc/hooks/051-hwclock.chroot'
229--- live-build/ubuntu-cpc/hooks/051-hwclock.chroot 1970-01-01 00:00:00 +0000
230+++ live-build/ubuntu-cpc/hooks/051-hwclock.chroot 2015-04-07 11:57:34 +0000
231@@ -0,0 +1,3 @@
232+#!/bin/bash
233+
234+printf "HWCLOCKACCESS=no" >> /etc/default/rcS
235
236=== added file 'live-build/ubuntu-cpc/hooks/052-ssh_authentication.chroot'
237--- live-build/ubuntu-cpc/hooks/052-ssh_authentication.chroot 1970-01-01 00:00:00 +0000
238+++ live-build/ubuntu-cpc/hooks/052-ssh_authentication.chroot 2015-04-07 11:57:34 +0000
239@@ -0,0 +1,3 @@
240+#!/bin/bash
241+
242+sed -i "s|#PasswordAuthentication yes|PasswordAuthentication no|g" /etc/ssh/sshd_config
243
244=== added file 'live-build/ubuntu-cpc/hooks/060-ipv6.chroot'
245--- live-build/ubuntu-cpc/hooks/060-ipv6.chroot 1970-01-01 00:00:00 +0000
246+++ live-build/ubuntu-cpc/hooks/060-ipv6.chroot 2015-04-07 11:57:34 +0000
247@@ -0,0 +1,18 @@
248+#!/bin/bash
249+#
250+# Disable IPv6 privacy extensions on Utopic and later
251+#
252+
253+codename=$(sh -c 'lsb_release --short --codename')
254+dist_ge() { [[ "$1" > "$2" || "$1" == "$2" ]]; }
255+
256+if ! dist_ge "${codename}" "trusty"; then
257+ exit 0
258+fi
259+
260+cat << EOF > /etc/sysctl.d/99-cloudimg-ipv6.conf
261+# Written by the Cloud Image build process
262+# See https://bugs.launchpad.net/ubuntu/+source/procps/+bug/1068756
263+net.ipv6.conf.all.use_tempaddr = 0
264+net.ipv6.conf.default.use_tempaddr = 0
265+EOF
266
267=== added file 'live-build/ubuntu-cpc/hooks/099-cleanup.chroot'
268--- live-build/ubuntu-cpc/hooks/099-cleanup.chroot 1970-01-01 00:00:00 +0000
269+++ live-build/ubuntu-cpc/hooks/099-cleanup.chroot 2015-04-07 11:57:34 +0000
270@@ -0,0 +1,57 @@
271+#!/bin/bash
272+
273+# Clean up extraneous log files that may be left around
274+rm /etc/ssh/ssh_host*key* || echo "No SSH keys to remove"
275+
276+# Fix LP: #1047707, 1019338
277+# Truncate logs that are owned, otherwise remove
278+whitelisted_logs=(/var/log/btmp /var/log/lastlog /var/log/wtmp /var/log/fsck/checkfs /var/log/fsck/checkroot)
279+
280+for log in $(find /var/log -type f)
281+do
282+ whitelisted=$(echo "${whitelisted_logs[@]}" | grep -o ${log})
283+
284+ if [ -n "${whitelisted}" ]; then
285+ : > ${log} &&
286+ echo "Truncated whitelisted log ${log}" ||
287+ echo "Failed to truncate whitelisted log ${log}"
288+ else
289+
290+ dpkg -S ${log} > /dev/null 2>&1 &&
291+ { : > ${log} ||
292+ echo "Failed to truncate $f"; } ||
293+ { rm ${log} &&
294+ echo "Removed ${log} as an orphaned log file" ||
295+ echo "Failed to remove unnecessary log $f"; }
296+ fi
297+done
298+
299+# Remove un-owned log directories
300+whitelisted_dirs=(/var/log/fsck)
301+
302+for log_d in $(find /var/log/* -type d)
303+do
304+ whitelisted=$(echo "${whitelisted_dirs[@]}" | grep -o "${log_d}")
305+ if [ -z "${whitelisted}" ]; then
306+ dpkg -S ${log_d} > /dev/null 2>&1 &&
307+ echo "Preserving log directory ${log_d}" ||
308+ { rm -rf ${log_d} &&
309+ echo "Removed log directory ${log_d} as orphaned log dir" ||
310+ echo "Failed to remove unnessasary log dir ${log_d}"; }
311+
312+ else
313+ echo "Preserving whitelisted directory ${log_d}"
314+ fi
315+
316+done
317+
318+
319+rm -rf /var/run/* || echo "Failed to clean /var/run/*"
320+rm /etc/passwd- || echo "No spare passwd file to cleanup"
321+rm /etc/shadow- || echo "No spare shadow file to cleanup"
322+rm /etc/gshadow- || echo "No spare gshadow file to cleanup"
323+rm /etc/group- || echo "No spare group file to clenaup"
324+rm -f /etc/apt/conf.d/00secure || echo "No apt cache to cleanup"
325+
326+# Truncate instead of delete, LP: #707311
327+truncate --size=0 -c /etc/popularity-contest.conf
328
329=== added file 'live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot'
330--- live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot 1970-01-01 00:00:00 +0000
331+++ live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot 2015-04-07 11:57:34 +0000
332@@ -0,0 +1,281 @@
333+#!/bin/bash
334+rootd="${1:-/}"
335+root_fs_label=cloudimg-rootfs
336+set -ex
337+
338+CLOUD_IMG_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process"
339+
340+LANG=C
341+
342+_xchroot() {
343+ # Prevent multiple chroots
344+ if [ "$1" = "/" ]; then
345+ shift;
346+ "$@"
347+ else
348+ chroot "$@"
349+ fi
350+}
351+
352+#### COMMON architecture independent functions
353+arch=$(_xchroot "${rootd}" dpkg --print-architecture)
354+
355+add_serial_console() {
356+ condev=$1
357+ idir="$rootd/etc/init"
358+ cat << EOF > "${idir}/${condev}.conf"
359+# CONDEV - getty
360+#
361+# This service maintains a getty on CONDEV from the point the system is
362+# started until it is shut down again.
363+
364+start on stopped rc RUNLEVEL=[2345] and (
365+ not-container or
366+ container CONTAINER=lxc or
367+ container CONTAINER=lxc-libvirt)
368+
369+stop on runlevel [!2345]
370+
371+pre-start script
372+ # getty will not be started if the serial console is not present
373+ stty -F /dev/CONDEV -a 2> /dev/null > /dev/null || { stop ; exit 0; }
374+end script
375+
376+respawn
377+script
378+ exec /sbin/getty -L CONDEV 115200 vt102
379+end script
380+${CLOUD_IMG_STR}
381+EOF
382+ sed -i "s/CONDEV/${condev}/g" "$idir/${condev}.conf"
383+}
384+
385+## --------------
386+# remove 127.0.1.1 entry (LP: #440757)
387+_xchroot "${rootd}" sh -c 'sed -i "/^127.0.1.1/d" /etc/hosts'
388+
389+## --------------
390+# remove ssh pregenerated keys (LP: #512377)
391+
392+_xchroot "${rootd}" sh -c 'rm -f /etc/ssh/ssh_host_[rd]sa_key*'
393+
394+## --------------
395+_xchroot "${rootd}" locale-gen en_US.utf8
396+
397+## --------------
398+# set cloud-init to be on
399+values="NoCloud, ConfigDrive, AltCloud, OVF, MAAS, Ec2, None"
400+printf "%s\t%s\t%s\t%s\n" \
401+ cloud-init cloud-init/datasources multiselect "$values" |
402+ _xchroot "${rootd}" debconf-set-selections
403+_xchroot "${rootd}" dpkg-reconfigure --frontend=noninteractive cloud-init
404+
405+## --------------
406+# write some build information to the guest
407+# the idea is that given runtime info and this info, the instance
408+# can at least determine if there is a newer build available
409+# these variables are passed in in environment from cloudimg-build-launcher
410+if [ -n "${build_name}" -o -n "${serial}" ]; then
411+ d="${rootd}/etc/cloud"
412+ [ -d "$d" ] || mkdir -p "${d}"
413+ {
414+ [ -n "${build_name}" ] && echo "build_name: ${build_name}"
415+ [ -n "${serial}" ] && echo "serial: ${serial}"
416+ } > "$d/build.info"
417+fi
418+
419+## --------------
420+# for maverick and newer, use LABEL= for the '/' entry in fstab
421+if [ -n "${root_fs_label}" ]; then
422+ bl="[:blank:]"
423+ lstr="LABEL=${root_fs_label}"
424+ sed -i "s,^[^#${bl}]*\([${bl}]*/[${bl}].*\),${lstr}\1," "${rootd}/etc/fstab"
425+fi
426+cat > /etc/fstab << EOM
427+LABEL=cloudimg-rootfs / ext4 defaults 0 0
428+EOM
429+
430+## Make sure that the update-motd.d directory exists
431+[ ! -e "${rootd}/etc/update-motd.d" ] &&
432+ mkdir -p "${rootd}/etc/update-motd.d"
433+
434+## write a MOTD file advertising support for images
435+cat > "${rootd}/etc/update-motd.d/51-cloudguest" << EOF
436+#!/bin/sh
437+#
438+${CLOUD_IMG_STR}
439+# This file is not managed by a package. If you no longer want to
440+# see this message you can safely remove the file.
441+echo ""
442+echo " Get cloud support with Ubuntu Advantage Cloud Guest:"
443+echo " http://www.ubuntu.com/business/services/cloud"
444+EOF
445+
446+chmod +x "${rootd}/etc/update-motd.d/51-cloudguest"
447+
448+# for quantal and newer, add /etc/overlayroot.local.conf
449+# but do not overwrite anything that somehow got there
450+if [ -f "${rootd}/etc/overlayroot.conf" ] &&
451+ [ ! -f "${rootd}/etc/overlayroot.local.conf" ]; then
452+ {
453+ echo "${CLOUD_IMG_STR}"
454+ echo "overlayroot_cfgdisk=LABEL=OROOTCFG"
455+ } > "${rootd}/etc/overlayroot.local.conf"
456+fi
457+
458+
459+#### END COMMON ARCH FUNCTIONS
460+
461+if [ "$arch" = "ppc64el" ]; then
462+ add_serial_console hvc0
463+ exit 0
464+fi
465+
466+# ARM images are special
467+if [[ "$arch" =~ (arm|arm64|aarch64) ]]; then
468+
469+ echo "Configuring ARM Serial Port"
470+ add_serial_console ttyAMA0
471+
472+ echo "Image architecture is ARM. Existing vmbuilder-fixups"
473+
474+ exit 0
475+fi
476+
477+## Add ttyS0 for i386/amd64 for Trusty and newer
478+if [ "$arch" = "i386" -o "$arch" = "amd64" ]; then
479+ add_serial_console ttyS0
480+fi
481+
482+
483+psuedo_grub_probe() {
484+ cat <<"PSUEDO_GRUB_PROBE"
485+#!/bin/sh
486+Usage() {
487+ cat <<EOF
488+Usage: euca-psuedo-grub-probe
489+ this is a wrapper around grub-probe to provide the answers for an ec2 guest
490+EOF
491+}
492+bad_Usage() { Usage 1>&2; fail "$@"; }
493+
494+short_opts=""
495+long_opts="device-map:,target:,device"
496+getopt_out=$(getopt --name "${0##*/}" \
497+ --options "${short_opts}" --long "${long_opts}" -- "$@") &&
498+ eval set -- "${getopt_out}" ||
499+ bad_Usage
500+
501+device_map=""
502+target=""
503+device=0
504+arg=""
505+
506+while [ $# -ne 0 ]; do
507+ cur=${1}; next=${2};
508+ case "$cur" in
509+ --device-map) device_map=${next}; shift;;
510+ --device) device=1;;
511+ --target) target=${next}; shift;;
512+ --) shift; break;;
513+ esac
514+ shift;
515+done
516+arg=${1}
517+
518+case "${target}:${device}:${arg}" in
519+ device:*:/*) echo "/dev/sda1"; exit 0;;
520+ fs:*:*) echo "ext2"; exit 0;;
521+ partmap:*:*)
522+ # older versions of grub (lucid) want 'part_msdos' written
523+ # rather than 'msdos'
524+ legacy_pre=""
525+ grubver=$(dpkg-query --show --showformat '${Version}\n' grub-pc 2>/dev/null) &&
526+ dpkg --compare-versions "${grubver}" lt 1.98+20100804-5ubuntu3 &&
527+ legacy_pre="part_"
528+ echo "${legacy_pre}msdos";
529+ exit 0;;
530+ abstraction:*:*) echo ""; exit 0;;
531+ drive:*:/dev/sda) echo "(hd0)";;
532+ drive:*:/dev/sda*) echo "(hd0,1)";;
533+ fs_uuid:*:*) exit 1;;
534+esac
535+PSUEDO_GRUB_PROBE
536+}
537+
538+## install / setup grub2
539+gprobe="${rootd}/usr/sbin/grub-probe"
540+moved=0
541+if [ -f "${gprobe}" ]; then
542+ mv "${gprobe}" "${gprobe}.dist"
543+ moved=1
544+fi
545+psuedo_grub_probe > "${gprobe}"
546+chmod 755 "${gprobe}"
547+
548+# for Quantal and later, use /etc/default/grub.d functionality
549+# rather than modifying the grub configuration itself.
550+# This avoids the mess of having to do dpkg stuff
551+# LP: 1179940
552+mkdir -p "${rootd}/etc/default/grub.d"
553+cat << EOF > "${rootd}/etc/default/grub.d/50-cloudimg-settings.cfg"
554+# Cloud Image specific Grub settings for Generic Cloud Images
555+${CLOUD_IMG_STR}
556+
557+# Set the recordfail timeout
558+GRUB_RECORDFAIL_TIMEOUT=0
559+
560+# Do not wait on grub prompt
561+GRUB_TIMEOUT=0
562+
563+# Set the default commandline
564+GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0"
565+
566+# Set the grub console type
567+GRUB_TERMINAL=console
568+EOF
569+_xchroot "${rootd}" update-grub2
570+
571+# since this is a disk image, we technically don't need to install all the
572+# grub modules, as the image itself is not bootable. This makes for a small
573+# disk image
574+_xchroot "${rootd}" update-grub
575+
576+# reconfigure grub so that upgrades to grub-pc do not force a debconf config
577+# changed prompt (LP: #1009294). This re-runs update-grub
578+_xchroot "${rootd}" env DEBIAN_FRONTEND=noninteractive \
579+ dpkg-reconfigure grub-pc
580+
581+grub2cfg="${rootd}/boot/grub/grub.cfg"
582+[ ! -f "${grub2cfg}" ] ||
583+ sed -i -e "s,root=/dev/sda1,root=LABEL=${root_fs_label}," "${grub2cfg}"
584+
585+[ ${moved} -eq 0 ] || mv "${gprobe}.dist" "${gprobe}"
586+
587+## modify /boot/grub/menu.lst if it exists
588+## this is generated at install time by grub-legacy-ec2, but will have
589+## devices as found from the _xchroot. Here we write what it will be on ec2
590+if [ -f "${rootd}/boot/grub/menu.lst" ]; then
591+ grub_root="(hd0)"
592+ linux_root=/dev/sda1
593+ [ -n "${root_fs_label}" ] && linux_root="LABEL=${root_fs_label}"
594+ # the sed code below basically fixes/sets the following lines in a
595+ # /boot/grub/menu.lst file:
596+ # # kopt=root=xxxxxxx ro
597+ # kernel /boot/vmlinuz-... root=xxxxxx ....
598+ # # groot=xxxxx
599+ # root xxxxx
600+ # uuuid xxxxx
601+ sed -i "${rootd}/boot/grub/menu.lst" \
602+ -e "s|^\(# kopt=root=\)[^ ]*|\1${linux_root}|" \
603+ -e "s|^\(kernel.*root=\)[^ ]*|\1${linux_root}|" \
604+ -e "s|^\(# groot=\)[^ ]*|\1${grub_root}|" \
605+ -e "s|^\(root\|uuid\)\([[:space:]]*\).*|root\2${grub_root}|"
606+
607+ # grub-legacy-ec2 writes this ucf entry. since we've modified
608+ # /boot/grub/menu.lst, we have to remove it, or the user will
609+ # get prompted for a 3 way merge of the changes the first time this runs
610+ _xchroot "${rootd}" /usr/bin/ucfr --purge grub /var/run/grub/menu.lst
611+fi
612+
613+# vi: ts=3 expandtab
614
615=== added directory 'live-build/ubuntu-cpc/includes.chroot'
616=== added directory 'live-build/ubuntu-cpc/includes.chroot/etc'
617=== added file 'live-build/ubuntu-cpc/includes.chroot/etc/hostname'
618--- live-build/ubuntu-cpc/includes.chroot/etc/hostname 1970-01-01 00:00:00 +0000
619+++ live-build/ubuntu-cpc/includes.chroot/etc/hostname 2015-04-07 11:57:34 +0000
620@@ -0,0 +1,1 @@
621+ubuntu
622
623=== added file 'live-build/ubuntu-cpc/includes.chroot/etc/hosts'
624--- live-build/ubuntu-cpc/includes.chroot/etc/hosts 1970-01-01 00:00:00 +0000
625+++ live-build/ubuntu-cpc/includes.chroot/etc/hosts 2015-04-07 11:57:34 +0000
626@@ -0,0 +1,9 @@
627+127.0.0.1 localhost
628+
629+# The following lines are desirable for IPv6 capable hosts
630+::1 ip6-localhost ip6-loopback
631+fe00::0 ip6-localnet
632+ff00::0 ip6-mcastprefix
633+ff02::1 ip6-allnodes
634+ff02::2 ip6-allrouters
635+ff02::3 ip6-allhosts
636
637=== added directory 'live-build/ubuntu-cpc/includes.chroot/etc/network'
638=== added file 'live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces'
639--- live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces 1970-01-01 00:00:00 +0000
640+++ live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces 2015-04-07 11:57:34 +0000
641@@ -0,0 +1,15 @@
642+# This file describes the network interfaces available on your system
643+# and how to activate them. For more information, see interfaces(5).
644+
645+# The loopback network interface
646+auto lo
647+iface lo inet loopback
648+
649+# Source interfaces
650+# Please check /etc/network/interfaces.d before changing this file
651+# as interfaces may have been defined in /etc/network/interfaces.d
652+# NOTE: the primary ethernet device is defined in
653+# /etc/network/interfaces.d/eth0
654+# See LP: #1262951
655+source /etc/network/interfaces.d/*.cfg
656+
657
658=== added directory 'live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces.d'
659=== added file 'live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces.d/eth0.cfg'
660--- live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces.d/eth0.cfg 1970-01-01 00:00:00 +0000
661+++ live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces.d/eth0.cfg 2015-04-07 11:57:34 +0000
662@@ -0,0 +1,3 @@
663+# The primary network interface
664+auto eth0
665+iface eth0 inet dhcp

Subscribers

People subscribed via source and target branches