Merge lp:~lool/linaro-image-tools/random-cleanups into lp:linaro-image-tools/11.11

Proposed by Loïc Minier
Status: Merged
Merged at revision: 119
Proposed branch: lp:~lool/linaro-image-tools/random-cleanups
Merge into: lp:linaro-image-tools/11.11
Diff against target: 399 lines (+109/-131)
1 file modified
linaro-media-create (+109/-131)
To merge this branch: bzr merge lp:~lool/linaro-image-tools/random-cleanups
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+36863@code.launchpad.net

Description of the change

A stupidly long collection of cleanup commits.

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

Hi,

18 -CODENAME=Chessy
19 +CODENAME="Chessy 10.05"

Where's that used? Shouldn't it be something else now?

126 -case $DEVNAME in
127 - beagle|igep|vexpress)
128 - ensure_command mkimage uboot-mkimage
129 - ;;
130 -esac

We don't need that anymore, or it is repeated elsewhere?

192 + -d "${DIR}/binary/${parts_dir}"/vmlinuz-*-linaro-omap \

Is that a little specific?

171 + mkdir -p ${BOOT_DISK}

While you are changing it you might as well quote "${BOOT_DISK}"

182 + ${BOOT_DISK}

ditto.

212 + sudo cp -v binary/usr/lib/u-boot/ca9x4_ct_vxp/u-boot.bin ${BOOT_DISK}

ditto

review: Approve
Revision history for this message
Loïc Minier (lool) wrote :

On Tue, Sep 28, 2010, James Westby wrote:
> 18 -CODENAME=Chessy
> 19 +CODENAME="Chessy 10.05"
> Where's that used? Shouldn't it be something else now?

 (It seems you're reading the diff as a whole; you might find it easier
 to read individual revisions to understand each change, especially
 since there are some isolated whitespace cleanup commits which clutter
 the diff a bit.)

 http://bazaar.launchpad.net/~lool/linaro-image-tools/random-cleanups/revision/107
 it was in the description of the boot script for beagles and igeps.

 I wish we'd remove this, I wanted to dump this first pass of
 mostly shell syntax improvements before the series would grow too large
 and I avoided controversial changes.

 But I could add a commit to drop this if you like; I think generated
 the boot script shouldn't say the release name. (I'm worried about
 other serious things with the boot script(s) though.)

> 126 -case $DEVNAME in
> 127 - beagle|igep|vexpress)
> 128 - ensure_command mkimage uboot-mkimage
> 129 - ;;
> 130 -esac
>
> We don't need that anymore, or it is repeated elsewhere?

 http://bazaar.launchpad.net/~lool/linaro-image-tools/random-cleanups/revision/117
 This test was broken (DEVNAME wasn't set in the script) and all the
 boards targets require mkimage, so I made it unconditional.

> 192 + -d "${DIR}/binary/${parts_dir}"/vmlinuz-*-linaro-omap \
> Is that a little specific?

 -vexpress was already enforcing linaro-vexpress on one file; I figured
 it was actually correct to do so, but it probably prevents installing
 relatively old Linaro images. I think that's ok.

> 171 + mkdir -p ${BOOT_DISK}
> While you are changing it you might as well quote "${BOOT_DISK}"
> 182 + ${BOOT_DISK}
> ditto.
> 212 + sudo cp -v binary/usr/lib/u-boot/ca9x4_ct_vxp/u-boot.bin ${BOOT_DISK}
> ditto

 Sure; I think I will do a quoting pass; it's just all over the place.
 I tried keeping each commit logical and not mixing two things in the
 same commit.

--
Loïc Minier

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

On Tue, 28 Sep 2010 17:13:43 -0000, Loïc Minier <email address hidden> wrote:
> On Tue, Sep 28, 2010, James Westby wrote:
> > 18 -CODENAME=Chessy
> > 19 +CODENAME="Chessy 10.05"
> > Where's that used? Shouldn't it be something else now?
>
> (It seems you're reading the diff as a whole; you might find it easier
> to read individual revisions to understand each change, especially
> since there are some isolated whitespace cleanup commits which clutter
> the diff a bit.)
>
> http://bazaar.launchpad.net/~lool/linaro-image-tools/random-cleanups/revision/107
> it was in the description of the boot script for beagles and igeps.
>
> I wish we'd remove this, I wanted to dump this first pass of
> mostly shell syntax improvements before the series would grow too large
> and I avoided controversial changes.
>
> But I could add a commit to drop this if you like; I think generated
> the boot script shouldn't say the release name. (I'm worried about
> other serious things with the boot script(s) though.)

