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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « scripts/image_signing/common.sh ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash
2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 # Customizes a Chrome OS release image by setting /etc/lsb-release values.
8
9 # Usage: ./set_lsb_release.sh <image.bin> [<key> <value>]
10 #
11 # If executed with key/value parameters, sets <key>=<value> in
12 # /etc/lsb-release and then dumps /etc/lsb-release to stdout. If
13 # executed with no key/value, dumps /etc/lsb-release to stdout. Note
14 # that the order of the keyvals in /etc/lsb-release may not be
15 # preserved.
16
17 # Load common constants and variables.
18 . "$(dirname "$0")/common.sh"
19
20 set_lsb_release_keyval() {
21 local rootfs=$1
22 local key=$2
23 local value=$3
24 echo "Setting '$key' to '$value'..."
25 local temp_lsb_release="$rootfs/etc/temp-lsb-release"
26 echo "$key=$value" | sudo tee "$temp_lsb_release" > /dev/null
27 grep -Ev "^$key=" "$rootfs/etc/lsb-release" \
28 | sudo tee -a "$temp_lsb_release" > /dev/null
29 sudo mv -f "$temp_lsb_release" "$rootfs/etc/lsb-release"
30 }
31
32 main() {
33 set -e
34
35 local image=$1
36 local key=$2
37 local value=$3
38 if [ $# -ne 1 ] && [ $# -ne 3 ]; then
39 echo "Usage: $PROG <image.bin> [<key> <value>]"
40 exit 1
41 fi
42
43 local rootfs=$(mktemp -d)
44 mount_image_partition "$image" 3 "$rootfs"
45 trap "sudo umount -d $rootfs; rm -rf $rootfs" EXIT
46 if [ -n "$key" ]; then
47 set_lsb_release_keyval "$rootfs" "$key" "$value"
48 touch "$image" # Updates the image modification time.
49 fi
50 echo ===
51 cat "$rootfs/etc/lsb-release"
52 echo ===
53 echo Done.
54 }
55
56 main $@
OLDNEW
« 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