History

Support building GCP ready images

Michael Aldridge committed 9 years ago

Commit 04bf2e81 parent a4b3dd33 files · +70 −4Browse files

Unified · Split

3 files
  1. .gitignore +2 −0
  2. mkimage.sh.in +62 −2
  3. mkrootfs.sh.in +6 −2
.gitignore+2−0
@@ -2,4 +2,6 @@ · 1 unmodified line
2*.img2*.img
3*.xz3*.xz
4*.iso4*.iso
5*.raw
6*.tar.gz
5xbps-cachedir*7xbps-cachedir*
mkimage.sh.in+62−2
@@ -1,6 +1,7 @@
1#!/bin/sh1#!/bin/sh
2#-2#-
3# Copyright (c) 2013-2016 Juan Romero Pardines.3# Copyright (c) 2013-2016 Juan Romero Pardines.
4# Copyright (c) 2017 Google
4# All rights reserved.5# All rights reserved.
5#6#
6# Redistribution and use in source and binary forms, with or without7# Redistribution and use in source and binary forms, with or without
@@ -29,7 +30,20 @@ readonly ARCH=$(uname -m) · 22 unmodified lines
29 30
30trap 'printf "\nInterrupted! exiting...\n"; cleanup; exit 0' INT TERM HUP31trap 'printf "\nInterrupted! exiting...\n"; cleanup; exit 0' INT TERM HUP
31 32
33mount_pseudofs() {
34 for f in sys dev proc; do
35 mkdir -p $ROOTFSDIR/$f
36 mount --bind /$f $ROOTFSDIR/$f
37 done
38}
39umount_pseudofs() {
40 umount -f $ROOTFSDIR/sys >/dev/null 2>&1
41 umount -f $ROOTFSDIR/dev >/dev/null 2>&1
42 umount -f $ROOTFSDIR/proc >/dev/null 2>&1
43}
44
32cleanup() {45cleanup() {
46 unmount_pseudofs
33 umount -f ${ROOTFSDIR}/boot 2>/dev/null47 umount -f ${ROOTFSDIR}/boot 2>/dev/null
34 umount -f ${ROOTFSDIR} 2>/dev/null48 umount -f ${ROOTFSDIR} 2>/dev/null
35 if [ -e "$LOOPDEV" ]; then49 if [ -e "$LOOPDEV" ]; then
@@ -113,7 +127,7 @@ fi · 77 unmodified lines
113 127
114# double check PLATFORM is supported...128# double check PLATFORM is supported...
115case "$PLATFORM" in129case "$PLATFORM" in
116 bananapi|beaglebone|cubieboard2|cubietruck|odroid-c2|odroid-u2|rpi|rpi2|rpi3|usbarmory|*-musl);;130 bananapi|beaglebone|cubieboard2|cubietruck|odroid-c2|odroid-u2|rpi|rpi2|rpi3|usbarmory|GCP|*-musl);;
117 *) die "The $PLATFORM is not supported, exiting..."131 *) die "The $PLATFORM is not supported, exiting..."
118esac132esac
119 133
@@ -212,6 +226,41 @@ ci20*) · 92 unmodified lines
212 dd if=${ROOTFSDIR}/boot/u-boot-spl.bin of=${LOOPDEV} obs=512 seek=1 >/dev/null 2>&1226 dd if=${ROOTFSDIR}/boot/u-boot-spl.bin of=${LOOPDEV} obs=512 seek=1 >/dev/null 2>&1
213 dd if=${ROOTFSDIR}/boot/u-boot.img of=${LOOPDEV} obs=1K seek=14 >/dev/null 2>&1227 dd if=${ROOTFSDIR}/boot/u-boot.img of=${LOOPDEV} obs=1K seek=14 >/dev/null 2>&1
214 ;;228 ;;
229GCP*)
230 # Setup GRUB
231 mount_pseudofs
232 chroot ${ROOTFSDIR} grub-install ${LOOPDEV}
233 sed -i "s:page_poison=1:page_poison=1 console=ttyS0,38400n8d:" ${ROOTFSDIR}/etc/default/grub
234 chroot ${ROOTFSDIR} update-grub
235 umount_pseudofs
236
237 # Setup the GCP Guest services
238 for _service in dhcpcd sshd agetty-console nanoklogd socklog-unix GCP-Guest-Initialization GCP-accounts GCP-clock-skew GCP-ip-forwarding ; do
239 chroot ${ROOTFSDIR} ln -sv /etc/sv/$_service /etc/runit/runsvdir/default/$_service
240 done
241
242 # Turn off the agetty's since we can't use them anyway
243 rm -v ${ROOTFSDIR}/etc/runit/runsvdir/default/agetty-tty*
244
245 # Disable root login over ssh and lock account
246 sed -i "s:PermitRootLogin yes:PermitRootLogin no:" ${ROOTFSDIR}/etc/ssh/sshd_config
247 chroot ${ROOTFSDIR} passwd -l root
248
249 # Set the Timezone
250 chroot ${ROOTFSDIR} ln -svf /usr/share/zoneinfo/UTC /etc/localtime
251
252 # Generate glibc-locales if necessary (this is a noop on musl)
253 if [ "$PLATFORM" = GCP ] ; then
254 chroot ${ROOTFSDIR} xbps-reconfigure -f glibc-locales
255 fi
256
257 # Remove SSH host keys (these will get rebuilt on first boot)
258 rm -v ${ROOTFSDIR}/etc/ssh/*key*
259 rm -v ${ROOTFSDIR}/etc/ssh/moduli
260
261 # Force hte hostname since this isn't read from DHCP
262 echo "void-GCE" > ${ROOTFSDIR}/etc/hostname
263 ;;
215esac264esac
216 265
217mountpoint -q ${ROOTFSDIR}/boot && umount ${ROOTFSDIR}/boot266mountpoint -q ${ROOTFSDIR}/boot && umount ${ROOTFSDIR}/boot
@@ -220,6 +269,17 @@ losetup -d $LOOPDEV · 2 unmodified lines
220rmdir $ROOTFSDIR269rmdir $ROOTFSDIR
221 270
222chmod 644 $FILENAME271chmod 644 $FILENAME
223info_msg "Successfully created $FILENAME image."272case "$PLATFORM" in
273 GCP*)
274 mv void-GCP*.img disk.raw
275 info_msg "Compressing disk.raw"
276 tar Sczf "${FILENAME/.img/.tar.gz}" disk.raw
277 rm disk.raw
278 info_msg "Sucessfully created ${FILENAME/.img/.tar.gz/} image."
279 ;;
280 *)
281 info_msg "Successfully created $FILENAME image."
282 ;;
283esac
224 284
225# vim: set ts=4 sw=4 et:285# vim: set ts=4 sw=4 et:
mkrootfs.sh.in+6−2
@@ -1,6 +1,7 @@
1#!/bin/sh1#!/bin/sh
2#-2#-
3# Copyright (c) 2013-2015 Juan Romero Pardines.3# Copyright (c) 2013-2015 Juan Romero Pardines.
4# Copyright (c) 2017 Google
4# All rights reserved.5# All rights reserved.
5#6#
6# Redistribution and use in source and binary forms, with or without7# Redistribution and use in source and binary forms, with or without
@@ -45,7 +46,7 @@ usage() { · 38 unmodified lines
45 cat <<_EOF46 cat <<_EOF
46Usage: $PROGNAME [options] <platform>47Usage: $PROGNAME [options] <platform>
47 48
48Supported platforms: i686, i686-musl, x86_64, x86_64-musl,49Supported platforms: i686, i686-musl, x86_64, x86_64-musl, GCP, GCP-musl
49 dockstar, bananapi, beaglebone, cubieboard2, cubietruck,50 dockstar, bananapi, beaglebone, cubieboard2, cubietruck,
50 odroid-c2, odroid-u2, rpi, rpi2 (armv7), rpi3 (aarch64),51 odroid-c2, odroid-u2, rpi, rpi2 (armv7), rpi3 (aarch64),
51 usbarmory, ci2052 usbarmory, ci20
@@ -138,6 +139,8 @@ SUBPLATFORM=$PLATFORM · 86 unmodified lines
138case "$PLATFORM" in139case "$PLATFORM" in
139 i686*) _TARGET_ARCH="$PLATFORM"; _ARCH="i686";;140 i686*) _TARGET_ARCH="$PLATFORM"; _ARCH="i686";;
140 x86_64*) _TARGET_ARCH="$PLATFORM"; _ARCH="x86_64";;141 x86_64*) _TARGET_ARCH="$PLATFORM"; _ARCH="x86_64";;
142 GCP) _TARGET_ARCH="x86_64"; _ARCH="x86_64";;
143 GCP-musl) _TARGET_ARCH="x86_64-musl"; _ARCH="x86_64";;
141 dockstar) _TARGET_ARCH="armv5tel"; _ARCH="armv5tel";;144 dockstar) _TARGET_ARCH="armv5tel"; _ARCH="armv5tel";;
142 rpi-musl) _TARGET_ARCH="armv6l-musl"; _ARCH="armv6l";;145 rpi-musl) _TARGET_ARCH="armv6l-musl"; _ARCH="armv6l";;
143 rpi) _TARGET_ARCH="armv6l"; _ARCH="armv6l";;146 rpi) _TARGET_ARCH="armv6l"; _ARCH="armv6l";;
@@ -178,6 +181,7 @@ case "$PLATFORM" in · 34 unmodified lines
178 odroid-c2*) SUBPLATFORM=${PLATFORM%-musl}; QEMU_BIN=qemu-aarch64-static;;181 odroid-c2*) SUBPLATFORM=${PLATFORM%-musl}; QEMU_BIN=qemu-aarch64-static;;
179 i686*) QEMU_BIN=qemu-i386-static;;182 i686*) QEMU_BIN=qemu-i386-static;;
180 x86_64*) QEMU_BIN=qemu-x86_64-static;;183 x86_64*) QEMU_BIN=qemu-x86_64-static;;
184 GCP*) SUBPLATFORM=${PLATFORM%-*}; QEMU_BIN=qemu-x86_64-static;;
181 *) die "$PROGNAME: invalid platform!";;185 *) die "$PROGNAME: invalid platform!";;
182esac186esac
183 187
@@ -233,7 +237,7 @@ fi · 49 unmodified lines
233if [ -n "${_ARCH}" ]; then237if [ -n "${_ARCH}" ]; then
234 info_msg "Reconfiguring packages for ${_ARCH} ..."238 info_msg "Reconfiguring packages for ${_ARCH} ..."
235 case "$PLATFORM" in239 case "$PLATFORM" in
236 i686*|x86_64*)240 i686*|x86_64*|GCP*)
237 run_cmd "XBPS_ARCH=${PLATFORM} xbps-reconfigure -r $rootfs base-files"241 run_cmd "XBPS_ARCH=${PLATFORM} xbps-reconfigure -r $rootfs base-files"
238 ;;242 ;;
239 *)243 *)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t