summaryrefslogtreecommitdiff
path: root/makelavaimg
blob: b7fc8232980cc59567c85482103012e27d42596f (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/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

set -e

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install --no-install-recommends -y kpartx u-boot-tools wget linaro-image-tools parted curl gdisk libc6:i386 libstdc++6:i386 zlib1g:i386 bc build-essential qemu-user-static linaro-image-tools python-pycurl python-beautifulsoup python-html2text python-xdg python-debian qemu-user-static

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

case $hwpack in
    mustang)
        echo "Mustang uses nfs"
        ${FILES}/makelavanfs $hwpack $FILES
        ${FILES}/jenkins/kernelbuild
        exit $?
        ;;
    arndale)
        ${FILES}/jenkins/kernelbuild
        ;;
    midway)
        echo "skip midway kernel"
        ;;
    *)
        echo "Unknown hwpack $hwpack"
        exit 1 
        ;;
esac


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

case $hwpack in
    midway)
            echo "trying release"
            HWPACK_BUILD_FILENAME="hwpack_linaro-midway_20140417-630_armhf_supported.tar.gz"
            HWPACK_BUILD_URL="http://releases.linaro.org/14.04/ubuntu/midway/hwpack_linaro-midway_20140417-630_armhf_supported.tar.gz"
            wget -nc --progress=dot -e dotbytes=2M ${HWPACK_BUILD_URL}
            # hack to use utopic - riku 12.06
            rm -rf tmp
            mkdir tmp
            (cd tmp
            tar xzf ../${HWPACK_BUILD_FILENAME}
            sed -i -e 's,saucy,utopic,g' sources.list.d/*
            rm -rf pkgs/linux-base*
            rm -rf pkgs/*perl*
            grep -v libuuid-perl manifest > m; mv m manifest
            cd pkgs; dpkg-scanpackages . /dev/null > Packages; cd ..
            tar czf ../${HWPACK_BUILD_FILENAME} *
            )
            rm -rf tmp
        ;;
    arndale)
            echo "use local build"
            export HWPACK_BUILD_FILENAME="hwpack*_armhf_supported.tar.gz"
        ;;
esac
set -e

#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

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


#loopmount partitions
sudo kpartx -s -a -v ${image}
set +e
ls -la /dev/loop*

#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
        ;;
    arndale)
        sudo rm -f ${MOUNT}/etc/init/auto-serial-console.conf
        ;;
esac

#add hvc0 init file and xen tools package to the rootfs image
sudo cp ${FILES}/files/hvc0.conf ${MOUNT}/etc/init/
sudo cp /etc/resolv.conf $MOUNT/etc/
sudo cp ${FILES}/files/xendefault /etc/default/xen
sudo cp /usr/bin/qemu-arm-static $MOUNT/usr/bin
sudo chroot $MOUNT apt-get update
sudo chroot $MOUNT apt-get install -y xen-system-armhf
sudo chroot $MOUNT apt-get clean
sudo cp $MOUNT/boot/xen-4.6-armhf $BOOTMOUNT/xen
cp $BOOTMOUNT/xen xen-binary
sudo rm $MOUNT/usr/bin/qemu-arm-static
sudo umount $MOUNT
sudo umount $BOOTMOUNT

#tidy up mapper devices
sudo kpartx -d ${image}
set -e
md5sum xen-binary

#compress the image
gzip -9 ${image}