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

Unified Diff: src/scripts/build_image

Issue 1794007: Harden build_image to not lose loopback devices. (Closed) Base URL: ssh://git@chromiumos-git//chromeos
Patch Set: Small fix Created 10 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scripts/build_image
diff --git a/src/scripts/build_image b/src/scripts/build_image
index e6fcdd364f01adc011d49b6efdf0a6d7648e3ac1..9f08f73fd10082b8a2c7796bca3ee73f45780ee3 100755
--- a/src/scripts/build_image
+++ b/src/scripts/build_image
@@ -115,23 +115,17 @@ fi
mkdir -p "$OUTPUT_DIR"
cleanup_rootfs_loop() {
- sudo umount "$LOOP_DEV"
- sleep 1 # in case $LOOP_DEV is in use.
- sudo losetup -d "$LOOP_DEV"
+ sudo umount -d "$ROOT_FS_DIR"
}
cleanup_stateful_fs_loop() {
sudo umount "${ROOT_FS_DIR}/usr/local"
sudo umount "${ROOT_FS_DIR}/var"
- sudo umount "${STATEFUL_DIR}"
- sleep 1 # follows from cleanup_root_fs_loop.
- sudo losetup -d "$STATEFUL_LOOP_DEV"
+ sudo umount -d "${STATEFUL_DIR}"
}
cleanup_esp_loop() {
- sudo umount "$ESP_DIR"
- sleep 1
- sudo losetup -d "$ESP_LOOP_DEV"
+ sudo umount -d "$ESP_DIR"
}
cleanup() {
@@ -154,6 +148,20 @@ cleanup() {
set -e
}
+delete_prompt() {
+ echo "An error occurred in your build so your latest output directory" \
+ "is invalid."
+ read -p "Would you like to delete the output directory (y/N)? " SURE
+ SURE="${SURE:0:1}" # Get just the first character
+ if [ "${SURE}" == "y" ] ; then
+ sudo rm -rf "$OUTPUT_DIR"
+ echo "Deleted $OUTPUT_DIR"
+ else
+ echo "Not deleting $OUTPUT_DIR. Note dev server updates will not work" \
+ "until you successfully build another image or delete this directory"
+ fi
+}
+
# ${DEV_IMAGE_ROOT} specifies the location of where developer packages will
# be installed on the stateful dir. On a Chromium OS system, this will
# translate to /usr/local
@@ -187,7 +195,7 @@ setup_symlinks_on_root() {
sudo ln -s "${2}" "${DEV_IMAGE_ROOT}/var"
}
-trap cleanup EXIT
+trap "cleanup && delete_prompt" EXIT
mkdir -p "$ROOT_FS_DIR"
@@ -428,6 +436,8 @@ setup_symlinks_on_root "/usr/local" "/var"
# Cleanup loop devices.
cleanup
+trap delete_prompt EXIT
+
# Create the GPT-formatted image
${SCRIPTS_DIR}/build_gpt.sh \
--arch=${ARCH} --board=${FLAGS_board} "${OUTPUT_DIR}" "${OUTPUT_IMG}"
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698