~ubuntu-core-dev/livecd-rootfs/trunk

« back to all changes in this revision

Viewing changes to live-build/ubuntu-desktop-next/hooks/500-move-kernel-to-device-tar.binary

  • Committer: Balint Reczey
  • Date: 2019-01-31 08:14:49 UTC
  • Revision ID: balint.reczey@canonical.com-20190131081449-ptfnz0r4c2emh0nt
Moved to git at https://git.launchpad.net/livecd-rootfs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
#
3
 
# move the kernel out into a new device tarfile with system/boot 
4
 
 
5
 
set -ex
6
 
 
7
 
echo "I: Moving kernel into device tarball"
8
 
 
9
 
HERE="$(pwd)"
10
 
TMPDIR="$(mktemp -d)"
11
 
mkdir -p $TMPDIR/system/
12
 
mkdir -p $TMPDIR/assets/
13
 
 
14
 
# cp files, we can't simply use tar --transform as it changes the symlink target
15
 
(
16
 
 cd binary/boot/filesystem.dir
17
 
 
18
 
 cp -ar --parent lib/modules/ $TMPDIR/system/
19
 
 cp -ar --parent lib/firmware/ $TMPDIR/system/
20
 
 
21
 
 # new assets handling
22
 
 if [ -f boot/vmlinu?-*.signed ]; then
23
 
    kernel=boot/vmlinu?-*.signed
24
 
 else
25
 
    kernel=boot/vmlinu?-*
26
 
 fi
27
 
 
28
 
 initrd=boot/initrd.img-*
29
 
 
30
 
 cp -ar $initrd $TMPDIR/assets/
31
 
 cp -ar $kernel $TMPDIR/assets/
32
 
 cp -ar boot/abi-* boot/System.map-* $TMPDIR/assets/
33
 
 
34
 
 dtbs=$(find lib/firmware -type d -name 'device-tree' -print0)
35
 
 if [ -n "$dtbs" ]; then
36
 
    mv "$dtbs" $TMPDIR/assets/dtbs
37
 
 fi
38
 
 
39
 
 # create hardware.yaml
40
 
 # this assumes armh == u-boot
41
 
 # and all others grub
42
 
 # common bits
43
 
 cat > $TMPDIR/hardware.yaml << EOF
44
 
kernel: assets/$(basename $kernel)
45
 
initrd: assets/$(basename $initrd)
46
 
partition-layout: system-AB
47
 
EOF
48
 
 
49
 
# arch specific ones
50
 
if [ "$ARCH" = "armhf" ]; then
51
 
 cat >> $TMPDIR/hardware.yaml << EOF
52
 
dtbs: assets/dtbs
53
 
bootloader: u-boot
54
 
EOF
55
 
else
56
 
 cat >> $TMPDIR/hardware.yaml << EOF
57
 
bootloader: grub
58
 
EOF
59
 
fi
60
 
)
61
 
 
62
 
# and tar it up
63
 
(
64
 
 cd $TMPDIR
65
 
 tar -c -z -f $HERE/device.tar.gz system assets hardware.yaml
66
 
)
67
 
 
68
 
rm -rf $TMPDIR
69
 
 
70
 
# remove files from the root filesystem
71
 
(cd binary/boot/filesystem.dir
72
 
 rm -f boot/vmlinu?-*
73
 
 rm -f boot/initrd.img-*
74
 
 rm -f boot/abi-*
75
 
 rm -f boot/System.map-*
76
 
 rm -f initrd.img
77
 
 rm -f vmlinu?
78
 
 rm -rf lib/modules
79
 
 rm -rf lib/firmware
80
 
)