mirror of
				https://git.launchpad.net/livecd-rootfs
				synced 2025-11-03 18:34:11 +00:00 
			
		
		
		
	Import patches-unapplied version 2.364 to ubuntu/xenial-proposed
Imported using git-ubuntu import.
Changelog parent: c9470d78b1f5a1d37001234373d905f5c627c264
New changelog entries:
  * ubunut-cpc:
    - extendend 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
			
			
This commit is contained in:
		
							parent
							
								
									c9470d78b1
								
							
						
					
					
						commit
						6cb42069f0
					
				
							
								
								
									
										12
									
								
								debian/changelog
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								debian/changelog
									
									
									
									
										vendored
									
									
								
							@ -1,3 +1,15 @@
 | 
			
		||||
livecd-rootfs (2.364) xenial; urgency=medium
 | 
			
		||||
 | 
			
		||||
  * ubunut-cpc:
 | 
			
		||||
    - extendend 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
 | 
			
		||||
 | 
			
		||||
 -- Ben Howard <ben.howard@ubuntu.com>  Thu, 10 Dec 2015 09:10:35 -0700
 | 
			
		||||
 | 
			
		||||
livecd-rootfs (2.363) xenial; urgency=medium
 | 
			
		||||
 | 
			
		||||
  * configure /etc/fw_env.config for all arm arches on snappy
 | 
			
		||||
 | 
			
		||||
@ -6,16 +6,23 @@ 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() {
 | 
			
		||||
    [ -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
 | 
			
		||||
    }
 | 
			
		||||
    if [ -z "${rootfs_dev_mapper}" ]; then
 | 
			
		||||
        return 0
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    if [ -n "${backing_img}" ]; then
 | 
			
		||||
        kpartx -v -d "${backing_img}"
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    unset backing_img
 | 
			
		||||
    unset loop_device
 | 
			
		||||
    unset loop_raw
 | 
			
		||||
    unset rootfs_dev_mapper
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
create_empty_disk_image() {
 | 
			
		||||
@ -32,6 +39,7 @@ make_ext4_partition() {
 | 
			
		||||
mount_image() {
 | 
			
		||||
    apt-get install -qqy kpartx
 | 
			
		||||
    trap clean_loops EXIT
 | 
			
		||||
    backing_img="$1"
 | 
			
		||||
    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"
 | 
			
		||||
@ -46,22 +54,80 @@ mount_partition() {
 | 
			
		||||
 | 
			
		||||
    mount "$partition" "$mountpoint"
 | 
			
		||||
    mount --bind /dev "$mountpoint/dev"
 | 
			
		||||
    mount devpts-live -t devpts "$mountpoint/dev/pts"
 | 
			
		||||
    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_disk_image() {
 | 
			
		||||
    local disk_image=${1}
 | 
			
		||||
    local mountpoint=${2}
 | 
			
		||||
    mount_image ${disk_image}
 | 
			
		||||
    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"
 | 
			
		||||
 | 
			
		||||
    mv resolv.conf.tmp "$mountpoint/etc/resolv.conf"
 | 
			
		||||
    umount "$mountpoint/proc"
 | 
			
		||||
    umount "$mountpoint/sys"
 | 
			
		||||
    umount "$mountpoint/dev/pts"
 | 
			
		||||
    umount "$mountpoint/dev"
 | 
			
		||||
    umount "$mountpoint"
 | 
			
		||||
    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() {
 | 
			
		||||
@ -129,3 +195,33 @@ create_vmdk() {
 | 
			
		||||
    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"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -2,15 +2,12 @@
 | 
			
		||||
 | 
			
		||||
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"
 | 
			
		||||
}
 | 
			
		||||
. /build/config/functions
 | 
			
		||||
 | 
			
		||||
convert_image binary/boot/disk.ext4 livecd.ubuntu-cpc.disk1.img
 | 
			
		||||
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_image binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.uefi1.img
 | 
			
		||||
    convert_to_qcow2 binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.uefi1.img
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
@ -6,16 +6,18 @@
 | 
			
		||||
architecture=$(chroot chroot dpkg --print-architecture)
 | 
			
		||||
 | 
			
		||||
extension="disk1.vmdk"
 | 
			
		||||
 | 
			
		||||
case ${architecture} in
 | 
			
		||||
         i386) image_target="binary/boot/disk.ext4";;
 | 
			
		||||
        amd64) image_target="binary/boot/disk-uefi.ext4"; extension="uefi1.vmdk";;
 | 
			
		||||
            *) echo "VMDK images are not supported for ${architecture} yet.";
 | 
			
		||||
               exit 0;;
 | 
			
		||||
         i386|amd64) ;;
 | 
			
		||||
                  *) echo "VMDK images are not supported for ${architecture} yet.";
 | 
			
		||||
                     exit 0;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
. /build/config/functions
 | 
			
		||||
 | 
			
		||||
create_vmdk binary/boot/disk.ext4 livecd.ubuntu-cpc.disk1.vmdk
 | 
			
		||||
if [ -e binary/boot/disk.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
 | 
			
		||||
 | 
			
		||||
@ -8,8 +8,11 @@ if [ ! -d ${my_dir}/extra ]; then
 | 
			
		||||
    exit 0
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Export the common functions to the extras
 | 
			
		||||
. /build/config/functions
 | 
			
		||||
 | 
			
		||||
# Execute extra binary hooks
 | 
			
		||||
for recipe in $(find ${extra_d} -type f -executable);
 | 
			
		||||
for recipe in $(find ${extra_d} -type f -executable -maxdepth 1);
 | 
			
		||||
do
 | 
			
		||||
    bash ${recipe}
 | 
			
		||||
    bash -xue ${recipe}
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user