mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-09 14:06:58 +02:00
Add feature to extract kernel image from other recovery image for use in recovery.
This CL adds a new option to mod_image_for_recovery that allows a dev to pass in another recovery image as an option and have mod_image_for_recovery use the kernel provided in that image when building a new recovery image. BUG=chromium-os:19189 TEST=Built using option on image signed with non-dev keys using appropriate recovery image as base. Change-Id: I02a3c3bf458fb3c9fee556364005d7eaff5acccc Reviewed-on: http://gerrit.chromium.org/gerrit/6031 Tested-by: Chris Sosa <sosa@chromium.org> Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
This commit is contained in:
parent
4fc9c2706d
commit
493cbf8426
@ -19,6 +19,8 @@ DEFINE_integer statefulfs_sectors 4096 \
|
||||
# Skips the build steps and just does the kernel swap.
|
||||
DEFINE_string kernel_image "" \
|
||||
"Path to a pre-built recovery kernel"
|
||||
DEFINE_string recovery_image_with_kernel "" \
|
||||
"Optional path to a recovery image with a pre-built kernel."
|
||||
DEFINE_string kernel_outfile "" \
|
||||
"Filename and path to emit the kernel outfile to. \
|
||||
If empty, emits to IMAGE_DIR."
|
||||
@ -281,6 +283,21 @@ install_recovery_kernel() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# Extracts a kernel from an existing recovery image.
|
||||
# $1 path to new kernel image.
|
||||
# $2 path to recovery image.
|
||||
extract_kernel_image() {
|
||||
local kernel_path="$1"
|
||||
local recovery_image="$2"
|
||||
|
||||
local kern_a_offset=$(partoffset ${recovery_image} 2)
|
||||
local kern_a_count=$(partsize ${recovery_image} 2)
|
||||
|
||||
info "Extracing kernel image from $2"
|
||||
dd if="$recovery_image" of="$kernel_path" bs=512 \
|
||||
skip=$kern_a_offset count=$kern_a_count
|
||||
}
|
||||
|
||||
update_partition_table() {
|
||||
local src_img=$1 # source image
|
||||
local temp_state=$2 # stateful partition image
|
||||
@ -413,7 +430,11 @@ FACTORY_ROOT="${BOARD_ROOT}/factory-root"
|
||||
USE="fbconsole initramfs" emerge_custom_kernel "$FACTORY_ROOT" ||
|
||||
failboat "Cannot emerge custom kernel"
|
||||
|
||||
if [ -z "$FLAGS_kernel_image" ]; then
|
||||
if [ -n "FLAGS_recovery_image_with_kernel" ]; then
|
||||
RECOVERY_KERNEL_IMAGE="$(tempfile -p "extracted_kernel")"
|
||||
extract_kernel_image "$RECOVERY_KERNEL_IMAGE" \
|
||||
"$FLAGS_recovery_image_with_kernel"
|
||||
elif [ -z "$FLAGS_kernel_image" ]; then
|
||||
create_recovery_kernel_image
|
||||
echo "Recovery kernel created at $RECOVERY_KERNEL_IMAGE"
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user