Merge lp:~ubuntu-on-ec2/livecd-rootfs/cpc2 into lp:livecd-rootfs
- cpc2
- Merge into trunk
Proposed by
Dan Watkins
Status: | Merged |
---|---|
Merged at revision: | 1096 |
Proposed branch: | lp:~ubuntu-on-ec2/livecd-rootfs/cpc2 |
Merge into: | lp:livecd-rootfs |
Diff against target: |
607 lines (+486/-4) 13 files modified
live-build/auto/build (+12/-0) live-build/auto/config (+42/-4) 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) |
To merge this branch: | bzr merge lp:~ubuntu-on-ec2/livecd-rootfs/cpc2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Vogt (community) | Approve | ||
Steve Langasek | Pending | ||
Review via email: mp+255468@code.launchpad.net |
Commit message
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.
To post a comment you must log in.
- 1095. By Dan Watkins
-
Get an image that looks about right building.
- 1096. By Dan Watkins
-
Get images building without our custom live-build.
- 1097. By Dan Watkins
-
Add our own hook.
- 1098. By Dan Watkins
-
Add hooks and includes.
- 1099. By Dan Watkins
-
Put correct apt sources in place.
- 1100. By Dan Watkins
-
Ensure we ship results of apt-get update.
- 1101. By Dan Watkins
-
Set the root_fs_label correctly.
- 1102. By Dan Watkins
-
Put our fstab in place.
- 1103. By Dan Watkins
-
Install the correct kernels on each arch.
- 1104. By Dan Watkins
-
Get the right package sets for arm* and ppc64el.
- 1105. By Dan Watkins
-
Set ext image options.
- 1106. By Dan Watkins
-
Don't try to install acpiphp any more (LP: #1430323).
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-08 08:34:32 +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-08 08:34:32 +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 directory 'live-build/ubuntu-cpc' |
117 | === added directory 'live-build/ubuntu-cpc/hooks' |
118 | === added file 'live-build/ubuntu-cpc/hooks/020-pkg-configure.chroot' |
119 | --- live-build/ubuntu-cpc/hooks/020-pkg-configure.chroot 1970-01-01 00:00:00 +0000 |
120 | +++ live-build/ubuntu-cpc/hooks/020-pkg-configure.chroot 2015-04-08 08:34:32 +0000 |
121 | @@ -0,0 +1,28 @@ |
122 | +#!/bin/bash |
123 | +# Configure certain packages |
124 | + |
125 | +## console-setup |
126 | + |
127 | +# Select the fontface |
128 | +printf "%s\t%s\t%s\t%s\n" \ |
129 | + console-setup console-setup/console-setup/fontface47 string "Fixed" debconf-set-selections || |
130 | + { echo "FAILED to setup console fontface"; exit 1; } |
131 | + |
132 | +# Select the code page for font |
133 | +printf "%s\t%s\t%s\t%s\n" \ |
134 | + console-setup console-setup/codesetcode string "Uni2" | debconf-set-selections || |
135 | + { echo "FAILED to setup console code page to Uni2"; exit 1; } |
136 | + |
137 | +# Set Language string for codepage 47 |
138 | +printf "%s\t%s\t%s\t%s\n" \ |
139 | + console-setup console-setup/codeset47 string ". Combined - Latin; Slavic Cyrillic; Greek" | debconf-set-selections || |
140 | + { echo "FAILED to setup codeset47 to proper string"; exti 1; } |
141 | + |
142 | +# Replace the console font and typ ein /etc/default/console-setup |
143 | +sed -i -e 's,^CODESET.*,CODESET="Uni2",g' \ |
144 | + -e 's,^FONTFACE.*,FONTFACE="Fixed",g' \ |
145 | + /etc/default/console-setup |
146 | + |
147 | +# Configure the console-setup |
148 | +dpkg-reconfigure --frontend=noninteractive console-setup || |
149 | + { echo "FAILED to recofigure console-setup"; exit 1; } |
150 | |
151 | === added file 'live-build/ubuntu-cpc/hooks/025-create-groups.chroot' |
152 | --- live-build/ubuntu-cpc/hooks/025-create-groups.chroot 1970-01-01 00:00:00 +0000 |
153 | +++ live-build/ubuntu-cpc/hooks/025-create-groups.chroot 2015-04-08 08:34:32 +0000 |
154 | @@ -0,0 +1,14 @@ |
155 | +#!/bin/bash |
156 | +# |
157 | +# Create the necessary users and set their passwords. If needed, |
158 | +# make sure they belong to the proper groups |
159 | +# |
160 | +# Author: Ben Howard <ben.howard@canonical.com> |
161 | +# Date: 29 Jun 2011 |
162 | +# |
163 | + |
164 | +echo "Adding admin group..." |
165 | +addgroup --system --quiet admin |
166 | + |
167 | +echo "Adding netdev group..." |
168 | +addgroup --system --quiet netdev |
169 | |
170 | === added file 'live-build/ubuntu-cpc/hooks/051-hwclock.chroot' |
171 | --- live-build/ubuntu-cpc/hooks/051-hwclock.chroot 1970-01-01 00:00:00 +0000 |
172 | +++ live-build/ubuntu-cpc/hooks/051-hwclock.chroot 2015-04-08 08:34:32 +0000 |
173 | @@ -0,0 +1,3 @@ |
174 | +#!/bin/bash |
175 | + |
176 | +printf "HWCLOCKACCESS=no" >> /etc/default/rcS |
177 | |
178 | === added file 'live-build/ubuntu-cpc/hooks/052-ssh_authentication.chroot' |
179 | --- live-build/ubuntu-cpc/hooks/052-ssh_authentication.chroot 1970-01-01 00:00:00 +0000 |
180 | +++ live-build/ubuntu-cpc/hooks/052-ssh_authentication.chroot 2015-04-08 08:34:32 +0000 |
181 | @@ -0,0 +1,3 @@ |
182 | +#!/bin/bash |
183 | + |
184 | +sed -i "s|#PasswordAuthentication yes|PasswordAuthentication no|g" /etc/ssh/sshd_config |
185 | |
186 | === added file 'live-build/ubuntu-cpc/hooks/060-ipv6.chroot' |
187 | --- live-build/ubuntu-cpc/hooks/060-ipv6.chroot 1970-01-01 00:00:00 +0000 |
188 | +++ live-build/ubuntu-cpc/hooks/060-ipv6.chroot 2015-04-08 08:34:32 +0000 |
189 | @@ -0,0 +1,18 @@ |
190 | +#!/bin/bash |
191 | +# |
192 | +# Disable IPv6 privacy extensions on Utopic and later |
193 | +# |
194 | + |
195 | +codename=$(sh -c 'lsb_release --short --codename') |
196 | +dist_ge() { [[ "$1" > "$2" || "$1" == "$2" ]]; } |
197 | + |
198 | +if ! dist_ge "${codename}" "trusty"; then |
199 | + exit 0 |
200 | +fi |
201 | + |
202 | +cat << EOF > /etc/sysctl.d/99-cloudimg-ipv6.conf |
203 | +# Written by the Cloud Image build process |
204 | +# See https://bugs.launchpad.net/ubuntu/+source/procps/+bug/1068756 |
205 | +net.ipv6.conf.all.use_tempaddr = 0 |
206 | +net.ipv6.conf.default.use_tempaddr = 0 |
207 | +EOF |
208 | |
209 | === added file 'live-build/ubuntu-cpc/hooks/099-cleanup.chroot' |
210 | --- live-build/ubuntu-cpc/hooks/099-cleanup.chroot 1970-01-01 00:00:00 +0000 |
211 | +++ live-build/ubuntu-cpc/hooks/099-cleanup.chroot 2015-04-08 08:34:32 +0000 |
212 | @@ -0,0 +1,57 @@ |
213 | +#!/bin/bash |
214 | + |
215 | +# Clean up extraneous log files that may be left around |
216 | +rm /etc/ssh/ssh_host*key* || echo "No SSH keys to remove" |
217 | + |
218 | +# Fix LP: #1047707, 1019338 |
219 | +# Truncate logs that are owned, otherwise remove |
220 | +whitelisted_logs=(/var/log/btmp /var/log/lastlog /var/log/wtmp /var/log/fsck/checkfs /var/log/fsck/checkroot) |
221 | + |
222 | +for log in $(find /var/log -type f) |
223 | +do |
224 | + whitelisted=$(echo "${whitelisted_logs[@]}" | grep -o ${log}) |
225 | + |
226 | + if [ -n "${whitelisted}" ]; then |
227 | + : > ${log} && |
228 | + echo "Truncated whitelisted log ${log}" || |
229 | + echo "Failed to truncate whitelisted log ${log}" |
230 | + else |
231 | + |
232 | + dpkg -S ${log} > /dev/null 2>&1 && |
233 | + { : > ${log} || |
234 | + echo "Failed to truncate $f"; } || |
235 | + { rm ${log} && |
236 | + echo "Removed ${log} as an orphaned log file" || |
237 | + echo "Failed to remove unnecessary log $f"; } |
238 | + fi |
239 | +done |
240 | + |
241 | +# Remove un-owned log directories |
242 | +whitelisted_dirs=(/var/log/fsck) |
243 | + |
244 | +for log_d in $(find /var/log/* -type d) |
245 | +do |
246 | + whitelisted=$(echo "${whitelisted_dirs[@]}" | grep -o "${log_d}") |
247 | + if [ -z "${whitelisted}" ]; then |
248 | + dpkg -S ${log_d} > /dev/null 2>&1 && |
249 | + echo "Preserving log directory ${log_d}" || |
250 | + { rm -rf ${log_d} && |
251 | + echo "Removed log directory ${log_d} as orphaned log dir" || |
252 | + echo "Failed to remove unnessasary log dir ${log_d}"; } |
253 | + |
254 | + else |
255 | + echo "Preserving whitelisted directory ${log_d}" |
256 | + fi |
257 | + |
258 | +done |
259 | + |
260 | + |
261 | +rm -rf /var/run/* || echo "Failed to clean /var/run/*" |
262 | +rm /etc/passwd- || echo "No spare passwd file to cleanup" |
263 | +rm /etc/shadow- || echo "No spare shadow file to cleanup" |
264 | +rm /etc/gshadow- || echo "No spare gshadow file to cleanup" |
265 | +rm /etc/group- || echo "No spare group file to clenaup" |
266 | +rm -f /etc/apt/conf.d/00secure || echo "No apt cache to cleanup" |
267 | + |
268 | +# Truncate instead of delete, LP: #707311 |
269 | +truncate --size=0 -c /etc/popularity-contest.conf |
270 | |
271 | === added file 'live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot' |
272 | --- live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot 1970-01-01 00:00:00 +0000 |
273 | +++ live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot 2015-04-08 08:34:32 +0000 |
274 | @@ -0,0 +1,281 @@ |
275 | +#!/bin/bash |
276 | +rootd="${1:-/}" |
277 | +root_fs_label=cloudimg-rootfs |
278 | +set -ex |
279 | + |
280 | +CLOUD_IMG_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" |
281 | + |
282 | +LANG=C |
283 | + |
284 | +_xchroot() { |
285 | + # Prevent multiple chroots |
286 | + if [ "$1" = "/" ]; then |
287 | + shift; |
288 | + "$@" |
289 | + else |
290 | + chroot "$@" |
291 | + fi |
292 | +} |
293 | + |
294 | +#### COMMON architecture independent functions |
295 | +arch=$(_xchroot "${rootd}" dpkg --print-architecture) |
296 | + |
297 | +add_serial_console() { |
298 | + condev=$1 |
299 | + idir="$rootd/etc/init" |
300 | + cat << EOF > "${idir}/${condev}.conf" |
301 | +# CONDEV - getty |
302 | +# |
303 | +# This service maintains a getty on CONDEV from the point the system is |
304 | +# started until it is shut down again. |
305 | + |
306 | +start on stopped rc RUNLEVEL=[2345] and ( |
307 | + not-container or |
308 | + container CONTAINER=lxc or |
309 | + container CONTAINER=lxc-libvirt) |
310 | + |
311 | +stop on runlevel [!2345] |
312 | + |
313 | +pre-start script |
314 | + # getty will not be started if the serial console is not present |
315 | + stty -F /dev/CONDEV -a 2> /dev/null > /dev/null || { stop ; exit 0; } |
316 | +end script |
317 | + |
318 | +respawn |
319 | +script |
320 | + exec /sbin/getty -L CONDEV 115200 vt102 |
321 | +end script |
322 | +${CLOUD_IMG_STR} |
323 | +EOF |
324 | + sed -i "s/CONDEV/${condev}/g" "$idir/${condev}.conf" |
325 | +} |
326 | + |
327 | +## -------------- |
328 | +# remove 127.0.1.1 entry (LP: #440757) |
329 | +_xchroot "${rootd}" sh -c 'sed -i "/^127.0.1.1/d" /etc/hosts' |
330 | + |
331 | +## -------------- |
332 | +# remove ssh pregenerated keys (LP: #512377) |
333 | + |
334 | +_xchroot "${rootd}" sh -c 'rm -f /etc/ssh/ssh_host_[rd]sa_key*' |
335 | + |
336 | +## -------------- |
337 | +_xchroot "${rootd}" locale-gen en_US.utf8 |
338 | + |
339 | +## -------------- |
340 | +# set cloud-init to be on |
341 | +values="NoCloud, ConfigDrive, AltCloud, OVF, MAAS, Ec2, None" |
342 | +printf "%s\t%s\t%s\t%s\n" \ |
343 | + cloud-init cloud-init/datasources multiselect "$values" | |
344 | + _xchroot "${rootd}" debconf-set-selections |
345 | +_xchroot "${rootd}" dpkg-reconfigure --frontend=noninteractive cloud-init |
346 | + |
347 | +## -------------- |
348 | +# write some build information to the guest |
349 | +# the idea is that given runtime info and this info, the instance |
350 | +# can at least determine if there is a newer build available |
351 | +# these variables are passed in in environment from cloudimg-build-launcher |
352 | +if [ -n "${build_name}" -o -n "${serial}" ]; then |
353 | + d="${rootd}/etc/cloud" |
354 | + [ -d "$d" ] || mkdir -p "${d}" |
355 | + { |
356 | + [ -n "${build_name}" ] && echo "build_name: ${build_name}" |
357 | + [ -n "${serial}" ] && echo "serial: ${serial}" |
358 | + } > "$d/build.info" |
359 | +fi |
360 | + |
361 | +## -------------- |
362 | +# for maverick and newer, use LABEL= for the '/' entry in fstab |
363 | +if [ -n "${root_fs_label}" ]; then |
364 | + bl="[:blank:]" |
365 | + lstr="LABEL=${root_fs_label}" |
366 | + sed -i "s,^[^#${bl}]*\([${bl}]*/[${bl}].*\),${lstr}\1," "${rootd}/etc/fstab" |
367 | +fi |
368 | +cat > /etc/fstab << EOM |
369 | +LABEL=cloudimg-rootfs / ext4 defaults 0 0 |
370 | +EOM |
371 | + |
372 | +## Make sure that the update-motd.d directory exists |
373 | +[ ! -e "${rootd}/etc/update-motd.d" ] && |
374 | + mkdir -p "${rootd}/etc/update-motd.d" |
375 | + |
376 | +## write a MOTD file advertising support for images |
377 | +cat > "${rootd}/etc/update-motd.d/51-cloudguest" << EOF |
378 | +#!/bin/sh |
379 | +# |
380 | +${CLOUD_IMG_STR} |
381 | +# This file is not managed by a package. If you no longer want to |
382 | +# see this message you can safely remove the file. |
383 | +echo "" |
384 | +echo " Get cloud support with Ubuntu Advantage Cloud Guest:" |
385 | +echo " http://www.ubuntu.com/business/services/cloud" |
386 | +EOF |
387 | + |
388 | +chmod +x "${rootd}/etc/update-motd.d/51-cloudguest" |
389 | + |
390 | +# for quantal and newer, add /etc/overlayroot.local.conf |
391 | +# but do not overwrite anything that somehow got there |
392 | +if [ -f "${rootd}/etc/overlayroot.conf" ] && |
393 | + [ ! -f "${rootd}/etc/overlayroot.local.conf" ]; then |
394 | + { |
395 | + echo "${CLOUD_IMG_STR}" |
396 | + echo "overlayroot_cfgdisk=LABEL=OROOTCFG" |
397 | + } > "${rootd}/etc/overlayroot.local.conf" |
398 | +fi |
399 | + |
400 | + |
401 | +#### END COMMON ARCH FUNCTIONS |
402 | + |
403 | +if [ "$arch" = "ppc64el" ]; then |
404 | + add_serial_console hvc0 |
405 | + exit 0 |
406 | +fi |
407 | + |
408 | +# ARM images are special |
409 | +if [[ "$arch" =~ (arm|arm64|aarch64) ]]; then |
410 | + |
411 | + echo "Configuring ARM Serial Port" |
412 | + add_serial_console ttyAMA0 |
413 | + |
414 | + echo "Image architecture is ARM. Existing vmbuilder-fixups" |
415 | + |
416 | + exit 0 |
417 | +fi |
418 | + |
419 | +## Add ttyS0 for i386/amd64 for Trusty and newer |
420 | +if [ "$arch" = "i386" -o "$arch" = "amd64" ]; then |
421 | + add_serial_console ttyS0 |
422 | +fi |
423 | + |
424 | + |
425 | +psuedo_grub_probe() { |
426 | + cat <<"PSUEDO_GRUB_PROBE" |
427 | +#!/bin/sh |
428 | +Usage() { |
429 | + cat <<EOF |
430 | +Usage: euca-psuedo-grub-probe |
431 | + this is a wrapper around grub-probe to provide the answers for an ec2 guest |
432 | +EOF |
433 | +} |
434 | +bad_Usage() { Usage 1>&2; fail "$@"; } |
435 | + |
436 | +short_opts="" |
437 | +long_opts="device-map:,target:,device" |
438 | +getopt_out=$(getopt --name "${0##*/}" \ |
439 | + --options "${short_opts}" --long "${long_opts}" -- "$@") && |
440 | + eval set -- "${getopt_out}" || |
441 | + bad_Usage |
442 | + |
443 | +device_map="" |
444 | +target="" |
445 | +device=0 |
446 | +arg="" |
447 | + |
448 | +while [ $# -ne 0 ]; do |
449 | + cur=${1}; next=${2}; |
450 | + case "$cur" in |
451 | + --device-map) device_map=${next}; shift;; |
452 | + --device) device=1;; |
453 | + --target) target=${next}; shift;; |
454 | + --) shift; break;; |
455 | + esac |
456 | + shift; |
457 | +done |
458 | +arg=${1} |
459 | + |
460 | +case "${target}:${device}:${arg}" in |
461 | + device:*:/*) echo "/dev/sda1"; exit 0;; |
462 | + fs:*:*) echo "ext2"; exit 0;; |
463 | + partmap:*:*) |
464 | + # older versions of grub (lucid) want 'part_msdos' written |
465 | + # rather than 'msdos' |
466 | + legacy_pre="" |
467 | + grubver=$(dpkg-query --show --showformat '${Version}\n' grub-pc 2>/dev/null) && |
468 | + dpkg --compare-versions "${grubver}" lt 1.98+20100804-5ubuntu3 && |
469 | + legacy_pre="part_" |
470 | + echo "${legacy_pre}msdos"; |
471 | + exit 0;; |
472 | + abstraction:*:*) echo ""; exit 0;; |
473 | + drive:*:/dev/sda) echo "(hd0)";; |
474 | + drive:*:/dev/sda*) echo "(hd0,1)";; |
475 | + fs_uuid:*:*) exit 1;; |
476 | +esac |
477 | +PSUEDO_GRUB_PROBE |
478 | +} |
479 | + |
480 | +## install / setup grub2 |
481 | +gprobe="${rootd}/usr/sbin/grub-probe" |
482 | +moved=0 |
483 | +if [ -f "${gprobe}" ]; then |
484 | + mv "${gprobe}" "${gprobe}.dist" |
485 | + moved=1 |
486 | +fi |
487 | +psuedo_grub_probe > "${gprobe}" |
488 | +chmod 755 "${gprobe}" |
489 | + |
490 | +# for Quantal and later, use /etc/default/grub.d functionality |
491 | +# rather than modifying the grub configuration itself. |
492 | +# This avoids the mess of having to do dpkg stuff |
493 | +# LP: 1179940 |
494 | +mkdir -p "${rootd}/etc/default/grub.d" |
495 | +cat << EOF > "${rootd}/etc/default/grub.d/50-cloudimg-settings.cfg" |
496 | +# Cloud Image specific Grub settings for Generic Cloud Images |
497 | +${CLOUD_IMG_STR} |
498 | + |
499 | +# Set the recordfail timeout |
500 | +GRUB_RECORDFAIL_TIMEOUT=0 |
501 | + |
502 | +# Do not wait on grub prompt |
503 | +GRUB_TIMEOUT=0 |
504 | + |
505 | +# Set the default commandline |
506 | +GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0" |
507 | + |
508 | +# Set the grub console type |
509 | +GRUB_TERMINAL=console |
510 | +EOF |
511 | +_xchroot "${rootd}" update-grub2 |
512 | + |
513 | +# since this is a disk image, we technically don't need to install all the |
514 | +# grub modules, as the image itself is not bootable. This makes for a small |
515 | +# disk image |
516 | +_xchroot "${rootd}" update-grub |
517 | + |
518 | +# reconfigure grub so that upgrades to grub-pc do not force a debconf config |
519 | +# changed prompt (LP: #1009294). This re-runs update-grub |
520 | +_xchroot "${rootd}" env DEBIAN_FRONTEND=noninteractive \ |
521 | + dpkg-reconfigure grub-pc |
522 | + |
523 | +grub2cfg="${rootd}/boot/grub/grub.cfg" |
524 | +[ ! -f "${grub2cfg}" ] || |
525 | + sed -i -e "s,root=/dev/sda1,root=LABEL=${root_fs_label}," "${grub2cfg}" |
526 | + |
527 | +[ ${moved} -eq 0 ] || mv "${gprobe}.dist" "${gprobe}" |
528 | + |
529 | +## modify /boot/grub/menu.lst if it exists |
530 | +## this is generated at install time by grub-legacy-ec2, but will have |
531 | +## devices as found from the _xchroot. Here we write what it will be on ec2 |
532 | +if [ -f "${rootd}/boot/grub/menu.lst" ]; then |
533 | + grub_root="(hd0)" |
534 | + linux_root=/dev/sda1 |
535 | + [ -n "${root_fs_label}" ] && linux_root="LABEL=${root_fs_label}" |
536 | + # the sed code below basically fixes/sets the following lines in a |
537 | + # /boot/grub/menu.lst file: |
538 | + # # kopt=root=xxxxxxx ro |
539 | + # kernel /boot/vmlinuz-... root=xxxxxx .... |
540 | + # # groot=xxxxx |
541 | + # root xxxxx |
542 | + # uuuid xxxxx |
543 | + sed -i "${rootd}/boot/grub/menu.lst" \ |
544 | + -e "s|^\(# kopt=root=\)[^ ]*|\1${linux_root}|" \ |
545 | + -e "s|^\(kernel.*root=\)[^ ]*|\1${linux_root}|" \ |
546 | + -e "s|^\(# groot=\)[^ ]*|\1${grub_root}|" \ |
547 | + -e "s|^\(root\|uuid\)\([[:space:]]*\).*|root\2${grub_root}|" |
548 | + |
549 | + # grub-legacy-ec2 writes this ucf entry. since we've modified |
550 | + # /boot/grub/menu.lst, we have to remove it, or the user will |
551 | + # get prompted for a 3 way merge of the changes the first time this runs |
552 | + _xchroot "${rootd}" /usr/bin/ucfr --purge grub /var/run/grub/menu.lst |
553 | +fi |
554 | + |
555 | +# vi: ts=3 expandtab |
556 | |
557 | === added directory 'live-build/ubuntu-cpc/includes.chroot' |
558 | === added directory 'live-build/ubuntu-cpc/includes.chroot/etc' |
559 | === added file 'live-build/ubuntu-cpc/includes.chroot/etc/hostname' |
560 | --- live-build/ubuntu-cpc/includes.chroot/etc/hostname 1970-01-01 00:00:00 +0000 |
561 | +++ live-build/ubuntu-cpc/includes.chroot/etc/hostname 2015-04-08 08:34:32 +0000 |
562 | @@ -0,0 +1,1 @@ |
563 | +ubuntu |
564 | |
565 | === added file 'live-build/ubuntu-cpc/includes.chroot/etc/hosts' |
566 | --- live-build/ubuntu-cpc/includes.chroot/etc/hosts 1970-01-01 00:00:00 +0000 |
567 | +++ live-build/ubuntu-cpc/includes.chroot/etc/hosts 2015-04-08 08:34:32 +0000 |
568 | @@ -0,0 +1,9 @@ |
569 | +127.0.0.1 localhost |
570 | + |
571 | +# The following lines are desirable for IPv6 capable hosts |
572 | +::1 ip6-localhost ip6-loopback |
573 | +fe00::0 ip6-localnet |
574 | +ff00::0 ip6-mcastprefix |
575 | +ff02::1 ip6-allnodes |
576 | +ff02::2 ip6-allrouters |
577 | +ff02::3 ip6-allhosts |
578 | |
579 | === added directory 'live-build/ubuntu-cpc/includes.chroot/etc/network' |
580 | === added file 'live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces' |
581 | --- live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces 1970-01-01 00:00:00 +0000 |
582 | +++ live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces 2015-04-08 08:34:32 +0000 |
583 | @@ -0,0 +1,15 @@ |
584 | +# This file describes the network interfaces available on your system |
585 | +# and how to activate them. For more information, see interfaces(5). |
586 | + |
587 | +# The loopback network interface |
588 | +auto lo |
589 | +iface lo inet loopback |
590 | + |
591 | +# Source interfaces |
592 | +# Please check /etc/network/interfaces.d before changing this file |
593 | +# as interfaces may have been defined in /etc/network/interfaces.d |
594 | +# NOTE: the primary ethernet device is defined in |
595 | +# /etc/network/interfaces.d/eth0 |
596 | +# See LP: #1262951 |
597 | +source /etc/network/interfaces.d/*.cfg |
598 | + |
599 | |
600 | === added directory 'live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces.d' |
601 | === added file 'live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces.d/eth0.cfg' |
602 | --- live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces.d/eth0.cfg 1970-01-01 00:00:00 +0000 |
603 | +++ live-build/ubuntu-cpc/includes.chroot/etc/network/interfaces.d/eth0.cfg 2015-04-08 08:34:32 +0000 |
604 | @@ -0,0 +1,3 @@ |
605 | +# The primary network interface |
606 | +auto eth0 |
607 | +iface eth0 inet dhcp |
Thanks, this looks fine.