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

Proposed by Guilherme Salgado
Status: Merged
Merged at revision: 96
Proposed branch: lp:~salgado/linaro-image-tools/refactor-lmc
Merge into: lp:linaro-image-tools/11.11
Diff against target: 163 lines (+29/-29)
1 file modified
linaro-media-create (+29/-29)
To merge this branch: bzr merge lp:~salgado/linaro-image-tools/refactor-lmc
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+36466@code.launchpad.net

Description of the change

This branch removes some unneeded code which was getting in the way of the refactoring I want to do. It also uses some constants to avoid repetition and make some things more obvious

To post a comment you must log in.
Revision history for this message
Guilherme Salgado (salgado) wrote :

- ln -sf binary/${parts_dir}/initrd.img-* .
- ln -sf binary/${parts_dir}/vmlinuz-* .

This is the unneeded code; those symlinks were not used by anything.

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

Looks good to me.

Thanks,

James

review: Approve
Revision history for this message
Peter Maydell (pmaydell) wrote :

- sudo dd if=/dev/zero of=${DIR}/disk/SWAP.swap bs=1M count=$SWAP_SIZE
- sudo mkswap ${DIR}/disk/SWAP.swap
- echo "/SWAP.swap none swap sw 0 0" | sudo tee -a ${DIR}/disk/etc/fstab
+ sudo dd if=/dev/zero of=${ROOT_DIR}/SWAP.swap bs=1M count=$SWAP_SIZE
+ sudo mkswap ${ROOT_DIR}/SWAP.swap
+ echo "/SWAP.swap none swap sw 0 0" | sudo tee -a ${ROOT_DIR}/etc/fstab

Shouldn't these (and other) uses of ROOT_DIR be ROOT_DISK instead? I can't see anywhere initialising ROOT_DIR...

+ mkdir -p ${ROOT_DISK} || true

I know they were in the previous version, but I don't think the "|| true" on "mkdir -p" or "rm -rf" is right. mkdir -p/rm -rf already exit 0 for the expected cases of "dir already exists" and "dir already deleted", and silently ignoring unexpected errors seems likely to just make us fail more obscurely later.

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

On Thu, 2010-09-23 at 16:31 +0000, Peter Maydell wrote:
> - sudo dd if=/dev/zero of=${DIR}/disk/SWAP.swap bs=1M count=$SWAP_SIZE
> - sudo mkswap ${DIR}/disk/SWAP.swap
> - echo "/SWAP.swap none swap sw 0 0" | sudo tee -a ${DIR}/disk/etc/fstab
> + sudo dd if=/dev/zero of=${ROOT_DIR}/SWAP.swap bs=1M count=$SWAP_SIZE
> + sudo mkswap ${ROOT_DIR}/SWAP.swap
> + echo "/SWAP.swap none swap sw 0 0" | sudo tee -a ${ROOT_DIR}/etc/fstab
>
> Shouldn't these (and other) uses of ROOT_DIR be ROOT_DISK instead? I can't see anywhere initialising ROOT_DIR...
>

Good catch, that should've been ROOT_DISK.

>
> + mkdir -p ${ROOT_DISK} || true
>
> I know they were in the previous version, but I don't think the "|| true" on "mkdir -p" or "rm -rf" is right. mkdir -p/rm -rf already exit 0 for the expected cases of "dir already exists" and "dir already deleted", and silently ignoring unexpected errors seems likely to just make us fail more obscurely later.

That makes total sense; I'll remove the "|| true".

Thanks!

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

97. By Guilherme Salgado

