ubuntu-cpc: nocloud data source for non-cloud cloud images (armhf+raspi2)

ubuntu/trusty
Robert C Jennings 8 years ago
parent 742985bb4d
commit 02340e2480

9
debian/changelog vendored

@ -1,3 +1,12 @@
livecd-rootfs (2.209.13) trusty; urgency=medium
[Adam Conrad]
* live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot: Add fake_cloud_init
function to create a nocloud data source for cloud images that aren't
meant to be used on real clouds and use it by default on armhf+raspi2
-- Robert C Jennings <robert.jennings@canonical.com> Tue, 23 May 2017 22:35:47 -0500
livecd-rootfs (2.209.12) trusty; urgency=medium livecd-rootfs (2.209.12) trusty; urgency=medium
[ Steve Langasek ] [ Steve Langasek ]

@ -50,6 +50,33 @@ EOF
sed -i "s/CONDEV/${condev}/g" "$idir/${condev}.conf" sed -i "s/CONDEV/${condev}/g" "$idir/${condev}.conf"
} }
fake_cloud_init() {
# If the cloud does not provide a meta-data service this should be run
# This will setup a nocloud datasource.
seed_d="${rootd}/var/lib/cloud/seed/nocloud-net"
mkdir -p "${seed_d}"
# fake instance-id
cat << EOF > "${seed_d}/meta-data"
instance_id: cloud-image
EOF
# fake user-data to create the default user/password
cat << EOF > "${seed_d}/user-data"
#cloud-config
password: ubuntu
chpasswd: ubuntu
ssh_pwauth: True
EOF
# tell cloud-init not to look for meta-data sources
cat << EOF > ${rootd}/etc/cloud/cloud.cfg.d/99-fake_cloud.cfg
# configure cloud-init for NoCloud
datasource_list: [ NoCloud, None ]
EOF
}
## -------------- ## --------------
# remove 127.0.1.1 entry (LP: #440757) # remove 127.0.1.1 entry (LP: #440757)
_xchroot "${rootd}" sh -c 'sed -i "/^127.0.1.1/d" /etc/hosts' _xchroot "${rootd}" sh -c 'sed -i "/^127.0.1.1/d" /etc/hosts'
@ -132,6 +159,11 @@ case $arch in
armhf|arm64) armhf|arm64)
echo "Configuring ARM Serial Port" echo "Configuring ARM Serial Port"
add_serial_console ttyAMA0 add_serial_console ttyAMA0
# Dirty hack because SUBARCH doesn't exist when running chroot hooks,
# and we don't want raspi2 images to depend on a cloud data source:
if _xchroot "${rootd}" dpkg -l linux-image-raspi2 2>/dev/null | grep -q '^.i'; then
fake_cloud_init
fi
echo "Image architecture is ARM. Existing vmbuilder-fixups" echo "Image architecture is ARM. Existing vmbuilder-fixups"

Loading…
Cancel
Save