Merge lp:~salgado/linaro-image-tools/standardise-indentation into lp:linaro-image-tools/11.11

Proposed by Guilherme Salgado
Status: Merged
Merged at revision: 80
Proposed branch: lp:~salgado/linaro-image-tools/standardise-indentation
Merge into: lp:linaro-image-tools/11.11
Diff against target: 610 lines (+267/-269)
1 file modified
linaro-media-create (+267/-269)
To merge this branch: bzr merge lp:~salgado/linaro-image-tools/standardise-indentation
Reviewer Review Type Date Requested Status
Alexander Sack (community) Approve
Review via email: mp+35550@code.launchpad.net

Description of the change

linaro-media-create uses a mix of 1, 2 and 4 spaces for indentation. This is an attempt at standardizing at 2.

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

I suggest using bzr explorer to see the diff as it will show a side-by-side diff which makes it easy to see that it's just the indentation that's changed.

Revision history for this message
Alexander Sack (asac) wrote :

looks good. i didnt see any typos on eyeball review.

if you have a headless tarball at hand, try to burn it to a SD card to see if things work still ;)

another followup whitespace cleanup project might be to make all the if ... ; then cases consistent.

some use new line before then, some use whitespace before and after ; or just after or no whitespace.

i would be fine with new line before "then" everyhwere.

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

Thanks for the review, Alexander.

I ran it on a headless tarball and it generated an image which was
exactly the same size as that generated by trunk's linaro-media-create.

