Merge lp:~salgado/linaro-image-tools/refactor-lmc into lp:linaro-image-tools/11.11

Proposed by Guilherme Salgado
Status: Merged
Merged at revision: 98
Proposed branch: lp:~salgado/linaro-image-tools/refactor-lmc
Merge into: lp:linaro-image-tools/11.11
Diff against target: 169 lines (+31/-43)
1 file modified
linaro-media-create (+31/-43)
To merge this branch: bzr merge lp:~salgado/linaro-image-tools/refactor-lmc
Reviewer Review Type Date Requested Status
Linaro Maintainers Pending
Review via email: mp+36579@code.launchpad.net

Description of the change

Refactor l-m-c so that we don't need extra unpack/repack steps when installing hwpacks.

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

Hi,

This looks sensible to me. I assume that you've tested that it produces
equivalent rootfs.

There are a couple of changes that I want to question:

74 - parts_dir=casper
75 boot_snippet='boot=casper'
76 [ "$IS_LOWMEM" ] && lowmem_opt=only-ubiquity
77 else
78 - parts_dir=boot

82 - # Remove the binary/ directory so that previous runs don't interfere here.
83 - rm -rf binary/
84 -
85 - extras=
86 - if [ "$DEVIMAGE" = beagle ]; then
87 - extras="binary/${MLO_FILE} binary/${UBOOT_FILE}"
88 - fi
89 - tar -xf $BINARY_TARBALL binary/${parts_dir} $extras
90 -

Are these just cleanup of unused code?

The main thing is that I don't understand what TMP_DIR is now,
it seems to not have much done with it, except for things like
boot.cmd being written to it. Is that going to work? It also
doesn't look like it will get cleaned up to me.

Thanks,

James

Revision history for this message
Guilherme Salgado (salgado) wrote :

On Fri, 2010-09-24 at 19:46 +0000, James Westby wrote:
> Hi,
>
> This looks sensible to me. I assume that you've tested that it produces
> equivalent rootfs.

It does, yes, but I can't boot any of them as I'm having trouble with my
beagle XM -- it doesn't even boot the Ängstrom SD that came with it.

>
> There are a couple of changes that I want to question:
>
> 74 - parts_dir=casper
> 75 boot_snippet='boot=casper'
> 76 [ "$IS_LOWMEM" ] && lowmem_opt=only-ubiquity
> 77 else
> 78 - parts_dir=boot
>
> 82 - # Remove the binary/ directory so that previous runs don't interfere here.
> 83 - rm -rf binary/
> 84 -
> 85 - extras=
> 86 - if [ "$DEVIMAGE" = beagle ]; then
> 87 - extras="binary/${MLO_FILE} binary/${UBOOT_FILE}"
> 88 - fi
> 89 - tar -xf $BINARY_TARBALL binary/${parts_dir} $extras
> 90 -
>
> Are these just cleanup of unused code?

No, this code was unpacking only the files that would later be used by
populate_boot, but that's no longer needed as now we unpack everything
before this is called.

>
> The main thing is that I don't understand what TMP_DIR is now,
> it seems to not have much done with it, except for things like
> boot.cmd being written to it. Is that going to work? It also
> doesn't look like it will get cleaned up to me.

It is just a temp dir, for anything we might need. Previously, we were
dumping temporary files (including the ones extracted from the binary
tarball, as you saw above) under binary/, but now we unpack the whole
tarball and it creates that directory with all its content in there, so
I thought it was a good idea to use a separate temp dir.

--
Guilherme Salgado <https://launchpad.net/~salgado>

Revision history for this message
James Westby (james-w) wrote :

On Mon, 27 Sep 2010 13:11:03 -0000, Guilherme Salgado <email address hidden> wrote:
> It is just a temp dir, for anything we might need. Previously, we were
> dumping temporary files (including the ones extracted from the binary
> tarball, as you saw above) under binary/, but now we unpack the whole
> tarball and it creates that directory with all its content in there, so
> I thought it was a good idea to use a separate temp dir.

Yep, and I see that boot.cmd is in fact used from there, which I missed
first time.

This all looks good to me.

Thanks,

