Move building of all architecture-specific CPC artifacts into Launchpad (LP: #1513754)

ubuntu/trusty
Robert C Jennings 8 years ago
parent 8a36dbc115
commit 38c87ca9af

8
debian/changelog vendored

@ -1,3 +1,11 @@
livecd-rootfs (2.209.1) trusty; urgency=medium
[Daniel Watkins]
* Move building of all architecture-specific CPC artifacts into Launchpad
(LP: #1513754).
-- Robert C Jennings <robert.jennings@canonical.com> Tue, 23 May 2017 16:33:44 -0500
livecd-rootfs (2.209) trusty; urgency=medium
* Add ubuntu-cpc project

@ -242,6 +242,10 @@ deb file:/var/lib/preinstalled-pool/ $LB_DISTRIBUTION $LB_PARENT_ARCHIVE_AREAS
Chroot chroot "ln -s /etc/media-info /var/log/installer/media-info"
fi
if [ "$PROJECT" = "ubuntu-cpc" ]; then
cat > chroot/etc/cloud/build.info << EOF
build_name: server
serial: $BUILDSTAMP
EOF
cat > chroot/etc/apt/sources.list << EOF
deb ${LB_PARENT_MIRROR_BINARY} ${LB_DISTRIBUTION} main restricted universe multiverse
deb ${LB_PARENT_MIRROR_BINARY} ${LB_DISTRIBUTION}-updates main restricted universe multiverse
@ -341,6 +345,10 @@ for FLAVOUR in $LB_LINUX_FLAVOURS; do
continue
fi
FLAVOUR=${FLAVOUR%%-lts-*}
if [ "$FLAVOUR" = "virtual" ]; then
# The virtual kernel is named generic in /boot
FLAVOUR="generic"
fi
KVERS="$( (cd "binary/$INITFS"; ls vmlinu?-* 2>/dev/null || true) | (fgrep -v .efi || true) | sed -n "s/^vmlinu.-\\([^-]*-[^-]*-$FLAVOUR\\)$/\\1/p" )"
if [ -z "$KVERS" ]; then
if [ -e "binary/$INITFS/vmlinuz" ]; then

@ -469,24 +469,22 @@ esac
if [ "$PROJECT" = "ubuntu-cpc" ]; then
BINARY_REMOVE_LINUX=false
OPTS="${OPTS:+$OPTS }--linux-packages=none --initramfs=none"
KERNEL_FLAVOURS=none
OPTS="${OPTS:+$OPTS }--initramfs=none"
KERNEL_FLAVOURS=virtual
case $ARCH in
armhf)
add_package install flash-kernel linux-generic-lpae
KERNEL_FLAVOURS=generic-lpae
add_package install flash-kernel
add_task install server
;;
arm64)
add_package install flash-kernel linux-generic
KERNEL_FLAVOURS=generic
add_package install flash-kernel
add_task install server
;;
ppc64el)
add_package install linux-virtual
add_task install server
;;
*)
add_package install linux-virtual
;;
esac
OPTS="${OPTS:+$OPTS }--system=normal"
OPTS="${OPTS:+$OPTS }--hdd-label=cloudimg-rootfs"

@ -0,0 +1,61 @@
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=
clean_loops() {
[ -z "${rootfs_dev_mapper}" ] || {
udevadm settle
find /dev/mapper -iname "${loop_device///dev\//}*" | \
xargs -n1 -I DEVICE dmsetup remove DEVICE ||
kpartx -d "${rootfs_dev_mapper}"
losetup -d "${loop_device}" || echo "Failed to detach disk"
unset loop_raw
}
}
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
loop_raw="$(kpartx -s -v -a "$1" )"
loop_device="$(echo -e "${loop_raw}" | head -n1 | awk '{print($(NF-1))}')"
rootfs_dev_mapper="/dev/mapper${loop_device///dev/}p1"
[ ! -b "${rootfs_dev_mapper}" ] &&
echo "${rootfs_dev_mapper} is not a block device" && exit 1
return 0
}
mount_partition() {
partition="$1"
mountpoint="$2"
mount "$partition" "$mountpoint"
mount --bind /dev "$mountpoint/dev"
mount proc-live -t proc "$mountpoint/proc"
mount sysfs-live -t sysfs "$mountpoint/sys"
mv "$mountpoint/etc/resolv.conf" resolv.conf.tmp
cp /etc/resolv.conf "$mountpoint/etc/resolv.conf"
}
umount_partition() {
mountpoint="$1"
mv resolv.conf.tmp "$mountpoint/etc/resolv.conf"
umount "$mountpoint/proc"
umount "$mountpoint/sys"
umount "$mountpoint/dev"
umount "$mountpoint"
}

