summaryrefslogtreecommitdiff
path: root/scripts/image_signing/set_lsb_release.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/image_signing/set_lsb_release.sh')
-rwxr-xr-xscripts/image_signing/set_lsb_release.sh34
1 files changed, 22 insertions, 12 deletions
diff --git a/scripts/image_signing/set_lsb_release.sh b/scripts/image_signing/set_lsb_release.sh
index 5d859d81..9d0addd0 100755
--- a/scripts/image_signing/set_lsb_release.sh
+++ b/scripts/image_signing/set_lsb_release.sh
@@ -24,12 +24,9 @@ set_lsb_release_keyval() {
main() {
set -e
- local image=$1
- local key=$2
- local value=$3
- if [ $# -ne 1 ] && [ $# -ne 3 ]; then
+ if [[ $(( $# % 2 )) -eq 0 ]]; then
cat <<EOF
-Usage: $PROG <image.bin> [<key> <value>]
+Usage: $PROG <image.bin> [<key> <value> [<key> <value> ...]]
Examples:
@@ -47,15 +44,28 @@ EOF
exit 1
fi
+ local image=$1
+ shift
local rootfs=$(make_temp_dir)
- mount_image_partition_ro "$image" 3 "$rootfs"
- if [ -n "$key" ]; then
- sudo umount "$rootfs"
- mount_image_partition "$image" 3 "$rootfs"
- set_lsb_release_keyval "$rootfs" "$key" "$value"
- touch "$image" # Updates the image modification time.
+
+ # If there are no key/value pairs to process, we don't need write access.
+ if [[ $# -eq 0 ]]; then
+ mount_image_partition_ro "${image}" 3 "${rootfs}"
+ else
+ mount_image_partition "${image}" 3 "${rootfs}"
+ touch "${image}" # Updates the image modification time.
fi
- cat "$rootfs/etc/lsb-release"
+
+ # Process all the key/value pairs.
+ local key value
+ while [[ $# -ne 0 ]]; do
+ key=$1 value=$2
+ shift 2
+ set_lsb_release_keyval "${rootfs}" "${key}" "${value}"
+ done
+
+ # Dump the final state.
+ cat "${rootfs}/etc/lsb-release"
}
main "$@"