Ubuntu Pastebin

Paste from ogra at Fri, 31 Jul 2015 12:57:34 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#! /bin/sh

set -e

dist="wily"
dtb="bcm2709-rpi-2-b.dtb"

# download latest deb
PPA_URL="http://ppa.launchpad.net/p-pisati/embedded/ubuntu/"
PPA_DEB="$(wget -O - -q $PPA_URL/dists/devel/main/binary-armhf/Packages |grep linux-bcm2709|grep image-|grep ^Filename|tail -1|sed 's/^Filename: //')"
PKG="$(echo $PPA_DEB|sed 's/^.*\///')"
if ! ls $PKG >/dev/null 2>&1; then
    wget $PPA_URL/$PPA_DEB
fi

# set some defaults based on the deb filename
version="$(ls *.deb|cut -d'_' -f1|sed 's/^linux-image-//')"
abi="$(ls *.deb|cut -d'_' -f2)"

# unpack deb
rm -rf unpack
dpkg -x linux-image-${version}_${abi}_armhf.deb unpack

# flush output dirs
rm -rf device && mkdir -p device/system && mkdir -p device/assets/dtbs

# copy kernel and devicetree
cp unpack/boot/vmlinuz-* device/assets/vmlinuz
cp unpack/lib/firmware/${version}/device-tree/$dtb device/assets/dtbs/

# copy extra files
mkdir -p device/system/boot/uboot/
cp unpack/usr/share/doc/linux-image-${version}/changelog.Debian.gz device/system/boot/uboot/changelog-vmlinuz.gz
cp unpack/boot/config-* device/system/boot/uboot/config-vmlinuz
cp unpack/boot/System.map-* device/system/boot/uboot/System.map

# handle modules
cp -a unpack/lib device/system/
modules_dir="$(ls unpack/lib/modules/)"
depmod -ea -F device/system/boot/uboot/System.map -b device/system/ ${modules_dir}

# handle initrd
DEVICE_URL="http://cdimage.ubuntu.com/ubuntu-core/daily-preinstalled/current/"
DEVICE_MD5="$(wget -q -O - $DEVICE_URL/MD5SUMS|grep armhf.device|cut -d ' ' -f1)"
TAR_MD5="$(md5sum initrd/cdimage.tar.gz|cut -d ' ' -f1)"

if [ "$DEVICE_MD5" != "$TAR_MD5" ]; then
    wget -O initrd/cdimage.tar.gz $DEVICE_URL/$dist-preinstalled-core-armhf.device.tar.gz
fi
tar xf initrd/cdimage.tar.gz -C initrd

rm -rf initrd/unpack/ && mkdir -p initrd/unpack/
cd initrd/unpack/
cat ../assets/initrd.img | unxz -c | cpio -i
rm -rf lib/modules/*
find . | cpio --create --format=newc | lzma > ../../device/assets/initrd.img
cd -

#cp initrd/assets/initrd.img device/assets/
rm -rf initrd/assets initrd/system initrd/hardware.yaml

cat << EOF > device/README.md
# Device part

This device part has 3 components:

- system: the system part, lands on the system partition, this is
          where you would generally layout the kernel modules.
- assets: this holds one or many kernels, initrds, and/or dtbs.
- hardware.yaml: a definition of what each asset is and which one to pick.
                 Some entries can be OEM overriden in the *oem part*.
                 Aside from that it determines the partition layout and
                 the bootloader technology.

# Custom or proprietary solutions for booting

If a custom or proprietary solution is seeked that does not use u-boot
or grub, set the bootloader to custom and the device part can be
provisioned with items in a *boot* directory which will layout the files
in the boot partition.
EOF

cat << EOF > device/hardware.yaml
kernel: assets/vmlinuz
initrd: assets/initrd.img
dtbs: assets/dtbs
EOF

# tar up device subdir
cd device
tar cJvf ../device-pi2-0.14.tar.xz *
cd -

exit 0
Download as text