@ -0,0 +1,4 @@
#!/bin/bash -eux
. /etc/os-release
echo "Ubuntu $VERSION" > /etc/ec2_version

@ -0,0 +1,25 @@
#!/bin/bash -ex
mkdir binary/boot/filesystem.dir
cp -a chroot/* binary/boot/filesystem.dir
mount --bind /dev "binary/boot/filesystem.dir/dev"
mount proc-live -t proc "binary/boot/filesystem.dir/proc"
mount sysfs-live -t sysfs "binary/boot/filesystem.dir/sys"
mv "binary/boot/filesystem.dir/etc/resolv.conf" resolv.conf.tmp
cp /etc/resolv.conf "binary/boot/filesystem.dir/etc/resolv.conf"
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-.*'
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"

@ -0,0 +1,3 @@
#!/bin/bash -ex
(cd "binary/boot/filesystem.dir/" && tar -c *) | \
xz > "livecd.ubuntu-cpc.rootfs.tar.xz"

@ -0,0 +1,60 @@
#!/bin/bash -eux
architecture=$(chroot chroot dpkg --print-architecture)
if [ "$architecture" = "ppc64el" ]; then
echo "ppc64el disk images are handled separately"
exit 0
fi
. /build/config/functions
create_empty_partition() {
apt-get install -qqy parted
parted_prefix="parted $1 --script --"
${parted_prefix} mklabel msdos
${parted_prefix} mkpart primary 1 -1
${parted_prefix} set 1 B
${parted_prefix} print
${parted_prefix} align-check opt 1
}
disk_image=binary/boot/disk.ext4
create_empty_disk_image "${disk_image}"
create_empty_partition "${disk_image}"
mount_image "${disk_image}"
# 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
should_install_grub() {
case $architecture in
armhf|arm64)
return 1
;;
*)
return 0
;;
esac
}
if should_install_grub; then
mkdir mountpoint
mount_partition "${rootfs_dev_mapper}" mountpoint
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
umount_partition mountpoint
rmdir mountpoint
fi
clean_loops
trap - EXIT

@ -0,0 +1,141 @@
#!/bin/bash -eux
architecture=$(chroot chroot dpkg --print-architecture)
case $architecture in
amd64|arm64)
;;
*)
echo "We don't create EFI images for $architecture."
exit 0
;;
esac
. /build/config/functions
create_partitions() {
disk_image="$1"
apt-get install -qqy gdisk
sgdisk "${disk_image}" --zap-all
case $architecture 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"
apt-get -qqy install dosfstools
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 $architecture 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"
chroot mountpoint cp /usr/lib/shim/shim.efi.signed "${efi_boot_dir}/shimx64.efi"
chroot mountpoint cp /usr/lib/shim/MokManager.efi.signed "${efi_boot_dir}/MokManager.efi"
chroot mountpoint cp /usr/lib/grub/x86_64-efi-signed/grubx64.efi.signed "${efi_boot_dir}/grubx64.efi"
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 [ $architecture = "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
sed -i "s,root=.* ,root=LABEL=cloudimg-rootfs ,g" mountpoint/boot/grub/grub.cfg
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
umount mountpoint/boot/efi
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}"
# 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,64 @@
#!/bin/bash -eux
architecture=$(chroot chroot dpkg --print-architecture)
if [ "$architecture" != "ppc64el" ]; then
exit 0
fi
. /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 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 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
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}"
# 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,16 @@
#!/bin/bash -ex
apt-get install -qqy qemu-utils
convert_image() {
src="$1"
destination="$2"
qemu-img convert -c -O qcow2 -o compat=0.10 "$src" "$destination"
qemu-img info "$destination"
}
convert_image binary/boot/disk.ext4 livecd.ubuntu-cpc.disk1.img
if [ -f binary/boot/disk-uefi.ext4 ]; then
convert_image binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.uefi1.img
fi

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash -x
rootd="${1:-/}"
root_fs_label=cloudimg-rootfs
set -ex
@ -147,7 +147,6 @@ if [ "$arch" = "i386" -o "$arch" = "amd64" ]; then
add_serial_console ttyS0
fi
psuedo_grub_probe() {
cat <<"PSUEDO_GRUB_PROBE"
#!/bin/sh
@ -248,7 +247,7 @@ _xchroot "${rootd}" env DEBIAN_FRONTEND=noninteractive \
grub2cfg="${rootd}/boot/grub/grub.cfg"
[ ! -f "${grub2cfg}" ] ||
sed -i -e "s,root=/dev/sda1,root=LABEL=${root_fs_label}," "${grub2cfg}"
sed -i -e "s,root=/dev/[hs]da1,root=LABEL=${root_fs_label}," "${grub2cfg}"
[ ${moved} -eq 0 ] || mv "${gprobe}.dist" "${gprobe}"

Loading…
Cancel
Save