James

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-23 18:06:49 +0000
3+++ linaro-media-create 2010-09-24 18:25:58 +0000
4@@ -35,6 +35,7 @@
5 IMAGE_SIZE=2G
6
7 DIR=$PWD
8+TMP_DIR=$(mktemp -d)
9 BOOT_DISK=${DIR}/boot-disc
10 ROOT_DISK=${DIR}/root-disc
11
12@@ -296,26 +297,22 @@
13 fi
14 }
15
16-install_hwpack_into_tarball() {
17+install_hwpack() {
18 ensure_command qemu-arm-static qemu-arm-static
19
20-
21- tmp_dir=$(mktemp -d)
22- chroot=${tmp_dir}/binary
23- # Make sure the tmp_dir where we unpack the tarball is removed when this
24- # script exits.
25- trap "sudo umount ${chroot}/proc || true; sudo rm -rf $tmp_dir" EXIT
26-
27- sudo tar -xf $BINARY_TARBALL -C $tmp_dir
28+ chroot=${DIR}/binary
29+ # Make sure we unmount /proc in the chroot or else it can't be moved to the
30+ # rootfs.
31+ trap "sudo umount ${chroot}/proc || true" EXIT
32
33 # XXX: Assume linaro-hwpack-install lives on the same directory as this
34 # script. This is far from optimal but should do for now.
35 LINARO_HWPACK_INSTALL=$(dirname $0)/linaro-hwpack-install
36
37- sudo mv -f ${chroot}/etc/resolv.conf ${tmp_dir}/resolv.conf.orig
38+ sudo mv -f ${chroot}/etc/resolv.conf ${TMP_DIR}/resolv.conf.orig
39 sudo cp /etc/resolv.conf ${chroot}/etc/resolv.conf
40
41- sudo mv -f ${chroot}/etc/hosts ${tmp_dir}/hosts.orig
42+ sudo mv -f ${chroot}/etc/hosts ${TMP_DIR}/hosts.orig
43 sudo cp /etc/hosts ${chroot}/etc/hosts
44
45 sudo cp /usr/bin/qemu-arm-static ${chroot}/usr/bin
46@@ -329,43 +326,36 @@
47 # Revert some changes we did to the rootfs as we don't want them in the
48 # image.
49 sudo umount ${chroot}/proc
50- sudo mv -f ${tmp_dir}/resolv.conf.orig ${chroot}/etc/resolv.conf
51- sudo mv -f ${tmp_dir}/hosts.orig ${chroot}/etc/hosts
52+ sudo mv -f ${TMP_DIR}/resolv.conf.orig ${chroot}/etc/resolv.conf
53+ sudo mv -f ${TMP_DIR}/hosts.orig ${chroot}/etc/hosts
54 sudo rm -f ${chroot}/usr/bin/qemu-arm-static
55 sudo rm -f ${chroot}/usr/bin/linaro-hwpack-install
56 sudo rm -f ${chroot}/$(basename "$HWPACK_FILE")
57-
58- sudo tar cf binary-with-hwpack.tar -C "$tmp_dir" binary
59- BINARY_TARBALL=${DIR}/binary-with-hwpack.tar
60-}
61-
62-prepare_sources() {
63+}
64+
65+unpack_binary_tarball() {
66+ # Remove the binary/ directory so that previous runs don't interfere here.
67+ remove_binary_dir
68+
69+ sudo tar -xf $BINARY_TARBALL
70+}
71+
72+create_boot_cmd() {
73 if [ "$IS_LIVE" ]; then
74- parts_dir=casper
75 boot_snippet='boot=casper'
76 [ "$IS_LOWMEM" ] && lowmem_opt=only-ubiquity
77 else
78- parts_dir=boot
79 boot_snippet='root=UUID='${RFS_UUID}
80 fi
81
82- # Remove the binary/ directory so that previous runs don't interfere here.
83- rm -rf binary/
84-
85- extras=
86- if [ "$DEVIMAGE" = beagle ]; then
87- extras="binary/${MLO_FILE} binary/${UBOOT_FILE}"
88- fi
89- tar -xf $BINARY_TARBALL binary/${parts_dir} $extras
90-
91 if [ "${IMAGE_FILE}" ]; then
92- cat > binary/boot.cmd << BOOTCMD
93+ cat > ${TMP_DIR}/boot.cmd << BOOTCMD
94 setenv bootcmd 'mmc init; fatload mmc 0:1 0x80000000 uImage; bootm 0x80000000'
95 setenv bootargs '${serial_opts} ${splash_opts} earlyprintk fixrtc nocompcache ${lowmem_opt} root=/dev/mmcblk0p2 rootwait rw vram=12M omapfb.debug=y omapfb.mode=dvi:1280x720MR-16@60'
96 boot
97 BOOTCMD
98 else
99- cat > binary/boot.cmd << BOOTCMD
100+ cat > ${TMP_DIR}/boot.cmd << BOOTCMD
101 setenv bootcmd 'mmc init; fatload mmc 0:1 0x80000000 uImage; fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 0x81600000'
102 setenv bootargs '${serial_opts} ${splash_opts} earlyprintk fixrtc nocompcache ${lowmem_opt} ${boot_snippet} rootwait ro vram=12M omapfb.debug=y omapfb.mode=dvi:1280x720MR-16@60'
103 boot
104@@ -474,12 +464,12 @@
105 "${BOOT_DISK}/uInitrd"
106
107 sudo mkimage -A arm -O linux -T script -C none -a 0 \
108- -e 0 -n "$CODENAME 10.05" -d "${DIR}/binary/boot.cmd" \
109+ -e 0 -n "$CODENAME 10.05" -d "${TMP_DIR}/boot.cmd" \
110 "${BOOT_DISK}/boot.scr"
111 sudo cp -v ${BOOT_DISK}/boot.scr ${BOOT_DISK}/boot.ini
112 ;;
113 vexpress)
114- sudo tar --strip-components=5 -C ${BOOT_DISK}/ -xf $BINARY_TARBALL binary/usr/lib/u-boot/ca9x4_ct_vxp/u-boot.bin
115+ cp binary/usr/lib/u-boot/ca9x4_ct_vxp/u-boot.bin ${BOOT_DISK}/
116 sudo mkimage -A arm -O linux -T kernel -C none -a 0x60008000 -e 0x60008000 \
117 -n "Linux" -d ${DIR}/binary/${parts_dir}/vmlinuz*-vexpress ${BOOT_DISK}/uImage
118 sudo mkimage -A arm -O linux -T ramdisk -C none -a 0x81000000 \
119@@ -489,7 +479,6 @@
120 ;;
121 *)
122 echo "Set --dev parameter: --dev <beagle|igep|vexpress>" 1>&2
123- cleanup_workdir
124 exit
125 ;;
126 esac
127@@ -510,9 +499,9 @@
128 mkdir -p ${ROOT_DISK}
129 sudo mount ${MMC2} ${ROOT_DISK}
130
131- sudo tar -xf $BINARY_TARBALL --strip-components=1 -C $ROOT_DISK
132+ sudo mv ${DIR}/binary/* $ROOT_DISK
133
134-## add fstab entry for rootfs and boot
135+ # add fstab entry for rootfs and boot
136 echo "UUID=${RFS_UUID} / ${RFS} errors=remount-ro 0 1 " | sudo tee -a ${ROOT_DISK}/etc/fstab
137
138 if [ "$CREATE_SWAP" ] ; then
139@@ -574,7 +563,7 @@
140 sudo qemu-img create -f raw $IMAGE_FILE $IMAGE_SIZE
141 }
142
143-cleanup_workdir() {
144+remove_binary_dir() {
145 if [ -d binary/ ]; then
146 sudo rm -rf binary/
147 fi
148@@ -627,12 +616,11 @@
149 usage
150 fi
151
152+ unpack_binary_tarball
153 if [ "$HWPACK_FILE" ]; then
154- # This will unpack the binary tarball, install the hwpack in it, tar it up
155- # again and make this script use that new tarball from now on.
156- install_hwpack_into_tarball
157+ install_hwpack
158 fi
159- prepare_sources
160+ create_boot_cmd
161 get_mmcs_by_id
162 cleanup_sd
163 create_partitions
164@@ -654,5 +642,5 @@
165 gzip -f ${IMAGE_FILE} > ${IMAGE_FILE}.gz
166 fi
167
168- cleanup_workdir
169+ remove_binary_dir
170

Subscribers

People subscribed via source and target branches