diff --git a/debian/changelog b/debian/changelog index 94b096e3..8da3a566 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +livecd-rootfs (2.357) UNRELEASED; urgency=medium + + * merge lp:~utlemming/livecd-rootfs/additional-cloud-targets: + * added additional CPC build targets: + - added manifest generation for squashfs and root.tar.gz + - added VMDK generation + - added OVA generation from VMDK's + - added generic Vagrant image generation + + -- Oliver Grawert Mon, 16 Nov 2015 15:50:17 +0100 + livecd-rootfs (2.356) xenial; urgency=medium * merge lp:~sil2100/livecd-rootfs/update_hashes to update the passwd db diff --git a/live-build/ubuntu-cpc/functions b/live-build/ubuntu-cpc/functions index 3c082ff2..b5500e70 100644 --- a/live-build/ubuntu-cpc/functions +++ b/live-build/ubuntu-cpc/functions @@ -1,3 +1,5 @@ +# vi: ts=4 expandtab syntax=sh + CLOUD_IMG_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" IMAGE_SIZE=$((2252*1024**2)) # 2.2G (the current size we ship) @@ -59,3 +61,69 @@ umount_partition() { umount "$mountpoint/dev" umount "$mountpoint" } + +modify_vmdk_header() { + # Modify the VMDK headers so that both VirtualBox _and_ VMware can + # read the vmdk and import them. The vodoo here is _not_ documented + # anywhere....so this will have to do. This is undocumented vodoo + # that has been learned by the Cloud Image team. + + vmdk_name="${1}" + descriptor=$(mktemp) + newdescriptor=$(mktemp) + + # Extract the vmdk header for manipulation + dd if="${vmdk_name}" of="${descriptor}" bs=1 skip=512 count=1024 + + # The sed lines below is where the magic is. Specifically: + # ddb.toolsVersion: sets the open-vm-tools so that VMware shows + # the tooling as current + # ddb.virtualHWVersion: set the version to 7, which covers most + # current versions of VMware + # createType: make sure its set to stream Optimized + # remove the vmdk-stream-converter comment and replace with + # # Disk DescriptorFile. This is needed for Virtualbox + # remove the comments from vmdk-stream-converter which causes + # VirtualBox and others to fail VMDK validation + + sed -e 's|# Description file.*|# Disk DescriptorFile|' \ + -e '/# Believe this is random*/d' \ + -e '/# Indicates no parent/d' \ + -e '/# The Disk Data Base/d' \ + -e 's|ddb.comment.*|ddb.toolsVersion = "2147483647"|' \ + "${descriptor}" > "${newdescriptor}" + + # The header is cannot be bigger than 1024 + expr $(stat --format=%s ${newdescriptor}) \< 1024 > /dev/null 2>&1 || { + echo "descriptor is too large, VMDK will be invalid!"; exit 1; } + + # Overwrite the vmdk header with our new, modified one + dd conv=notrunc,nocreat \ + if="${newdescriptor}" of="${vmdk_name}" \ + bs=1 seek=512 count=1024 + + rm ${descriptor} ${newdescriptor} +} + +create_vmdk() { + # There is no real good way to create a _compressed_ VMDK using open source + # tooling that works across multiple VMDK-capable platforms. This functions + # uses vmdk-stream-converter and then calls modify_vmdk_header to produce a + # compatible VMDK. + + src="$1" + destination="$2" + size="${3:-10240}" + + apt-get install -qqy qemu-utils vmdk-stream-converter + streamconverter="/usr/share/pyshared/VMDKstream.py" + scratch_d=$(mktemp -d) + cp ${src} ${scratch_d}/resize.img + + truncate --size=${size}M ${scratch_d}/resize.img + python ${streamconverter} ${scratch_d}/resize.img ${destination} + modify_vmdk_header ${destination} + + qemu-img info ${destination} + rm -rf ${scratch_d} +} diff --git a/live-build/ubuntu-cpc/hooks/031-root-xz.binary b/live-build/ubuntu-cpc/hooks/031-root-xz.binary index b2503adb..a3ee963d 100755 --- a/live-build/ubuntu-cpc/hooks/031-root-xz.binary +++ b/live-build/ubuntu-cpc/hooks/031-root-xz.binary @@ -1,3 +1,9 @@ #!/bin/bash -ex +# vi: ts=4 noexpandtab +# +# Generate the rootfs.tar.gz and manifest + +dpkg-query --admindir=binary/boot/filesystem.dir/var/lib/dpkg -W > livecd.ubuntu-cpc.rootfs.manifest + (cd "binary/boot/filesystem.dir/" && tar -c *) | \ xz > "livecd.ubuntu-cpc.rootfs.tar.xz" diff --git a/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary b/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary new file mode 100755 index 00000000..37d612f9 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary @@ -0,0 +1,15 @@ +#!/bin/bash -eux +# vi: ts=4 noexpandtab +# +# Generate a squashfs root and manifest + +apt-get -qqy install squashfs-tools + +squashfs_f="${PWD}/livecd.ubuntu-cpc.squashfs" +squashfs_f_manifest="${squashfs_f}.manifest" + +dpkg-query --admindir=binary/boot/filesystem.dir/var/lib/dpkg -W > ${squashfs_f_manifest} + +(cd "binary/boot/filesystem.dir/" && + mksquashfs . ${squashfs_f} \ + -no-progress -xattrs -comp xz ) diff --git a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary index ccc6cca9..e0e90c18 100755 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -12,9 +12,10 @@ esac . /build/config/functions +apt-get -qqy install dosfstools gdisk + create_partitions() { disk_image="$1" - apt-get install -qqy gdisk sgdisk "${disk_image}" --zap-all case $architecture in arm64) @@ -39,7 +40,6 @@ create_partitions() { create_and_mount_uefi_partition() { uefi_dev="/dev/mapper${loop_device///dev/}p15" - apt-get -qqy install dosfstools mountpoint="$1" mkfs.vfat -F 32 -n UEFI "${uefi_dev}" diff --git a/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary new file mode 100755 index 00000000..44f876dc --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary @@ -0,0 +1,22 @@ +#!/bin/bash -eux +# vi: ts=4 expandtab +# +# Generate VMDK files + +architecture=$(chroot chroot dpkg --print-architecture) + +extension="disk1.vmdk" +case ${architecture} in + i386) image_target="binary/boot/disk.ext4";; + amd64) image_target="binary/boot/disk-uefi.ext4"; extension="uefi1.vmdk";; + *) echo "VMDK images are not supported for ${architecture} yet."; + exit 0;; +esac + +. /build/config/functions + +create_vmdk binary/boot/disk.ext4 livecd.ubuntu-cpc.disk1.vmdk + +if [ -e binary/boot/disk-uefi.ext4 ]; then + create_vmdk binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.uefi.vmdk +fi diff --git a/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary b/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary new file mode 100755 index 00000000..84134c42 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/041-vmdk-ova-image.binary @@ -0,0 +1,88 @@ +#!/bin/bash -eux +# vi: ts=4 expandtab +# +# Generate OVA images +# +# OVA images are, by defintiion a tarball consisting of a disk image, OVF file +# and checksums. This step produces an OVA that is suitable for use with +# Cloud's that support the OVF specification. +# +# For this step, we re-use the VMDK's made in 040-vmdk-image.binary + +cur_d=${PWD} +my_d=$(dirname $(readlink -f ${0})) + +architecture=$(chroot chroot dpkg --print-architecture) + +base_vmdk="livecd.ubuntu-cpc.disk1.vmdk" +case ${architecture} in + amd64) base_vmdk="livecd.ubuntu-cpc.uefi.vmdk";; + *) echo "OVA images are not supported for ${architecture} yet."; + exit 0;; +esac + +if [ ! -e ${base_vmdk} ]; then + find . | grep vmdk + exit 0 +fi + +# Lets be safe about this +scratch_d=$(mktemp -d) +trap "rm -rf ${scratch_d}" EXIT + +# Used to identify bits +suite=$(chroot chroot lsb_release -c -s) +version=$(chroot chroot lsb_release --release --short) +distro=$(chroot chroot lsb_release --id --short | tr [:upper:] [:lower:]) + +# Put our vmdk in place for OVA conversion +prefix="${distro}-${suite}-${version}-cloudimg" +vmdk_f="${scratch_d}/${prefix}.vmdk" +cp ${base_vmdk} ${vmdk_f} + +# Get information about the VMDK +vmdk_size=$(du -b "${vmdk_f}" | cut -f1) +vmdk_capacity=$(qemu-img info "${vmdk_f}" | awk '-F[\( ]' '$1 ~ /virtual/ && $NF ~ /bytes.*/ {print$(NF-1)}') + +# Populate the OVF template +ovf="${scratch_d}/${prefix}.ovf" +cp ${my_d}/ovf/ubuntu-ova-v1-vmdk.tmpl ${ovf} +serial_stamp=$(date +%Y%m%d) +sed -i "${ovf}" \ + -e "s/@@NAME@@/${prefix}-${serial_stamp}/g" \ + -e "s/@@FILENAME@@/${vmdk_f##*/}/g" \ + -e "s/@@VMDK_FILE_SIZE@@/${vmdk_size}/g" \ + -e "s/@@VMDK_CAPACITY@@/${vmdk_capacity}/g" \ + -e "s/@@NUM_CPUS@@/2/g" \ + -e "s/@@VERSION@@/${version}/g" \ + -e "s/@@DATE@@/${serial_stamp}/g" \ + -e "s/@@MEM_SIZE@@/1024/g" + +# Get the checksums +vmdk_sha256=$(sha256sum ${vmdk_f} | cut -d' ' -f1) +ovf_sha256=$(sha256sum ${ovf} | cut -d' ' -f1) + +# Generate the manifest +manifest="${scratch_d}/${prefix}.mf" +cat > "${manifest}" < ${seed_d}/user-data < ${seed_d}/meta-data < ${box_d}/Vagrantfile < ${box_d}/metadata.json < "${manifest}" < + + + + + + + Virtual disk information + + + + + The list of logical networks + + The VM Network network + + + + A virtual machine + @@NAME@@ + + The kind of installed guest operating system + + + + Cloud-Init customization + Ubuntu @@VERSION@@ Server (@@DATE@@) + + + Specifies the instance id. This is required and used to determine if the machine should take "first boot" actions + + + Specifies the hostname for the appliance + + + + This field is optional, but indicates that the instance should 'seed' user-data and meta-data from the given url. If set to 'http://tinyurl.com/sm-' is given, meta-data will be pulled from http://tinyurl.com/sm-meta-data and user-data from http://tinyurl.com/sm-user-data. Leave this empty if you do not want to seed from a url. + + + + This field is optional, but indicates that the instance should populate the default user's 'authorized_keys' with this value + + + + In order to fit into a xml attribute, this value is base64 encoded . It will be decoded, and then processed normally as user-data. + + + + + If set, the default user's password will be set to this value to allow password based login. The password will be good for only a single login. If set to the string 'RANDOM' then a random password will be generated, and written to the console. + + + + + Virtual hardware requirements + + Virtual Hardware Family + 0 + @@NAME@@ + vmx-10 + + + hertz * 10^6 + Number of Virtual CPUs + @@NUM_CPUS@@ virtual CPU(s) + 1 + 3 + @@NUM_CPUS@@ + + + byte * 2^20 + Memory Size + @@MEM_SIZE@@MB of memory + 2 + 4 + @@MEM_SIZE@@ + + + 0 + SCSI Controller + SCSI Controller 0 + 3 + VirtualSCSI + 6 + + + 1 + IDE Controller + VirtualIDEController 1 + 4 + 5 + + + 0 + IDE Controller + VirtualIDEController 0 + 5 + 5 + + + false + VirtualVideoCard + 6 + 24 + + + + + + + + false + VirtualVMCIDevice + 7 + vmware.vmci + 1 + + + + 0 + false + CD-ROM 1 + 8 + 4 + vmware.cdrom.remotepassthrough + 15 + + + + 0 + Hard Disk 1 + ovf:/disk/vmdisk1 + 9 + 3 + 17 + + + + 1 + ConfigDriveDisk + ovf:/disk/vmdisk2 + 10 + 3 + 17 + + + + 7 + true + VM Network + VmxNet3 ethernet adapter on "VM Network" + Ethernet 1 + 11 + VmxNet3 + 10 + + + + + + + + + + + + + + + + + + + + + + diff --git a/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ova-v1-vmdk.tmpl b/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ova-v1-vmdk.tmpl new file mode 100644 index 00000000..0eaa85a4 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ova-v1-vmdk.tmpl @@ -0,0 +1,177 @@ + + + + + + + Virtual disk information + + + + The list of logical networks + + The VM Network network + + + + A virtual machine + @@NAME@@ + + The kind of installed guest operating system + + + + Cloud-Init customization + Ubuntu @@VERSION@@ Server (@@DATE@@) + + + Specifies the instance id. This is required and used to determine if the machine should take "first boot" actions + + + Specifies the hostname for the appliance + + + + This field is optional, but indicates that the instance should 'seed' user-data and meta-data from the given url. If set to 'http://tinyurl.com/sm-' is given, meta-data will be pulled from http://tinyurl.com/sm-meta-data and user-data from http://tinyurl.com/sm-user-data. Leave this empty if you do not want to seed from a url. + + + + This field is optional, but indicates that the instance should populate the default user's 'authorized_keys' with this value + + + + In order to fit into a xml attribute, this value is base64 encoded . It will be decoded, and then processed normally as user-data. + + + + + If set, the default user's password will be set to this value to allow password based login. The password will be good for only a single login. If set to the string 'RANDOM' then a random password will be generated, and written to the console. + + + + + Virtual hardware requirements + + Virtual Hardware Family + 0 + @@NAME@@ + vmx-10 + + + hertz * 10^6 + Number of Virtual CPUs + @@NUM_CPUS@@ virtual CPU(s) + 1 + 3 + @@NUM_CPUS@@ + + + byte * 2^20 + Memory Size + @@MEM_SIZE@@MB of memory + 2 + 4 + @@MEM_SIZE@@ + + + 0 + SCSI Controller + SCSI Controller 0 + 3 + VirtualSCSI + 6 + + + 1 + IDE Controller + VirtualIDEController 1 + 4 + 5 + + + 0 + IDE Controller + VirtualIDEController 0 + 5 + 5 + + + false + VirtualVideoCard + 6 + 24 + + + + + + + + false + VirtualVMCIDevice + 7 + vmware.vmci + 1 + + + + 0 + false + CD-ROM 1 + 8 + 4 + vmware.cdrom.remotepassthrough + 15 + + + + 0 + Hard Disk 1 + ovf:/disk/vmdisk1 + 9 + 3 + 17 + + + + 0 + false + Floppy Drive + Floppy 1 + 10 + vmware.floppy.remotedevice + 14 + + + 7 + true + VM Network + VmxNet3 ethernet adapter on "VM Network" + Ethernet 1 + 11 + VmxNet3 + 10 + + + + + + + + + + + + + + + + + + + + + + diff --git a/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ovf-v1-img.tmpl b/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ovf-v1-img.tmpl new file mode 100644 index 00000000..161b8f61 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/ovf/ubuntu-ovf-v1-img.tmpl @@ -0,0 +1,130 @@ + + + + + + + Virtual disk information + + + + The list of logical networks + + The bridged network + + + + A virtual machine + $VIRTUAL_SYSTEM_NAME + + $VIRTUAL_SYSTEM_OS_INFO + + + Cloud-Init customization + $VIRTUAL_SYSTEM_OS_INFO + + + Specifies the instance id. This is required and used to determine if the machine should take "first boot" actions + + + Specifies the hostname for the appliance + + + + This field is optional, but indicates that the instance should 'seed' user-data and meta-data from the given url. If set to 'http://tinyurl.com/sm-' is given, meta-data will be pulled from http://tinyurl.com/sm-meta-data and user-data from http://tinyurl.com/sm-user-data. Leave this empty if you do not want to seed from a url. + + + + This field is optional, but indicates that the instance should populate the default user's 'authorized_keys' with this value + + + + In order to fit into a xml attribute, this value is base64 encoded . It will be decoded, and then processed normally as user-data. + + + + + If set, the default user's password will be set to this value to allow password based login. The password will be good for only a single login. If set to the string 'RANDOM' then a random password will be generated, and written to the console. + + + + Virtual hardware requirements + + Virtual Hardware Family + 0 + $VIRTUAL_SYSTEM_IDENTIFIER + $VIRTUAL_SYSTEM_TYPES + + + hertz * 10^6 + Number of Virtual CPUs + 1 virtual CPU(s) + 1 + 3 + 1 + + + byte * 2^20 + Memory Size + 256MB of memory + 2 + 4 + 256 + + + 0 + USB Controller + usb + 3 + 23 + + + 0 + SCSI Controller + scsiController0 + 4 + lsilogic + 6 + + + 1 + IDE Controller + ideController1 + 5 + 5 + + + 0 + false + cdrom1 + 6 + 5 + 15 + + + 0 + disk1 + ovf:/disk/vmdisk1 + 7 + 4 + 17 + + + 2 + true + bridged + ethernet adapter on "bridged" + ethernet0 + 8 + E1000 + 10 + + + + $ANNOTATION_INFO + $ANNOTATION + + +