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

Unified Diff: scripts/image_signing/set_lsb_release.sh

Issue 3145008: A utility for updating /etc/lsb-release values. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git
Patch Set: address review comments Created 10 years, 4 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 | « scripts/image_signing/common.sh ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/image_signing/set_lsb_release.sh
diff --git a/scripts/image_signing/set_lsb_release.sh b/scripts/image_signing/set_lsb_release.sh
new file mode 100755
index 0000000000000000000000000000000000000000..645e9870b74354a534b85c567a129ac4b1f0980c
--- /dev/null
+++ b/scripts/image_signing/set_lsb_release.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Customizes a Chrome OS release image by setting /etc/lsb-release values.
+
+# Usage: ./set_lsb_release.sh <image.bin> [<key> <value>]
+#
+# If executed with key/value parameters, sets <key>=<value> in
+# /etc/lsb-release and then dumps /etc/lsb-release to stdout. If
+# executed with no key/value, dumps /etc/lsb-release to stdout. Note
+# that the order of the keyvals in /etc/lsb-release may not be
+# preserved.
+
+# Load common constants and variables.
+. "$(dirname "$0")/common.sh"
+
+set_lsb_release_keyval() {
+ local rootfs=$1
+ local key=$2
+ local value=$3
+ echo "Setting '$key' to '$value'..."
+ local temp_lsb_release="$rootfs/etc/temp-lsb-release"
+ echo "$key=$value" | sudo tee "$temp_lsb_release" > /dev/null
+ grep -Ev "^$key=" "$rootfs/etc/lsb-release" \
+ | sudo tee -a "$temp_lsb_release" > /dev/null
+ sudo mv -f "$temp_lsb_release" "$rootfs/etc/lsb-release"
+}
+
+main() {
+ set -e
+
+ local image=$1
+ local key=$2
+ local value=$3
+ if [ $# -ne 1 ] && [ $# -ne 3 ]; then
+ echo "Usage: $PROG <image.bin> [<key> <value>]"
+ exit 1
+ fi
+
+ local rootfs=$(mktemp -d)
+ mount_image_partition "$image" 3 "$rootfs"
+ trap "sudo umount -d $rootfs; rm -rf $rootfs" EXIT
+ if [ -n "$key" ]; then
+ set_lsb_release_keyval "$rootfs" "$key" "$value"
+ touch "$image" # Updates the image modification time.
+ fi
+ echo ===
+ cat "$rootfs/etc/lsb-release"
+ echo ===
+ echo Done.
+}
+
+main $@
« no previous file with comments | « scripts/image_signing/common.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698