image_signing: make_dev_ssd.sh: convert to info/error helpers

This makes the output easier to follow when multiple scripts are being run.

BRANCH=None
BUG=chromium:714598
TEST=signing images still works

Change-Id: I96e20f38b6a51ad4dc8064fa3fb3d4302c47888f
Reviewed-on: https://chromium-review.googlesource.com/497302
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: David Riley <davidriley@chromium.org>
This commit is contained in:
Mike Frysinger
2017-05-07 02:17:02 -04:00
committed by chrome-bot
parent 3a6d6f886e
commit eb7c7632fe

View File

@@ -122,7 +122,7 @@ find_valid_kernel_partitions() {
local name="$(cros_kernel_name $part_id)" local name="$(cros_kernel_name $part_id)"
local kernel_part="$(make_partition_dev "$FLAGS_image" "$part_id")" local kernel_part="$(make_partition_dev "$FLAGS_image" "$part_id")"
if [ -z "$(dump_kernel_config "$kernel_part" 2>"$EXEC_LOG")" ]; then if [ -z "$(dump_kernel_config "$kernel_part" 2>"$EXEC_LOG")" ]; then
echo "INFO: $name: no kernel boot information, ignored." >&2 info "${name}: no kernel boot information, ignored." >&2
else else
[ -z "$valid_partitions" ] && [ -z "$valid_partitions" ] &&
valid_partitions="$part_id" || valid_partitions="$part_id" ||
@@ -158,11 +158,11 @@ resign_ssd_kernel() {
size="$(partsize "$ssd_device" "$kernel_index")" || size="$(partsize "$ssd_device" "$kernel_index")" ||
err_die "Failed to get partition $kernel_index size from $ssd_device" err_die "Failed to get partition $kernel_index size from $ssd_device"
if [ ! $size -gt $min_kernel_size ]; then if [ ! $size -gt $min_kernel_size ]; then
echo "INFO: $name seems too small ($size), ignored." info "${name} seems too small (${size}), ignored."
continue continue
fi fi
if [ ! $size -le $max_kernel_size ]; then if [ ! $size -le $max_kernel_size ]; then
echo "INFO: $name seems too large ($size), ignored." info "${name} seems too large (${size}), ignored."
continue continue
fi fi
@@ -173,7 +173,7 @@ resign_ssd_kernel() {
local kernel_config local kernel_config
if ! kernel_config="$(dump_kernel_config "$old_blob" 2>"$EXEC_LOG")"; then if ! kernel_config="$(dump_kernel_config "$old_blob" 2>"$EXEC_LOG")"; then
debug_msg "dump_kernel_config error message: $(cat "$EXEC_LOG")" debug_msg "dump_kernel_config error message: $(cat "$EXEC_LOG")"
echo "INFO: $name: no kernel boot information, ignored." info "${name}: no kernel boot information, ignored."
continue continue
fi fi
@@ -181,7 +181,7 @@ resign_ssd_kernel() {
# Save current kernel config # Save current kernel config
local old_config_file local old_config_file
old_config_file="${FLAGS_save_config}.$kernel_index" old_config_file="${FLAGS_save_config}.$kernel_index"
echo "Saving $name config to $old_config_file" info "Saving ${name} config to ${old_config_file}"
echo "$kernel_config" > "$old_config_file" echo "$kernel_config" > "$old_config_file"
# Just save; don't resign # Just save; don't resign
continue continue
@@ -194,7 +194,7 @@ resign_ssd_kernel() {
kernel_config="$(cat "$new_config_file")" || kernel_config="$(cat "$new_config_file")" ||
err_die "Failed to read new kernel config from $new_config_file" err_die "Failed to read new kernel config from $new_config_file"
debug_msg "New kernel config: $kernel_config)" debug_msg "New kernel config: $kernel_config)"
echo "$name: Replaced config from $new_config_file" info "${name}: Replaced config from ${new_config_file}"
fi fi
if [ "${FLAGS_edit_config}" = ${FLAGS_TRUE} ]; then if [ "${FLAGS_edit_config}" = ${FLAGS_TRUE} ]; then
@@ -203,7 +203,7 @@ resign_ssd_kernel() {
echo "${kernel_config}" >"${new_config_file}" echo "${kernel_config}" >"${new_config_file}"
local old_md5sum="$(md5sum "${new_config_file}")" local old_md5sum="$(md5sum "${new_config_file}")"
local editor="${VISUAL:-${EDITOR:-vi}}" local editor="${VISUAL:-${EDITOR:-vi}}"
echo "${name}: Editing kernel config:" info "${name}: Editing kernel config:"
# On ChromiumOS, some builds may come with broken EDITOR that refers to # On ChromiumOS, some builds may come with broken EDITOR that refers to
# nano so we want to check again if the editor really exists. # nano so we want to check again if the editor really exists.
if type "${editor}" >/dev/null 2>&1; then if type "${editor}" >/dev/null 2>&1; then
@@ -217,10 +217,10 @@ resign_ssd_kernel() {
fi fi
kernel_config="$(cat "${new_config_file}")" kernel_config="$(cat "${new_config_file}")"
if [ "$(md5sum "${new_config_file}")" = "${old_md5sum}" ]; then if [ "$(md5sum "${new_config_file}")" = "${old_md5sum}" ]; then
echo "${name}: Config not changed." info "${name}: Config not changed."
else else
debug_msg "New kernel config: ${kernel_config})" debug_msg "New kernel config: ${kernel_config})"
echo "${name}: Config updated" info "${name}: Config updated"
fi fi
fi fi
@@ -230,7 +230,7 @@ resign_ssd_kernel() {
debug_msg "Changing boot parameter to remove rootfs verification" debug_msg "Changing boot parameter to remove rootfs verification"
kernel_config="$(remove_rootfs_verification "$kernel_config")" kernel_config="$(remove_rootfs_verification "$kernel_config")"
debug_msg "New kernel config: $kernel_config" debug_msg "New kernel config: $kernel_config"
echo "$name: Disabled rootfs verification." info "${name}: Disabled rootfs verification."
remove_legacy_boot_rootfs_verification "$ssd_device" remove_legacy_boot_rootfs_verification "$ssd_device"
fi fi
@@ -272,9 +272,9 @@ resign_ssd_kernel() {
local backup_file_path="$FLAGS_backup_dir/$backup_file_name" local backup_file_path="$FLAGS_backup_dir/$backup_file_name"
if mkdir -p "$FLAGS_backup_dir" && if mkdir -p "$FLAGS_backup_dir" &&
cp -f "$old_blob" "$backup_file_path"; then cp -f "$old_blob" "$backup_file_path"; then
echo "Backup of $name is stored in: $backup_file_path" info "Backup of ${name} is stored in: ${backup_file_path}"
else else
echo "WARNING: Cannot create file in $FLAGS_backup_dir... Ignore backups." warning "Cannot create file in ${FLAGS_backup_dir} ... Ignore backups."
fi fi
debug_msg "Writing $name to partition $kernel_index" debug_msg "Writing $name to partition $kernel_index"
@@ -313,12 +313,12 @@ resign_ssd_kernel() {
# safety, let's try to sync more. # safety, let's try to sync more.
sync; sync; sync sync; sync; sync
echo "$name: Re-signed with developer keys successfully." info "${name}: Re-signed with developer keys successfully."
done done
# If we saved the kernel config, exit now so we don't print an error # If we saved the kernel config, exit now so we don't print an error
if [ -n "${FLAGS_save_config}" ]; then if [ -n "${FLAGS_save_config}" ]; then
echo "(Kernels have not been resigned.)" info "(Kernels have not been resigned.)"
exit 0 exit 0
fi fi
@@ -359,7 +359,7 @@ sanity_check_live_partitions() {
fi fi
if [ "$ORIGINAL_PARTITIONS" != "" ]; then if [ "$ORIGINAL_PARTITIONS" != "" ]; then
debug_msg "user has assigned partitions - provide more info." debug_msg "user has assigned partitions - provide more info."
echo "INFO: Making change to $FLAGS_partitions on $FLAGS_image." info "Making change to ${FLAGS_partitions} on ${FLAGS_image}."
return return
fi fi
echo " echo "
@@ -387,7 +387,7 @@ sanity_check_live_firmware() {
debug_msg "Loading firmware to check root key..." debug_msg "Loading firmware to check root key..."
local bios_image="$(make_temp_file)" local bios_image="$(make_temp_file)"
local rootkey_file="$(make_temp_file)" local rootkey_file="$(make_temp_file)"
echo "INFO: checking system firmware..." info "checking system firmware..."
sudo flashrom -p host -i GBB -r "$bios_image" >/dev/null 2>&1 sudo flashrom -p host -i GBB -r "$bios_image" >/dev/null 2>&1
gbb_utility -g --rootkey="$rootkey_file" "$bios_image" >/dev/null 2>&1 gbb_utility -g --rootkey="$rootkey_file" "$bios_image" >/dev/null 2>&1
if [ ! -s "$rootkey_file" ]; then if [ ! -s "$rootkey_file" ]; then
@@ -487,8 +487,8 @@ main() {
debug_msg "Complete." debug_msg "Complete."
if [ $num_signed -gt 0 -a $num_signed -le $num_given ]; then if [ $num_signed -gt 0 -a $num_signed -le $num_given ]; then
# signed something at least # signed something at least
echo "Successfully re-signed $num_signed of $num_given kernel(s)" \ info "Successfully re-signed ${num_signed} of ${num_given} kernel(s)" \
" on device $FLAGS_image". " on device ${FLAGS_image}."
else else
err_die "Failed re-signing kernels." err_die "Failed re-signing kernels."
fi fi