summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2015-04-22 18:52:02 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-04-23 02:36:26 +0000
commita0185aecc9e7eec34969aa5c59f4af70d05f8071 (patch)
tree31f1370418ed88ded645a58bece32a6bfb3a3302
parent710485a5710215da2e0d4cd4d45c5843e360f0e7 (diff)
downloadvboot-a0185aecc9e7eec34969aa5c59f4af70d05f8071.tar.gz
make_dev_ssd: Add '--edit_config' to support in-place editing.
The '--save_config' and '--set_config' are found to be very useful for developers but it's sometimes inconvenient that developer must specify a temporary path and to know the implicit rules of how the files are generated. Since most people just want to do in-place editing, we can add a --edit_config so developers can simply invoke "make_dev_ssd --edit_config --partitions 2" to start changing kernel command line without worrying about where to store the temporary files. BRANCH=none BUG=none TEST=./make_dev_ssd.sh --edit_config --partition 2 Change-Id: Ib8f19115df31f3f250b4378201d0f7ea562fec15 Reviewed-on: https://chromium-review.googlesource.com/266814 Tested-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org>
-rwxr-xr-xscripts/image_signing/make_dev_ssd.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/image_signing/make_dev_ssd.sh b/scripts/image_signing/make_dev_ssd.sh
index df8ad469..28d42a69 100755
--- a/scripts/image_signing/make_dev_ssd.sh
+++ b/scripts/image_signing/make_dev_ssd.sh
@@ -35,6 +35,8 @@ DEFINE_string save_config "" \
"Base filename to store kernel configs to, instead of resigning." ""
DEFINE_string set_config "" \
"Base filename to load kernel configs from" ""
+DEFINE_boolean edit_config "${FLAGS_FALSE}" \
+ "Edit kernel config in-place." ""
DEFINE_string partitions "" \
"List of partitions to examine (default: $DEFAULT_PARTITIONS)" ""
DEFINE_boolean recovery_key "$FLAGS_FALSE" \
@@ -192,6 +194,33 @@ resign_ssd_kernel() {
echo "$name: Replaced config from $new_config_file"
fi
+ if [ "${FLAGS_edit_config}" = ${FLAGS_TRUE} ]; then
+ debug_msg "Editing kernel config file."
+ local new_config_file="$(make_temp_file)"
+ echo "${kernel_config}" >"${new_config_file}"
+ local old_md5sum="$(md5sum "${new_config_file}")"
+ local editor="${VISUAL:-${EDITOR:-vi}}"
+ echo "${name}: Editing kernel config:"
+ # On ChromiumOS, some builds may come with broken EDITOR that refers to
+ # nano so we want to check again if the editor really exists.
+ if type "${editor}" >/dev/null 2>&1; then
+ "${editor}" "${new_config_file}"
+ else
+ # This script runs under dash but we want readline in bash to support
+ # editing in in console.
+ bash -c "read -e -i '${kernel_config}' &&
+ echo \"\${REPLY}\" >${new_config_file}" ||
+ err_die "Failed to run editor. Please specify editor name by VISUAL."
+ fi
+ kernel_config="$(cat "${new_config_file}")"
+ if [ "$(md5sum "${new_config_file}")" = "${old_md5sum}" ]; then
+ echo "${name}: Config not changed."
+ else
+ debug_msg "New kernel config: ${kernel_config})"
+ echo "${name}: Config updated"
+ fi
+ fi
+
if [ ${FLAGS_remove_rootfs_verification} = $FLAGS_FALSE ]; then
debug_msg "Bypassing rootfs verification check"
else