Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Unified Diff: src/scripts/image_to_vmware.sh

Issue 1512001: test-fixet: Automated VMWare test of AutoUpdate (Closed)
Patch Set: fixes for review Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/platform/memento_softwareupdate/autoupdated_vm_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scripts/image_to_vmware.sh
diff --git a/src/scripts/image_to_vmware.sh b/src/scripts/image_to_vmware.sh
index d54e60d5221e44948fec5e80909e4fcd889a944b..2ea5df4f94d52ce6de7cb5b672d12e645e0ec1fb 100755
--- a/src/scripts/image_to_vmware.sh
+++ b/src/scripts/image_to_vmware.sh
@@ -29,6 +29,8 @@ DEFINE_string from "$DEFAULT_FROM" \
"Directory containing rootfs.image and mbr.image"
DEFINE_string to "$DEFAULT_TO" \
"Destination folder for VM output file(s)"
+DEFINE_string state_image "" \
+ "Stateful partition image (defaults to creating new statful partition)"
DEFINE_string format "vmware" \
"Output format, either vmware or virtualbox"
@@ -60,40 +62,46 @@ fi
FLAGS_from=`eval readlink -f $FLAGS_from`
FLAGS_to=`eval readlink -f $FLAGS_to`
-# Make sure we have the gpt tool
-if [ -z "$GPT" ]; then
- echo Unable to find gpt
- exit 1
-fi
-
-# Fix bootloader config.
-TEMP_IMG=$(mktemp)
-TEMP_MNT=$(mktemp -d)
+# Split apart the partitions and make some new ones
+TEMP_DIR=$(mktemp -d)
+(cd "$TEMP_DIR" &&
+ "${FLAGS_from}/unpack_partitions.sh" "${FLAGS_from}/chromiumos_image.bin")
-LOOP_DEV=$(sudo losetup -f)
-if [ -z "$LOOP_DEV" ]; then
- echo "No free loop device"
- exit 1
+# Fix the kernel command line
+TEMP_ROOTFS="$TEMP_DIR"/part_3
+TEMP_STATE="$TEMP_DIR"/part_1
+if [ -n "${FLAGS_state_image}" ]; then
+ TEMP_STATE="${FLAGS_state_image}"
fi
+TEMP_KERN="$TEMP_DIR"/part_2
+TEMP_PMBR="$TEMP_DIR"/pmbr
+dd if="${FLAGS_from}/chromiumos_image.bin" of="$TEMP_PMBR" bs=512 count=1
-# Get rootfs offset
-OFFSET=$(( $(partoffset "${FLAGS_from}/chromiumos_image.bin" 3) * 512 )) # bytes
-
-echo Copying to temp file
-cp "${FLAGS_from}/chromiumos_image.bin" "$TEMP_IMG"
-
+TEMP_MNT=$(mktemp -d)
cleanup() {
- sudo umount "$TEMP_MNT" || true
- sudo losetup -d "$LOOP_DEV"
+ sudo umount -d "$TEMP_MNT"
+ rmdir "$TEMP_MNT"
}
trap cleanup INT TERM EXIT
-sudo losetup -o $OFFSET "$LOOP_DEV" "$TEMP_IMG"
mkdir -p "$TEMP_MNT"
-sudo mount "$LOOP_DEV" "$TEMP_MNT"
+sudo mount -o loop "$TEMP_ROOTFS" "$TEMP_MNT"
sudo "$TEMP_MNT"/postinst /dev/sda3
trap - INT TERM EXIT
cleanup
-rmdir "$TEMP_MNT"
+
+# Make 3 GiB output image
+TEMP_IMG=$(mktemp)
+# TOOD(adlr): pick a size that will for sure accomodate the partitions
+sudo dd if=/dev/zero of="${TEMP_IMG}" bs=1 count=1 \
+ seek=$((3 * 1024 * 1024 * 1024 - 1))
+
+# Set up the partition table
+install_gpt "$TEMP_IMG" "$TEMP_ROOTFS" "$TEMP_KERN" "$TEMP_STATE" \
+ "$TEMP_PMBR" true
+# Copy into the partition parts of the file
+dd if="$TEMP_ROOTFS" of="$TEMP_IMG" conv=notrunc bs=512 seek="$START_ROOTFS_A"
+dd if="$TEMP_STATE" of="$TEMP_IMG" conv=notrunc bs=512 seek="$START_STATEFUL"
+dd if="$TEMP_KERN" of="$TEMP_IMG" conv=notrunc bs=512 seek="$START_KERN_A"
echo Creating final image
# Convert image to output format
@@ -109,7 +117,10 @@ else
exit 1
fi
-rm -f "$TEMP_IMG" "${VBOX_TEMP_IMAGE}"
+rm -rf "$TEMP_DIR" "${VBOX_TEMP_IMAGE}" "$TEMP_IMG"
+if [ -z "$FLAGS_state_image" ]; then
+ rm -f "$STATE_IMAGE"
+fi
echo "Created image ${FLAGS_to}"
« no previous file with comments | « src/platform/memento_softwareupdate/autoupdated_vm_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698