Fix some places in l-m-c that were using ROOT_DIR when they meant ROOT_DISC and some changes suggested by Peter Maydell

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'linaro-media-create'
--- linaro-media-create 2010-09-20 15:52:54 +0000
+++ linaro-media-create 2010-09-23 18:09:43 +0000
@@ -35,6 +35,8 @@
35IMAGE_SIZE=2G35IMAGE_SIZE=2G
3636
37DIR=$PWD37DIR=$PWD
38BOOT_DISK=${DIR}/boot-disc
39ROOT_DISK=${DIR}/root-disc
3840
39ensure_command() {41ensure_command() {
40 # ensure_command foo foo-package42 # ensure_command foo foo-package
@@ -297,6 +299,7 @@
297install_hwpack_into_tarball() {299install_hwpack_into_tarball() {
298 ensure_command qemu-arm-static qemu-arm-static300 ensure_command qemu-arm-static qemu-arm-static
299301
302
300 tmp_dir=$(mktemp -d)303 tmp_dir=$(mktemp -d)
301 chroot=${tmp_dir}/binary304 chroot=${tmp_dir}/binary
302 # Make sure the tmp_dir where we unpack the tarball is removed when this305 # Make sure the tmp_dir where we unpack the tarball is removed when this
@@ -346,9 +349,8 @@
346 boot_snippet='root=UUID='${RFS_UUID}349 boot_snippet='root=UUID='${RFS_UUID}
347 fi350 fi
348351
349 rm -rf ${DIR}/binary/ || true352 # Remove the binary/ directory so that previous runs don't interfere here.
350 rm -rf binary/initrd.img-* || true353 rm -rf binary/
351 rm -rf binary/vmlinuz-* || true
352354
353 extras=355 extras=
354 if [ "$DEVIMAGE" = beagle ]; then356 if [ "$DEVIMAGE" = beagle ]; then
@@ -356,9 +358,6 @@
356 fi358 fi
357 tar -xf $BINARY_TARBALL binary/${parts_dir} $extras359 tar -xf $BINARY_TARBALL binary/${parts_dir} $extras
358360
359 ln -sf binary/${parts_dir}/initrd.img-* .
360 ln -sf binary/${parts_dir}/vmlinuz-* .
361
362 if [ "${IMAGE_FILE}" ]; then361 if [ "${IMAGE_FILE}" ]; then
363 cat > binary/boot.cmd << BOOTCMD362 cat > binary/boot.cmd << BOOTCMD
364setenv bootcmd 'mmc init; fatload mmc 0:1 0x80000000 uImage; bootm 0x80000000'363setenv bootcmd 'mmc init; fatload mmc 0:1 0x80000000 uImage; bootm 0x80000000'
@@ -452,14 +451,14 @@
452 parts_dir=boot451 parts_dir=boot
453 fi452 fi
454 453
455 mkdir -p ${DIR}/disk || true454 mkdir -p ${BOOT_DISK} || true
456 sudo mount ${MMC1} ${DIR}/disk455 sudo mount ${MMC1} ${BOOT_DISK}
457 case "$DEVIMAGE" in456 case "$DEVIMAGE" in
458 beagle|igep)457 beagle|igep)
459 if [ "$DEVIMAGE" = "beagle" ]; then458 if [ "$DEVIMAGE" = "beagle" ]; then
460 if [ -e binary/${MLO_FILE} ] && [ -e binary/${UBOOT_FILE} ]; then459 if [ -e binary/${MLO_FILE} ] && [ -e binary/${UBOOT_FILE} ]; then
461 sudo cp -v binary/${MLO_FILE} ${DIR}/disk/MLO460 sudo cp -v binary/${MLO_FILE} ${BOOT_DISK}/MLO
462 sudo cp -v binary/${UBOOT_FILE} ${DIR}/disk/u-boot.bin461 sudo cp -v binary/${UBOOT_FILE} ${BOOT_DISK}/u-boot.bin
463 fi462 fi
464 fi463 fi
465 sync464 sync
@@ -468,25 +467,25 @@
468 467
469 sudo mkimage -A arm -O linux -T kernel -C none -a 0x80008000 \468 sudo mkimage -A arm -O linux -T kernel -C none -a 0x80008000 \
470 -e 0x80008000 -n Linux -d "${DIR}/binary/${parts_dir}"/vmlinuz-*omap \469 -e 0x80008000 -n Linux -d "${DIR}/binary/${parts_dir}"/vmlinuz-*omap \
471 "${DIR}/disk/uImage"470 "${BOOT_DISK}/uImage"
472 471
473 sudo mkimage -A arm -O linux -T ramdisk -C none -a 0 \472 sudo mkimage -A arm -O linux -T ramdisk -C none -a 0 \
474 -e 0 -n initramfs -d "${DIR}/binary/${parts_dir}"/initrd.img-*-omap \473 -e 0 -n initramfs -d "${DIR}/binary/${parts_dir}"/initrd.img-*-omap \
475 "${DIR}/disk/uInitrd"474 "${BOOT_DISK}/uInitrd"
476 475
477 sudo mkimage -A arm -O linux -T script -C none -a 0 \476 sudo mkimage -A arm -O linux -T script -C none -a 0 \
478 -e 0 -n "$CODENAME 10.05" -d "${DIR}/binary/boot.cmd" \477 -e 0 -n "$CODENAME 10.05" -d "${DIR}/binary/boot.cmd" \
479 "${DIR}/disk/boot.scr"478 "${BOOT_DISK}/boot.scr"
480 sudo cp -v ${DIR}/disk/boot.scr ${DIR}/disk/boot.ini479 sudo cp -v ${BOOT_DISK}/boot.scr ${BOOT_DISK}/boot.ini
481 ;;480 ;;
482 vexpress)481 vexpress)
483 sudo tar --strip-components=5 -C ${DIR}/disk/ -xf $BINARY_TARBALL binary/usr/lib/u-boot/ca9x4_ct_vxp/u-boot.bin482 sudo tar --strip-components=5 -C ${BOOT_DISK}/ -xf $BINARY_TARBALL binary/usr/lib/u-boot/ca9x4_ct_vxp/u-boot.bin
484 sudo mkimage -A arm -O linux -T kernel -C none -a 0x60008000 -e 0x60008000 \483 sudo mkimage -A arm -O linux -T kernel -C none -a 0x60008000 -e 0x60008000 \
485 -n "Linux" -d ${DIR}/binary/${parts_dir}/vmlinuz*-vexpress ${DIR}/disk/uImage484 -n "Linux" -d ${DIR}/binary/${parts_dir}/vmlinuz*-vexpress ${BOOT_DISK}/uImage
486 sudo mkimage -A arm -O linux -T ramdisk -C none -a 0x81000000 \485 sudo mkimage -A arm -O linux -T ramdisk -C none -a 0x81000000 \
487 -e 0x81000000 -n "initramfs" -d \486 -e 0x81000000 -n "initramfs" -d \
488 ${DIR}/binary/${parts_dir}/initrd.img-*-linaro-vexpress \487 ${DIR}/binary/${parts_dir}/initrd.img-*-linaro-vexpress \
489 "${DIR}"/disk/uInitrd488 "${BOOT_DISK}"/uInitrd
490 ;;489 ;;
491 *)490 *)
492 echo "Set --dev parameter: --dev <beagle|igep|vexpress>" 1>&2491 echo "Set --dev parameter: --dev <beagle|igep|vexpress>" 1>&2
@@ -495,12 +494,12 @@
495 ;;494 ;;
496 esac495 esac
497 496
498 cd ${DIR}/disk/497 cd ${BOOT_DISK}/
499 sync498 sync
500 sync499 sync
501 cd ${DIR}/500 cd ${DIR}/
502 501
503 sudo umount ${DIR}/disk || true502 sudo umount ${BOOT_DISK} || true
504}503}
505504
506populate_rootfs() {505populate_rootfs() {
@@ -508,12 +507,13 @@
508 echo "Populating rootfs Partition"507 echo "Populating rootfs Partition"
509 echo "Be patient, this may take a few minutes"508 echo "Be patient, this may take a few minutes"
510 echo ""509 echo ""
511 sudo mount ${MMC2} ${DIR}/disk510 mkdir -p ${ROOT_DISK}
511 sudo mount ${MMC2} ${ROOT_DISK}
512512
513 sudo tar -xf $BINARY_TARBALL --strip-components=1 -C disk/513 sudo tar -xf $BINARY_TARBALL --strip-components=1 -C $ROOT_DISK
514514
515## add fstab entry for rootfs and boot515## add fstab entry for rootfs and boot
516 echo "UUID=${RFS_UUID} / ${RFS} errors=remount-ro 0 1 " | sudo tee -a ${DIR}/disk/etc/fstab516 echo "UUID=${RFS_UUID} / ${RFS} errors=remount-ro 0 1 " | sudo tee -a ${ROOT_DISK}/etc/fstab
517517
518 if [ "$CREATE_SWAP" ] ; then518 if [ "$CREATE_SWAP" ] ; then
519519
@@ -521,14 +521,14 @@
521 echo "Creating SWAP File"521 echo "Creating SWAP File"
522 echo ""522 echo ""
523523
524 SPACE_LEFT=$(df ${DIR}/disk/ | grep ${MMC2} | awk '{print $4}')524 SPACE_LEFT=$(df ${ROOT_DISK} | grep ${MMC2} | awk '{print $4}')
525525
526 let SIZE=$SWAP_SIZE*1024526 let SIZE=$SWAP_SIZE*1024
527527
528 if [ $SPACE_LEFT -ge $SIZE ] ; then528 if [ $SPACE_LEFT -ge $SIZE ] ; then
529 sudo dd if=/dev/zero of=${DIR}/disk/SWAP.swap bs=1M count=$SWAP_SIZE529 sudo dd if=/dev/zero of=${ROOT_DISK}/SWAP.swap bs=1M count=$SWAP_SIZE
530 sudo mkswap ${DIR}/disk/SWAP.swap530 sudo mkswap ${ROOT_DISK}/SWAP.swap
531 echo "/SWAP.swap none swap sw 0 0" | sudo tee -a ${DIR}/disk/etc/fstab531 echo "/SWAP.swap none swap sw 0 0" | sudo tee -a ${ROOT_DISK}/etc/fstab
532 else532 else
533 echo "SWAP file bigger then whats left on partition"533 echo "SWAP file bigger then whats left on partition"
534 fi534 fi
@@ -538,14 +538,14 @@
538 echo "Creating /etc/flash-kernel.conf"538 echo "Creating /etc/flash-kernel.conf"
539 echo ""539 echo ""
540540
541 echo "UBOOT_PART=/dev/mmcblk0p1" | sudo tee ${DIR}/disk/etc/flash-kernel.conf >/dev/null541 echo "UBOOT_PART=/dev/mmcblk0p1" | sudo tee ${ROOT_DISK}/etc/flash-kernel.conf >/dev/null
542542
543 cd ${DIR}/disk/543 cd ${ROOT_DISK}
544 sync544 sync
545 sync545 sync
546 cd ${DIR}/546 cd ${DIR}/
547547
548 sudo umount ${DIR}/disk || true548 sudo umount ${ROOT_DISK} || true
549}549}
550550
551calculatesize() {551calculatesize() {

Subscribers

People subscribed via source and target branches