* Add ubuntu-cpc project (LP: #1693018)
* Move building of all architecture-specific CPC artifacts into Launchpad - Fixup virtual FLAVOUR kernel name * 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 * Fix typo in ubuntu-cpc preventing non-intel builds. * add devpts-live to hook builds * add logic to settle the disks after UEFI builds * extended hooks/functions to support creation of derivative images * including mounting images. * added the ability to create qcow2 images in hooks/functions * simplified loop clean-up in hooks/functions * removed assumption that disk1.img would be built * switched qcow2 generation to use hooks/functions function * Produce OVA files for i386 cloud builds. * Remove unneeded packages from the root.tar.{gz,xz} cloud image targets * Install grub in ppc64el cloud images so they are bootable * Set timeout options so ppc64el cloud images don't display a grub boot menu (matching the behaviour of other cloud images). * Specify a regex to run-parts so that cloud image extra scripts are found and executed. * Refactor/reorder ubuntu-cpc support for consistency with other flavors, so that subarch overrides can be applied correctly. * fixed loop setup due to change of kpartx output * only use grub-install logic for Intel architectures * Refactor some non-idiomatic architecture handling in live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot that also misidentifies the architecture name for armhf. * Add hooks to ubuntu-cpc to divert /bin/sync in the chroot and undivert it at the end. This is a general-purpose change that should be applied to all flavors and archs, but at the moment it's only needed on armhf+raspi2 to work around the raspberrypi2-firmware postinst calling sync, which is actually warranted in the normal case. * If a subarch is specified for a cloud image build, don't build rootfs artifacts; these should come from the 'generic' build. * Fix architecture handling in hooks. We know we're always being invoked from a launchpad-buildd-like setup, which passes ARCH and SUBARCH in the environment, because auto/config and auto/build both rely on this. So don't scatter dpkg --print-architecture calls throughout, especially when many of these are not cross-build-aware. * Refactor ubuntu-cpc hooks to allow us to handle images where the root partition should not be partition 1. * ubuntu-cpc: fix hooks/032-disk-image.binary call to create_empty_partition, which requires five args due to "-u" * ubuntu-cpc: in hooks/030-root-tarball.binary create /lib/modules to fix * Refactor ubuntu-cpc hooks to always produce a 'plain' rootfs via live-build and reuse this for the tarball, instead of lb_binary_rootfs creating some artifact that we ignore / throw away. * Initial support for raspi2 subarch. * Import live-build/ubuntu-cpc/hooks/raspi2/mkknlimg from https://github.com/raspberrypi/linux/blob/rpi-4.1.y/scripts/mkknlimg and use it to install a bootable uboot.bin. * 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 * live-build/ubuntu-cpc/hooks/042-vagrant.binary: add serial device for Vagrant images * Refactor ubuntu-cpc hooks to hard-code producing an 'ext4' rootfs, which is used outside of the livecd-rootfs build process (specifically for EC2 publication). * live-build/ubuntu-cpc/hooks/042-vagrant.binary: scope serial device for Virtualbox only. * Enable building of powerpc cloud images. * Fixes for vagrant box builder in ubuntu-cpc - Install virtualbox-guest-utils - Don't disable default synced folder - Don't set vm name - Add cloud-init config to manage /etc/hosts * live-build/ubuntu-cpc/hooks/042-vagrant.binary: fix unmount handling so that the teardown is done properly /before/ we try to make an image from our filesystem, since otherwise /etc/resolv.conf is broken. * Don't overwrite the default sources.list in cloud images. * Replace sources.list generated using COMPONENTS with the sources.list from an Ubuntu Server installation (i.e. with all components enabled, and all deb-src lines commented). * Fix the manifest generation in OVA files so that ovf files don't have double extensions. * Fix the OVF's metadata to include Ubuntu specific identifiers and descriptions instead of the generic Linux ones. * Add replace_grub_root_with_label function thereby consolidating multiple uses of the same calls to sed. * ubuntu-cpc: Remove redundant copy of grub files. * Add `apt-get update` to ubuntu-cpc ppc64el builds so they use the new sources.ubuntu/trusty
commit
3468b592b8
@ -0,0 +1,259 @@
|
||||
# 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)
|
||||
|
||||
rootfs_dev_mapper=
|
||||
loop_device=
|
||||
loop_raw=
|
||||
backing_img=
|
||||
|
||||
apt-get -qqy install dosfstools gdisk
|
||||
|
||||
clean_loops() {
|
||||
|
||||
if [ -n "${backing_img}" ]; then
|
||||
kpartx -v -d "${backing_img}"
|
||||
unset backing_img
|
||||
fi
|
||||
|
||||
if [ -z "${rootfs_dev_mapper}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
unset loop_device
|
||||
unset loop_raw
|
||||
unset rootfs_dev_mapper
|
||||
}
|
||||
|
||||
create_empty_disk_image() {
|
||||
# Prepare an empty disk image
|
||||
dd if=/dev/zero of="$1" bs=1 count=0 seek="${IMAGE_SIZE}"
|
||||
}
|
||||
|
||||
make_ext4_partition() {
|
||||
device="$1"
|
||||
|
||||
mkfs.ext4 -F -b 4096 -i 8192 -m 0 -L cloudimg-rootfs -E resize=536870912 "$device"
|
||||
}
|
||||
|
||||
mount_image() {
|
||||
apt-get install -qqy kpartx
|
||||
trap clean_loops EXIT
|
||||
backing_img="$1"
|
||||
local rootpart="$2"
|
||||
kpartx_mapping="$(kpartx -s -v -a ${backing_img})"
|
||||
|
||||
# Find the loop device
|
||||
loop_p1="$(echo -e ${kpartx_mapping} | head -n1 | awk '{print$3}')"
|
||||
loop_device="/dev/loop$(echo ${loop_p1} | cut -b5)"
|
||||
if [ ! -b ${loop_device} ]; then
|
||||
echo "unable to find loop device for ${backing_img}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find the rootfs location
|
||||
rootfs_dev_mapper="/dev/mapper/${loop_p1%%[0-9]}${rootpart}"
|
||||
if [ ! -b "${rootfs_dev_mapper}" ]; then
|
||||
echo "${rootfs_dev_mapper} is not a block device";
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Add some information to the debug logs
|
||||
echo "Mounted disk image ${backing_img} to ${rootfs_dev_mapper}"
|
||||
blkid ${rootfs_dev_mapper} || true
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_mountpoint() {
|
||||
local mountpoint="$1"
|
||||
|
||||
mount --bind /dev "$mountpoint/dev"
|
||||
mount devpts-live -t proc "$mountpoint/dev/pts"
|
||||
mount proc-live -t proc "$mountpoint/proc"
|
||||
mount sysfs-live -t sysfs "$mountpoint/sys"
|
||||
mount -t tmpfs none "$mountpoint/tmp"
|
||||
mv "$mountpoint/etc/resolv.conf" resolv.conf.tmp
|
||||
cp /etc/resolv.conf "$mountpoint/etc/resolv.conf"
|
||||
|
||||
}
|
||||
|
||||
mount_partition() {
|
||||
partition="$1"
|
||||
mountpoint="$2"
|
||||
|
||||
mount "$partition" "$mountpoint"
|
||||
setup_mountpoint "$mountpoint"
|
||||
}
|
||||
|
||||
|
||||
mount_disk_image() {
|
||||
local disk_image=${1}
|
||||
local mountpoint=${2}
|
||||
mount_image ${disk_image} 1
|
||||
mount_partition "${rootfs_dev_mapper}" $mountpoint
|
||||
|
||||
local uefi_dev="/dev/mapper${loop_device///dev/}p15"
|
||||
if [ -b ${uefi_dev} -a -e $mountpoint/boot/efi ]; then
|
||||
mount "${uefi_dev}" $mountpoint/boot/efi
|
||||
fi
|
||||
|
||||
# This is needed to allow for certain operations
|
||||
# such as updating grub and installing software
|
||||
cat > $mountpoint/usr/sbin/policy-rc.d << EOF
|
||||
#!/bin/sh
|
||||
# ${CLOUD_IMG_STR}
|
||||
echo "All runlevel operations denied by policy" >&2
|
||||
exit 101
|
||||
EOF
|
||||
chmod 0755 $mountpoint/usr/sbin/policy-rc.d
|
||||
|
||||
}
|
||||
|
||||
umount_settle() {
|
||||
# Unmount device, and let it settle
|
||||
umount $1
|
||||
udevadm settle
|
||||
sleep 3
|
||||
}
|
||||
|
||||
umount_partition() {
|
||||
local mountpoint=${1}
|
||||
mv resolv.conf.tmp "$mountpoint/etc/resolv.conf"
|
||||
for submnt in proc sys dev/pts dev tmp;
|
||||
do
|
||||
umount_settle $mountpoint/$submnt
|
||||
done
|
||||
umount_settle $mountpoint
|
||||
|
||||
if [ -n "${rootfs_dev_mapper}" -a -b "${rootfs_dev_mapper}" ]; then
|
||||
# buildd's don't have /etc/mtab symlinked
|
||||
# /etc/mtab is needed in order zerofree space for ext4 filesystems
|
||||
[ -e /etc/mtab ] || ln -s /proc/mounts /etc/mtab
|
||||
|
||||
# both of these are likely overkill, but it does result in slightly
|
||||
# smaller ext4 filesystem
|
||||
apt-get -qqy install zerofree
|
||||
e2fsck -y -E discard ${rootfs_dev_mapper}
|
||||
zerofree ${rootfs_dev_mapper}
|
||||
fi
|
||||
}
|
||||
|
||||
umount_disk_image() {
|
||||
mountpoint="$1"
|
||||
|
||||
local uefi_dev="/dev/mapper${loop_device///dev/}p15"
|
||||
if [ -e "$mountpoint/boot/efi" -a -b "$uefi_dev" ]; then
|
||||
umount --detach-loop "$mountpoint/boot/efi"
|
||||
fi
|
||||
|
||||
if [ -e $mountpoint/usr/sbin/policy-rc.d ]; then
|
||||
rm $mountpoint/usr/sbin/policy-rc.d
|
||||
fi
|
||||
umount_partition $mountpoint
|
||||
clean_loops
|
||||
}
|
||||
|
||||
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}
|
||||
}
|
||||
|
||||
create_derivative() {
|
||||
# arg1 is the disk type
|
||||
# arg2 is the new name
|
||||
unset derivative_img
|
||||
case ${1} in
|
||||
uefi) disk_image="binary/boot/disk-uefi.ext4";
|
||||
dname="${disk_image//-uefi/-$2-uefi}";;
|
||||
*) disk_image="binary/boot/disk.ext4";
|
||||
dname="${disk_image//.ext4/-$2.ext4}";;
|
||||
esac
|
||||
|
||||
if [ ! -e ${disk_image} ]; then
|
||||
echo "Did not find ${disk_image}!"; exit 1;
|
||||
fi
|
||||
|
||||
cp ${disk_image} ${dname}
|
||||
export derivative_img=${dname}
|
||||
}
|
||||
|
||||
convert_to_qcow2() {
|
||||
apt-get install -qqy qemu-utils
|
||||
|
||||
src="$1"
|
||||
destination="$2"
|
||||
qemu-img convert -c -O qcow2 -o compat=0.10 "$src" "$destination"
|
||||
qemu-img info "$destination"
|
||||
}
|
||||
|
||||
replace_grub_root_with_label() {
|
||||
# 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
|
||||
CHROOT_ROOT="$1"
|
||||
|
||||
sed -i -e "s,root=[^ ]\+,root=LABEL=cloudimg-rootfs," \
|
||||
"$CHROOT_ROOT/boot/grub/grub.cfg"
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
dpkg-divert --quiet --add --divert /bin/sync.REAL --rename /bin/sync
|
||||
cat > /bin/sync <<'EOF'
|
||||
#! /bin/sh
|
||||
echo "$0: diverted by livecd-rootfs" >&2
|
||||
exit 0
|
||||
EOF
|
||||
|
||||
chmod +x /bin/sync
|
@ -0,0 +1,4 @@
|
||||
#!/bin/bash -eux
|
||||
|
||||
. /etc/os-release
|
||||
echo "Ubuntu $VERSION" > /etc/ec2_version
|
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
# Configure certain packages
|
||||
|
||||
## console-setup
|
||||
|
||||
# Select the fontface
|
||||
printf "%s\t%s\t%s\t%s\n" \
|
||||
console-setup console-setup/console-setup/fontface47 string "Fixed" debconf-set-selections ||
|
||||
{ echo "FAILED to setup console fontface"; exit 1; }
|
||||
|
||||
# Select the code page for font
|
||||
printf "%s\t%s\t%s\t%s\n" \
|
||||
console-setup console-setup/codesetcode string "Uni2" | debconf-set-selections ||
|
||||
{ echo "FAILED to setup console code page to Uni2"; exit 1; }
|
||||
|
||||
# Set Language string for codepage 47
|
||||
printf "%s\t%s\t%s\t%s\n" \
|
||||
console-setup console-setup/codeset47 string ". Combined - Latin; Slavic Cyrillic; Greek" | debconf-set-selections ||
|
||||
{ echo "FAILED to setup codeset47 to proper string"; exti 1; }
|
||||
|
||||
# Replace the console font and typ ein /etc/default/console-setup
|
||||
sed -i -e 's,^CODESET.*,CODESET="Uni2",g' \
|
||||
-e 's,^FONTFACE.*,FONTFACE="Fixed",g' \
|
||||
/etc/default/console-setup
|
||||
|
||||
# Configure the console-setup
|
||||
dpkg-reconfigure --frontend=noninteractive console-setup ||
|
||||
{ echo "FAILED to recofigure console-setup"; exit 1; }
|
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Create the necessary users and set their passwords. If needed,
|
||||
# make sure they belong to the proper groups
|
||||
#
|
||||
# Author: Ben Howard <ben.howard@canonical.com>
|
||||
# Date: 29 Jun 2011
|
||||
#
|
||||
|
||||
echo "Adding admin group..."
|
||||
addgroup --system --quiet admin
|
||||
|
||||
echo "Adding netdev group..."
|
||||
addgroup --system --quiet netdev
|
@ -0,0 +1,32 @@
|
||||
#!/bin/bash -ex
|
||||
|
||||
if [ -n "$SUBARCH" ]; then
|
||||
echo "Skipping rootfs build for subarch flavor build"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
. /build/config/functions
|
||||
|
||||
mkdir binary/boot/filesystem.dir
|
||||
cp -a chroot/* binary/boot/filesystem.dir
|
||||
|
||||
setup_mountpoint binary/boot/filesystem.dir
|
||||
|
||||
chroot binary/boot/filesystem.dir dpkg-divert --local --rename /usr/sbin/grub-probe
|
||||
chroot binary/boot/filesystem.dir touch /usr/sbin/grub-probe
|
||||
chroot binary/boot/filesystem.dir chmod +x /usr/sbin/grub-probe
|
||||
|
||||
env DEBIAN_FRONTEND=noninteractive chroot binary/boot/filesystem.dir apt-get --purge remove --assume-yes '^linux-.*'
|
||||
env DEBIAN_FRONTEND=noninteractive chroot binary/boot/filesystem.dir apt-get --purge remove --assume-yes '^grub-.*'
|
||||
env DEBIAN_FRONTEND=noninteractive chroot binary/boot/filesystem.dir apt-get autoremove --purge --assume-yes
|
||||
chroot binary/boot/filesystem.dir mkdir /lib/modules
|
||||
|
||||
chroot binary/boot/filesystem.dir rm /usr/sbin/grub-probe
|
||||
chroot binary/boot/filesystem.dir dpkg-divert --remove --local --rename /usr/sbin/grub-probe
|
||||
|
||||
mv resolv.conf.tmp "binary/boot/filesystem.dir/etc/resolv.conf"
|
||||
umount "binary/boot/filesystem.dir/proc"
|
||||
umount "binary/boot/filesystem.dir/sys"
|
||||
umount "binary/boot/filesystem.dir/dev/pts"
|
||||
umount "binary/boot/filesystem.dir/dev"
|
||||
umount "binary/boot/filesystem.dir/tmp"
|
@ -0,0 +1,13 @@
|
||||
#!/bin/bash -ex
|
||||
# vi: ts=4 noexpandtab
|
||||
#
|
||||
# Generate the rootfs.tar.gz and manifest
|
||||
|
||||
if [ -n "$SUBARCH" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
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"
|
@ -0,0 +1,124 @@
|
||||
#!/bin/bash -ex
|
||||
|
||||
. /build/config/functions
|
||||
|
||||
BOOTPART_START=
|
||||
BOOTPART_END=
|
||||
BOOT_MOUNTPOINT=
|
||||
ROOTPART_START=1
|
||||
|
||||
case $ARCH:$SUBARCH in
|
||||
ppc64el:*|powerpc:*)
|
||||
echo "POWER disk images are handled separately"
|
||||
exit 0
|
||||
;;
|
||||
armhf:raspi2)
|
||||
# matches the size of the snappy image
|
||||
IMAGE_SIZE=$((4*1000*1000*1000))
|
||||
|
||||
BOOTPART_START=8192s
|
||||
BOOTPART_END=138M
|
||||
BOOT_MOUNTPOINT=/boot/firmware
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
create_empty_partition_table() {
|
||||
apt-get install -qqy parted
|
||||
|
||||
parted "$1" --script -- mklabel msdos
|
||||
}
|
||||
|
||||
create_empty_partition() {
|
||||
local disk="$1"
|
||||
local part="$2"
|
||||
local start="$3"
|
||||
local end="$4"
|
||||
local type="$5"
|
||||
local bootable="$6"
|
||||
|
||||
parted_prefix="parted $disk --script --"
|
||||
${parted_prefix} mkpart primary "$type" "$start" "$end"
|
||||
if [ -n "$bootable" ]; then
|
||||
${parted_prefix} set "$part" B
|
||||
fi
|
||||
${parted_prefix} print
|
||||
${parted_prefix} align-check opt "$part"
|
||||
}
|
||||
|
||||
disk_image=binary/boot/disk.ext4
|
||||
|
||||
create_empty_disk_image "${disk_image}"
|
||||
create_empty_partition_table "${disk_image}"
|
||||
|
||||
ROOTPART=1
|
||||
ROOT_BOOTABLE=1
|
||||
if [ -n "$BOOTPART_START" ]; then
|
||||
ROOTPART=2
|
||||
ROOTPART_START="$BOOTPART_END"
|
||||
ROOT_BOOTABLE=
|
||||
create_empty_partition "$disk_image" 1 "$BOOTPART_START" "$BOOTPART_END" fat32 1
|
||||
fi
|
||||
create_empty_partition "${disk_image}" "$ROOTPART" "$ROOTPART_START" -1 ext2 "$ROOT_BOOTABLE"
|
||||
|
||||
mount_image "${disk_image}" "$ROOTPART"
|
||||
|
||||
# Copy the chroot in to the disk
|
||||
make_ext4_partition "${rootfs_dev_mapper}"
|
||||
mkdir mountpoint
|
||||
mount "${rootfs_dev_mapper}" mountpoint
|
||||
|
||||
if [ -n "$BOOT_MOUNTPOINT" ]; then
|
||||
boot_dev_mapper="${rootfs_dev_mapper%%[0-9]}1"
|
||||
# assume fat32 for now
|
||||
mkfs.vfat -n system-boot "$boot_dev_mapper"
|
||||
mkdir -p "mountpoint/$BOOT_MOUNTPOINT"
|
||||
mount "$boot_dev_mapper" "mountpoint/$BOOT_MOUNTPOINT"
|
||||
fi
|
||||
|
||||
cp -a chroot/* mountpoint/
|
||||
|
||||
setup_mountpoint mountpoint
|
||||
|
||||
case $ARCH:$SUBARCH in
|
||||
armhf:raspi2)
|
||||
chroot mountpoint flash-kernel \
|
||||
--machine "Raspberry Pi 2 Model B"
|
||||
# not the best place for this, but neither flash-kernel nor
|
||||
# u-boot have provisions for installing u-boot via maintainer
|
||||
# script
|
||||
/build/config/hooks/raspi2/mkknlimg --dtok \
|
||||
mountpoint/usr/lib/u-boot/rpi_2/u-boot.bin \
|
||||
mountpoint/boot/firmware/uboot.bin
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
case $ARCH in
|
||||
amd64|i386) should_install_grub=1;;
|
||||
*) should_install_grub=0;;
|
||||
esac
|
||||
|
||||
if [ "${should_install_grub}" -eq 1 ]; then
|
||||
echo "(hd0) ${loop_device}" > mountpoint/tmp/device.map
|
||||
chroot mountpoint grub-install ${loop_device}
|
||||
chroot mountpoint grub-bios-setup \
|
||||
--boot-image=i386-pc/boot.img \
|
||||
--core-image=i386-pc/core.img \
|
||||
--skip-fs-probe \
|
||||
--device-map=/tmp/device.map \
|
||||
${loop_device}
|
||||
|
||||
rm mountpoint/tmp/device.map
|
||||
fi
|
||||
|
||||
if [ -n "$BOOT_MOUNTPOINT" ]; then
|
||||
umount "mountpoint/$BOOT_MOUNTPOINT"
|
||||
fi
|
||||
|
||||
umount_partition mountpoint
|
||||
rmdir mountpoint
|
||||
|
||||
clean_loops
|
||||
trap - EXIT
|
@ -0,0 +1,19 @@
|
||||
#!/bin/bash -ex
|
||||
# vi: ts=4 noexpandtab
|
||||
#
|
||||
# Generate a squashfs root and manifest
|
||||
|
||||
if [ -n "$SUBARCH" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
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 )
|
@ -0,0 +1,141 @@
|
||||
#!/bin/bash -eux
|
||||
|
||||
case $ARCH in
|
||||
amd64|arm64)
|
||||
;;
|
||||
*)
|
||||
echo "We don't create EFI images for $ARCH."
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
. /build/config/functions
|
||||
|
||||
apt-get -qqy install dosfstools gdisk
|
||||
|
||||
create_partitions() {
|
||||
disk_image="$1"
|
||||
sgdisk "${disk_image}" --zap-all
|
||||
case $ARCH in
|
||||
arm64)
|
||||
sgdisk "${disk_image}" \
|
||||
--new=15:0:204800 \
|
||||
--typecode=15:ef00 \
|
||||
--new=1:
|
||||
;;
|
||||
amd64)
|
||||
sgdisk "${disk_image}" \
|
||||
--new=14::+4M \
|
||||
--new=15::+106M \
|
||||
--new=1::
|
||||
sgdisk "${disk_image}" \
|
||||
-t 14:ef02 \
|
||||
-t 15:ef00
|
||||
;;
|
||||
esac
|
||||
sgdisk "${disk_image}" \
|
||||
--print
|
||||
}
|
||||
|
||||
create_and_mount_uefi_partition() {
|
||||
uefi_dev="/dev/mapper${loop_device///dev/}p15"
|
||||
mountpoint="$1"
|
||||
mkfs.vfat -F 32 -n UEFI "${uefi_dev}"
|
||||
|
||||
mkdir -p "${mountpoint}"/boot/efi
|
||||
mount "${uefi_dev}" "$mountpoint"/boot/efi
|
||||
|
||||
cat << EOF >> "mountpoint/etc/fstab"
|
||||
LABEL=UEFI /boot/efi vfat defaults 0 0
|
||||
EOF
|
||||
}
|
||||
|
||||
install_grub() {
|
||||
mkdir mountpoint
|
||||
mount_partition "${rootfs_dev_mapper}" mountpoint
|
||||
|
||||
create_and_mount_uefi_partition mountpoint
|
||||
|
||||
echo "(hd0) ${loop_device}" > mountpoint/tmp/device.map
|
||||
mkdir -p mountpoint/etc/default/grub.d
|
||||
efi_boot_dir="/boot/efi/EFI/BOOT"
|
||||
chroot mountpoint mkdir -p "${efi_boot_dir}"
|
||||
|
||||
case $ARCH in
|
||||
arm64)
|
||||
chroot mountpoint apt-get -qqy install --no-install-recommends grub-efi-arm64 grub-efi-arm64-bin
|
||||
grub_modules="part_gpt fat gzio ext2 normal chain boot configfile linux search_fs_uuid search_label terminal serial video video_fb efi_gop"
|
||||
efi_target=arm64-efi
|
||||
;;
|
||||
amd64)
|
||||
chroot mountpoint apt-get install -qqy grub-efi-amd64-signed grub-efi-amd64 shim-signed
|
||||
grub_modules="part_gpt fat ext2 normal chain boot configfile linux multiboot search_fs_uuid search_label terminal serial video video_fb video_bochs usb usb_keyboard efi_gop efi_uga"
|
||||
efi_target=x86_64-efi
|
||||
;;
|
||||
esac
|
||||
|
||||
cat << EOF >> mountpoint/etc/default/grub.d/50-cloudimg-settings.cfg
|
||||
${CLOUD_IMG_STR}
|
||||
# For Cloud Image compatability
|
||||
GRUB_PRELOAD_MODULES="${grub_modules}"
|
||||
EOF
|
||||
chroot mountpoint grub-install "${loop_device}" \
|
||||
--boot-directory=/boot \
|
||||
--efi-directory=/boot/efi \
|
||||
--target=${efi_target} \
|
||||
--removable \
|
||||
--uefi-secure-boot \
|
||||
--no-nvram \
|
||||
--modules="${grub_modules}"
|
||||
|
||||
if [ -f mountpoint/boot/efi/EFI/BOOT/grub.cfg ]; then
|
||||
sed -i "s| root| root hd0,gpt1|" mountpoint/boot/efi/EFI/BOOT/grub.cfg
|
||||
sed -i "1i${CLOUD_IMG_STR}" mountpoint/boot/efi/EFI/BOOT/grub.cfg
|
||||
# For some reason the grub disk is looking for /boot/grub/grub.cfg on
|
||||
# part 15....
|
||||
chroot mountpoint mkdir -p /boot/efi/boot/grub
|
||||
chroot mountpoint cp /boot/efi/EFI/BOOT/grub.cfg /boot/efi/boot/grub
|
||||
fi
|
||||
|
||||
if [ "$ARCH" = "amd64" ]; then
|
||||
# Install the BIOS/GPT bits. Since GPT boots from the ESP partition,
|
||||
# it means that we just run this simple command and we're done
|
||||
chroot mountpoint grub-install --target=i386-pc "${loop_device}"
|
||||
fi
|
||||
|
||||
chroot mountpoint dpkg-divert --local --rename /etc/grub.d/30_os-prober
|
||||
chroot mountpoint update-grub
|
||||
replace_grub_root_with_label mountpoint
|
||||
chroot mountpoint dpkg-divert --remove --local --rename /etc/grub.d/30_os-prober
|
||||
|
||||
chroot mountpoint apt-get -y clean
|
||||
chroot mountpoint apt-get -y update
|
||||
|
||||
rm mountpoint/tmp/device.map
|
||||
sync
|
||||
umount mountpoint/boot/efi
|
||||
sleep 5
|
||||
udevadm settle
|
||||
mount
|
||||
umount_partition mountpoint
|
||||
rmdir mountpoint
|
||||
}
|
||||
|
||||
disk_image=binary/boot/disk-uefi.ext4
|
||||
|
||||
create_empty_disk_image "${disk_image}"
|
||||
create_partitions "${disk_image}"
|
||||
mount_image "${disk_image}" 1
|
||||
|
||||
# Copy the chroot in to the disk
|
||||
make_ext4_partition "${rootfs_dev_mapper}"
|
||||
mkdir mountpoint
|
||||
mount "${rootfs_dev_mapper}" mountpoint
|
||||
cp -a chroot/* mountpoint/
|
||||
umount mountpoint
|
||||
rmdir mountpoint
|
||||
|
||||
install_grub
|
||||
|
||||
clean_loops
|
||||
trap - EXIT
|
@ -0,0 +1,79 @@
|
||||
#!/bin/bash -eux
|
||||
case $ARCH in
|
||||
ppc64el|powerpc)
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
. /build/config/functions
|
||||
|
||||
create_partitions() {
|
||||
disk_image="$1"
|
||||
apt-get install -qqy gdisk
|
||||
sgdisk "${disk_image}" \
|
||||
--zap-all
|
||||
sgdisk "${disk_image}" \
|
||||
--new=2::+8M \
|
||||
--new=1:
|
||||
sgdisk "${disk_image}" -t 2:4100
|
||||
sgdisk "${disk_image}" \
|
||||
--print
|
||||
}
|
||||
|
||||
install_grub() {
|
||||
mkdir mountpoint
|
||||
mount_partition "${rootfs_dev_mapper}" mountpoint
|
||||
|
||||
chroot mountpoint apt-get -qqy update
|
||||
chroot mountpoint apt-get -qqy install grub2
|
||||
chroot mountpoint apt-get -qqy remove --purge grub-legacy-ec2
|
||||
|
||||
# set the kernel commandline to use hvc0
|
||||
mkdir -p mountpoint/etc/default/grub.d
|
||||
cat << EOF > mountpoint/etc/default/grub.d/50-cloudimg-settings.cfg
|
||||
${CLOUD_IMG_STR}
|
||||
|
||||
# Set the recordfail timeout
|
||||
GRUB_RECORDFAIL_TIMEOUT=0
|
||||
|
||||
# Do not wait on grub prompt
|
||||
GRUB_TIMEOUT=0
|
||||
|
||||
# Set the default commandline
|
||||
GRUB_CMDLINE_LINUX_DEFAULT="console=hvc0 earlyprintk"
|
||||
EOF
|
||||
prep_partition="/dev/mapper${loop_device///dev/}p2"
|
||||
chroot mountpoint grub-install "${prep_partition}" \
|
||||
--no-nvram \
|
||||
--boot-directory=/boot \
|
||||
--target=powerpc-ieee1275
|
||||
|
||||
chroot mountpoint dpkg-divert --local --rename /etc/grub.d/30_os-prober
|
||||
chroot mountpoint update-grub
|
||||
replace_grub_root_with_label mountpoint
|
||||
chroot mountpoint dpkg-divert --remove --local --rename /etc/grub.d/30_os-prober
|
||||
|
||||
umount_partition mountpoint
|
||||
rmdir mountpoint
|
||||
}
|
||||
|
||||
disk_image=binary/boot/disk.ext4
|
||||
|
||||
create_empty_disk_image "${disk_image}"
|
||||
create_partitions "${disk_image}"
|
||||
mount_image "${disk_image}" 1
|
||||
|
||||
# Copy the chroot in to the disk
|
||||
make_ext4_partition "${rootfs_dev_mapper}"
|
||||
mkdir mountpoint
|
||||
mount "${rootfs_dev_mapper}" mountpoint
|
||||
cp -a chroot/* mountpoint/
|
||||
umount mountpoint
|
||||
rmdir mountpoint
|
||||
|
||||
install_grub
|
||||
|
||||
clean_loops
|
||||
trap - EXIT
|
@ -0,0 +1,23 @@
|
||||
#!/bin/bash -ex
|
||||
|
||||
case $ARCH:$SUBARCH in
|
||||
# Not sure if any other cloud images use subarch for something that
|
||||
# should take qcow2 format, so only skipping this on raspi2 for now.
|
||||
armhf:raspi2)
|
||||
apt-get install -qqy pxz
|
||||
pxz -T4 -c binary/boot/disk.ext4 > livecd.ubuntu-cpc.disk1.img.xz
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
apt-get install -qqy qemu-utils
|
||||
|
||||
. /build/config/functions
|
||||
|
||||
if [ -f binary/boot/disk.ext4 ]; then
|
||||
convert_to_qcow2 binary/boot/disk.ext4 livecd.ubuntu-cpc.disk1.img
|
||||
fi
|
||||
|
||||
if [ -f binary/boot/disk-uefi.ext4 ]; then
|
||||
convert_to_qcow2 binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.uefi1.img
|
||||
fi
|
@ -0,0 +1,22 @@
|
||||
#!/bin/bash -eux
|
||||
# vi: ts=4 expandtab
|
||||
#
|
||||
# Generate VMDK files
|
||||
|
||||
extension="disk1.vmdk"
|
||||
|
||||
case $ARCH in
|
||||
i386|amd64) ;;
|
||||
*) echo "VMDK images are not supported for $ARCH yet.";
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
. /build/config/functions
|
||||
|
||||
if [ -e binary/boot/disk.ext4 ]; then
|
||||
create_vmdk binary/boot/disk.ext4 livecd.ubuntu-cpc.disk1.vmdk
|
||||
fi
|
||||
|
||||
if [ -e binary/boot/disk-uefi.ext4 ]; then
|
||||
create_vmdk binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.uefi.vmdk
|
||||
fi
|
@ -0,0 +1,105 @@
|
||||
#!/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
|
||||
|
||||
|
||||
# Switch on $ARCH to determine which ID and description to use in the produced
|
||||
# OVF. We have fancy Ubuntu-specific IDs in the OVF specification, we might as
|
||||
# well use them.
|
||||
case $ARCH in
|
||||
amd64)
|
||||
ovf_id=94
|
||||
ovf_os_type="ubuntu64Guest"
|
||||
ovf_desc_bits=64 ;;
|
||||
i386)
|
||||
ovf_id=93
|
||||
ovf_os_type="ubuntu32Guest"
|
||||
ovf_desc_bits=32 ;;
|
||||
*)
|
||||
echo "OVA images are not supported for $ARCH yet.";
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
cur_d=${PWD}
|
||||
my_d=$(dirname $(readlink -f ${0}))
|
||||
|
||||
base_vmdk="livecd.ubuntu-cpc.disk1.vmdk"
|
||||
if [ "$ARCH" = "amd64" ]; then
|
||||
base_vmdk="livecd.ubuntu-cpc.uefi.vmdk"
|
||||
fi
|
||||
|
||||
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" \
|
||||
-e "s/@@OVF_ID@@/${ovf_id}/g" \
|
||||
-e "s/@@OVF_OS_TYPE@@/${ovf_os_type}/g" \
|
||||
-e "s/@@OVF_DESC_BITS@@/${ovf_desc_bits}/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}" <<EOF
|
||||
SHA256(${vmdk_f##*/})= ${vmdk_sha256}
|
||||
SHA256(${ovf##*/})= ${ovf_sha256}
|
||||
EOF
|
||||
|
||||
# Now create the OVA
|
||||
echo "Creating OVA with the following attributes:"
|
||||
cat <<EOM
|
||||
OVA information:
|
||||
Name: ${prefix}
|
||||
Size: ${vmdk_size}
|
||||
Capacity: ${vmdk_capacity}
|
||||
VMDK Name: ${vmdk_f##*/}
|
||||
VMDK SHA256: ${vmdk_sha256}
|
||||
OVF SHA256: ${ovf_sha256}
|
||||
EOM
|
||||
|
||||
tar -C ${scratch_d} \
|
||||
-cf ${cur_d}/livecd.ubuntu-cpc.ova \
|
||||
${prefix}.ovf \
|
||||
${prefix}.mf \
|
||||
${vmdk_f##*/}
|
@ -0,0 +1,221 @@
|
||||
#!/bin/bash -ex
|
||||
# vi: ts=4 noexpandtab
|
||||
#
|
||||
# Generate a generic Vagrant Box.
|
||||
#
|
||||
# Vagrant images are essentially nothing more than OVA's with extra-metadata
|
||||
# and some preinstalled packages.
|
||||
#
|
||||
# We can't use the OVA's for Vagrant since Vagrant uses SSH to modify the
|
||||
# instance. This build step creates a cloud-config ISO so that Cloud-Init
|
||||
# will configure the initial user, creates meta-data that tells Vagrant how
|
||||
# to interact with the cloud-init created users, and finally create the OVA.
|
||||
#
|
||||
# For this step, we make a deriviative of binary/boot/disk.ext4 and install
|
||||
# some packages in it, convert it to a vmdk, and then assemble the vagrant
|
||||
# box.
|
||||
|
||||
cur_d=${PWD}
|
||||
my_d=$(dirname $(readlink -f ${0}))
|
||||
|
||||
# Switch on $ARCH to determine which ID and description to use in the produced
|
||||
# OVF. We have fancy Ubuntu-specific IDs in the OVF specification, we might as
|
||||
# well use them.
|
||||
case $ARCH in
|
||||
amd64)
|
||||
ovf_id=94
|
||||
ovf_os_type="ubuntu64Guest"
|
||||
ovf_desc_bits=64 ;;
|
||||
i386)
|
||||
ovf_id=93
|
||||
ovf_os_type="ubuntu32Guest"
|
||||
ovf_desc_bits=32 ;;
|
||||
*)
|
||||
echo "Vagrant images are not supported for $ARCH yet."
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
. /build/config/functions
|
||||
|
||||
# Virtualbox is needed for making a small VMDK
|
||||
apt-get -qqy install genisoimage qemu-utils
|
||||
|
||||
# Lets be safe about this
|
||||
box_d=$(mktemp -d)
|
||||
seed_d=$(mktemp -d)
|
||||
mount_d=$(mktemp -d)
|
||||
|
||||
create_derivative "disk" "vagrant" #sets ${derivative_img}
|
||||
mount_disk_image ${derivative_img} ${mount_d}
|
||||
|
||||
cleanup_vagrant() {
|
||||
if [ -d "$mount_d" ]; then
|
||||
umount_disk_image "$mount_d"
|
||||
fi
|
||||
rm -rf ${box_d} ${seed_d} ${mount_d} ${derivative_img}
|
||||
}
|
||||
trap cleanup_vagrant EXIT
|
||||
|
||||
chroot ${mount_d} apt-get update
|
||||
# virtualbox-guest-utils Recommends: virtualbox-guest-x11, which we want to
|
||||
# avoid pulling into a cloud image.
|
||||
chroot ${mount_d} apt-get install --no-install-recommends -y virtualbox-guest-utils
|
||||
chroot ${mount_d} apt-get clean
|
||||
umount_disk_image "$mount_d"
|
||||
rmdir "$mount_d"
|
||||
|
||||
# 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:])
|
||||
|
||||
# Get the VMDK in place
|
||||
prefix="${distro}-${suite}-${version}-cloudimg"
|
||||
vmdk_f="${box_d}/${prefix}.vmdk"
|
||||
create_vmdk ${derivative_img} ${vmdk_f}
|
||||
|
||||
# Vagrant needs a base user. We either inject the well-known SSH key
|
||||
# or use password authentication. Both are ugly. So we'll use a password
|
||||
# and make it random. This obviously is insecure...but at least its
|
||||
# better than the alternatives.
|
||||
ubuntu_user_pass=$(openssl rand -hex 12)
|
||||
|
||||
####################################
|
||||
# Create the ConfigDrive
|
||||
# This is a cloud-init piece that instructs cloud-init to configure
|
||||
# a default user at first boot.
|
||||
|
||||
cdrom_vmdk_f="${box_d}/${prefix}-configdrive.vmdk"
|
||||
|
||||
# Create the user-data. This is totally insecure, but so is Vagrant. To
|
||||
# mitigate this insecurity, the vagrant instance is not accessible
|
||||
# except via local host.
|
||||
cat > ${seed_d}/user-data <<END
|
||||
#cloud-config
|
||||
password: ${ubuntu_user_pass}
|
||||
chpasswd: { expire: False }
|
||||
ssh_pwauth: True
|
||||
manage_etc_hosts: localhost
|
||||
END
|
||||
|
||||
# Create the fake meta-data
|
||||
cat > ${seed_d}/meta-data <<END
|
||||
instance-id: iid-$(openssl rand -hex 8)
|
||||
local-hostname: ubuntu-${suite}
|
||||
END
|
||||
|
||||
# Pad the cdrom, otherwise the VMDK will be invalid
|
||||
dd if=/dev/zero of=${seed_d}/bloat_file bs=1M count=10
|
||||
|
||||
# Create the ISO
|
||||
genisoimage \
|
||||
-output ${seed_d}/seed.iso \
|
||||
-volid cidata \
|
||||
-joliet -rock \
|
||||
-input-charset utf-8 \
|
||||
${seed_d}/user-data \
|
||||
${seed_d}/meta-data
|
||||
|
||||
# Make a VMDK out of the seed file.
|
||||
create_vmdk ${seed_d}/seed.iso ${cdrom_vmdk_f} 10
|
||||
|
||||
### END Create ConfigDrive
|
||||
##########################
|
||||
|
||||
##########################
|
||||
# VAGRANT meta-data
|
||||
|
||||
# Create the Vagrant file. This file is used by Vagrant to define how
|
||||
# Vagrant uses Virtualbox and how Vagrant interacts with the host.
|
||||
macaddr="02$(openssl rand -hex 5 | tr [:lower:] [:upper:])"
|
||||
cat > ${box_d}/Vagrantfile <<EOF
|
||||
# Front load the includes
|
||||
include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)
|
||||
load include_vagrantfile if File.exist?(include_vagrantfile)
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.base_mac = "${macaddr}"
|
||||
config.ssh.username = "ubuntu"
|
||||
config.ssh.password = "${ubuntu_user_pass}"
|
||||
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
vb.customize [ "modifyvm", :id, "--uart1", "0x3F8", "4" ]
|
||||
vb.customize [ "modifyvm", :id, "--uartmode1", "file", File.join(Dir.pwd, "${prefix}-console.log") ]
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
# Tag it as a Virtualbox Vagrant
|
||||
cat > ${box_d}/metadata.json <<EOF
|
||||
{
|
||||
"provider": "virtualbox"
|
||||
}
|
||||
EOF
|
||||
|
||||
# END
|
||||
##########################
|
||||
|
||||
##########################
|
||||
# Create the actual box
|
||||
|
||||
# Get information about the disks for the OVF
|
||||
vmdk_size=$(du -b "${vmdk_f}" | cut -f1)
|
||||
vmdk_capacity=$(qemu-img info "${vmdk_f}" | awk '-F[\( ]' '$1 ~ /virtual/ && $NF ~ /bytes.*/ {print$(NF-1)}')
|
||||
vmdk_sha256=$(sha256sum ${vmdk_f} | cut -d' ' -f1)
|
||||
|
||||
cdrom_size=$(du -b "${cdrom_vmdk_f}" | cut -f1)
|
||||
cdrom_capacity=$(qemu-img info "${cdrom_vmdk_f}" | awk '-F[\( ]' '$1 ~ /virtual/ && $NF ~ /bytes.*/ {print$(NF-1)}')
|
||||
cdrom_sha256=$(sha256sum ${cdrom_vmdk_f} | cut -d' ' -f1)
|
||||
|
||||
# Populate the OVF template
|
||||
ovf="${box_d}/box.ovf"
|
||||
cp ${my_d}/ovf/ubuntu-ova-v1-cloudcfg-vmdk.tmpl ${ovf}
|
||||
serial_stamp=$(date +%Y%m%d)
|
||||
sed -i "${ovf}" \
|
||||
-e "s/@@NAME@@/${prefix}-${serial_stamp}/g" \
|
||||
-e "s/@@FILENAME1@@/${vmdk_f##*/}/g" \
|
||||
-e "s/@@VMDK_FILE_SIZE@@/${vmdk_size}/g" \
|
||||
-e "s/@@VMDK_CAPACITY@@/${vmdk_capacity}/g" \
|
||||
-e "s/@@FILENAME2@@/${cdrom_vmdk_f##*/}/g" \
|
||||
-e "s/@@VMDK_FILE_SIZE2@@/${cdrom_size}/g" \
|
||||
-e "s/@@VMDK_CAPACITY2@@/${cdrom_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" \
|
||||
-e "s/@@OVF_ID@@/${ovf_id}/g" \
|
||||
-e "s/@@OVF_OS_TYPE@@/${ovf_os_type}/g" \
|
||||
-e "s/@@OVF_DESC_BITS@@/${ovf_desc_bits}/g"
|
||||
|
||||
ovf_sha256=$(sha256sum ${ovf} | cut -d' ' -f1)
|
||||
|
||||
# Generate the manifest
|
||||
manifest="${box_d}/${prefix}.mf"
|
||||
cat > "${manifest}" <<EOF
|
||||
SHA256(${vmdk_f##*/})= ${vmdk_sha256}
|
||||
SHA256(${cdrom_vmdk_f##*/})= ${cdrom_sha256}
|
||||
SHA256(${ovf##*/})= ${ovf_sha256}
|
||||
EOF
|
||||
|
||||
# Now create the box
|
||||
echo "Creating OVA with the following attributes:"
|
||||
cat <<EOM
|
||||
OVA information:
|
||||
Name: ${prefix}
|
||||
Size: ${vmdk_size}
|
||||
VMDK Name: ${vmdk_f##*/}
|
||||
VMDK Capacity: ${vmdk_capacity}
|
||||
VMDK SHA256: ${vmdk_sha256}
|
||||
CDROM Name: ${cdrom_vmdk_f##*/}
|
||||
CDROM Capacity: ${cdrom_capacity}
|
||||
CDROM SHA256: ${cdrom_sha256}
|
||||
EOM
|
||||
|
||||
tar -C ${box_d} \
|
||||
-cf ${cur_d}/livecd.ubuntu-cpc.vagrant.box \
|
||||
box.ovf \
|
||||
Vagrantfile \
|
||||
metadata.json \
|
||||
${prefix}.mf \
|
||||
${vmdk_f##*/} \
|
||||
${cdrom_vmdk_f##*/}
|
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
printf "HWCLOCKACCESS=no" >> /etc/default/rcS
|
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
sed -i "s|#PasswordAuthentication yes|PasswordAuthentication no|g" /etc/ssh/sshd_config
|
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Disable IPv6 privacy extensions on Utopic and later
|
||||
#
|
||||
|
||||
codename=$(sh -c 'lsb_release --short --codename')
|
||||
dist_ge() { [[ "$1" > "$2" || "$1" == "$2" ]]; }
|
||||
|
||||
if ! dist_ge "${codename}" "trusty"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cat << EOF > /etc/sysctl.d/99-cloudimg-ipv6.conf
|
||||
# Written by the Cloud Image build process
|
||||
# See https://bugs.launchpad.net/ubuntu/+source/procps/+bug/1068756
|
||||
net.ipv6.conf.all.use_tempaddr = 0
|
||||
net.ipv6.conf.default.use_tempaddr = 0
|
||||
EOF
|
@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Clean up extraneous log files that may be left around
|
||||
rm /etc/ssh/ssh_host*key* || echo "No SSH keys to remove"
|
||||
|
||||
# Fix LP: #1047707, 1019338
|
||||
# Truncate logs that are owned, otherwise remove
|
||||
whitelisted_logs=(/var/log/btmp /var/log/lastlog /var/log/wtmp /var/log/fsck/checkfs /var/log/fsck/checkroot)
|
||||
|
||||
for log in $(find /var/log -type f)
|
||||
do
|
||||
whitelisted=$(echo "${whitelisted_logs[@]}" | grep -o ${log})
|
||||
|
||||
if [ -n "${whitelisted}" ]; then
|
||||
: > ${log} &&
|
||||
echo "Truncated whitelisted log ${log}" ||
|
||||
echo "Failed to truncate whitelisted log ${log}"
|
||||
else
|
||||
|
||||
dpkg -S ${log} > /dev/null 2>&1 &&
|
||||
{ : > ${log} ||
|
||||
echo "Failed to truncate $f"; } ||
|
||||
{ rm ${log} &&
|
||||
echo "Removed ${log} as an orphaned log file" ||
|
||||
echo "Failed to remove unnecessary log $f"; }
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove un-owned log directories
|
||||
whitelisted_dirs=(/var/log/fsck)
|
||||
|
||||
for log_d in $(find /var/log/* -type d)
|
||||
do
|
||||
whitelisted=$(echo "${whitelisted_dirs[@]}" | grep -o "${log_d}")
|
||||
if [ -z "${whitelisted}" ]; then
|
||||
dpkg -S ${log_d} > /dev/null 2>&1 &&
|
||||
echo "Preserving log directory ${log_d}" ||
|
||||
{ rm -rf ${log_d} &&
|
||||
echo "Removed log directory ${log_d} as orphaned log dir" ||
|
||||
echo "Failed to remove unnessasary log dir ${log_d}"; }
|
||||
|
||||
else
|
||||
echo "Preserving whitelisted directory ${log_d}"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
rm -rf /var/run/* || echo "Failed to clean /var/run/*"
|
||||
rm /etc/passwd- || echo "No spare passwd file to cleanup"
|
||||
rm /etc/shadow- || echo "No spare shadow file to cleanup"
|
||||
rm /etc/gshadow- || echo "No spare gshadow file to cleanup"
|
||||
rm /etc/group- || echo "No spare group file to clenaup"
|
||||
rm -f /etc/apt/conf.d/00secure || echo "No apt cache to cleanup"
|
||||
|
||||
# Truncate instead of delete, LP: #707311
|
||||
truncate --size=0 -c /etc/popularity-contest.conf
|
@ -0,0 +1,312 @@
|
||||
#!/bin/bash -x
|
||||
rootd="${1:-/}"
|
||||
root_fs_label=cloudimg-rootfs
|
||||
set -ex
|
||||
|
||||
CLOUD_IMG_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process"
|
||||
|
||||
LANG=C
|
||||
|
||||
_xchroot() {
|
||||
# Prevent multiple chroots
|
||||
if [ "$1" = "/" ]; then
|
||||
shift;
|
||||
"$@"
|
||||
else
|
||||
chroot "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
#### COMMON architecture independent functions
|
||||
arch=$(_xchroot "${rootd}" dpkg --print-architecture)
|
||||
|
||||
add_serial_console() {
|
||||
condev=$1
|
||||
idir="$rootd/etc/init"
|
||||
cat << EOF > "${idir}/${condev}.conf"
|
||||
# CONDEV - getty
|
||||
#
|
||||
# This service maintains a getty on CONDEV from the point the system is
|
||||
# started until it is shut down again.
|
||||
|
||||
start on stopped rc RUNLEVEL=[2345] and (
|
||||
not-container or
|
||||
container CONTAINER=lxc or
|
||||
container CONTAINER=lxc-libvirt)
|
||||
|
||||
stop on runlevel [!2345]
|
||||
|
||||
pre-start script
|
||||
# getty will not be started if the serial console is not present
|
||||
stty -F /dev/CONDEV -a 2> /dev/null > /dev/null || { stop ; exit 0; }
|
||||
end script
|
||||
|
||||
respawn
|
||||
script
|
||||
exec /sbin/getty -L CONDEV 115200 vt102
|
||||
end script
|
||||
${CLOUD_IMG_STR}
|
||||
EOF
|
||||
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)
|
||||
_xchroot "${rootd}" sh -c 'sed -i "/^127.0.1.1/d" /etc/hosts'
|
||||
|
||||
## --------------
|
||||
# remove ssh pregenerated keys (LP: #512377)
|
||||
|
||||
_xchroot "${rootd}" sh -c 'rm -f /etc/ssh/ssh_host_[rd]sa_key*'
|
||||
|
||||
## --------------
|
||||
_xchroot "${rootd}" locale-gen en_US.utf8
|
||||
|
||||
## --------------
|
||||
# set cloud-init to be on
|
||||
values="NoCloud, ConfigDrive, AltCloud, OVF, MAAS, Ec2, None"
|
||||
printf "%s\t%s\t%s\t%s\n" \
|
||||
cloud-init cloud-init/datasources multiselect "$values" |
|
||||
_xchroot "${rootd}" debconf-set-selections
|
||||
_xchroot "${rootd}" dpkg-reconfigure --frontend=noninteractive cloud-init
|
||||
|
||||
## --------------
|
||||
# write some build information to the guest
|
||||
# the idea is that given runtime info and this info, the instance
|
||||
# can at least determine if there is a newer build available
|
||||
# these variables are passed in in environment from cloudimg-build-launcher
|
||||
if [ -n "${build_name}" -o -n "${serial}" ]; then
|
||||
d="${rootd}/etc/cloud"
|
||||
[ -d "$d" ] || mkdir -p "${d}"
|
||||
{
|
||||
[ -n "${build_name}" ] && echo "build_name: ${build_name}"
|
||||
[ -n "${serial}" ] && echo "serial: ${serial}"
|
||||
} > "$d/build.info"
|
||||
fi
|
||||
|
||||
## --------------
|
||||
# for maverick and newer, use LABEL= for the '/' entry in fstab
|
||||
if [ -n "${root_fs_label}" ]; then
|
||||
bl="[:blank:]"
|
||||
lstr="LABEL=${root_fs_label}"
|
||||
sed -i "s,^[^#${bl}]*\([${bl}]*/[${bl}].*\),${lstr}\1," "${rootd}/etc/fstab"
|
||||
fi
|
||||
cat > /etc/fstab << EOM
|
||||
LABEL=cloudimg-rootfs / ext4 defaults 0 0
|
||||
EOM
|
||||
|
||||
## Make sure that the update-motd.d directory exists
|
||||
[ ! -e "${rootd}/etc/update-motd.d" ] &&
|
||||
mkdir -p "${rootd}/etc/update-motd.d"
|
||||
|
||||
## write a MOTD file advertising support for images
|
||||
cat > "${rootd}/etc/update-motd.d/51-cloudguest" << EOF
|
||||
#!/bin/sh
|
||||
#
|
||||
${CLOUD_IMG_STR}
|
||||
# This file is not managed by a package. If you no longer want to
|
||||
# see this message you can safely remove the file.
|
||||
echo ""
|
||||
echo " Get cloud support with Ubuntu Advantage Cloud Guest:"
|
||||
echo " http://www.ubuntu.com/business/services/cloud"
|
||||
EOF
|
||||
|
||||
chmod +x "${rootd}/etc/update-motd.d/51-cloudguest"
|
||||
|
||||
# for quantal and newer, add /etc/overlayroot.local.conf
|
||||
# but do not overwrite anything that somehow got there
|
||||
if [ -f "${rootd}/etc/overlayroot.conf" ] &&
|
||||
[ ! -f "${rootd}/etc/overlayroot.local.conf" ]; then
|
||||
{
|
||||
echo "${CLOUD_IMG_STR}"
|
||||
echo "overlayroot_cfgdisk=LABEL=OROOTCFG"
|
||||
} > "${rootd}/etc/overlayroot.local.conf"
|
||||
fi
|
||||
|
||||
|
||||
#### END COMMON ARCH FUNCTIONS
|
||||
|
||||
|
||||
case $arch in
|
||||
# ARM images are special
|
||||
armhf|arm64)
|
||||
echo "Configuring ARM Serial Port"
|
||||
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"
|
||||
|
||||
exit 0
|
||||
;;
|
||||
## Add ttyS0 for i386/amd64 for Trusty and newer
|
||||
i386|amd64)
|
||||
add_serial_console ttyS0
|
||||
;;
|
||||
powerpc|ppc64el)
|
||||
add_serial_console hvc0
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
psuedo_grub_probe() {
|
||||
cat <<"PSUEDO_GRUB_PROBE"
|
||||
#!/bin/sh
|
||||
Usage() {
|
||||
cat <<EOF
|
||||
Usage: euca-psuedo-grub-probe
|
||||
this is a wrapper around grub-probe to provide the answers for an ec2 guest
|
||||
EOF
|
||||
}
|
||||
bad_Usage() { Usage 1>&2; fail "$@"; }
|
||||
|
||||
short_opts=""
|
||||
long_opts="device-map:,target:,device"
|
||||
getopt_out=$(getopt --name "${0##*/}" \
|
||||
--options "${short_opts}" --long "${long_opts}" -- "$@") &&
|
||||
eval set -- "${getopt_out}" ||
|
||||
bad_Usage
|
||||
|
||||
device_map=""
|
||||
target=""
|
||||
device=0
|
||||
arg=""
|
||||
|
||||
while [ $# -ne 0 ]; do
|
||||
cur=${1}; next=${2};
|
||||
case "$cur" in
|
||||
--device-map) device_map=${next}; shift;;
|
||||
--device) device=1;;
|
||||
--target) target=${next}; shift;;
|
||||
--) shift; break;;
|
||||
esac
|
||||
shift;
|
||||
done
|
||||
arg=${1}
|
||||
|
||||
case "${target}:${device}:${arg}" in
|
||||
device:*:/*) echo "/dev/sda1"; exit 0;;
|
||||
fs:*:*) echo "ext2"; exit 0;;
|
||||
partmap:*:*)
|
||||
# older versions of grub (lucid) want 'part_msdos' written
|
||||
# rather than 'msdos'
|
||||
legacy_pre=""
|
||||
grubver=$(dpkg-query --show --showformat '${Version}\n' grub-pc 2>/dev/null) &&
|
||||
dpkg --compare-versions "${grubver}" lt 1.98+20100804-5ubuntu3 &&
|
||||
legacy_pre="part_"
|
||||
echo "${legacy_pre}msdos";
|
||||
exit 0;;
|
||||
abstraction:*:*) echo ""; exit 0;;
|
||||
drive:*:/dev/sda) echo "(hd0)";;
|
||||
drive:*:/dev/sda*) echo "(hd0,1)";;
|
||||
fs_uuid:*:*) exit 1;;
|
||||
esac
|
||||
PSUEDO_GRUB_PROBE
|
||||
}
|
||||
|
||||
## install / setup grub2
|
||||
gprobe="${rootd}/usr/sbin/grub-probe"
|
||||
moved=0
|
||||
if [ -f "${gprobe}" ]; then
|
||||
mv "${gprobe}" "${gprobe}.dist"
|
||||
moved=1
|
||||
fi
|
||||
psuedo_grub_probe > "${gprobe}"
|
||||
chmod 755 "${gprobe}"
|
||||
|
||||
# for Quantal and later, use /etc/default/grub.d functionality
|
||||
# rather than modifying the grub configuration itself.
|
||||
# This avoids the mess of having to do dpkg stuff
|
||||
# LP: 1179940
|
||||
mkdir -p "${rootd}/etc/default/grub.d"
|
||||
cat << EOF > "${rootd}/etc/default/grub.d/50-cloudimg-settings.cfg"
|
||||
# Cloud Image specific Grub settings for Generic Cloud Images
|
||||
${CLOUD_IMG_STR}
|
||||
|
||||
# Set the recordfail timeout
|
||||
GRUB_RECORDFAIL_TIMEOUT=0
|
||||
|
||||
# Do not wait on grub prompt
|
||||
GRUB_TIMEOUT=0
|
||||
|
||||
# Set the default commandline
|
||||
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0"
|
||||
|
||||
# Set the grub console type
|
||||
GRUB_TERMINAL=console
|
||||
EOF
|
||||
_xchroot "${rootd}" update-grub2
|
||||
|
||||
# since this is a disk image, we technically don't need to install all the
|
||||
# grub modules, as the image itself is not bootable. This makes for a small
|
||||
# disk image
|
||||
_xchroot "${rootd}" update-grub
|
||||
|
||||
# reconfigure grub so that upgrades to grub-pc do not force a debconf config
|
||||
# changed prompt (LP: #1009294). This re-runs update-grub
|
||||
_xchroot "${rootd}" env DEBIAN_FRONTEND=noninteractive \
|
||||
dpkg-reconfigure grub-pc
|
||||
|
||||
grub2cfg="${rootd}/boot/grub/grub.cfg"
|
||||
[ ! -f "${grub2cfg}" ] ||
|
||||
sed -i -e "s,root=/dev/[hs]da1,root=LABEL=${root_fs_label}," "${grub2cfg}"
|
||||
|
||||
[ ${moved} -eq 0 ] || mv "${gprobe}.dist" "${gprobe}"
|
||||
|
||||
## modify /boot/grub/menu.lst if it exists
|
||||
## this is generated at install time by grub-legacy-ec2, but will have
|
||||
## devices as found from the _xchroot. Here we write what it will be on ec2
|
||||
if [ -f "${rootd}/boot/grub/menu.lst" ]; then
|
||||
grub_root="(hd0)"
|
||||
linux_root=/dev/sda1
|
||||
[ -n "${root_fs_label}" ] && linux_root="LABEL=${root_fs_label}"
|
||||
# the sed code below basically fixes/sets the following lines in a
|
||||
# /boot/grub/menu.lst file:
|
||||
# # kopt=root=xxxxxxx ro
|
||||
# kernel /boot/vmlinuz-... root=xxxxxx ....
|
||||
# # groot=xxxxx
|
||||
# root xxxxx
|
||||
# uuuid xxxxx
|
||||
sed -i "${rootd}/boot/grub/menu.lst" \
|
||||
-e "s|^\(# kopt=root=\)[^ ]*|\1${linux_root}|" \
|
||||
-e "s|^\(kernel.*root=\)[^ ]*|\1${linux_root}|" \
|
||||
-e "s|^\(# groot=\)[^ ]*|\1${grub_root}|" \
|
||||
-e "s|^\(root\|uuid\)\([[:space:]]*\).*|root\2${grub_root}|"
|
||||
|
||||
# grub-legacy-ec2 writes this ucf entry. since we've modified
|
||||
# /boot/grub/menu.lst, we have to remove it, or the user will
|
||||
# get prompted for a 3 way merge of the changes the first time this runs
|
||||
_xchroot "${rootd}" /usr/bin/ucfr --purge grub /var/run/grub/menu.lst
|
||||
fi
|
||||
|
||||
# vi: ts=3 expandtab
|
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
# Execute extra binary hooks.
|
||||
|
||||
my_dir=$(dirname $(readlink -f ${0}))
|
||||
extra_d=${my_dir}/extra
|
||||
|
||||
if [ ! -d ${my_dir}/extra ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Export the common functions to the extras
|
||||
. /build/config/functions
|
||||
|
||||
# Cleaner execution
|
||||
/bin/run-parts --regex ".*\.binary" "${extra_d}"
|
@ -0,0 +1,5 @@
|
||||
#! /bin/sh
|
||||
set -e
|
||||
|
||||
rm -f /bin/sync
|
||||
dpkg-divert --quiet --remove --rename /bin/sync
|
@ -0,0 +1,180 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Envelope xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<References>
|
||||
<File ovf:href="@@FILENAME1@@" ovf:id="file1" ovf:size="@@VMDK_FILE_SIZE@@"/>
|
||||
<File ovf:href="@@FILENAME2@@" ovf:id="file2" ovf:size="@@VMDK_FILE_SIZE2@@"/>
|
||||
</References>
|
||||
<DiskSection>
|
||||
<Info>Virtual disk information</Info>
|
||||
<Disk ovf:capacity="@@VMDK_CAPACITY@@" ovf:capacityAllocationUnits="byte" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" ovf:populatedSize="0"/>
|
||||
<Disk ovf:capacity="@@VMDK_CAPACITY2@@" ovf:capacityAllocationUnits="byte" ovf:diskId="vmdisk2" ovf:fileRef="file2" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" ovf:populatedSize="0"/>
|
||||
</DiskSection>
|
||||
<NetworkSection>
|
||||
<Info>The list of logical networks</Info>
|
||||
<Network ovf:name="VM Network">
|
||||
<Description>The VM Network network</Description>
|
||||
</Network>
|
||||
</NetworkSection>
|
||||
<VirtualSystem ovf:id="@@NAME@@">
|
||||
<Info>A virtual machine</Info>
|
||||
<Name>@@NAME@@</Name>
|
||||
<OperatingSystemSection ovf:id="@@OVF_ID@@" vmw:osType="@@OVF_OS_TYPE@@">
|
||||
<Info>The kind of installed guest operating system</Info>
|
||||
<Description>Ubuntu Linux (@@OVF_DESC_BITS@@-bit)</Description>
|
||||
</OperatingSystemSection>
|
||||
|
||||
<ProductSection ovf:required="false">
|
||||
<Info>Cloud-Init customization</Info>
|
||||
<Product>Ubuntu @@VERSION@@ Server (@@DATE@@)</Product>
|
||||
<Property ovf:key="instance-id" ovf:type="string" ovf:userConfigurable="true" ovf:value="id-ovf">
|
||||
<Label>A Unique Instance ID for this instance</Label>
|
||||
<Description>Specifies the instance id. This is required and used to determine if the machine should take "first boot" actions</Description>
|
||||
</Property>
|
||||
<Property ovf:key="hostname" ovf:type="string" ovf:userConfigurable="true" ovf:value="ubuntuguest">
|
||||
<Description>Specifies the hostname for the appliance</Description>
|
||||
</Property>
|
||||
<Property ovf:key="seedfrom" ovf:type="string" ovf:userConfigurable="true">
|
||||
<Label>Url to seed instance data from</Label>
|
||||
<Description>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.</Description>
|
||||
</Property>
|
||||
<Property ovf:key="public-keys" ovf:type="string" ovf:userConfigurable="true" ovf:value="">
|
||||
<Label>ssh public keys</Label>
|
||||
<Description>This field is optional, but indicates that the instance should populate the default user's 'authorized_keys' with this value</Description>
|
||||
</Property>
|
||||
<Property ovf:key="user-data" ovf:type="string" ovf:userConfigurable="true" ovf:value="">
|
||||
<Label>Encoded user-data</Label>
|
||||
<Description>In order to fit into a xml attribute, this value is base64 encoded . It will be decoded, and then processed normally as user-data.</Description>
|
||||
<!-- The following represents '#!/bin/sh\necho "hi world"'
|
||||
ovf:value="IyEvYmluL3NoCmVjaG8gImhpIHdvcmxkIgo="
|
||||
-->
|
||||
</Property>
|
||||
<Property ovf:key="password" ovf:type="string" ovf:userConfigurable="true" ovf:value="">
|
||||
<Label>Default User's password</Label>
|
||||
<Description>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.</Description>
|
||||
</Property>
|
||||
</ProductSection>
|
||||
|
||||
<VirtualHardwareSection ovf:transport="iso">
|
||||
<Info>Virtual hardware requirements</Info>
|
||||
<System>
|
||||
<vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
|
||||
<vssd:InstanceID>0</vssd:InstanceID>
|
||||
<vssd:VirtualSystemIdentifier>@@NAME@@</vssd:VirtualSystemIdentifier>
|
||||
<vssd:VirtualSystemType>vmx-10</vssd:VirtualSystemType>
|
||||
</System>
|
||||
<Item>
|
||||
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
|
||||
<rasd:Description>Number of Virtual CPUs</rasd:Description>
|
||||
<rasd:ElementName>@@NUM_CPUS@@ virtual CPU(s)</rasd:ElementName>
|
||||
<rasd:InstanceID>1</rasd:InstanceID>
|
||||
<rasd:ResourceType>3</rasd:ResourceType>
|
||||
<rasd:VirtualQuantity>@@NUM_CPUS@@</rasd:VirtualQuantity>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
|
||||
<rasd:Description>Memory Size</rasd:Description>
|
||||
<rasd:ElementName>@@MEM_SIZE@@MB of memory</rasd:ElementName>
|
||||
<rasd:InstanceID>2</rasd:InstanceID>
|
||||
<rasd:ResourceType>4</rasd:ResourceType>
|
||||
<rasd:VirtualQuantity>@@MEM_SIZE@@</rasd:VirtualQuantity>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:Address>0</rasd:Address>
|
||||
<rasd:Description>SCSI Controller</rasd:Description>
|
||||
<rasd:ElementName>SCSI Controller 0</rasd:ElementName>
|
||||
<rasd:InstanceID>3</rasd:InstanceID>
|
||||
<rasd:ResourceSubType>VirtualSCSI</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>6</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:Address>1</rasd:Address>
|
||||
<rasd:Description>IDE Controller</rasd:Description>
|
||||
<rasd:ElementName>VirtualIDEController 1</rasd:ElementName>
|
||||
<rasd:InstanceID>4</rasd:InstanceID>
|
||||
<rasd:ResourceType>5</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:Address>0</rasd:Address>
|
||||
<rasd:Description>IDE Controller</rasd:Description>
|
||||
<rasd:ElementName>VirtualIDEController 0</rasd:ElementName>
|
||||
<rasd:InstanceID>5</rasd:InstanceID>
|
||||
<rasd:ResourceType>5</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item ovf:required="false">
|
||||
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
|
||||
<rasd:ElementName>VirtualVideoCard</rasd:ElementName>
|
||||
<rasd:InstanceID>6</rasd:InstanceID>
|
||||
<rasd:ResourceType>24</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="enable3DSupport" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="enableMPTSupport" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="use3dRenderer" vmw:value="automatic"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="useAutoDetect" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="videoRamSizeInKB" vmw:value="4096"/>
|
||||
</Item>
|
||||
<Item ovf:required="false">
|
||||
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
|
||||
<rasd:ElementName>VirtualVMCIDevice</rasd:ElementName>
|
||||
<rasd:InstanceID>7</rasd:InstanceID>
|
||||
<rasd:ResourceSubType>vmware.vmci</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>1</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="allowUnrestrictedCommunication" vmw:value="false"/>
|
||||
</Item>
|
||||
<Item ovf:required="false">
|
||||
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
||||
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
|
||||
<rasd:ElementName>CD-ROM 1</rasd:ElementName>
|
||||
<rasd:InstanceID>8</rasd:InstanceID>
|
||||
<rasd:Parent>4</rasd:Parent>
|
||||
<rasd:ResourceSubType>vmware.cdrom.remotepassthrough</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>15</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="backing.exclusive" vmw:value="false"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
||||
<rasd:ElementName>Hard Disk 1</rasd:ElementName>
|
||||
<rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>
|
||||
<rasd:InstanceID>9</rasd:InstanceID>
|
||||
<rasd:Parent>3</rasd:Parent>
|
||||
<rasd:ResourceType>17</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="backing.writeThrough" vmw:value="false"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AddressOnParent>1</rasd:AddressOnParent>
|
||||
<rasd:ElementName>ConfigDriveDisk</rasd:ElementName>
|
||||
<rasd:HostResource>ovf:/disk/vmdisk2</rasd:HostResource>
|
||||
<rasd:InstanceID>10</rasd:InstanceID>
|
||||
<rasd:Parent>3</rasd:Parent>
|
||||
<rasd:ResourceType>17</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="backing.writeThrough" vmw:value="false"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AddressOnParent>7</rasd:AddressOnParent>
|
||||
<rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
|
||||
<rasd:Connection>VM Network</rasd:Connection>
|
||||
<rasd:Description>VmxNet3 ethernet adapter on "VM Network"</rasd:Description>
|
||||
<rasd:ElementName>Ethernet 1</rasd:ElementName>
|
||||
<rasd:InstanceID>11</rasd:InstanceID>
|
||||
<rasd:ResourceSubType>VmxNet3</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>10</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="wakeOnLanEnabled" vmw:value="true"/>
|
||||
</Item>
|
||||
<vmw:Config ovf:required="false" vmw:key="cpuHotAddEnabled" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="cpuHotRemoveEnabled" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="firmware" vmw:value="bios"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="virtualICH7MPresent" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="virtualSMCPresent" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="memoryHotAddEnabled" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="nestedHVEnabled" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.powerOffType" vmw:value="preset"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.resetType" vmw:value="preset"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.standbyAction" vmw:value="checkpoint"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.suspendType" vmw:value="preset"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.afterPowerOn" vmw:value="true"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.afterResume" vmw:value="true"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.beforeGuestShutdown" vmw:value="true"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.beforeGuestStandby" vmw:value="true"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.syncTimeWithHost" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.toolsUpgradePolicy" vmw:value="manual"/>
|
||||
</VirtualHardwareSection>
|
||||
</VirtualSystem>
|
||||
</Envelope>
|
@ -0,0 +1,178 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Envelope xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<References>
|
||||
<File ovf:href="@@FILENAME@@" ovf:id="file1" ovf:size="@@VMDK_FILE_SIZE@@"/>
|
||||
</References>
|
||||
<DiskSection>
|
||||
<Info>Virtual disk information</Info>
|
||||
<Disk ovf:capacity="@@VMDK_CAPACITY@@" ovf:capacityAllocationUnits="byte" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" ovf:populatedSize="0"/>
|
||||
</DiskSection>
|
||||
<NetworkSection>
|
||||
<Info>The list of logical networks</Info>
|
||||
<Network ovf:name="VM Network">
|
||||
<Description>The VM Network network</Description>
|
||||
</Network>
|
||||
</NetworkSection>
|
||||
<VirtualSystem ovf:id="@@NAME@@">
|
||||
<Info>A virtual machine</Info>
|
||||
<Name>@@NAME@@</Name>
|
||||
<OperatingSystemSection ovf:id="@@OVF_ID@@" vmw:osType="@@OVF_OS_TYPE@@">
|
||||
<Info>The kind of installed guest operating system</Info>
|
||||
<Description>Ubuntu Linux (@@OVF_DESC_BITS@@-bit)</Description>
|
||||
</OperatingSystemSection>
|
||||
|
||||
<ProductSection ovf:required="false">
|
||||
<Info>Cloud-Init customization</Info>
|
||||
<Product>Ubuntu @@VERSION@@ Server (@@DATE@@)</Product>
|
||||
<Property ovf:key="instance-id" ovf:type="string" ovf:userConfigurable="true" ovf:value="id-ovf">
|
||||
<Label>A Unique Instance ID for this instance</Label>
|
||||
<Description>Specifies the instance id. This is required and used to determine if the machine should take "first boot" actions</Description>
|
||||
</Property>
|
||||
<Property ovf:key="hostname" ovf:type="string" ovf:userConfigurable="true" ovf:value="ubuntuguest">
|
||||
<Description>Specifies the hostname for the appliance</Description>
|
||||
</Property>
|
||||
<Property ovf:key="seedfrom" ovf:type="string" ovf:userConfigurable="true">
|
||||
<Label>Url to seed instance data from</Label>
|
||||
<Description>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.</Description>
|
||||
</Property>
|
||||
<Property ovf:key="public-keys" ovf:type="string" ovf:userConfigurable="true" ovf:value="">
|
||||
<Label>ssh public keys</Label>
|
||||
<Description>This field is optional, but indicates that the instance should populate the default user's 'authorized_keys' with this value</Description>
|
||||
</Property>
|
||||
<Property ovf:key="user-data" ovf:type="string" ovf:userConfigurable="true" ovf:value="">
|
||||
<Label>Encoded user-data</Label>
|
||||
<Description>In order to fit into a xml attribute, this value is base64 encoded . It will be decoded, and then processed normally as user-data.</Description>
|
||||
<!-- The following represents '#!/bin/sh\necho "hi world"'
|
||||
ovf:value="IyEvYmluL3NoCmVjaG8gImhpIHdvcmxkIgo="
|
||||
-->
|
||||
</Property>
|
||||
<Property ovf:key="password" ovf:type="string" ovf:userConfigurable="true" ovf:value="">
|
||||
<Label>Default User's password</Label>
|
||||
<Description>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.</Description>
|
||||
</Property>
|
||||
</ProductSection>
|
||||
|
||||
<VirtualHardwareSection ovf:transport="iso">
|
||||
<Info>Virtual hardware requirements</Info>
|
||||
<System>
|
||||
<vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
|
||||
<vssd:InstanceID>0</vssd:InstanceID>
|
||||
<vssd:VirtualSystemIdentifier>@@NAME@@</vssd:VirtualSystemIdentifier>
|
||||
<vssd:VirtualSystemType>vmx-10</vssd:VirtualSystemType>
|
||||
</System>
|
||||
<Item>
|
||||
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
|
||||
<rasd:Description>Number of Virtual CPUs</rasd:Description>
|
||||
<rasd:ElementName>@@NUM_CPUS@@ virtual CPU(s)</rasd:ElementName>
|
||||
<rasd:InstanceID>1</rasd:InstanceID>
|
||||
<rasd:ResourceType>3</rasd:ResourceType>
|
||||
<rasd:VirtualQuantity>@@NUM_CPUS@@</rasd:VirtualQuantity>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
|
||||
<rasd:Description>Memory Size</rasd:Description>
|
||||
<rasd:ElementName>@@MEM_SIZE@@MB of memory</rasd:ElementName>
|
||||
<rasd:InstanceID>2</rasd:InstanceID>
|
||||
<rasd:ResourceType>4</rasd:ResourceType>
|
||||
<rasd:VirtualQuantity>@@MEM_SIZE@@</rasd:VirtualQuantity>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:Address>0</rasd:Address>
|
||||
<rasd:Description>SCSI Controller</rasd:Description>
|
||||
<rasd:ElementName>SCSI Controller 0</rasd:ElementName>
|
||||
<rasd:InstanceID>3</rasd:InstanceID>
|
||||
<rasd:ResourceSubType>VirtualSCSI</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>6</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:Address>1</rasd:Address>
|
||||
<rasd:Description>IDE Controller</rasd:Description>
|
||||
<rasd:ElementName>VirtualIDEController 1</rasd:ElementName>
|
||||
<rasd:InstanceID>4</rasd:InstanceID>
|
||||
<rasd:ResourceType>5</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:Address>0</rasd:Address>
|
||||
<rasd:Description>IDE Controller</rasd:Description>
|
||||
<rasd:ElementName>VirtualIDEController 0</rasd:ElementName>
|
||||
<rasd:InstanceID>5</rasd:InstanceID>
|
||||
<rasd:ResourceType>5</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item ovf:required="false">
|
||||
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
|
||||
<rasd:ElementName>VirtualVideoCard</rasd:ElementName>
|
||||
<rasd:InstanceID>6</rasd:InstanceID>
|
||||
<rasd:ResourceType>24</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="enable3DSupport" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="enableMPTSupport" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="use3dRenderer" vmw:value="automatic"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="useAutoDetect" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="videoRamSizeInKB" vmw:value="4096"/>
|
||||
</Item>
|
||||
<Item ovf:required="false">
|
||||
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
|
||||
<rasd:ElementName>VirtualVMCIDevice</rasd:ElementName>
|
||||
<rasd:InstanceID>7</rasd:InstanceID>
|
||||
<rasd:ResourceSubType>vmware.vmci</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>1</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="allowUnrestrictedCommunication" vmw:value="false"/>
|
||||
</Item>
|
||||
<Item ovf:required="false">
|
||||
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
||||
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
|
||||
<rasd:ElementName>CD-ROM 1</rasd:ElementName>
|
||||
<rasd:InstanceID>8</rasd:InstanceID>
|
||||
<rasd:Parent>4</rasd:Parent>
|
||||
<rasd:ResourceSubType>vmware.cdrom.remotepassthrough</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>15</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="backing.exclusive" vmw:value="false"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
||||
<rasd:ElementName>Hard Disk 1</rasd:ElementName>
|
||||
<rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>
|
||||
<rasd:InstanceID>9</rasd:InstanceID>
|
||||
<rasd:Parent>3</rasd:Parent>
|
||||
<rasd:ResourceType>17</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="backing.writeThrough" vmw:value="false"/>
|
||||
</Item>
|
||||
<Item ovf:required="false">
|
||||
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
||||
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
|
||||
<rasd:Description>Floppy Drive</rasd:Description>
|
||||
<rasd:ElementName>Floppy 1</rasd:ElementName>
|
||||
<rasd:InstanceID>10</rasd:InstanceID>
|
||||
<rasd:ResourceSubType>vmware.floppy.remotedevice</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>14</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AddressOnParent>7</rasd:AddressOnParent>
|
||||
<rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
|
||||
<rasd:Connection>VM Network</rasd:Connection>
|
||||
<rasd:Description>VmxNet3 ethernet adapter on "VM Network"</rasd:Description>
|
||||
<rasd:ElementName>Ethernet 1</rasd:ElementName>
|
||||
<rasd:InstanceID>11</rasd:InstanceID>
|
||||
<rasd:ResourceSubType>VmxNet3</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>10</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="wakeOnLanEnabled" vmw:value="true"/>
|
||||
</Item>
|
||||
<vmw:Config ovf:required="false" vmw:key="cpuHotAddEnabled" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="cpuHotRemoveEnabled" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="firmware" vmw:value="bios"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="virtualICH7MPresent" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="virtualSMCPresent" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="memoryHotAddEnabled" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="nestedHVEnabled" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.powerOffType" vmw:value="preset"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.resetType" vmw:value="preset"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.standbyAction" vmw:value="checkpoint"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.suspendType" vmw:value="preset"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.afterPowerOn" vmw:value="true"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.afterResume" vmw:value="true"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.beforeGuestShutdown" vmw:value="true"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.beforeGuestStandby" vmw:value="true"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.syncTimeWithHost" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.toolsUpgradePolicy" vmw:value="manual"/>
|
||||
</VirtualHardwareSection>
|
||||
</VirtualSystem>
|
||||
</Envelope>
|
@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Envelope xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<References>
|
||||
<File ovf:href="$FILE_DISK_HREF" ovf:id="file1" ovf:size="$FILE_DISK_SIZE" />
|
||||
</References>
|
||||
<DiskSection>
|
||||
<Info>Virtual disk information</Info>
|
||||
<Disk ovf:capacity="$DISK_CAPACITY" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://wiki.qemu.org/download/qcow2-spec.html"/>
|
||||
</DiskSection>
|
||||
<NetworkSection>
|
||||
<Info>The list of logical networks</Info>
|
||||
<Network ovf:name="bridged">
|
||||
<Description>The bridged network</Description>
|
||||
</Network>
|
||||
</NetworkSection>
|
||||
<VirtualSystem ovf:id="vm">
|
||||
<Info>A virtual machine</Info>
|
||||
<Name>$VIRTUAL_SYSTEM_NAME</Name>
|
||||
<OperatingSystemSection ovf:id="93">
|
||||
<Info>$VIRTUAL_SYSTEM_OS_INFO</Info>
|
||||
</OperatingSystemSection>
|
||||
<ProductSection>
|
||||
<Info>Cloud-Init customization</Info>
|
||||
<Product>$VIRTUAL_SYSTEM_OS_INFO</Product>
|
||||
<Property ovf:key="instance-id" ovf:type="string" ovf:userConfigurable="true" ovf:value="id-ovf">
|
||||
<Label>A Unique Instance ID for this instance</Label>
|
||||
<Description>Specifies the instance id. This is required and used to determine if the machine should take "first boot" actions</Description>
|
||||
</Property>
|
||||
<Property ovf:key="hostname" ovf:type="string" ovf:userConfigurable="true" ovf:value="ubuntuguest">
|
||||
<Description>Specifies the hostname for the appliance</Description>
|
||||
</Property>
|
||||
<Property ovf:key="seedfrom" ovf:type="string" ovf:userConfigurable="true">
|
||||
<Label>Url to seed instance data from</Label>
|
||||
<Description>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.</Description>
|
||||
</Property>
|
||||
<Property ovf:key="public-keys" ovf:type="string" ovf:userConfigurable="true" ovf:value="">
|
||||
<Label>ssh public keys</Label>
|
||||
<Description>This field is optional, but indicates that the instance should populate the default user's 'authorized_keys' with this value</Description>
|
||||
</Property>
|
||||
<Property ovf:key="user-data" ovf:type="string" ovf:userConfigurable="true" ovf:value="">
|
||||
<Label>Encoded user-data</Label>
|
||||
<Description>In order to fit into a xml attribute, this value is base64 encoded . It will be decoded, and then processed normally as user-data.</Description>
|
||||
<!-- The following represents '#!/bin/sh\necho "hi world"'
|
||||
ovf:value="IyEvYmluL3NoCmVjaG8gImhpIHdvcmxkIgo="
|
||||
-->
|
||||
</Property>
|
||||
<Property ovf:key="password" ovf:type="string" ovf:userConfigurable="true" ovf:value="">
|
||||
<Label>Default User's password</Label>
|
||||
<Description>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.</Description>
|
||||
</Property>
|
||||
</ProductSection>
|
||||
<VirtualHardwareSection ovf:transport="iso">
|
||||
<Info>Virtual hardware requirements</Info>
|
||||
<System>
|
||||
<vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
|
||||
<vssd:InstanceID>0</vssd:InstanceID>
|
||||
<vssd:VirtualSystemIdentifier>$VIRTUAL_SYSTEM_IDENTIFIER</vssd:VirtualSystemIdentifier>
|
||||
<vssd:VirtualSystemType>$VIRTUAL_SYSTEM_TYPES</vssd:VirtualSystemType>
|
||||
</System>
|
||||
<Item>
|
||||
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
|
||||
<rasd:Description>Number of Virtual CPUs</rasd:Description>
|
||||
<rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
|
||||
<rasd:InstanceID>1</rasd:InstanceID>
|
||||
<rasd:ResourceType>3</rasd:ResourceType>
|
||||
<rasd:VirtualQuantity>1</rasd:VirtualQuantity>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
|
||||
<rasd:Description>Memory Size</rasd:Description>
|
||||
<rasd:ElementName>256MB of memory</rasd:ElementName>
|
||||
<rasd:InstanceID>2</rasd:InstanceID>
|
||||
<rasd:ResourceType>4</rasd:ResourceType>
|
||||
<rasd:VirtualQuantity>256</rasd:VirtualQuantity>
|
||||
</Item>
|
||||
<Item ovf:required="false">
|
||||
<rasd:Address>0</rasd:Address>
|
||||
<rasd:Description>USB Controller</rasd:Description>
|
||||
<rasd:ElementName>usb</rasd:ElementName>
|
||||
<rasd:InstanceID>3</rasd:InstanceID>
|
||||
<rasd:ResourceType>23</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:Address>0</rasd:Address>
|
||||
<rasd:Description>SCSI Controller</rasd:Description>
|
||||
<rasd:ElementName>scsiController0</rasd:ElementName>
|
||||
<rasd:InstanceID>4</rasd:InstanceID>
|
||||
<rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>6</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:Address>1</rasd:Address>
|
||||
<rasd:Description>IDE Controller</rasd:Description>
|
||||
<rasd:ElementName>ideController1</rasd:ElementName>
|
||||
<rasd:InstanceID>5</rasd:InstanceID>
|
||||
<rasd:ResourceType>5</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item ovf:required="false">
|
||||
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
||||
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
|
||||
<rasd:ElementName>cdrom1</rasd:ElementName>
|
||||
<rasd:InstanceID>6</rasd:InstanceID>
|
||||
<rasd:Parent>5</rasd:Parent>
|
||||
<rasd:ResourceType>15</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
||||
<rasd:ElementName>disk1</rasd:ElementName>
|
||||
<rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>
|
||||
<rasd:InstanceID>7</rasd:InstanceID>
|
||||
<rasd:Parent>4</rasd:Parent>
|
||||
<rasd:ResourceType>17</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AddressOnParent>2</rasd:AddressOnParent>
|
||||
<rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
|
||||
<rasd:Connection>bridged</rasd:Connection>
|
||||
<rasd:Description>ethernet adapter on "bridged"</rasd:Description>
|
||||
<rasd:ElementName>ethernet0</rasd:ElementName>
|
||||
<rasd:InstanceID>8</rasd:InstanceID>
|
||||
<rasd:ResourceSubType>E1000</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>10</rasd:ResourceType>
|
||||
</Item>
|
||||
</VirtualHardwareSection>
|
||||
<AnnotationSection ovf:required="false">
|
||||
<Info>$ANNOTATION_INFO</Info>
|
||||
<Annotation>$ANNOTATION</Annotation>
|
||||
</AnnotationSection>
|
||||
</VirtualSystem>
|
||||
</Envelope>
|
@ -0,0 +1,244 @@
|
||||
#!/usr/bin/env perl
|
||||
# ----------------------------------------------------------------------
|
||||
# mkknlimg by Phil Elwell for Raspberry Pi
|
||||
# based on extract-ikconfig by Dick Streefland
|
||||
#
|
||||
# (c) 2009,2010 Dick Streefland <dick@streefland.net>
|
||||
# (c) 2014,2015 Raspberry Pi (Trading) Limited <info@raspberrypi.org>
|
||||
#
|
||||
# Licensed under the terms of the GNU General Public License.
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use integer;
|
||||
|
||||
my $trailer_magic = 'RPTL';
|
||||
|
||||
my $tmpfile1 = "/tmp/mkknlimg_$$.1";
|
||||
my $tmpfile2 = "/tmp/mkknlimg_$$.2";
|
||||
|
||||
my $dtok = 0;
|
||||
my $is_283x = 0;
|
||||
|
||||
while (@ARGV && ($ARGV[0] =~ /^-/))
|
||||
{
|
||||
my $arg = shift(@ARGV);
|
||||
if ($arg eq '--dtok')
|
||||
{
|
||||
$dtok = 1;
|
||||
}
|
||||
elsif ($arg eq '--283x')
|
||||
{
|
||||
$is_283x = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print ("* Unknown option '$arg'\n");
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
usage() if (@ARGV != 2);
|
||||
|
||||
my $kernel_file = $ARGV[0];
|
||||
my $out_file = $ARGV[1];
|
||||
|
||||
if (! -r $kernel_file)
|
||||
{
|
||||
print ("* File '$kernel_file' not found\n");
|
||||
usage();
|
||||
}
|
||||
|
||||
my @wanted_strings =
|
||||
(
|
||||
'bcm2708_fb',
|
||||
'brcm,bcm2835-mmc',
|
||||
'brcm,bcm2835-sdhost',
|
||||
'brcm,bcm2708-pinctrl',
|
||||
'brcm,bcm2835-gpio',
|
||||
'brcm,bcm2835',
|
||||
'brcm,bcm2836'
|
||||
);
|
||||
|
||||
my $res = try_extract($kernel_file, $tmpfile1);
|
||||
$res = try_decompress('\037\213\010', 'xy', 'gunzip', 0,
|
||||
$kernel_file, $tmpfile1, $tmpfile2) if (!$res);
|
||||
$res = try_decompress('\3757zXZ\000', 'abcde', 'unxz --single-stream', -1,
|
||||
$kernel_file, $tmpfile1, $tmpfile2) if (!$res);
|
||||
$res = try_decompress('BZh', 'xy', 'bunzip2', 0,
|
||||
$kernel_file, $tmpfile1, $tmpfile2) if (!$res);
|
||||
$res = try_decompress('\135\0\0\0', 'xxx', 'unlzma', 0,
|
||||
$kernel_file, $tmpfile1, $tmpfile2) if (!$res);
|
||||
$res = try_decompress('\211\114\132', 'xy', 'lzop -d', 0,
|
||||
$kernel_file, $tmpfile1, $tmpfile2) if (!$res);
|
||||
$res = try_decompress('\002\041\114\030', 'xy', 'lz4 -d', 1,
|
||||
$kernel_file, $tmpfile1, $tmpfile2) if (!$res);
|
||||
|
||||
my $append_trailer;
|
||||
my $trailer;
|
||||
my $kver = '?';
|
||||
|
||||
$append_trailer = $dtok;
|
||||
|
||||
if ($res)
|
||||
{
|
||||
$kver = $res->{''} || '?';
|
||||
print("Version: $kver\n");
|
||||
|
||||
$append_trailer = $dtok;
|
||||
if (!$dtok)
|
||||
{
|
||||
if (config_bool($res, 'bcm2708_fb') ||
|
||||
config_bool($res, 'brcm,bcm2835-mmc') ||
|
||||
config_bool($res, 'brcm,bcm2835-sdhost'))
|
||||
{
|
||||
$dtok ||= config_bool($res, 'brcm,bcm2708-pinctrl');
|
||||
$dtok ||= config_bool($res, 'brcm,bcm2835-gpio');
|
||||
$is_283x ||= config_bool($res, 'brcm,bcm2835');
|
||||
$is_283x ||= config_bool($res, 'brcm,bcm2836');
|
||||
$dtok ||= $is_283x;
|
||||
$append_trailer = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print ("* This doesn't look like a Raspberry Pi kernel. In pass-through mode.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif (!$dtok)
|
||||
{
|
||||
print ("* Is this a valid kernel? In pass-through mode.\n");
|
||||
}
|
||||
|
||||
if ($append_trailer)
|
||||
{
|
||||
printf("DT: %s\n", $dtok ? "y" : "n");
|
||||
printf("283x: %s\n", $is_283x ? "y" : "n");
|
||||
|
||||
my @atoms;
|
||||
|
||||
push @atoms, [ $trailer_magic, pack('V', 0) ];
|
||||
push @atoms, [ 'KVer', $kver ];
|
||||
push @atoms, [ 'DTOK', pack('V', $dtok) ];
|
||||
push @atoms, [ '283x', pack('V', $is_283x) ];
|
||||
|
||||
$trailer = pack_trailer(\@atoms);
|
||||
$atoms[0]->[1] = pack('V', length($trailer));
|
||||
|
||||
$trailer = pack_trailer(\@atoms);
|
||||
}
|
||||
|
||||
my $ofh;
|
||||
my $total_len = 0;
|
||||
|
||||
if ($out_file eq $kernel_file)
|
||||
{
|
||||
die "* Failed to open '$out_file' for append\n"
|
||||
if (!open($ofh, '>>', $out_file));
|
||||
$total_len = tell($ofh);
|
||||
}
|
||||
else
|
||||
{
|
||||
die "* Failed to open '$kernel_file'\n"
|
||||
if (!open(my $ifh, '<', $kernel_file));
|
||||
die "* Failed to create '$out_file'\n"
|
||||
if (!open($ofh, '>', $out_file));
|
||||
|
||||
my $copybuf;
|
||||
while (1)
|
||||
{
|
||||
my $bytes = sysread($ifh, $copybuf, 64*1024);
|
||||
last if (!$bytes);
|
||||
syswrite($ofh, $copybuf, $bytes);
|
||||
$total_len += $bytes;
|
||||
}
|
||||
close($ifh);
|
||||
}
|
||||
|
||||
if ($trailer)
|
||||
{
|
||||
# Pad to word-alignment
|
||||
syswrite($ofh, "\x000\x000\x000", (-$total_len & 0x3));
|
||||
syswrite($ofh, $trailer);
|
||||
}
|
||||
|
||||
close($ofh);
|
||||
|
||||
exit($trailer ? 0 : 1);
|
||||
|
||||
END {
|
||||
unlink($tmpfile1) if ($tmpfile1);
|
||||
unlink($tmpfile2) if ($tmpfile2);
|
||||
}
|
||||
|
||||
|
||||
sub usage
|
||||
{
|
||||
print ("Usage: mkknlimg [--dtok] [--283x] <vmlinux|zImage|bzImage> <outfile>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sub try_extract
|
||||
{
|
||||
my ($knl, $tmp) = @_;
|
||||
|
||||
my $ver = `strings "$knl" | grep -a -E "^Linux version [1-9]"`;
|
||||
|
||||
return undef if (!$ver);
|
||||
|
||||
chomp($ver);
|
||||
|
||||
my $res = { ''=>$ver };
|
||||
my $string_pattern = '^('.join('|', @wanted_strings).')$';
|
||||
|
||||
my @matches = `strings \"$knl\" | grep -E \"$string_pattern\"`;
|
||||
foreach my $match (@matches)
|
||||
{
|
||||
chomp($match);
|
||||
$res->{$match} = 1;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
sub try_decompress
|
||||
{
|
||||
my ($magic, $subst, $zcat, $idx, $knl, $tmp1, $tmp2) = @_;
|
||||
|
||||
my $pos = `tr "$magic\n$subst" "\n$subst=" < "$knl" | grep -abo "^$subst"`;
|
||||
if ($pos)
|
||||
{
|
||||
chomp($pos);
|
||||
$pos = (split(/[\r\n]+/, $pos))[$idx];
|
||||
return undef if (!defined($pos));
|
||||
$pos =~ s/:.*[\r\n]*$//s;
|
||||
my $cmd = "tail -c+$pos \"$knl\" | $zcat > $tmp2 2> /dev/null";
|
||||
my $err = (system($cmd) >> 8);
|
||||
return undef if (($err != 0) && ($err != 2));
|
||||
|
||||
return try_extract($tmp2, $tmp1);
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub pack_trailer
|
||||
{
|
||||
my ($atoms) = @_;
|
||||
my $trailer = pack('VV', 0, 0);
|
||||
for (my $i = $#$atoms; $i>=0; $i--)
|
||||
{
|
||||
my $atom = $atoms->[$i];
|
||||
$trailer .= pack('a*x!4Va4', $atom->[1], length($atom->[1]), $atom->[0]);
|
||||
}
|
||||
return $trailer;
|
||||
}
|
||||
|
||||
sub config_bool
|
||||
{
|
||||
my ($configs, $wanted) = @_;
|
||||
my $val = $configs->{$wanted} || 'n';
|
||||
return (($val eq 'y') || ($val eq '1'));
|
||||
}
|
@ -0,0 +1 @@
|
||||
ubuntu
|
@ -0,0 +1,9 @@
|
||||
127.0.0.1 localhost
|
||||
|
||||
# The following lines are desirable for IPv6 capable hosts
|
||||
::1 ip6-localhost ip6-loopback
|
||||
fe00::0 ip6-localnet
|
||||
ff00::0 ip6-mcastprefix
|
||||
ff02::1 ip6-allnodes
|
||||
ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
@ -0,0 +1,15 @@
|
||||
# This file describes the network interfaces available on your system
|
||||
# and how to activate them. For more information, see interfaces(5).
|
||||
|
||||
# The loopback network interface
|
||||
auto lo
|
||||
iface lo inet loopback
|
||||
|
||||
# Source interfaces
|
||||
# Please check /etc/network/interfaces.d before changing this file
|
||||
# as interfaces may have been defined in /etc/network/interfaces.d
|
||||
# NOTE: the primary ethernet device is defined in
|
||||
# /etc/network/interfaces.d/eth0
|
||||
# See LP: #1262951
|
||||
source /etc/network/interfaces.d/*.cfg
|
||||
|
@ -0,0 +1,3 @@
|
||||
# The primary network interface
|
||||
auto eth0
|
||||
iface eth0 inet dhcp
|
Loading…
Reference in new issue