mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-08 21:46:58 +02:00
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:
parent
25602368f4
commit
e7ea070644
@ -129,7 +129,7 @@ image_map_partition() {
|
|||||||
local size="$(image_part_size "$file" "$part_num")" ||
|
local size="$(image_part_size "$file" "$part_num")" ||
|
||||||
image_die "failed to find partition #$part_num from: $file"
|
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"
|
-f --show "$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ image_map_partition() {
|
|||||||
image_unmap_partition() {
|
image_unmap_partition() {
|
||||||
local map_point="$1"
|
local map_point="$1"
|
||||||
|
|
||||||
losetup -d "$map_point"
|
sudo losetup -d "$map_point"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Mounts a specific partition inside a given image file
|
# Mounts a specific partition inside a given image file
|
||||||
@ -156,7 +156,7 @@ image_mount_partition() {
|
|||||||
mount_opt=",ro"
|
mount_opt=",ro"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mount \
|
sudo mount \
|
||||||
-o "loop,offset=$((offset * 512)),sizelimit=$((size * 512)),$mount_opt" \
|
-o "loop,offset=$((offset * 512)),sizelimit=$((size * 512)),$mount_opt" \
|
||||||
"$file" \
|
"$file" \
|
||||||
"$mount_point"
|
"$mount_point"
|
||||||
@ -166,7 +166,7 @@ image_mount_partition() {
|
|||||||
image_umount_partition() {
|
image_umount_partition() {
|
||||||
local mount_point="$1"
|
local mount_point="$1"
|
||||||
|
|
||||||
umount -d "$mount_point"
|
sudo umount -d "$mount_point"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Copy a partition from one image to another.
|
# Copy a partition from one image to another.
|
||||||
|
@ -245,6 +245,11 @@ umount_esp() {
|
|||||||
generate_img() {
|
generate_img() {
|
||||||
local outdev="$(readlink -f "$FLAGS_diskimg")"
|
local outdev="$(readlink -f "$FLAGS_diskimg")"
|
||||||
local sectors="$FLAGS_sectors"
|
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
|
prepare_img
|
||||||
|
|
||||||
@ -272,6 +277,14 @@ generate_img() {
|
|||||||
echo "EFI Partition"
|
echo "EFI Partition"
|
||||||
image_partition_copy "${FACTORY_IMAGE}" 12 "${outdev}" 12
|
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
|
# TODO(nsanders, wad): consolidate this code into some common code
|
||||||
# when cleaning up kernel commandlines. There is code that touches
|
# when cleaning up kernel commandlines. There is code that touches
|
||||||
# this in postint/chromeos-setimage and build_image. However none
|
# this in postint/chromeos-setimage and build_image. However none
|
||||||
|
Loading…
Reference in New Issue
Block a user