Merge lp:~salgado/linaro-image-tools/use-hwpacks-in-media-create into lp:linaro-image-tools/11.11

Proposed by Guilherme Salgado
Status: Merged
Merged at revision: 93
Proposed branch: lp:~salgado/linaro-image-tools/use-hwpacks-in-media-create
Merge into: lp:linaro-image-tools/11.11
Diff against target: 153 lines (+74/-26)
1 file modified
linaro-media-create (+74/-26)
To merge this branch: bzr merge lp:~salgado/linaro-image-tools/use-hwpacks-in-media-create
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+35846@code.launchpad.net

Description of the change

Add a --hwpack argument to linaro-media-create, which is then installed (using linaro-hwpack-install) before the image is generated.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Hi,

Looks ok to me.

Thanks,

James

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro-media-create'
2--- linaro-media-create 2010-09-15 23:44:53 +0000
3+++ linaro-media-create 2010-09-17 16:14:40 +0000
4@@ -22,7 +22,7 @@
5 MLO_FILE=usr/lib/x-loader-omap/MLO
6 UBOOT_FILE=usr/lib/u-boot/omap3_beagle/u-boot.bin
7
8-unset MMC MMC1 MMC2 MMC3 IMAGE_FILE
9+unset MMC MMC1 MMC2 MMC3 IMAGE_FILE HWPACK_FILE
10
11 #Defaults
12 RFS=ext3
13@@ -37,8 +37,8 @@
14 DIR=$PWD
15
16 ensure_command() {
17-# ensure_command foo foo-package
18-which "$1" 2>/dev/null 1>/dev/null || ( echo "Installing required command $1 from package $2" && sudo apt-get install "$2" )
19+ # ensure_command foo foo-package
20+ which "$1" 2>/dev/null 1>/dev/null || ( echo "Installing required command $1 from package $2" && sudo apt-get install "$2" )
21 }
22
23 ensure_command sfdisk util-linux
24@@ -96,6 +96,9 @@
25 add a console to kernel boot parameter; this parameter can be defined
26 multiple times.
27
28+--hwpack <filename>
29+ A hardware pack that should be installed in the rootfs.
30+
31 --image_size nnnG or nnnM
32 specify size of SD image to create; use with --image_file only (default: 2G)
33
34@@ -183,6 +186,10 @@
35 usage
36 MMC=1
37 ;;
38+ --hwpack)
39+ checkparm $2
40+ HWPACK_FILE="$2"
41+ ;;
42 --mmc)
43 checkparm $2
44 MMC="$2"
45@@ -262,29 +269,65 @@
46 RFS_UUID=`uuidgen -r`
47
48 get_mmcs_by_id() {
49-if [ ! ${IMAGE_FILE} ]; then
50- for device in /dev/disk/by-id/*; do
51- if [ `realpath $device` = $MMC ]; then
52- if echo "$device" | grep -q -- "-part[0-9]*$"; then
53- echo "device $MMC must not be a partition part ($device)" 1>&2
54- exit 1
55+ if [ ! ${IMAGE_FILE} ]; then
56+ for device in /dev/disk/by-id/*; do
57+ if [ `realpath $device` = $MMC ]; then
58+ if echo "$device" | grep -q -- "-part[0-9]*$"; then
59+ echo "device $MMC must not be a partition part ($device)" 1>&2
60+ exit 1
61+ fi
62+ for part_id in `ls "$device-part"*`; do
63+ part=`realpath $part_id`
64+ part_no=`echo $part_id | sed -e 's/.*-part//g'`
65+ # echo "part $part_no found: $part_id" 1>&2
66+ if test "$part_no" = 1; then
67+ MMC1=$part
68+ elif test "$part_no" = 2; then
69+ MMC2=$part
70+ elif test "$part_no" = 3; then
71+ MMC3=$part
72+ fi
73+ done
74+ break
75 fi
76- for part_id in `ls "$device-part"*`; do
77- part=`realpath $part_id`
78- part_no=`echo $part_id | sed -e 's/.*-part//g'`
79- # echo "part $part_no found: $part_id" 1>&2
80- if test "$part_no" = 1; then
81- MMC1=$part
82- elif test "$part_no" = 2; then
83- MMC2=$part
84- elif test "$part_no" = 3; then
85- MMC3=$part
86- fi
87- done
88- break
89- fi
90- done
91-fi
92+ done
93+ fi
94+}
95+
96+install_hwpack_into_tarball() {
97+ ensure_command qemu-arm-static qemu-arm-static
98+
99+ tmp_dir=$(mktemp -d)
100+ trap "rm -rf $tmp_dir" EXIT
101+ sudo tar -xf $BINARY_TARBALL -C $tmp_dir
102+
103+ # XXX: Assume linaro-hwpack-install lives on the same directory as this
104+ # script. This is far from optimal but should do for now.
105+ LINARO_HWPACK_INSTALL=$(dirname $0)/linaro-hwpack-install
106+
107+ chroot=${tmp_dir}/binary
108+ sudo mv -f ${chroot}/etc/resolv.conf ${tmp_dir}/resolv.conf.orig
109+ sudo cp /etc/resolv.conf ${chroot}/etc/resolv.conf
110+
111+ sudo mv -f ${chroot}/etc/hosts ${tmp_dir}/hosts.orig
112+ sudo cp /etc/hosts ${chroot}/etc/hosts
113+
114+ sudo cp /usr/bin/qemu-arm-static ${chroot}/usr/bin
115+ sudo cp $LINARO_HWPACK_INSTALL ${chroot}/usr/bin
116+ sudo cp "$HWPACK_FILE" "$chroot"
117+
118+ sudo mount proc ${chroot}/proc -t proc
119+ sudo chroot "$chroot" linaro-hwpack-install /$(basename "$HWPACK_FILE")
120+ sudo umount ${chroot}/proc
121+
122+ sudo mv -f ${tmp_dir}/resolv.conf.orig ${chroot}/etc/resolv.conf
123+ sudo mv -f ${tmp_dir}/hosts.orig ${chroot}/etc/hosts
124+ sudo rm -f ${chroot}/usr/bin/qemu-arm-static
125+ sudo rm -f ${chroot}/usr/bin/linaro-hwpack-install
126+ sudo rm -f ${chroot}/$(basename "$HWPACK_FILE")
127+
128+ sudo tar cf binary-with-hwpack.tar -C "$tmp_dir" binary
129+ BINARY_TARBALL=${DIR}/binary-with-hwpack.tar
130 }
131
132 prepare_sources() {
133@@ -480,7 +523,7 @@
134 sudo dd if=/dev/zero of=${DIR}/disk/SWAP.swap bs=1M count=$SWAP_SIZE
135 sudo mkswap ${DIR}/disk/SWAP.swap
136 echo "/SWAP.swap none swap sw 0 0" | sudo tee -a ${DIR}/disk/etc/fstab
137- else
138+ else
139 echo "SWAP file bigger then whats left on partition"
140 fi
141 fi
142@@ -578,6 +621,11 @@
143 usage
144 fi
145
146+ if [ "$HWPACK_FILE" ]; then
147+ # This will unpack the binary tarball, install the hwpack in it, tar it up
148+ # again and make this script use that new tarball from now on.
149+ install_hwpack_into_tarball
150+ fi
151 prepare_sources
152 get_mmcs_by_id
153 cleanup_sd

Subscribers

People subscribed via source and target branches