I wasn't able to boot it using qemu but that's likely to not be related
to my changes as I can't boot the img generated with trunk's version
either.

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-14 23:59:33 +0000
+++ linaro-media-create 2010-09-15 16:09:44 +0000
@@ -132,256 +132,254 @@
132}132}
133133
134create_partitions() {134create_partitions() {
135if [ "${IMAGE_FILE}" ]; then135 if [ "${IMAGE_FILE}" ]; then
136partdev=${IMAGE_FILE}136 partdev=${IMAGE_FILE}
137else137 else
138partdev=${MMC}138 partdev=${MMC}
139fi139 fi
140140
141if [ "$FAT_SIZE" = "32" ]; then141 if [ "$FAT_SIZE" = "32" ]; then
142 PARTITION_TYPE="0x0C"142 PARTITION_TYPE="0x0C"
143else143 else
144 PARTITION_TYPE="0x0E"144 PARTITION_TYPE="0x0E"
145fi145 fi
146146
147# Create a VFAT or FAT16 partition of 9 cylinders which is about 64M147 # Create a VFAT or FAT16 partition of 9 cylinders which is about 64M
148# and a linux partition of the rest148 # and a linux partition of the rest
149149 sudo sfdisk -D -H $HEADS -S $SECTORS $CYLINDER_ARG $partdev << THEEND
150sudo sfdisk -D -H $HEADS -S $SECTORS $CYLINDER_ARG $partdev << THEEND
151,9,$PARTITION_TYPE,*150,9,$PARTITION_TYPE,*
152,,,-151,,,-
153THEEND152THEEND
154153
155if [ "${IMAGE_FILE}" ]; then154 if [ "${IMAGE_FILE}" ]; then
156VFATOFFSET=$(($(fdisk -l -u $IMAGE_FILE | grep FAT | awk '{print $3}')*512))155 VFATOFFSET=$(($(fdisk -l -u $IMAGE_FILE | grep FAT | awk '{print $3}')*512))
157VFATSIZE=$(($(fdisk -l -u $IMAGE_FILE | grep FAT | awk '{print $5}')*1024))156 VFATSIZE=$(($(fdisk -l -u $IMAGE_FILE | grep FAT | awk '{print $5}')*1024))
158ROOTOFFSET=$(($(fdisk -l -u $IMAGE_FILE | grep Linux | awk '{print $2}')*512))157 ROOTOFFSET=$(($(fdisk -l -u $IMAGE_FILE | grep Linux | awk '{print $2}')*512))
159ROOTSIZE2=$(($(fdisk -l -u $IMAGE_FILE | grep Linux | awk '{print $3}')))158 ROOTSIZE2=$(($(fdisk -l -u $IMAGE_FILE | grep Linux | awk '{print $3}')))
160ROOTSIZE1=$(($(fdisk -l -u $IMAGE_FILE | grep Linux | awk '{print $2}')))159 ROOTSIZE1=$(($(fdisk -l -u $IMAGE_FILE | grep Linux | awk '{print $2}')))
161ROOTSIZE=$((((ROOTSIZE2-ROOTSIZE1)/2)*1024))160 ROOTSIZE=$((((ROOTSIZE2-ROOTSIZE1)/2)*1024))
162MMC1=$(sudo losetup -f --show $IMAGE_FILE --offset $VFATOFFSET --sizelimit $VFATSIZE)161 MMC1=$(sudo losetup -f --show $IMAGE_FILE --offset $VFATOFFSET --sizelimit $VFATSIZE)
163MMC2=$(sudo losetup -f --show $IMAGE_FILE --offset $ROOTOFFSET --sizelimit $ROOTSIZE)162 MMC2=$(sudo losetup -f --show $IMAGE_FILE --offset $ROOTOFFSET --sizelimit $ROOTSIZE)
164fi163 fi
165}164}
166165
167166
168prepare_partitions() {167prepare_partitions() {
169168 echo ""
170echo ""169 echo "Formating Boot Partition"
171echo "Formating Boot Partition"170 echo ""
172echo ""171
173172 sudo mkfs.vfat -F ${FAT_SIZE} ${MMC1} -n ${BOOT_LABEL}
174sudo mkfs.vfat -F ${FAT_SIZE} ${MMC1} -n ${BOOT_LABEL}173
175174 echo ""
176echo ""175 echo "Formating ${RFS} Partition"
177echo "Formating ${RFS} Partition"176 echo ""
178echo ""177 sudo mkfs.${RFS} -U "$RFS_UUID" ${MMC2} -L ${RFS_LABEL}
179sudo mkfs.${RFS} -U "$RFS_UUID" ${MMC2} -L ${RFS_LABEL}
180}178}
181179
182populate_boot() {180populate_boot() {
183 echo ""181 echo ""
184 echo "Populating Boot Partition"182 echo "Populating Boot Partition"
185 echo ""183 echo ""
186184
187 echo ""185 echo ""
188 echo "Installing Boot Loader"186 echo "Installing Boot Loader"
189 echo ""187 echo ""
190188
191 if [ "$IS_LIVE" ]; then189 if [ "$IS_LIVE" ]; then
192 parts_dir=casper190 parts_dir=casper
193 else191 else
194 parts_dir=boot192 parts_dir=boot
195 fi193 fi
196194
197 mkdir -p ${DIR}/disk || true195 mkdir -p ${DIR}/disk || true
198 sudo mount ${MMC1} ${DIR}/disk196 sudo mount ${MMC1} ${DIR}/disk
199 case "$DEVIMAGE" in197 case "$DEVIMAGE" in
200 beagle|igep)198 beagle|igep)
201 if [ "$DEVIMAGE" = "beagle" ]; then199 if [ "$DEVIMAGE" = "beagle" ]; then
202 if [ -e binary/${parts_dir}/${MLO_FILE} ] && [ -e binary/${parts_dir}/${UBOOT_FILE} ]; then200 if [ -e binary/${parts_dir}/${MLO_FILE} ] && [ -e binary/${parts_dir}/${UBOOT_FILE} ]; then
203 sudo cp -v binary/${parts_dir}/${MLO_FILE} ${DIR}/disk/MLO201 sudo cp -v binary/${parts_dir}/${MLO_FILE} ${DIR}/disk/MLO
204 sudo cp -v binary/${parts_dir}/${UBOOT_FILE} ${DIR}/disk/u-boot.bin202 sudo cp -v binary/${parts_dir}/${UBOOT_FILE} ${DIR}/disk/u-boot.bin
205 fi203 fi
206 fi204 fi
207 sync205 sync
208 cd ${DIR}206 cd ${DIR}
209 echo "done"207 echo "done"
210208
211 sudo mkimage -A arm -O linux -T kernel -C none -a 0x80008000 \209 sudo mkimage -A arm -O linux -T kernel -C none -a 0x80008000 \
212 -e 0x80008000 -n Linux -d "${DIR}/binary/${parts_dir}"/vmlinuz-*omap \210 -e 0x80008000 -n Linux -d "${DIR}/binary/${parts_dir}"/vmlinuz-*omap \
213 "${DIR}/disk/uImage"211 "${DIR}/disk/uImage"
214212
215 sudo mkimage -A arm -O linux -T ramdisk -C none -a 0 \213 sudo mkimage -A arm -O linux -T ramdisk -C none -a 0 \
216 -e 0 -n initramfs -d "${DIR}/binary/${parts_dir}"/initrd.img-*-omap \214 -e 0 -n initramfs -d "${DIR}/binary/${parts_dir}"/initrd.img-*-omap \
217 "${DIR}/disk/uInitrd"215 "${DIR}/disk/uInitrd"
218216
219 sudo mkimage -A arm -O linux -T script -C none -a 0 \217 sudo mkimage -A arm -O linux -T script -C none -a 0 \
220 -e 0 -n "$CODENAME 10.05" -d "${DIR}/binary/boot.cmd" \218 -e 0 -n "$CODENAME 10.05" -d "${DIR}/binary/boot.cmd" \
221 "${DIR}/disk/boot.scr"219 "${DIR}/disk/boot.scr"
222 sudo cp -v ${DIR}/disk/boot.scr ${DIR}/disk/boot.ini220 sudo cp -v ${DIR}/disk/boot.scr ${DIR}/disk/boot.ini
223 ;;221 ;;
224 vexpress)222 vexpress)
225 sudo tar --strip-components=5 -C ${DIR}/disk/ -xf $BINARY_TARBALL binary/usr/lib/u-boot/ca9x4_ct_vxp/u-boot.bin223 sudo tar --strip-components=5 -C ${DIR}/disk/ -xf $BINARY_TARBALL binary/usr/lib/u-boot/ca9x4_ct_vxp/u-boot.bin
226 sudo mkimage -A arm -O linux -T kernel -C none -a 0x60008000 -e 0x60008000 \224 sudo mkimage -A arm -O linux -T kernel -C none -a 0x60008000 -e 0x60008000 \
227 -n "Linux" -d ${DIR}/binary/${parts_dir}/vmlinuz*-vexpress ${DIR}/disk/uImage225 -n "Linux" -d ${DIR}/binary/${parts_dir}/vmlinuz*-vexpress ${DIR}/disk/uImage
228 sudo mkimage -A arm -O linux -T ramdisk -C none -a 0x81000000 \226 sudo mkimage -A arm -O linux -T ramdisk -C none -a 0x81000000 \
229 -e 0x81000000 -n "initramfs" -d \227 -e 0x81000000 -n "initramfs" -d \
230 ${DIR}/binary/${parts_dir}/initrd.img-*-linaro-vexpress \228 ${DIR}/binary/${parts_dir}/initrd.img-*-linaro-vexpress \
231 "${DIR}"/disk/uInitrd229 "${DIR}"/disk/uInitrd
232 ;;230 ;;
233 *)231 *)
234 echo "Set --dev parameter: --dev <beagle|igep|vexpress>" 1>&2232 echo "Set --dev parameter: --dev <beagle|igep|vexpress>" 1>&2
235 cleanup_workdir233 cleanup_workdir
236 exit234 exit
237 ;;235 ;;
238 esac236 esac
239237
240 cd ${DIR}/disk/238 cd ${DIR}/disk/
241 sync239 sync
242 sync240 sync
243 cd ${DIR}/241 cd ${DIR}/
244242
245 sudo umount ${DIR}/disk || true243 sudo umount ${DIR}/disk || true
246}244}
247245
248populate_rootfs() {246populate_rootfs() {
249 echo ""247 echo ""
250 echo "Populating rootfs Partition"248 echo "Populating rootfs Partition"
251 echo "Be patient, this may take a few minutes"249 echo "Be patient, this may take a few minutes"
252 echo ""250 echo ""
253 sudo mount ${MMC2} ${DIR}/disk251 sudo mount ${MMC2} ${DIR}/disk
254252
255 sudo tar -xf $BINARY_TARBALL --strip-components=1 -C disk/253 sudo tar -xf $BINARY_TARBALL --strip-components=1 -C disk/
256254
257# add fstab entry for rootfs and boot255## add fstab entry for rootfs and boot
258 echo "UUID=${RFS_UUID} / ${RFS} errors=remount-ro 0 1 " | sudo tee -a ${DIR}/disk/etc/fstab256 echo "UUID=${RFS_UUID} / ${RFS} errors=remount-ro 0 1 " | sudo tee -a ${DIR}/disk/etc/fstab
259257
260 if [ "$CREATE_SWAP" ] ; then258 if [ "$CREATE_SWAP" ] ; then
261259
262 echo ""260 echo ""
263 echo "Creating SWAP File"261 echo "Creating SWAP File"
264 echo ""262 echo ""
265263
266 SPACE_LEFT=$(df ${DIR}/disk/ | grep ${MMC2} | awk '{print $4}')264 SPACE_LEFT=$(df ${DIR}/disk/ | grep ${MMC2} | awk '{print $4}')
267265
268 let SIZE=$SWAP_SIZE*1024266 let SIZE=$SWAP_SIZE*1024
269267
270 if [ $SPACE_LEFT -ge $SIZE ] ; then268 if [ $SPACE_LEFT -ge $SIZE ] ; then
271 sudo dd if=/dev/zero of=${DIR}/disk/SWAP.swap bs=1M count=$SWAP_SIZE269 sudo dd if=/dev/zero of=${DIR}/disk/SWAP.swap bs=1M count=$SWAP_SIZE
272 sudo mkswap ${DIR}/disk/SWAP.swap270 sudo mkswap ${DIR}/disk/SWAP.swap
273 echo "/SWAP.swap none swap sw 0 0" | sudo tee -a ${DIR}/disk/etc/fstab271 echo "/SWAP.swap none swap sw 0 0" | sudo tee -a ${DIR}/disk/etc/fstab
274 else272 else
275 echo "SWAP file bigger then whats left on partition"273 echo "SWAP file bigger then whats left on partition"
274 fi
276 fi275 fi
277 fi276
278277 echo ""
279 echo ""278 echo "Creating /etc/flash-kernel.conf"
280 echo "Creating /etc/flash-kernel.conf"279 echo ""
281 echo ""280
282281 echo "UBOOT_PART=/dev/mmcblk0p1" > ${DIR}/disk/etc/flash-kernel.conf
283 echo "UBOOT_PART=/dev/mmcblk0p1" > ${DIR}/disk/etc/flash-kernel.conf282
284283 cd ${DIR}/disk/
285 cd ${DIR}/disk/284 sync
286 sync285 sync
287 sync286 cd ${DIR}/
288 cd ${DIR}/287
289288 sudo umount ${DIR}/disk || true
290 sudo umount ${DIR}/disk || true
291}289}
292290
293check_mmc() {291check_mmc() {
294 FDISK=$(sudo LC_ALL=C sfdisk -l | grep "[Disk] ${MMC}" | awk '{print $2}')292 FDISK=$(sudo LC_ALL=C sfdisk -l | grep "[Disk] ${MMC}" | awk '{print $2}')
295293
296 if test "-$FDISK-" = "-$MMC:-"294 if test "-$FDISK-" = "-$MMC:-"
297 then295 then
298 echo ""296 echo ""
299 echo "I see..."297 echo "I see..."
300 echo "sudo sfdisk -l:"298 echo "sudo sfdisk -l:"
301 sudo LC_ALL=C sfdisk -l | grep "[Disk] /dev/" --color=never299 sudo LC_ALL=C sfdisk -l | grep "[Disk] /dev/" --color=never
302 echo ""300 echo ""
303 echo "mount:"301 echo "mount:"
304 mount | grep -v none | grep "/dev/" --color=never302 mount | grep -v none | grep "/dev/" --color=never
305 echo ""303 echo ""
306 read -p "Are you 100% sure, on selecting [${MMC}] (y/n)? "304 read -p "Are you 100% sure, on selecting [${MMC}] (y/n)? "
307 [ "$REPLY" == "y" ] || exit305 [ "$REPLY" == "y" ] || exit
308 echo ""306 echo ""
309 else307 else
310 echo ""308 echo ""
311 echo "Are you sure? I Don't see [${MMC}], here is what I do see..."309 echo "Are you sure? I Don't see [${MMC}], here is what I do see..."
312 echo ""310 echo ""
313 echo "sudo sfdisk -l:"311 echo "sudo sfdisk -l:"
314 sudo LC_ALL=C sfdisk -l | grep "[Disk] /dev/" --color=never312 sudo LC_ALL=C sfdisk -l | grep "[Disk] /dev/" --color=never
315 echo ""313 echo ""
316 echo "mount:"314 echo "mount:"
317 mount | grep -v none | grep "/dev/" --color=never315 mount | grep -v none | grep "/dev/" --color=never
318 echo ""316 echo ""
319 exit317 exit
320 fi318 fi
321}319}
322320
323check_fs_type() {321check_fs_type() {
324 IN_VALID_FS=1322 IN_VALID_FS=1
325323
326 if test "-$FS_TYPE-" = "-ext2-"324 if test "-$FS_TYPE-" = "-ext2-"
327 then325 then
328 RFS=ext2326 RFS=ext2
329 unset IN_VALID_FS327 unset IN_VALID_FS
330 fi328 fi
331329
332 if test "-$FS_TYPE-" = "-ext3-"330 if test "-$FS_TYPE-" = "-ext3-"
333 then331 then
334 RFS=ext3332 RFS=ext3
335 unset IN_VALID_FS333 unset IN_VALID_FS
336 fi334 fi
337335
338 if test "-$FS_TYPE-" = "-ext4-"336 if test "-$FS_TYPE-" = "-ext4-"
339 then337 then
340 RFS=ext4338 RFS=ext4
341 unset IN_VALID_FS339 unset IN_VALID_FS
342 fi340 fi
343341
344 if test "-$FS_TYPE-" = "-btrfs-"342 if test "-$FS_TYPE-" = "-btrfs-"
345 then343 then
346 RFS=btrfs344 RFS=btrfs
347 unset IN_VALID_FS345 unset IN_VALID_FS
348 fi346 fi
349347
350 if [ "$IN_VALID_FS" ] ; then348 if [ "$IN_VALID_FS" ] ; then
351 usage349 usage
352 fi350 fi
353}351}
354352
355calculatesize() {353calculatesize() {
356 IMAGE_SIZE=${IMAGE_SIZE/G/M*1024}354 IMAGE_SIZE=${IMAGE_SIZE/G/M*1024}
357 IMAGE_SIZE=${IMAGE_SIZE/M/K*1024}355 IMAGE_SIZE=${IMAGE_SIZE/M/K*1024}
358 IMAGE_SIZE=${IMAGE_SIZE/K/*1024}356 IMAGE_SIZE=${IMAGE_SIZE/K/*1024}
359 IMAGE_SIZE=$(($IMAGE_SIZE))357 IMAGE_SIZE=$(($IMAGE_SIZE))
360}358}
361359
362setup_sizes() {360setup_sizes() {
363 HEADS=255361 HEADS=255
364 SECTORS=63362 SECTORS=63
365 SECTORSIZE=512363 SECTORSIZE=512
366 if [ "${IMAGE_FILE}" ]; then364 if [ "${IMAGE_FILE}" ]; then
367 calculatesize365 calculatesize
368 CYLINDERSIZE=$(($HEADS*$SECTORS*$SECTORSIZE))366 CYLINDERSIZE=$(($HEADS*$SECTORS*$SECTORSIZE))
369 CYLINDERS=$(($IMAGE_SIZE/$CYLINDERSIZE))367 CYLINDERS=$(($IMAGE_SIZE/$CYLINDERSIZE))
370 CYLINDER_ARG="-C $CYLINDERS"368 CYLINDER_ARG="-C $CYLINDERS"
371 IMAGE_SIZE=$(($CYLINDERS*$CYLINDERSIZE))369 IMAGE_SIZE=$(($CYLINDERS*$CYLINDERSIZE))
372 else370 else
373 CYLINDER_ARG=""371 CYLINDER_ARG=""
374 fi372 fi
375}373}
376374
377setup_image() {375setup_image() {
378 sudo qemu-img create -f raw $IMAGE_FILE $IMAGE_SIZE376 sudo qemu-img create -f raw $IMAGE_FILE $IMAGE_SIZE
379}377}
380378
381usage() {379usage() {
382 echo "usage: $(basename $0) --mmc /dev/sdd"380 echo "usage: $(basename $0) --mmc /dev/sdd"
383 echo "<or>"381 echo "<or>"
384 echo "usage: $(basename $0) --image_file mmc.img"382 echo "usage: $(basename $0) --image_file mmc.img"
385cat <<EOF383cat <<EOF
386384
387required options:385required options:
@@ -440,10 +438,10 @@
440}438}
441439
442checkparm() {440checkparm() {
443 if [ "$(echo $1|grep ^'\-')" ];then441 if [ "$(echo $1|grep ^'\-')" ];then
444 echo "E: Need an argument"442 echo "E: Need an argument"
445 usage443 usage
446 fi444 fi
447}445}
448446
449cleanup_workdir() {447cleanup_workdir() {
@@ -457,63 +455,63 @@
457455
458# parse commandline options456# parse commandline options
459while [ ! -z "$1" ]; do457while [ ! -z "$1" ]; do
460 case $1 in458 case $1 in
461 -h|--help)459 -h|--help)
462 usage460 usage
463 MMC=1461 MMC=1
464 ;;462 ;;
465 --mmc)463 --mmc)
466 checkparm $2464 checkparm $2
467 MMC="$2"465 MMC="$2"
468 check_mmc466 check_mmc
469 ;;467 ;;
470 --image_file)468 --image_file)
471 checkparm $2469 checkparm $2
472 IMAGE_FILE="$2"470 IMAGE_FILE="$2"
473 ;;471 ;;
474 --image_size)472 --image_size)
475 checkparm $2473 checkparm $2
476 IMAGE_SIZE=$2474 IMAGE_SIZE=$2
477 ;;475 ;;
478 --rootfs)476 --rootfs)
479 checkparm $2477 checkparm $2
480 FS_TYPE="$2"478 FS_TYPE="$2"
481 check_fs_type479 check_fs_type
482 ;;480 ;;
483 --boot_label)481 --boot_label)
484 checkparm $2482 checkparm $2
485 BOOT_LABEL="$2"483 BOOT_LABEL="$2"
486 ;;484 ;;
487 --rfs_label)485 --rfs_label)
488 checkparm $2486 checkparm $2
489 RFS_LABEL="$2"487 RFS_LABEL="$2"
490 ;;488 ;;
491 --swap_file)489 --swap_file)
492 checkparm $2490 checkparm $2
493 SWAP_SIZE="$2"491 SWAP_SIZE="$2"
494 CREATE_SWAP=1492 CREATE_SWAP=1
495 ;;493 ;;
496 --live)494 --live)
497 IS_LIVE=1495 IS_LIVE=1
498 ;;496 ;;
499 --live-256m)497 --live-256m)
500 IS_LIVE=1498 IS_LIVE=1
501 IS_LOWMEM=1499 IS_LOWMEM=1
502 ;;500 ;;
503 --console)501 --console)
504 checkparm $2502 checkparm $2
505 consoles="$consoles $2"503 consoles="$consoles $2"
506 ;;504 ;;
507 --dev)505 --dev)
508 checkparm $2506 checkparm $2
509 DEVIMAGE=$2507 DEVIMAGE=$2
510 ;;508 ;;
511 --binary)509 --binary)
512 checkparm $2510 checkparm $2
513 BINARY_TARBALL="$2"511 BINARY_TARBALL="$2"
514 ;;512 ;;
515 esac513 esac
516 shift514 shift
517done515done
518516
519setup_sizes517setup_sizes
@@ -559,7 +557,7 @@
559fi557fi
560558
561if [ ! "${MMC}" -a ! "${IMAGE_FILE}" ]; then559if [ ! "${MMC}" -a ! "${IMAGE_FILE}" ]; then
562 usage560 usage
563fi561fi
564562
565 prepare_sources563 prepare_sources

Subscribers

People subscribed via source and target branches