make_factory_package: allow updating HWID for image creation

BUG=chromium-os:16733
TEST=./make_factory_package --release RELEASE \
     --factory FACTORY --hwid HWID_UPDATER \
     --diskimg IMAGE_FILE

Change-Id: I1a817e1f176d22d830bf0ce8a6ccb6956086f749
Reviewed-on: http://gerrit.chromium.org/gerrit/3306
Reviewed-by: Jay Kim <yongjaek@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
This commit is contained in:
Hung-Te Lin 2011-06-28 18:23:10 +08:00
parent 25602368f4
commit e7ea070644
2 changed files with 17 additions and 4 deletions

View File

@ -129,7 +129,7 @@ image_map_partition() {
local size="$(image_part_size "$file" "$part_num")" ||
image_die "failed to find partition #$part_num from: $file"
losetup --offset $((offset * 512)) --sizelimit=$((size * 512)) \
sudo losetup --offset $((offset * 512)) --sizelimit=$((size * 512)) \
-f --show "$file"
}
@ -137,7 +137,7 @@ image_map_partition() {
image_unmap_partition() {
local map_point="$1"
losetup -d "$map_point"
sudo losetup -d "$map_point"
}
# Mounts a specific partition inside a given image file
@ -156,7 +156,7 @@ image_mount_partition() {
mount_opt=",ro"
fi
mount \
sudo mount \
-o "loop,offset=$((offset * 512)),sizelimit=$((size * 512)),$mount_opt" \
"$file" \
"$mount_point"
@ -166,7 +166,7 @@ image_mount_partition() {
image_umount_partition() {
local mount_point="$1"
umount -d "$mount_point"
sudo umount -d "$mount_point"
}
# Copy a partition from one image to another.

View File

@ -245,6 +245,11 @@ umount_esp() {
generate_img() {
local outdev="$(readlink -f "$FLAGS_diskimg")"
local sectors="$FLAGS_sectors"
local hwid_updater="${FLAGS_hwid_updater}"
if [ -n "${FLAGS_hwid_updater}" ]; then
hwid_updater="$(readlink -f "$FLAGS_hwid_updater")"
fi
prepare_img
@ -272,6 +277,14 @@ generate_img() {
echo "EFI Partition"
image_partition_copy "${FACTORY_IMAGE}" 12 "${outdev}" 12
if [ -n "${hwid_updater}" ]; then
local state_dev="$(image_map_partition "${outdev}" 1)"
local hwid_result="0"
sudo sh "$hwid_updater" "$state_dev" || hwid_result="$?"
image_unmap_partition "$state_dev" || true
[ $hwid_result = "0" ] || die "Failed to update HWID ($hwid_result). abort."
fi
# TODO(nsanders, wad): consolidate this code into some common code
# when cleaning up kernel commandlines. There is code that touches
# this in postint/chromeos-setimage and build_image. However none