livecd-rootfs/live-build/ubuntu-core/hooks/500-move-kernel-to-device-tar.binary
Adam Conrad 4c697dbaf6 Import patches-unapplied version 2.301 to ubuntu/wily-proposed
Imported using git-ubuntu import.

Changelog parent: 35251d626be197aae93c082c48ffc67dad49ed42

New changelog entries:
  [ Michael Vogt ]
  * create /boot/uboot on armhf to ensure that its in the system
    tarball and still on the system if ubuntu-core-upgrader
    performs a "format" (LP: #1447652)
  * live-build/ubuntu-core/hooks/500-move-kernel-to-device-tar.binary:
    - fix typo in hardware.yaml
  * live-build/auto/config:
    - add grub-efi-ia32-bin for i386 for efi support
  [ Adam Conrad ]
  * live-build/auto/config: Handle applying priorities to EXTRA_PPAS
    via the extra_ppa="user/ppaname:priority" syntax (LP: #1450257)
2015-05-07 00:34:29 +00:00

109 lines
2.8 KiB
Bash

#!/bin/sh
#
# move the kernel out into a new device tarfile with system/boot
set -ex
echo "I: Moving kernel into device tarball"
HERE="$(pwd)"
TMPDIR="$(mktemp -d)"
ARCH=$(dpkg --print-architecture)
mkdir -p $TMPDIR/system/
mkdir -p $TMPDIR/assets/
# cp files, we can't simply use tar --transform as it changes the symlink target
(
cd binary/boot/filesystem.dir
# for compatibility with current grub/u-d-f
cp -ar --parent boot/vmlinu?-* boot/initrd.img-* boot/abi-* boot/System.map-* $TMPDIR/system/
if [ -e vmlinu? ] && [ -e initrd.img ]; then
cp -ar --parent vmlinu? initrd.img $TMPDIR/system
fi
cp -ar --parent lib/modules/ $TMPDIR/system/
cp -ar --parent lib/firmware/ $TMPDIR/system/
# new assets handling
cp -ar boot/vmlinu?-* $TMPDIR/assets/vmlinuz
cp -ar boot/initrd.img-* $TMPDIR/assets/initrd.img
cp -ar boot/vmlinu?-* boot/initrd.img-* boot/abi-* boot/System.map-* $TMPDIR/assets/
dtbs=$(find lib/firmware -type d -name 'device-tree' -print0)
[ -n "$dtbs" ] && mv "$dtbs" $TMPDIR/assets/dtbs
if [ -e vmlinu? ] && [ -e initrd.img ]; then
cp -ar --parent vmlinu? initrd.img $TMPDIR/assets
cp -ar --parent vmlinu? initrd.img $TMPDIR/assets
fi
)
# create hardware.yaml for u-boot
# this assumes armh == u-boot
# and all others grub
(
# common bits
cat > $TMPDIR/hardware.yaml << EOF
kernel: assets/vmlinuz
initrd: assets/initrd.img
partition-layout: system-AB
EOF
# arch specific ones
if [ "$ARCH" = "armhf" ]; then
cat >> $TMPDIR/hardware.yaml << EOF
dtbs: assets/dtbs
bootloader: u-boot
EOF
else
cat >> $TMPDIR/hardware.yaml << EOF
bootloader: grub
EOF
fi
)
# and tar it up
(
cd $TMPDIR
tar -c -z -f $HERE/device.tar.gz system assets hardware.yaml
)
# now build the azure device tarball by adding walinuxagent
if [ -e binary/boot/filesystem.dir/var/lib/dpkg/info/walinuxagent.list ];
then
(
cd binary/boot/filesystem.dir
while read line; do
line=$(echo $line |cut -d/ -f2-)
if [ -e "$line" ] && [ ! -d "$line" ]; then
cp -ar --parent $line $TMPDIR/system
fi
done < var/lib/dpkg/info/walinuxagent.list
# created by walinuxagent postinst/dh-systemd
cp -ar --parent var/lib/systemd/deb-systemd-helper-enabled/walinuxagent* $TMPDIR/system
cp -ar --parent etc/systemd/system/multi-user.target.wants/walinuxagent* $TMPDIR/system
mkdir -p $TMPDIR/system/var/lib/waagent
)
# and tar it up
(
cd $TMPDIR
tar -c -z -f $HERE/device-azure.tar.gz system assets hardware.yaml
)
fi
rm -rf $TMPDIR
# remove files from the root filesystem
(cd binary/boot/filesystem.dir
rm -f boot/vmlinu?-*
rm -f boot/initrd.img-*
rm -f boot/abi-*
rm -f boot/System.map-*
rm -f initrd.img
rm -f vmlinu?
rm -rf lib/modules
rm -rf lib/firmware
# remove walinuxagent
if [ -e var/lib/dpkg/info/walinuxagent.list ]; then
chroot . dpkg --purge walinuxagent || true
fi
)