OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # | 2 # |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 # | 6 # |
7 # Script which ensures that a given image has an up-to-date | 7 # Script which ensures that a given image has an up-to-date |
8 # kernel partition, rootfs integrity hashes, and legacy bootloader configs. | 8 # kernel partition, rootfs integrity hashes, and legacy bootloader configs. |
9 | 9 |
10 # Load common constants. This should be the first executable line. | 10 # Load common constants. This should be the first executable line. |
11 # The path to common.sh should be relative to your script's location. | 11 # The path to common.sh should be relative to your script's location. |
12 COMMON_PATH="$(dirname "$0")/../common.sh" | 12 COMMON_PATH="$(dirname "$0")/../common.sh" |
13 if [ ! -r "${COMMON_PATH}" ]; then | 13 if [ ! -r "${COMMON_PATH}" ]; then |
14 echo "ERROR! Cannot find common.sh: ${COMMON_PATH}" 1>&2 | 14 echo "ERROR! Cannot find common.sh: ${COMMON_PATH}" 1>&2 |
15 exit 1 | 15 exit 1 |
16 fi | 16 fi |
17 . "$(dirname "$0")/../common.sh" | 17 . "$(dirname "$0")/../common.sh" |
18 | 18 |
19 set -e | 19 set -e |
20 . "$(dirname "$0")/../chromeos-common.sh" # for partoffset and partsize | 20 . "$(dirname "$0")/../chromeos-common.sh" # for partoffset and partsize |
21 | 21 |
| 22 if [ $# -lt 2 ]; then |
| 23 echo "Usage: ${0} /PATH/TO/IMAGE IMAGE.BIN [shflags overrides]" |
| 24 exit 1 |
| 25 fi |
| 26 |
22 BOOT_DESC_FILE="${1}/boot.desc" | 27 BOOT_DESC_FILE="${1}/boot.desc" |
23 IMAGE="${1}/${2}" | 28 IMAGE="${1}/${2}" |
| 29 shift |
| 30 shift |
| 31 FLAG_OVERRIDES="${@}" |
24 | 32 |
25 if [ ! -r "${BOOT_DESC_FILE}" ]; then | 33 if [ ! -r "${BOOT_DESC_FILE}" ]; then |
26 warning "${BOOT_DESC_FILE} cannot be read!" | 34 warn "${BOOT_DESC_FILE} cannot be read!" |
27 warning "Falling back to command line parsing" | 35 warn "Falling back to command line parsing" |
28 BOOT_DESC="${@}" | 36 BOOT_DESC="${@}" |
29 else | 37 else |
30 BOOT_DESC="$(cat ${BOOT_DESC_FILE} | tr -s '\n' ' ')" | 38 BOOT_DESC="$(cat ${BOOT_DESC_FILE} | tr -s '\n' ' ')" |
31 info "Boot-time configuration for $(dirname ${IMAGE}): " | 39 info "Boot-time configuration for $(dirname ${IMAGE}): " |
32 cat ${BOOT_DESC_FILE} | while read line; do | 40 cat ${BOOT_DESC_FILE} | while read line; do |
33 info " ${line}" | 41 info " ${line}" |
34 done | 42 done |
35 fi | 43 fi |
36 | 44 |
37 if [ ! -r "${IMAGE}" ]; then | 45 if [ ! -r "${IMAGE}" ]; then |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 DEFINE_string rootfs_mountpoint "/tmp/rootfs" \ | 93 DEFINE_string rootfs_mountpoint "/tmp/rootfs" \ |
86 "Path where the rootfs can be safely mounted" | 94 "Path where the rootfs can be safely mounted" |
87 DEFINE_string statefulfs_mountpoint "/tmp/statefulfs" \ | 95 DEFINE_string statefulfs_mountpoint "/tmp/statefulfs" \ |
88 "Path where the statefulfs can be safely mounted" | 96 "Path where the statefulfs can be safely mounted" |
89 DEFINE_string espfs_mountpoint "/tmp/espfs" \ | 97 DEFINE_string espfs_mountpoint "/tmp/espfs" \ |
90 "Path where the espfs can be safely mounted" | 98 "Path where the espfs can be safely mounted" |
91 | 99 |
92 DEFINE_boolean use_dev_keys ${FLAGS_FALSE} \ | 100 DEFINE_boolean use_dev_keys ${FLAGS_FALSE} \ |
93 "Use developer keys for signing. (Default: false)" | 101 "Use developer keys for signing. (Default: false)" |
94 | 102 |
95 # Parse command-line flags present after positional args, if any. This needs | 103 # Parse the boot.desc and any overrides |
96 # to happen before we parse boot.desc (otherwise the flags would be lost) | 104 eval set -- "${BOOT_DESC} ${FLAG_OVERRIDES}" |
97 FLAGS "${@}" || exit 1 | |
98 | |
99 # Parse the boot.desc | |
100 eval set -- "${BOOT_DESC}" | |
101 FLAGS "${@}" || exit 1 | 105 FLAGS "${@}" || exit 1 |
102 | 106 |
103 # Only now can we die on error. shflags functions leak non-zero error codes, | 107 # Only now can we die on error. shflags functions leak non-zero error codes, |
104 # so will die prematurely if 'set -e' is specified before now. | 108 # so will die prematurely if 'set -e' is specified before now. |
105 set -e -u | 109 set -e -u |
106 | 110 |
107 # $1 - Directory where developer rootfs is mounted. | 111 # $1 - Directory where developer rootfs is mounted. |
108 # $2 - Directory where developer stateful_partition is mounted. | 112 # $2 - Directory where developer stateful_partition is mounted. |
109 # $3 - Directory where the ESP partition is mounted. | 113 # $3 - Directory where the ESP partition is mounted. |
110 mount_gpt_cleanup() { | 114 mount_gpt_cleanup() { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 mkdir -p ${FLAGS_statefulfs_mountpoint} | 252 mkdir -p ${FLAGS_statefulfs_mountpoint} |
249 mkdir -p ${FLAGS_espfs_mountpoint} | 253 mkdir -p ${FLAGS_espfs_mountpoint} |
250 | 254 |
251 make_image_bootable ${IMAGE} | 255 make_image_bootable ${IMAGE} |
252 | 256 |
253 if [ ${FLAGS_cleanup_dirs} -eq ${FLAGS_TRUE} ]; then | 257 if [ ${FLAGS_cleanup_dirs} -eq ${FLAGS_TRUE} ]; then |
254 rmdir ${FLAGS_rootfs_mountpoint} | 258 rmdir ${FLAGS_rootfs_mountpoint} |
255 rmdir ${FLAGS_statefulfs_mountpoint} | 259 rmdir ${FLAGS_statefulfs_mountpoint} |
256 rmdir ${FLAGS_espfs_mountpoint} | 260 rmdir ${FLAGS_espfs_mountpoint} |
257 fi | 261 fi |
OLD | NEW |