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

Unified Diff: scripts/image_signing/common.sh

Issue 3772013: make_dev_ssd: new script to change SSD image to dev key (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git
Patch Set: Refine shflags dependency Created 10 years, 2 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 | scripts/image_signing/make_dev_firmware.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/image_signing/common.sh
diff --git a/scripts/image_signing/common.sh b/scripts/image_signing/common.sh
index b05ec5006fe81842a6de7c881b7120c4efed30dd..7b6dc9f327bab8242a982bda4bbbbe820be280dc 100755
--- a/scripts/image_signing/common.sh
+++ b/scripts/image_signing/common.sh
@@ -12,12 +12,20 @@ GPT=cgpt
# The tag when the rootfs is changed.
TAG_NEEDS_TO_BE_SIGNED="/root/.need_to_be_signed"
-# Load shflags
-if [ -f /usr/lib/shflags ]; then
- . /usr/lib/shflags
-else
- . "${SCRIPT_DIR}/lib/shflags/shflags"
-fi
+# Finds and loads the 'shflags' library, or return as failed.
+load_shflags() {
+ # Load shflags
+ if [ -f /usr/lib/shflags ]; then
+ . /usr/lib/shflags
+ elif [ -f "${SCRIPT_DIR}/shflags" ]; then
+ . "${SCRIPT_DIR}/shflags"
+ elif [ -f "${SCRIPT_DIR}/lib/shflags/shflags" ]; then
+ . "${SCRIPT_DIR}/lib/shflags/shflags"
+ else
+ echo "ERROR: Cannot find the required shflags library."
+ return 1
+ fi
+}
# List of Temporary files and mount points.
TEMP_FILE_LIST=$(mktemp)
@@ -46,27 +54,18 @@ tag_as_needs_to_be_resigned() {
# Determines if the target file system has the tag for resign
# Args: MOUNTDIRECTORY
-# Returns: $FLAGS_TRUE if the tag is there, otherwise $FLAGS_FALSE
+# Returns: true if the tag is there otherwise false
has_needs_to_be_resigned_tag() {
local mount_dir="$1"
- if [ -f "$mount_dir/$TAG_NEEDS_TO_BE_SIGNED" ]; then
- return ${FLAGS_TRUE}
- else
- return ${FLAGS_FALSE}
- fi
+ [ -f "$mount_dir/$TAG_NEEDS_TO_BE_SIGNED" ]
}
# Determines if the target file system is a Chrome OS root fs
# Args: MOUNTDIRECTORY
-# Returns: $FLAGS_TRUE if MOUNTDIRECTORY looks like root fs,
-# otherwise $FLAGS_FALSE
+# Returns: true if MOUNTDIRECTORY looks like root fs, otherwise false
is_rootfs_partition() {
local mount_dir="$1"
- if [ -f "$mount_dir/$(dirname "$TAG_NEEDS_TO_BE_SIGNED")" ]; then
- return ${FLAGS_TRUE}
- else
- return ${FLAGS_FALSE}
- fi
+ [ -f "$mount_dir/$(dirname "$TAG_NEEDS_TO_BE_SIGNED")" ]
}
# Mount a partition read-only from an image into a local directory
@@ -149,5 +148,18 @@ cleanup_temps_and_mounts() {
rm -rf $TEMP_DIR_LIST $TEMP_FILE_LIST
}
+# Returns true if all files in parameters exist.
+ensure_files_exist() {
+ local filename return_value=0
+ for filename in "$@"; do
+ if [ ! -f "$filename" -a ! -b "$filename" ]; then
+ echo "ERROR: Cannot find required file: $filename"
+ return_value=1
+ fi
+ done
+
+ return $return_value
+}
+
trap "cleanup_temps_and_mounts" EXIT
« no previous file with comments | « no previous file | scripts/image_signing/make_dev_firmware.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698