summaryrefslogtreecommitdiff
path: root/makelavaimg
blob: 1859ede7d9a7c9441b7bbc118134bee639adff68 (plain)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/sh
# this script needs linaro-image-tools and kpartx installed

#simple version
#wget -N http://releases.linaro.org/13.08/ubuntu/vexpress/hwpack_linaro-vexpress_20130826-443_armhf_supported.tar.gz
#wget -N http://releases.linaro.org/13.08/ubuntu/${suite}-images/nano/linaro-${suite}-nano-20130826-474.tar.gz
#wget -N http://snapshots.linaro.org/components/platform/xen/latest/xen

if [ -n "$1" -a -n "$2" ]; then 
 export hwpack="$1"
 export FILES="$2"
else
 echo "usage: $0 <boardname> <filesource>"
 exit 1
fi

image="xenlava-${hwpack}.img"
suite="saucy"

#CI build version
export HWPACK_BUILD_NUMBER=`wget -q --no-check-certificate -O - https://ci.linaro.org/jenkins/job/ubuntu-armhf-hwpacks/hwpack=${hwpack},label=build/lastSuccessfulBuild/buildNumber`
export HWPACK_BUILD_TIMESTAMP=`wget -q --no-check-certificate -O - https://ci.linaro.org/jenkins/job/ubuntu-armhf-hwpacks/hwpack=${hwpack},label=build/lastSuccessfulBuild/buildTimestamp?format=yyyyMMdd`
#get hwpack numver manually
export HWPACK_BUILD_NUMBER=598
export HWPACK_BUILD_TIMESTAMP=20140128
export HWPACK_BUILD_FILENAME="hwpack_linaro-${hwpack}_${HWPACK_BUILD_TIMESTAMP}-${HWPACK_BUILD_NUMBER}_armhf_supported.tar.gz"
export HWPACK_BUILD_URL="http://snapshots.linaro.org/ubuntu/hwpacks/${hwpack}/${HWPACK_BUILD_NUMBER}/${HWPACK_BUILD_FILENAME}"

wget -N --progress=dot -e dotbytes=2M ${HWPACK_BUILD_URL}
if [ $? -ne 0 ]; then
    echo "hwpack download failed"
    exit 1
fi
#get last rootfs that built OK
export ROOTFS_BUILD_NUMBER=`wget -q --no-check-certificate -O - https://ci.linaro.org/jenkins/job/ubuntu-armhf-rootfs/label=build,rootfs=nano-lava/lastSuccessfulBuild/buildNumber`
export ROOTFS_BUILD_TIMESTAMP=`wget -q --no-check-certificate -O - https://ci.linaro.org/jenkins/job/ubuntu-armhf-rootfs/label=build,rootfs=nano-lava/lastSuccessfulBuild/buildTimestamp?format=yyyyMMdd`
export ROOTFS_BUILD_FILENAME="linaro-${suite}-nano-lava-${ROOTFS_BUILD_TIMESTAMP}-${ROOTFS_BUILD_NUMBER}.tar.gz"
export ROOTFS_BUILD_URL="http://snapshots.linaro.org/ubuntu/images/nano-lava/${ROOTFS_BUILD_NUMBER}/${ROOTFS_BUILD_FILENAME}"
wget -N --progress=dot -e dotbytes=2M ${ROOTFS_BUILD_URL}
if [ $? -ne 0 ]; then
    echo "rootfs download failed"
    exit 1
fi
#get xen hypervisor and tools
export XEN_BUILD_NUMBER=`wget -q --no-check-certificate -O - https://ci.linaro.org/jenkins/job/xen-base/lastSuccessfulBuild/buildNumber`
wget -N --progress=dot -e dotbytes=2M "http://snapshots.linaro.org/components/platform/xen/${XEN_BUILD_NUMBER}/xen"
if [ $? -ne 0 ]; then
    echo "Can't download xen binary"
    exit 1
fi

wget -N --progress=dot -e dotbytes=2M "http://snapshots.linaro.org/components/platform/xen/${XEN_BUILD_NUMBER}/xen-upstream-4.4-rc2.deb"
if [ $? -ne 0 ]; then
    echo "Can't download xen deb"
    exit 1
fi

case $hwpack in 
    arndale)
        BOOT=/dev/mapper/loop0p2
        ROOTFS=/dev/mapper/loop0p3
        dev=${hwpack}
        ;;
    midway)
        BOOT=/dev/mapper/loop0p1
        ROOTFS=/dev/mapper/loop0p2
        dev=highbank
        ;;
    *)
        BOOT=/dev/mapper/loop0p1
        ROOTFS=/dev/mapper/loop0p2
        dev=${hwpack}
        ;;
esac

BOOTMOUNT=bootfs
MOUNT=rootfs

sudo rm -rf ${image} ${image}.gz $MOUNT $BOOTMOUNT

#make a suitable image from the standard hwpack+nano rootfs
sudo  linaro-media-create --hwpack-force-yes --dev ${dev} --image-file xenlava-${hwpack}.img \
--hwpack ${HWPACK_BUILD_FILENAME} --binary ${ROOTFS_BUILD_FILENAME} \
--image-size 3G --bootloader u_boot

# Install kpartx
sudo apt-get install -y kpartx u-boot-tools

#loopmount partitions
sudo kpartx -a -v ${image}

#add the hypervisor to the boot image
mkdir $BOOTMOUNT
sudo mount $BOOT $BOOTMOUNT
mkdir $MOUNT
sudo mount $ROOTFS $MOUNT

# midway uses a u-boot script for booting, we use our own script with xen stuff

case $hwpack in 
    midway)
        sudo chmod a+r $BOOTMOUNT/boot.txt
        UUID=`tr ' ' '\n' < $BOOTMOUNT/boot.txt |sed -n /UUID/s/.*=//p`
        sed -e "s/%%UUID%%/$UUID/" ${FILES}/files/midway-boot.txt > /tmp/boot.txt
        mkimage -A arm -T script -C none -n "xen lava" -d /tmp/boot.txt /tmp/boot.scr
        sudo cp /tmp/boot.txt /tmp/boot.scr $BOOTMOUNT
        cat /tmp/boot.txt
        sudo cp $MOUNT/boot/vmlinuz*midway $BOOTMOUNT/zImage
        ;;
esac

sudo cp xen $BOOTMOUNT

#add hvc0 init file and xen tools package to the rootfs image
sudo cp ${FILES}/files/hvc0.conf ${MOUNT}/etc/init/
sudo cp ${FILES}/files/linaro-repo.list ${MOUNT}/etc/apt/sources.list.d/
sudo dpkg-deb --extract xen-upstream-*.deb $MOUNT

sudo umount $MOUNT
sudo umount $BOOTMOUNT

#tidy up mapper devices
sudo kpartx -d ${image}

#compress the image
gzip -9 ${image}