Merge lp:~mwaddel/linaro-image-tools/split-deploy-v3 into lp:linaro-image-tools/11.11

Proposed by Matt Waddel
Status: Merged
Approved by: Loïc Minier
Approved revision: 153
Merged at revision: 153
Proposed branch: lp:~mwaddel/linaro-image-tools/split-deploy-v3
Merge into: lp:linaro-image-tools/11.11
Diff against target: 295 lines (+92/-51)
1 file modified
linaro-media-create (+92/-51)
To merge this branch: bzr merge lp:~mwaddel/linaro-image-tools/split-deploy-v3
Reviewer Review Type Date Requested Status
Loïc Minier (community) Approve
Review via email: mp+38799@code.launchpad.net

Description of the change

Added code review corrections from Loic to branch:

https://code.launchpad.net/~mwaddel/linaro-image-tools/split-deploy-v2

To post a comment you must log in.
Revision history for this message
Loïc Minier (lool) wrote :
Revision history for this message
Loïc Minier (lool) wrote :

Looks good to me, except for a typo in the comment in r153: s/devives/devices/

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-10-13 21:57:24 +0000
3+++ linaro-media-create 2010-10-19 02:49:41 +0000
4@@ -19,8 +19,8 @@
5
6 set -e
7
8-unset MMC MMC1 MMC2 MMC3 IMAGE_FILE HWPACK_FILE UBOOT_FLAVOR KERNEL_ADDR
9-unset INITRD_ADDR CREATE_SWAP SWAP_SIZE
10+unset DEVICE BOOTFS ROOTFS IMAGE_FILE HWPACK_FILE UBOOT_FLAVOR KERNEL_ADDR
11+unset INITRD_ADDR CREATE_SWAP SWAP_SIZE DEPLOY_STEPS
12
13 #Defaults
14 RFS=ext3
15@@ -31,6 +31,9 @@
16 FAT_SIZE=32
17 IMAGE_SIZE=2G
18 MMC_PART_OFFSET=0
19+BOOTFS_STEP="create_boot_cmd populate_boot"
20+ROOTFS_STEP="populate_rootfs"
21+PARTITION_STEP="create_partitions"
22
23 DIR=$PWD
24 TMP_DIR=$(mktemp -d)
25@@ -55,7 +58,7 @@
26
27 required options:
28 --mmc </dev/sdX>
29- Unformated MMC Card
30+ Unformatted Storage Device
31 <or>
32 --image_file <xxx>
33 specify name of image file
34@@ -108,14 +111,23 @@
35
36 --binary <filename>
37 specify file used to create the bootable system. Default binary-tar.tar.gz
38+
39+--no-rootfs
40+ do not deploy the root filesystem
41+
42+--no-bootfs
43+ do not deploy the boot filesystem
44+
45+--no-part
46+ reuse existing partitions on the deploy media
47 EOF
48 exit
49 }
50
51-check_mmc() {
52- FDISK=$(sudo LC_ALL=C sfdisk -l | grep "[Disk] ${MMC}" | awk '{print $2}')
53+check_device() {
54+ FDISK=$(sudo LC_ALL=C sfdisk -l | grep "[Disk] ${DEVICE}" | awk '{print $2}')
55
56- if test "-$FDISK-" = "-$MMC:-"
57+ if test "-$FDISK-" = "-$DEVICE:-"
58 then
59 echo ""
60 echo "I see..."
61@@ -125,12 +137,12 @@
62 echo "mount:"
63 LC_ALL=C mount | grep -v none | grep "/dev/" --color=never
64 echo ""
65- read -p "Are you 100% sure, on selecting [${MMC}] (y/n)? "
66+ read -p "Are you 100% sure, on selecting [${DEVICE}] (y/n)? "
67 [ "$REPLY" == "y" ] || exit
68 echo ""
69 else
70 echo ""
71- echo "Are you sure? I Don't see [${MMC}], here is what I do see..."
72+ echo "Are you sure? I Don't see [${DEVICE}], here is what I do see..."
73 echo ""
74 echo "sudo sfdisk -l:"
75 sudo LC_ALL=C sfdisk -l | grep "[Disk] /dev/" --color=never
76@@ -176,8 +188,8 @@
77 ;;
78 --mmc)
79 checkparm "$2"
80- MMC="$2"
81- check_mmc
82+ DEVICE="$2"
83+ check_device
84 ;;
85 --image_file)
86 checkparm "$2"
87@@ -224,10 +236,21 @@
88 checkparm "$2"
89 BINARY_TARBALL="$2"
90 ;;
91+ --no-rootfs)
92+ ROOTFS_STEP=""
93+ ;;
94+ --no-bootfs)
95+ BOOTFS_STEP=""
96+ ;;
97+ --no-part)
98+ PARTITION_STEP=""
99+ ;;
100 esac
101 shift
102 done
103
104+DEPLOY_STEPS="$PARTITION_STEP prepare_partitions $BOOTFS_STEP $ROOTFS_STEP"
105+
106 ensure_command mkimage uboot-mkimage
107 ensure_command uuidgen uuid-runtime
108 ensure_command parted parted
109@@ -254,13 +277,13 @@
110
111 RFS_UUID=`uuidgen -r`
112
113-get_mmcs_by_id() {
114+get_device_by_id() {
115 if [ ! "${IMAGE_FILE}" ]; then
116 for device in /dev/disk/by-id/*; do
117- if [ `realpath $device` = $MMC ]; then
118+ if [ `realpath $device` = $DEVICE ]; then
119 case "$device" in
120 *-part[0-9]*)
121- echo "device $MMC must not be a partition part ($device)" >&2
122+ echo "device $DEVICE must not be a partition part ($device)" >&2
123 exit 1
124 ;;
125 esac
126@@ -270,11 +293,9 @@
127 # echo "part $part_no found: $part_id" 1>&2
128 # if there is a non-fs-data part (e.g. mx51evk), MMC_PART_OFFSET=1
129 if test "$part_no" = $((1 + $MMC_PART_OFFSET)); then
130- MMC1=$part
131+ BOOTFS=$part
132 elif test "$part_no" = $((2 + $MMC_PART_OFFSET)) ; then
133- MMC2=$part
134- elif test "$part_no" = $((3 + $MMC_PART_OFFSET)); then
135- MMC3=$part
136+ ROOTFS=$part
137 fi
138 done
139 break
140@@ -367,22 +388,23 @@
141 echo "Umounting Partitions"
142 echo ""
143
144- if test -n "$MMC1"; then
145- sudo umount ${MMC1} &> /dev/null || true
146- fi
147- if test -n "$MMC2"; then
148- sudo umount ${MMC2} &> /dev/null || true
149- fi
150- if [ "${MMC}" ]; then
151- sudo parted -s ${MMC} mklabel msdos
152+ if test -n "$BOOTFS"; then
153+ sudo umount ${BOOTFS} &> /dev/null || true
154+ fi
155+ if test -n "$ROOTFS"; then
156+ sudo umount ${ROOTFS} &> /dev/null || true
157 fi
158 }
159
160 create_partitions() {
161+ if [ "${DEVICE}" ]; then
162+ sudo parted -s ${DEVICE} mklabel msdos
163+ fi
164+
165 if [ "${IMAGE_FILE}" ]; then
166 partdev=${IMAGE_FILE}
167 else
168- partdev=${MMC}
169+ partdev=${DEVICE}
170 fi
171
172 if [ "$FAT_SIZE" = "32" ]; then
173@@ -419,23 +441,43 @@
174 ROOTSIZE2=$(($(LC_ALL=C fdisk -l -u "$IMAGE_FILE" | grep Linux | awk '{print $3}')))
175 ROOTSIZE1=$(($(LC_ALL=C fdisk -l -u "$IMAGE_FILE" | grep Linux | awk '{print $2}')))
176 ROOTSIZE=$((((ROOTSIZE2+1-ROOTSIZE1)/2)*1024))
177- MMC1=$(sudo losetup -f --show "$IMAGE_FILE" --offset $VFATOFFSET --sizelimit $VFATSIZE)
178- MMC2=$(sudo losetup -f --show "$IMAGE_FILE" --offset $ROOTOFFSET --sizelimit $ROOTSIZE)
179+ BOOTFS=$(sudo losetup -f --show "$IMAGE_FILE" --offset $VFATOFFSET --sizelimit $VFATSIZE)
180+ ROOTFS=$(sudo losetup -f --show "$IMAGE_FILE" --offset $ROOTOFFSET --sizelimit $ROOTSIZE)
181 fi
182 }
183
184
185 prepare_partitions() {
186+
187+echo -n "waiting for partitioning to settle ..."
188+sync
189+sleep 3
190+echo "done."
191+get_device_by_id
192+
193+if [ "$BOOTFS_STEP" ]; then
194 echo ""
195 echo "Formating Boot Partition"
196 echo ""
197-
198- sudo mkfs.vfat -F ${FAT_SIZE} ${MMC1} -n ${BOOT_LABEL}
199-
200+ if [ -z "$BOOTFS" ]; then
201+ echo "Partition $BOOTFS does not exist"
202+ exit 2
203+ else
204+ sudo mkfs.vfat -F ${FAT_SIZE} ${BOOTFS} -n ${BOOT_LABEL}
205+ fi
206+fi
207+
208+if [ "$ROOTFS_STEP" ]; then
209 echo ""
210 echo "Formating ${RFS} Partition"
211 echo ""
212- sudo mkfs.${RFS} -U "$RFS_UUID" ${MMC2} -L ${RFS_LABEL}
213+ if [ -z "$ROOTFS" ]; then
214+ echo "Partition $ROOTFS does not exist"
215+ exit 2
216+ else
217+ sudo mkfs.${RFS} -U "$RFS_UUID" ${ROOTFS} -L ${RFS_LABEL}
218+ fi
219+fi
220 }
221
222 populate_boot() {
223@@ -454,7 +496,7 @@
224 fi
225
226 mkdir -p "${BOOT_DISK}"
227- sudo mount ${MMC1} "${BOOT_DISK}"
228+ sudo mount ${BOOTFS} "${BOOT_DISK}"
229
230 if [ -n "$UBOOT_FLAVOR" ]; then
231 sudo cp -v "binary/usr/lib/u-boot/${UBOOT_FLAVOR}/u-boot.bin" \
232@@ -526,7 +568,7 @@
233 echo "Be patient, this may take a few minutes"
234 echo ""
235 mkdir -p "${ROOT_DISK}"
236- sudo mount ${MMC2} "${ROOT_DISK}"
237+ sudo mount ${ROOTFS} "${ROOT_DISK}"
238
239 sudo mv ${DIR}/binary/* "$ROOT_DISK"
240
241@@ -539,7 +581,7 @@
242 echo "Creating SWAP File"
243 echo ""
244
245- SPACE_LEFT=$(LC_ALL=C df "${ROOT_DISK}" | grep ${MMC2} | awk '{print $4}')
246+ SPACE_LEFT=$(LC_ALL=C df "${ROOT_DISK}" | grep ${ROOTFS} | awk '{print $4}')
247
248 let SIZE=$SWAP_SIZE*1024
249
250@@ -675,31 +717,30 @@
251 TARGET_BOOT_DEV=/dev/mmcblk0p$(( 1 + $MMC_PART_OFFSET ))
252 TARGET_ROOT_DEV=/dev/mmcblk0p$(( 2 + $MMC_PART_OFFSET ))
253
254-if [ ! "${MMC}" -a ! "${IMAGE_FILE}" ]; then
255+if [ ! "${DEVICE}" -a ! "${IMAGE_FILE}" ]; then
256 usage
257 fi
258
259+# The bootfs and rootfs deploy options are only available with physical
260+# devives. These options are intended for deploying to different devices like
261+# a USB drive and an MMC device. The options do not apply to qemu image_files.
262+if [ "${IMAGE_FILE}" ]; then
263+ if [ -z "${ROOTFS_STEP}" ] || [ -z "${BOOTFS_STEP}" ]; then
264+ echo "Do not use --no-rootfs or --no-bootfs with the --image_file option"
265+ exit
266+ fi
267+fi
268+
269 unpack_binary_tarball
270 if [ "$HWPACK_FILE" ]; then
271 install_hwpack
272 else
273 echo "Warning, --hwpack <filename> was not specified, the result is unlikely to be functional without manual effort to setup uImage, MLO, u-boot.bin and so as as appropriate for your hardware."
274 fi
275-create_boot_cmd
276-get_mmcs_by_id
277+get_device_by_id
278 cleanup_sd
279-create_partitions
280-echo -n "waiting for partitioning to settle ..."
281-sync
282-sleep 3
283-echo "done."
284-get_mmcs_by_id
285-if test -z "$MMC1" -o -z "$MMC2"; then
286- echo "MMC1: $MMC1 nor MMC2: $MMC2 must be empty"
287- exit 2
288-fi
289-prepare_partitions
290-populate_boot
291-populate_rootfs
292+for func in $DEPLOY_STEPS; do
293+ $func
294+done
295 remove_binary_dir
296

Subscribers

People subscribed via source and target branches