|
|
@ -1,7 +1,7 @@
|
|
|
|
# vi: ts=4 expandtab syntax=sh
|
|
|
|
# vi: ts=4 expandtab syntax=sh
|
|
|
|
|
|
|
|
|
|
|
|
CLOUD_IMG_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process"
|
|
|
|
imagesize=${IMAGE_SIZE:-$((2252*1024**2))} # 2.2G (the current size we ship)
|
|
|
|
IMAGE_SIZE=$((2252*1024**2)) # 2.2G (the current size we ship)
|
|
|
|
fs_label="${FS_LABEL:-rootfs}"
|
|
|
|
|
|
|
|
|
|
|
|
rootfs_dev_mapper=
|
|
|
|
rootfs_dev_mapper=
|
|
|
|
loop_device=
|
|
|
|
loop_device=
|
|
|
@ -28,13 +28,13 @@ clean_loops() {
|
|
|
|
|
|
|
|
|
|
|
|
create_empty_disk_image() {
|
|
|
|
create_empty_disk_image() {
|
|
|
|
# Prepare an empty disk image
|
|
|
|
# Prepare an empty disk image
|
|
|
|
dd if=/dev/zero of="$1" bs=1 count=0 seek="${IMAGE_SIZE}"
|
|
|
|
dd if=/dev/zero of="$1" bs=1 count=0 seek="${imagesize}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
make_ext4_partition() {
|
|
|
|
make_ext4_partition() {
|
|
|
|
device="$1"
|
|
|
|
device="$1"
|
|
|
|
|
|
|
|
label=${fs_label:+-L "${fs_label}"}
|
|
|
|
mkfs.ext4 -F -b 4096 -i 8192 -m 0 -L cloudimg-rootfs -E resize=536870912 "$device"
|
|
|
|
mkfs.ext4 -F -b 4096 -i 8192 -m 0 ${label} -E resize=536870912 "$device"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mount_image() {
|
|
|
|
mount_image() {
|
|
|
@ -103,7 +103,7 @@ mount_disk_image() {
|
|
|
|
# such as updating grub and installing software
|
|
|
|
# such as updating grub and installing software
|
|
|
|
cat > $mountpoint/usr/sbin/policy-rc.d << EOF
|
|
|
|
cat > $mountpoint/usr/sbin/policy-rc.d << EOF
|
|
|
|
#!/bin/sh
|
|
|
|
#!/bin/sh
|
|
|
|
# ${CLOUD_IMG_STR}
|
|
|
|
# ${IMAGE_STR}
|
|
|
|
echo "All runlevel operations denied by policy" >&2
|
|
|
|
echo "All runlevel operations denied by policy" >&2
|
|
|
|
exit 101
|
|
|
|
exit 101
|
|
|
|
EOF
|
|
|
|
EOF
|
|
|
@ -251,9 +251,9 @@ convert_to_qcow2() {
|
|
|
|
|
|
|
|
|
|
|
|
replace_grub_root_with_label() {
|
|
|
|
replace_grub_root_with_label() {
|
|
|
|
# When update-grub is run, it will detect the disks in the build system.
|
|
|
|
# When update-grub is run, it will detect the disks in the build system.
|
|
|
|
# Instead, we want grub to use the cloudimg-rootfs labelled disk
|
|
|
|
# Instead, we want grub to use the right labelled disk
|
|
|
|
CHROOT_ROOT="$1"
|
|
|
|
CHROOT_ROOT="$1"
|
|
|
|
|
|
|
|
|
|
|
|
sed -i -e "s,root=[^ ]\+,root=LABEL=cloudimg-rootfs," \
|
|
|
|
sed -i -e "s,root=[^ ]\+,root=LABEL=${fs_label}," \
|
|
|
|
"$CHROOT_ROOT/boot/grub/grub.cfg"
|
|
|
|
"$CHROOT_ROOT/boot/grub/grub.cfg"
|
|
|
|
}
|
|
|
|
}
|