| 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 to manipulate the tag files in the output of build_image | 7 # Script to manipulate the tag files in the output of build_image |
| 8 | 8 |
| 9 # Load common constants. This should be the first executable line. | 9 # Load common constants. This should be the first executable line. |
| 10 # The path to common.sh should be relative to your script's location. | 10 # The path to common.sh should be relative to your script's location. |
| 11 . "$(dirname "$0")/common.sh" | 11 . "$(dirname "$0")/common.sh" |
| 12 | 12 |
| 13 DEFINE_string from "chromiumos_image.bin" \ | 13 DEFINE_string from "chromiumos_image.bin" \ |
| 14 "Input file name of Chrome OS image to tag/stamp." | 14 "Input file name of Chrome OS image to tag/stamp." |
| 15 DEFINE_string dev_mode "" \ |
| 16 "(build-info) Tag as a developer mode build (1 to enable, 0 to disable)" |
| 15 DEFINE_string update_firmware "" \ | 17 DEFINE_string update_firmware "" \ |
| 16 "Tag to force updating firmware (1 to enable, 0 to disable)" | 18 "(auto-update) Force updating firmware (1 to enable, 0 to disable)" |
| 17 DEFINE_string dev_mode "" \ | 19 DEFINE_string forget_usernames "" \ |
| 18 "Tag for developer mode (1 to enable, 0 to disable)" | 20 "(session-manager) Forget usernames (1 to enable, 0 to disable)" |
| 21 DEFINE_string leave_core "" \ |
| 22 "(crash-reporter) Leave core dumps (1 to enable, 0 to disable)" |
| 23 |
| 24 # TODO(hungte) we can add factory_installer and factory_test, |
| 25 # but I don't see any reason to tweak/check these values. |
| 19 | 26 |
| 20 # Parse command line | 27 # Parse command line |
| 21 FLAGS "$@" || exit 1 | 28 FLAGS "$@" || exit 1 |
| 22 eval set -- "${FLAGS_ARGV}" | 29 eval set -- "${FLAGS_ARGV}" |
| 23 | 30 |
| 24 # Abort on error | 31 # Abort on error |
| 25 set -e | 32 set -e |
| 26 | 33 |
| 27 if [ -z ${FLAGS_from} ] || [ ! -f ${FLAGS_from} ] ; then | 34 if [ -z "${FLAGS_from}" ] || [ ! -s "${FLAGS_from}" ] ; then |
| 28 echo "Error: invalid flag --from" | 35 echo "Error: need a valid file by --from" |
| 29 exit 1 | 36 exit 1 |
| 30 fi | 37 fi |
| 31 | 38 |
| 32 # Global variable to track if image is modified. | 39 # Global variable to track if image is modified. |
| 33 g_modified=${FLAGS_FALSE} | 40 g_modified=${FLAGS_FALSE} |
| 34 | 41 |
| 35 # Processes (enable, disable, or simply report) a tag file. | 42 # Processes (enable, disable, or simply report) a tag file. |
| 36 # Args: DO_MODIFICATION NAME ROOT TAG_FILE ACTION | 43 # Args: DO_MODIFICATION NAME ROOT TAG_FILE ACTION |
| 37 # | 44 # |
| 38 # When DO_MODIFICATION=${FLAGS_TRUE}, | 45 # When DO_MODIFICATION=${FLAGS_TRUE}, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 112 |
| 106 # Iterates all tags to a given partition root. | 113 # Iterates all tags to a given partition root. |
| 107 # Args: ROOTFS DO_MODIFICATION | 114 # Args: ROOTFS DO_MODIFICATION |
| 108 # | 115 # |
| 109 # Check process_tag for the meaning of parameters. | 116 # Check process_tag for the meaning of parameters. |
| 110 process_all_tags() { | 117 process_all_tags() { |
| 111 local rootfs="$1" | 118 local rootfs="$1" |
| 112 local do_modification="$2" | 119 local do_modification="$2" |
| 113 | 120 |
| 114 process_tag "${do_modification}" \ | 121 process_tag "${do_modification}" \ |
| 115 "Update Firmware" \ | 122 "(build-info) dev_mode" \ |
| 123 "${rootfs}" \ |
| 124 /root/.dev_mode \ |
| 125 "${FLAGS_dev_mode}" |
| 126 |
| 127 process_tag "${do_modification}" \ |
| 128 "(auto-update) update_firmware" \ |
| 116 "${rootfs}" \ | 129 "${rootfs}" \ |
| 117 /root/.force_update_firmware \ | 130 /root/.force_update_firmware \ |
| 118 "${FLAGS_update_firmware}" | 131 "${FLAGS_update_firmware}" |
| 119 | 132 |
| 120 process_tag "${do_modification}" \ | 133 process_tag "${do_modification}" \ |
| 121 "Developer Mode" \ | 134 "(session-manager) forget_usernames" \ |
| 122 "${rootfs}" \ | 135 "${rootfs}" \ |
| 123 /root/.dev_mode \ | 136 /root/.forget_usernames \ |
| 124 "${FLAGS_dev_mode}" | 137 "${FLAGS_forget_usernames}" |
| 138 |
| 139 process_tag "${do_modification}" \ |
| 140 "(crash-reporter) leave_core" \ |
| 141 "${rootfs}" \ |
| 142 /root/.leave_core \ |
| 143 "${FLAGS_leave_core}" |
| 125 } | 144 } |
| 126 | 145 |
| 127 IMAGE=$(readlink -f "${FLAGS_from}") | 146 IMAGE=$(readlink -f "${FLAGS_from}") |
| 128 if [[ -z "${IMAGE}" || ! -f "${IMAGE}" ]]; then | 147 if [[ -z "${IMAGE}" || ! -f "${IMAGE}" ]]; then |
| 129 echo "Missing required argument: --from (image to update)" | 148 echo "Missing required argument: --from (image to update)" |
| 130 usage | 149 usage |
| 131 exit 1 | 150 exit 1 |
| 132 fi | 151 fi |
| 133 | 152 |
| 134 # First round, mount as read-only and check if we read any modification. | 153 # First round, mount as read-only and check if we read any modification. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 149 # Second round, apply the modification to image. | 168 # Second round, apply the modification to image. |
| 150 process_all_tags "${rootfs}" ${FLAGS_TRUE} | 169 process_all_tags "${rootfs}" ${FLAGS_TRUE} |
| 151 | 170 |
| 152 # this is supposed to be automatically done in mount_image_partition, | 171 # this is supposed to be automatically done in mount_image_partition, |
| 153 # but it's no harm to explicitly make it again here. | 172 # but it's no harm to explicitly make it again here. |
| 154 tag_as_needs_to_be_resigned "${rootfs}" | 173 tag_as_needs_to_be_resigned "${rootfs}" |
| 155 echo "IMAGE IS MODIFIED. PLEASE REMEMBER TO RESIGN YOUR IMAGE." | 174 echo "IMAGE IS MODIFIED. PLEASE REMEMBER TO RESIGN YOUR IMAGE." |
| 156 else | 175 else |
| 157 echo "Image is not modified." | 176 echo "Image is not modified." |
| 158 fi | 177 fi |
| OLD | NEW |