A followup to use "Linaro 10.11" or something would be fine with me.

> > 126 -case $DEVNAME in
> > 127 - beagle|igep|vexpress)
> > 128 - ensure_command mkimage uboot-mkimage
> > 129 - ;;
> > 130 -esac
> >
> > We don't need that anymore, or it is repeated elsewhere?
>
> http://bazaar.launchpad.net/~lool/linaro-image-tools/random-cleanups/revision/117
> This test was broken (DEVNAME wasn't set in the script) and all the
> boards targets require mkimage, so I made it unconditional.

Isn't that unconditionally not there? Don't we want to check the command
is present and give the nice error?

> > 171 + mkdir -p ${BOOT_DISK}
> > While you are changing it you might as well quote "${BOOT_DISK}"
> > 182 + ${BOOT_DISK}
> > ditto.
> > 212 + sudo cp -v binary/usr/lib/u-boot/ca9x4_ct_vxp/u-boot.bin ${BOOT_DISK}
> > ditto
>
> Sure; I think I will do a quoting pass; it's just all over the place.
> I tried keeping each commit logical and not mixing two things in the
> same commit.

If you could do quoting as another pass that would be great, I've
reviewed all of this now, and pulling in all the results of quoting
would be a pain to re-review.

Thanks,

James

Revision history for this message
Loïc Minier (lool) wrote :

I pushed a couple of additional commits addressing your comments

118. By Loïc Minier

Drop CODENAME and use "boot script" as the description of the boot script.

119. By Loïc Minier

Quote uses of BOOT_DISK and ROOT_DISK.

Revision history for this message
Loïc Minier (lool) wrote :

On Tue, Sep 28, 2010, James Westby wrote:
> A followup to use "Linaro 10.11" or something would be fine with me.

 I just dropped it in favor of "boot script" as a description.

> > http://bazaar.launchpad.net/~lool/linaro-image-tools/random-cleanups/revision/117
> > This test was broken (DEVNAME wasn't set in the script) and all the
> > boards targets require mkimage, so I made it unconditional.
>
> Isn't that unconditionally not there? Don't we want to check the command
> is present and give the nice error?

 I'm not sure what you mean; it's there around line 224:
ensure_command mkimage uboot-mkimage

> If you could do quoting as another pass that would be great, I've
> reviewed all of this now, and pulling in all the results of quoting
> would be a pain to re-review.

 Sorry; pushed that as my last commit now, but it's basically the latest
 commit.

--
Loïc Minier

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

On Tue, 28 Sep 2010 17:55:56 -0000, Loïc Minier <email address hidden> wrote:
> I'm not sure what you mean; it's there around line 224:
> ensure_command mkimage uboot-mkimage

Yep, don't know how I missed that, sorry.

Thanks,

James

Revision history for this message
Steve Langasek (vorlon) wrote :

On Tue, Sep 28, 2010 at 01:29:43PM -0000, Loïc Minier wrote:
> Loïc Minier has proposed merging lp:~lool/linaro-image-tools/random-cleanups into lp:linaro-image-tools.

> Requested reviews:
> Linaro Maintainers (linaro-maintainers)

> A stupidly long collection of cleanup commits.

I think this has collided with my refactoring of uboot installation in
l-m-c. Update & resubmit?

BTW, the whitespace changes here call attention to the many uses of sync in
this script. Are any of these *not* gratuitous? In the worst case, we
should call sync once before unmounting the filesystem; but even then that
would be a kernel bug if it fails to flush the data out to disk before
unmounting, and I'm not aware of any such bugs at present. I think this
script would run a bit faster, without negative consequences, if we were to
clear out all these 'sync' calls...

Revision history for this message
Loïc Minier (lool) wrote :

Steve, I resolved the conflict when merging already.

I did kill some sync calls, but not all of them. I wasn't sure why there were there, so I only killed the easy ones.

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 20:53:10 +0000
3+++ linaro-media-create 2010-09-28 17:47:01 +0000
4@@ -19,9 +19,6 @@
5
6 set -e
7
8-MLO_FILE=usr/lib/x-loader-omap/MLO
9-UBOOT_FILE=usr/lib/u-boot/omap3_beagle/u-boot.bin
10-
11 unset MMC MMC1 MMC2 MMC3 IMAGE_FILE HWPACK_FILE
12
13 #Defaults
14@@ -29,15 +26,14 @@
15 BINARY_TARBALL='binary-tar.tar.gz'
16 BOOT_LABEL=boot
17 RFS_LABEL=rootfs
18-CODENAME=Chessy
19 IS_LIVE=
20 FAT_SIZE=32
21 IMAGE_SIZE=2G
22
23 DIR=$PWD
24 TMP_DIR=$(mktemp -d)
25-BOOT_DISK=${DIR}/boot-disc
26-ROOT_DISK=${DIR}/root-disc
27+BOOT_DISK="${DIR}/boot-disc"
28+ROOT_DISK="${DIR}/root-disc"
29
30 ensure_command() {
31 # ensure_command foo foo-package
32@@ -51,7 +47,7 @@
33 echo "usage: $(basename $0) --mmc /dev/sdd"
34 echo "<or>"
35 echo "usage: $(basename $0) --image_file mmc.img"
36-cat <<EOF
37+ cat <<EOF
38
39 required options:
40 --mmc </dev/sdX>
41@@ -108,7 +104,7 @@
42 --binary <filename>
43 specify file used to create the bootable system. Default binary-tar.tar.gz
44 EOF
45-exit
46+ exit
47 }
48
49 check_mmc() {
50@@ -142,35 +138,14 @@
51 }
52
53 check_fs_type() {
54- IN_VALID_FS=1
55-
56- if test "-$FS_TYPE-" = "-ext2-"
57- then
58- RFS=ext2
59- unset IN_VALID_FS
60- fi
61-
62- if test "-$FS_TYPE-" = "-ext3-"
63- then
64- RFS=ext3
65- unset IN_VALID_FS
66- fi
67-
68- if test "-$FS_TYPE-" = "-ext4-"
69- then
70- RFS=ext4
71- unset IN_VALID_FS
72- fi
73-
74- if test "-$FS_TYPE-" = "-btrfs-"
75- then
76- RFS=btrfs
77- unset IN_VALID_FS
78- fi
79-
80- if [ "$IN_VALID_FS" ] ; then
81- usage
82- fi
83+ case "$RFS" in
84+ ext2|ext3|ext4|btrfs)
85+ :
86+ ;;
87+ *)
88+ usage
89+ ;;
90+ esac
91 }
92
93 checkparm() {
94@@ -187,7 +162,6 @@
95 case $1 in
96 -h|--help)
97 usage
98- MMC=1
99 ;;
100 --hwpack)
101 checkparm $2
102@@ -208,7 +182,7 @@
103 ;;
104 --rootfs)
105 checkparm $2
106- FS_TYPE="$2"
107+ RFS="$2"
108 check_fs_type
109 ;;
110 --boot_label)
111@@ -247,27 +221,20 @@
112 shift
113 done
114
115+ensure_command mkimage uboot-mkimage
116 ensure_command uuidgen uuid-runtime
117 ensure_command parted parted
118 ensure_command wget wget
119 ensure_command md5sum coreutils
120 ensure_command realpath realpath
121-case $RFS in
122- ext3)
123- ensure_command mkfs.ext3 e2fsprogs
124- ;;
125- ext4)
126- ensure_command mkfs.ext4 e2fsprogs
127+case "$RFS" in
128+ ext2|ext3|ext4)
129+ ensure_command "mkfs.$RFS" e2fsprogs
130 ;;
131 btrfs)
132 ensure_command mkfs.btrfs btrfs-tools
133 ;;
134 esac
135-case $DEVNAME in
136- beagle|igep|vexpress)
137- ensure_command mkimage uboot-mkimage
138- ;;
139-esac
140
141 RFS_UUID=`uuidgen -r`
142
143@@ -365,19 +332,19 @@
144
145 cleanup_sd() {
146
147- echo ""
148- echo "Umounting Partitions"
149- echo ""
150+ echo ""
151+ echo "Umounting Partitions"
152+ echo ""
153
154- if test -n "$MMC1"; then
155- sudo umount ${MMC1} &> /dev/null || true
156- fi
157- if test -n "$MMC2"; then
158- sudo umount ${MMC2} &> /dev/null || true
159- fi
160- if [ "${MMC}" ]; then
161- sudo parted -s ${MMC} mklabel msdos
162- fi
163+ if test -n "$MMC1"; then
164+ sudo umount ${MMC1} &> /dev/null || true
165+ fi
166+ if test -n "$MMC2"; then
167+ sudo umount ${MMC2} &> /dev/null || true
168+ fi
169+ if [ "${MMC}" ]; then
170+ sudo parted -s ${MMC} mklabel msdos
171+ fi
172 }
173
174 create_partitions() {
175@@ -441,54 +408,53 @@
176 parts_dir=boot
177 fi
178
179- mkdir -p ${BOOT_DISK} || true
180- sudo mount ${MMC1} ${BOOT_DISK}
181+ mkdir -p "${BOOT_DISK}"
182+ sudo mount ${MMC1} "${BOOT_DISK}"
183 case "$DEVIMAGE" in
184 beagle|igep)
185 if [ "$DEVIMAGE" = "beagle" ]; then
186- if [ -e binary/${MLO_FILE} ] && [ -e binary/${UBOOT_FILE} ]; then
187- sudo cp -v binary/${MLO_FILE} ${BOOT_DISK}/MLO
188- sudo cp -v binary/${UBOOT_FILE} ${BOOT_DISK}/u-boot.bin
189- fi
190+ sudo cp -v binary/usr/lib/x-loader-omap/MLO \
191+ binary/usr/lib/u-boot/omap3_beagle/u-boot.bin \
192+ "${BOOT_DISK}"
193 fi
194 sync
195- cd ${DIR}
196 echo "done"
197-
198+
199 sudo mkimage -A arm -O linux -T kernel -C none -a 0x80008000 \
200- -e 0x80008000 -n Linux -d "${DIR}/binary/${parts_dir}"/vmlinuz-*omap \
201+ -e 0x80008000 -n Linux \
202+ -d "${DIR}/binary/${parts_dir}"/vmlinuz-*-linaro-omap \
203 "${BOOT_DISK}/uImage"
204-
205 sudo mkimage -A arm -O linux -T ramdisk -C none -a 0 \
206- -e 0 -n initramfs -d "${DIR}/binary/${parts_dir}"/initrd.img-*-omap \
207+ -e 0 -n initramfs \
208+ -d "${DIR}/binary/${parts_dir}"/initrd.img-*-linaro-omap \
209 "${BOOT_DISK}/uInitrd"
210-
211 sudo mkimage -A arm -O linux -T script -C none -a 0 \
212- -e 0 -n "$CODENAME 10.05" -d "${TMP_DIR}/boot.cmd" \
213+ -e 0 -n "boot script" -d "${TMP_DIR}/boot.cmd" \
214 "${BOOT_DISK}/boot.scr"
215- sudo cp -v ${BOOT_DISK}/boot.scr ${BOOT_DISK}/boot.ini
216+ sudo cp -v "${BOOT_DISK}/boot.scr" "${BOOT_DISK}/boot.ini"
217 ;;
218+
219 vexpress)
220- cp binary/usr/lib/u-boot/ca9x4_ct_vxp/u-boot.bin ${BOOT_DISK}/
221- sudo mkimage -A arm -O linux -T kernel -C none -a 0x60008000 -e 0x60008000 \
222- -n "Linux" -d ${DIR}/binary/${parts_dir}/vmlinuz*-vexpress ${BOOT_DISK}/uImage
223+ sudo cp -v binary/usr/lib/u-boot/ca9x4_ct_vxp/u-boot.bin "${BOOT_DISK}"
224+ sudo mkimage -A arm -O linux -T kernel -C none -a 0x60008000 \
225+ -e 0x60008000 -n Linux \
226+ -d "${DIR}/binary/${parts_dir}"/vmlinuz-*-linaro-vexpress \
227+ "${BOOT_DISK}/uImage"
228 sudo mkimage -A arm -O linux -T ramdisk -C none -a 0x81000000 \
229- -e 0x81000000 -n "initramfs" -d \
230- ${DIR}/binary/${parts_dir}/initrd.img-*-linaro-vexpress \
231- "${BOOT_DISK}"/uInitrd
232+ -e 0x81000000 -n initramfs \
233+ -d "${DIR}/binary/${parts_dir}"/initrd.img-*-linaro-vexpress \
234+ "${BOOT_DISK}/uInitrd"
235 ;;
236+
237 *)
238- echo "Set --dev parameter: --dev <beagle|igep|vexpress>" 1>&2
239- exit
240+ echo "Internal error; missing support for $DEVIMAGE" >&2
241+ exit 1
242 ;;
243 esac
244-
245- cd ${BOOT_DISK}/
246- sync
247- sync
248- cd ${DIR}/
249-
250- sudo umount ${BOOT_DISK} || true
251+
252+ sync
253+ sync
254+ sudo umount "${BOOT_DISK}" || true
255 }
256
257 populate_rootfs() {
258@@ -496,13 +462,13 @@
259 echo "Populating rootfs Partition"
260 echo "Be patient, this may take a few minutes"
261 echo ""
262- mkdir -p ${ROOT_DISK}
263- sudo mount ${MMC2} ${ROOT_DISK}
264+ mkdir -p "${ROOT_DISK}"
265+ sudo mount ${MMC2} "${ROOT_DISK}"
266
267- sudo mv ${DIR}/binary/* $ROOT_DISK
268+ sudo mv ${DIR}/binary/* "$ROOT_DISK"
269
270 # add fstab entry for rootfs and boot
271- echo "UUID=${RFS_UUID} / ${RFS} errors=remount-ro 0 1 " | sudo tee -a ${ROOT_DISK}/etc/fstab
272+ echo "UUID=${RFS_UUID} / ${RFS} errors=remount-ro 0 1 " | sudo tee -a "${ROOT_DISK}/etc/fstab"
273
274 if [ "$CREATE_SWAP" ] ; then
275
276@@ -510,14 +476,14 @@
277 echo "Creating SWAP File"
278 echo ""
279
280- SPACE_LEFT=$(df ${ROOT_DISK} | grep ${MMC2} | awk '{print $4}')
281+ SPACE_LEFT=$(df "${ROOT_DISK}" | grep ${MMC2} | awk '{print $4}')
282
283 let SIZE=$SWAP_SIZE*1024
284
285 if [ $SPACE_LEFT -ge $SIZE ] ; then
286- sudo dd if=/dev/zero of=${ROOT_DISK}/SWAP.swap bs=1M count=$SWAP_SIZE
287- sudo mkswap ${ROOT_DISK}/SWAP.swap
288- echo "/SWAP.swap none swap sw 0 0" | sudo tee -a ${ROOT_DISK}/etc/fstab
289+ sudo dd if=/dev/zero "of=${ROOT_DISK}/SWAP.swap" bs=1M count=$SWAP_SIZE
290+ sudo mkswap "${ROOT_DISK}/SWAP.swap"
291+ echo "/SWAP.swap none swap sw 0 0" | sudo tee -a "${ROOT_DISK}/etc/fstab"
292 else
293 echo "SWAP file bigger then whats left on partition"
294 fi
295@@ -527,14 +493,11 @@
296 echo "Creating /etc/flash-kernel.conf"
297 echo ""
298
299- echo "UBOOT_PART=/dev/mmcblk0p1" | sudo tee ${ROOT_DISK}/etc/flash-kernel.conf >/dev/null
300-
301- cd ${ROOT_DISK}
302- sync
303- sync
304- cd ${DIR}/
305-
306- sudo umount ${ROOT_DISK} || true
307+ echo "UBOOT_PART=/dev/mmcblk0p1" | sudo tee "${ROOT_DISK}/etc/flash-kernel.conf" >/dev/null
308+
309+ sync
310+ sync
311+ sudo umount "${ROOT_DISK}" || true
312 }
313
314 calculatesize() {
315@@ -585,6 +548,20 @@
316 fi
317 fi
318
319+case "$DEVIMAGE" in
320+ beagle|igep|vexpress)
321+ :
322+ ;;
323+ "")
324+ echo "Please set some target device with --dev" >&2
325+ usage
326+ ;;
327+ *)
328+ echo "Unknown target device $DEVIMAGE" >&2
329+ usage
330+ ;;
331+esac
332+
333 if [ "$DEVIMAGE" ]; then
334 case "$DEVIMAGE" in
335 beagle|igep)
336@@ -603,7 +580,8 @@
337 FAT_SIZE=16
338 ;;
339 *)
340- echo "unknown --dev paramater: $DEVIMAGE" 1>&2
341+ echo "Internal error; missing support for $DEVIMAGE" >&2
342+ exit 1
343 ;;
344 esac
345 else
346@@ -616,31 +594,31 @@
347 usage
348 fi
349
350- unpack_binary_tarball
351- if [ "$HWPACK_FILE" ]; then
352- install_hwpack
353- fi
354- create_boot_cmd
355- get_mmcs_by_id
356- cleanup_sd
357- create_partitions
358- echo -n "waiting for partitioning to settle ..."
359- sync
360- sleep 3
361- echo "done."
362- get_mmcs_by_id
363- if test -z "$MMC1" -o -z "$MMC2"; then
364- echo "MMC1: $MMC1 nor MMC2: $MMC2 must be empty"
365- exit 2
366- fi
367- prepare_partitions
368- populate_boot
369- populate_rootfs
370+unpack_binary_tarball
371+if [ "$HWPACK_FILE" ]; then
372+ install_hwpack
373+fi
374+create_boot_cmd
375+get_mmcs_by_id
376+cleanup_sd
377+create_partitions
378+echo -n "waiting for partitioning to settle ..."
379+sync
380+sleep 3
381+echo "done."
382+get_mmcs_by_id
383+if test -z "$MMC1" -o -z "$MMC2"; then
384+ echo "MMC1: $MMC1 nor MMC2: $MMC2 must be empty"
385+ exit 2
386+fi
387+prepare_partitions
388+populate_boot
389+populate_rootfs
390
391- if [ "${IMAGE_FILE}" ]; then
392+if [ "${IMAGE_FILE}" ]; then
393 echo "Create ${IMAGE_FILE}.gz"
394 gzip -f ${IMAGE_FILE} > ${IMAGE_FILE}.gz
395- fi
396+fi
397
398- remove_binary_dir
399+remove_binary_dir
400

Subscribers

People subscribed via source and target branches