blob: 590ca3156c269724a654b293c634bafd62ce97ba [file] [log] [blame]
Will Drewry69563b72010-06-24 16:12:58 -05001#!/bin/bash
2
3# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# Helper script that generates the signed kernel image
8
George Engelbrecht4aa33ca2020-11-16 11:12:59 -07009# All kernel command line changes must update the security base lines in
10# the signer. It rejects any settings it does not recognize and breaks the
11# build. So any kernel parameter changes that are made here needs to be
12# reflected in ensure_secure_kernelparams.config and deployed to production
13# signing before landed here.
14
Brian Harringaa13ea42012-03-15 18:31:03 -070015SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
David James359d3e12012-07-10 13:09:48 -070016. "${SCRIPT_ROOT}/common.sh" || exit 1
Will Drewry69563b72010-06-24 16:12:58 -050017
Will Drewry69563b72010-06-24 16:12:58 -050018# Flags.
19DEFINE_string arch "x86" \
Sonny Rao0679b362011-10-12 13:53:19 -070020 "The boot architecture: arm, x86, or amd64. (Default: x86)"
Albert Chaulk5d190f72013-07-12 11:42:18 -070021DEFINE_string board "${DEFAULT_BOARD}" \
22 "Board we're building for."
Will Drewry69563b72010-06-24 16:12:58 -050023DEFINE_string to "/tmp/vmlinuz.image" \
24 "The path to the kernel image to be created. (Default: /tmp/vmlinuz.image)"
Gabe Blacke41371c2014-07-29 15:48:40 -070025DEFINE_string hd_vblock "" \
26 "The path to the installed kernel's vblock"
Will Drewry69563b72010-06-24 16:12:58 -050027DEFINE_string vmlinuz "vmlinuz" \
28 "The path to the kernel (Default: vmlinuz)"
29DEFINE_string working_dir "/tmp/vmlinuz.working" \
30 "Working directory for in-progress files. (Default: /tmp/vmlinuz.working)"
31DEFINE_boolean keep_work ${FLAGS_FALSE} \
32 "Keep temporary files (*.keyblock, *.vbpubk). (Default: false)"
Mike Frysinger34808e52017-01-11 21:14:08 -050033DEFINE_string keys_dir "${VBOOT_TESTKEYS_DIR}" \
Bill Richardson2ace49e2010-07-01 10:23:27 -070034 "Directory with the RSA signing keys. (Defaults to test keys)"
Gabe Blacke41371c2014-07-29 15:48:40 -070035DEFINE_string keyblock "kernel.keyblock" \
36 "The keyblock to use. (Defaults to kernel.keyblock)"
37DEFINE_string private "kernel_data_key.vbprivk" \
38 "The private key to sign the kernel (Defaults to kernel_data_key.vbprivk)"
39DEFINE_string public "kernel_subkey.vbpubk" \
40 "The public key to verify the kernel (Defaults to kernel_subkey.vbpubk)"
Will Drewrybcbf1c42010-07-03 10:23:30 -050041# Note, to enable verified boot, the caller would manually pass:
Will Drewryb910de82011-02-23 13:26:50 -060042# --boot_args='dm="... %U+1 %U+1 ..." \
Will Drewry69563b72010-06-24 16:12:58 -050043# --root=/dev/dm-0
44DEFINE_string boot_args "noinitrd" \
45 "Additional boot arguments to pass to the commandline (Default: noinitrd)"
Will Drewrybcbf1c42010-07-03 10:23:30 -050046# If provided, will automatically add verified boot arguments.
47DEFINE_string rootfs_image "" \
48 "Optional path to the rootfs device or image.(Default: \"\")"
Alex Deymo87dced62015-03-03 12:54:58 -080049DEFINE_string rootfs_image_size "" \
50 "Optional size in bytes of the rootfs_image file. Must be a multiple of 4 \
51KiB. If omitted, the filesystem size detected from rootfs_image is used."
Will Drewrybcbf1c42010-07-03 10:23:30 -050052DEFINE_string rootfs_hash "" \
53 "Optional path to output the rootfs hash to. (Default: \"\")"
Liam McLoughline81a2322012-09-24 10:37:34 +000054DEFINE_integer verity_error_behavior 3 \
Will Drewrybcbf1c42010-07-03 10:23:30 -050055 "Verified boot error behavior [0: I/O errors, 1: reboot, 2: nothing] \
Liam McLoughline81a2322012-09-24 10:37:34 +000056(Default: 3)"
Will Drewryb910de82011-02-23 13:26:50 -060057DEFINE_integer verity_max_ios -1 \
58 "Optional number of outstanding I/O operations. (Default: -1)"
Betul Soysal86bea8d2019-10-31 15:05:30 -070059DEFINE_string verity_hash_alg "sha256" \
60 "Cryptographic hash algorithm used for dm-verity. (Default: sha256)"
Elly Jones9ca3e4c2011-09-26 15:18:19 -040061DEFINE_string verity_salt "" \
62 "Salt to use for rootfs hash (Default: \"\")"
Paul Taysom5b2c7e92012-09-05 10:13:03 -070063DEFINE_boolean enable_rootfs_verification ${FLAGS_TRUE} \
64 "Enable kernel-based root fs integrity checking. (Default: true)"
Paul Taysom00df6f62012-11-20 12:35:40 -080065DEFINE_boolean enable_bootcache ${FLAGS_FALSE} \
66 "Enable boot cache to accelerate booting. (Default: false)"
Paul Taysom5e39bb62013-01-18 07:39:25 -080067DEFINE_string enable_serial "" \
68 "Enable serial port for printks. Example values: ttyS0"
Zach Reiznerf09d3d12014-09-24 10:45:19 -070069DEFINE_integer loglevel 7 \
70 "The loglevel to add to the kernel command line."
Will Drewrybcbf1c42010-07-03 10:23:30 -050071
Will Drewry69563b72010-06-24 16:12:58 -050072# Parse flags
73FLAGS "$@" || exit 1
74eval set -- "${FLAGS_ARGV}"
75
76# Die on error
Brian Harring7f175a52012-03-02 05:37:00 -080077switch_to_strict_mode
Will Drewry69563b72010-06-24 16:12:58 -050078
Mike Frysinger94a82df2013-11-26 14:51:50 -050079# N.B. Ordering matters for some of the libraries below, because
80# some of the files contain initialization used by later files.
81. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
Dan Ehrenberg21cee6e2014-11-18 17:29:16 -080082. "${BUILD_LIBRARY_DIR}/disk_layout_util.sh" || exit 1
Mike Frysinger94a82df2013-11-26 14:51:50 -050083
Dan Ehrenbergcdac45f2015-01-16 15:16:03 -080084
Paul Taysom00df6f62012-11-20 12:35:40 -080085rootdigest() {
86 local digest=${table#*root_hexdigest=}
87 echo ${digest% salt*}
88}
89
90salt() {
91 local salt=${table#*salt=}
92 echo ${salt%}
93}
94
95hashstart() {
96 local hash=${table#*hashstart=}
97 echo ${hash% alg*}
98}
99
100# Estimate of sectors used by verity
101# (num blocks) * 32 (bytes per hash) * 2 (overhead) / 512 (bytes per sector)
102veritysize() {
103 echo $((root_fs_blocks * 32 * 2 / 512))
104}
105
Chris Masone175a2692014-01-21 16:06:44 -0800106# Munge the kernel command line.
107# Intended to be overridden by boards that wish to add to the command line.
108# $1 - Configuration file containing boot args.
Bryan Freed17d39bd2015-07-20 14:57:28 -0700109#
110# All kernel command line changes must update the security base lines in
111# the signer. It rejects any settings it does not recognize and breaks the
112# build. So any modify_kernel_command_line() function change here or in a
113# board specific build_kernel_image.sh needs to be reflected in
114# ensure_secure_kernelparams.config.
115# See https://chrome-internal-review.googlesource.com/#/c/216896 as an example.
Chris Masone175a2692014-01-21 16:06:44 -0800116modify_kernel_command_line() {
117 :
118}
119
Dan Ehrenberg21cee6e2014-11-18 17:29:16 -0800120get_base_root() {
121 echo 'PARTUUID=%U/PARTNROFF=1'
122}
123
Steve Fung88897cc2015-03-25 13:38:38 -0700124load_board_specific_script "build_kernel_image.sh"
Albert Chaulk5d190f72013-07-12 11:42:18 -0700125
Dan Ehrenberg21cee6e2014-11-18 17:29:16 -0800126base_root=$(get_base_root)
127
Paul Taysom00df6f62012-11-20 12:35:40 -0800128device_mapper_args=
Will Drewrybcbf1c42010-07-03 10:23:30 -0500129# Even with a rootfs_image, root= is not changed unless specified.
130if [[ -n "${FLAGS_rootfs_image}" && -n "${FLAGS_rootfs_hash}" ]]; then
Will Drewrybcbf1c42010-07-03 10:23:30 -0500131 # Gets the number of blocks. 4096 byte blocks _are_ expected.
Alex Deymo87dced62015-03-03 12:54:58 -0800132 if [[ -n "${FLAGS_rootfs_image_size}" ]]; then
133 root_fs_size=${FLAGS_rootfs_image_size}
Da Zheng87465ea2011-07-30 16:25:28 -0700134 else
Alex Deymo87dced62015-03-03 12:54:58 -0800135 # We try to autodetect the rootfs_image filesystem size.
136 if [[ -f "${FLAGS_rootfs_image}" ]]; then
137 root_fs_size=$(stat -c '%s' ${FLAGS_rootfs_image})
138 elif [[ -b "${FLAGS_rootfs_image}" ]]; then
139 root_fs_type="$(awk -v rootdev="${FLAGS_rootfs_image}" \
140 '$1 == rootdev { print $3 }' /proc/mounts | head -n 1)"
141 case "${root_fs_type}" in
142 squashfs)
143 # unsquashfs returns the size in KiB as a float value with two
144 # decimals, rounded as printf() would do. To avoid corner cases like
145 # when the fractional part of the size in KiB is less than 0.005,
146 # instead of rounding up the value to the nearest 4KiB, we round it
147 # down and add 1 extra 4 KiB block.
148 root_fs_size_kib=$(sudo unsquashfs -stat "${FLAGS_rootfs_image}" |
149 grep -E -o 'Filesystem size [0-9\.]+ Kbytes' |
150 cut -f 3 -d ' ' | cut -f 1 -d '.')
151 root_fs_size=$(( (root_fs_size_kib / 4 + 1) * 4096 ))
152 ;;
153 ext[234])
154 root_fs_blocks=$(sudo dumpe2fs "${FLAGS_rootfs_image}" 2>/dev/null |
155 grep "Block count" |
156 tr -d ' ' |
157 cut -f2 -d:)
158 root_fs_block_sz=$(sudo dumpe2fs "${FLAGS_rootfs_image}" 2>/dev/null |
159 grep "Block size" |
160 tr -d ' ' |
161 cut -f2 -d:)
162 root_fs_size=$(( root_fs_blocks * root_fs_block_sz ))
163 ;;
164 *)
165 die "Unknown root filesystem type ${root_fs_type}."
166 ;;
167 esac
168 else
169 die "Couldn't determine the size of ${FLAGS_rootfs_image}, pass the size \
170with --rootfs_image_size."
171 fi
Da Zheng87465ea2011-07-30 16:25:28 -0700172 fi
Alex Deymo87dced62015-03-03 12:54:58 -0800173 # Verity assumes a 4 KiB block size.
174 if [[ ! $(( root_fs_size % 4096 )) -eq 0 ]]; then
175 die "The root filesystem size (${root_fs_size}) must be a multiple of \
1764 KiB."
Will Drewrybcbf1c42010-07-03 10:23:30 -0500177 fi
Alex Deymo87dced62015-03-03 12:54:58 -0800178 root_fs_blocks=$((root_fs_size / 4096))
179 info "rootfs is ${root_fs_blocks} blocks of 4096 bytes."
Will Drewrybcbf1c42010-07-03 10:23:30 -0500180
Elly Jones9ca3e4c2011-09-26 15:18:19 -0400181 info "Generating root fs hash tree (salt '${FLAGS_verity_salt}')."
Will Drewrybcbf1c42010-07-03 10:23:30 -0500182 # Runs as sudo in case the image is a block device.
Elly Jones5e7a4302011-05-27 16:08:16 -0400183 table=$(sudo verity mode=create \
184 alg=${FLAGS_verity_hash_alg} \
185 payload=${FLAGS_rootfs_image} \
186 payload_blocks=${root_fs_blocks} \
Elly Jonesf4e48332011-09-02 13:25:04 -0400187 hashtree=${FLAGS_rootfs_hash} \
Elly Jones9ca3e4c2011-09-26 15:18:19 -0400188 salt=${FLAGS_verity_salt})
Will Drewry821d07c2010-07-03 17:14:58 -0700189 if [[ -f "${FLAGS_rootfs_hash}" ]]; then
190 sudo chmod a+r "${FLAGS_rootfs_hash}"
191 fi
Paul Taysom5b2c7e92012-09-05 10:13:03 -0700192 # Don't claim the root device unless verity is enabled.
193 # Doing so will claim /dev/sdDP out from under the system.
194 if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then
Paul Taysom00df6f62012-11-20 12:35:40 -0800195 if [[ ${FLAGS_enable_bootcache} -eq ${FLAGS_TRUE} ]]; then
196 base_root='254:0' # major:minor numbers for /dev/dm-0
Paul Taysom00df6f62012-11-20 12:35:40 -0800197 fi
Kenneth Watersed54d932010-09-21 10:29:54 -0700198 table=${table//HASH_DEV/${base_root}}
199 table=${table//ROOT_DEV/${base_root}}
Will Drewrybcbf1c42010-07-03 10:23:30 -0500200 fi
Paul Taysom00df6f62012-11-20 12:35:40 -0800201 verity_dev="vroot none ro 1,${table}"
202 if [[ ${FLAGS_enable_bootcache} -eq ${FLAGS_TRUE} ]]; then
203 signature=$(rootdigest)
204 cachestart=$(($(hashstart) + $(veritysize)))
205 size_limit=512
206 max_trace=20000
207 max_pages=100000
Paul Taysoma59a0b32013-07-24 15:56:18 -0700208 bootcache_args="PARTUUID=%U/PARTNROFF=1"
209 bootcache_args+=" ${cachestart} ${signature} ${size_limit}"
210 bootcache_args+=" ${max_trace} ${max_pages}"
Paul Taysom00df6f62012-11-20 12:35:40 -0800211 bootcache_dev="vboot none ro 1,0 ${cachestart} bootcache ${bootcache_args}"
212 device_mapper_args="dm=\"2 ${bootcache_dev}, ${verity_dev}\""
213 else
214 device_mapper_args="dm=\"1 ${verity_dev}\""
215 fi
216 info "device mapper configuration: ${device_mapper_args}"
Will Drewrybcbf1c42010-07-03 10:23:30 -0500217fi
218
219mkdir -p "${FLAGS_working_dir}"
Will Drewryd6435d42010-10-20 15:37:46 -0500220
221# Only let dm-verity block if rootfs verification is configured.
Paul Taysom5b2c7e92012-09-05 10:13:03 -0700222# By default, we use a firmware enumerated value, but it isn't reliable for
223# production use. If +%d can be added upstream, then we can use:
224# root_dev=PARTUID=uuid+1
Will Drewryd6435d42010-10-20 15:37:46 -0500225dev_wait=0
Dan Ehrenberg21cee6e2014-11-18 17:29:16 -0800226root_dev=${base_root}
Paul Taysom5b2c7e92012-09-05 10:13:03 -0700227if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then
Will Drewryd6435d42010-10-20 15:37:46 -0500228 dev_wait=1
Paul Taysom00df6f62012-11-20 12:35:40 -0800229 if [[ ${FLAGS_enable_bootcache} -eq ${FLAGS_TRUE} ]]; then
230 root_dev=/dev/dm-1
231 else
232 root_dev=/dev/dm-0
233 fi
234else
235 if [[ ${FLAGS_enable_bootcache} -eq ${FLAGS_TRUE} ]]; then
236 die "Having bootcache without verity is not supported"
237 fi
Will Drewryd6435d42010-10-20 15:37:46 -0500238fi
239
Paul Taysoma59a0b32013-07-24 15:56:18 -0700240# kern_guid should eventually be changed to use PARTUUID
Will Drewrybcbf1c42010-07-03 10:23:30 -0500241cat <<EOF > "${FLAGS_working_dir}/boot.config"
Paul Taysom5b2c7e92012-09-05 10:13:03 -0700242root=${root_dev}
Olof Johanssone0b75512011-01-26 14:31:26 -0800243rootwait
244ro
Will Drewry1670d482010-07-09 13:08:38 -0700245dm_verity.error_behavior=${FLAGS_verity_error_behavior}
246dm_verity.max_bios=${FLAGS_verity_max_ios}
Will Drewryd6435d42010-10-20 15:37:46 -0500247dm_verity.dev_wait=${dev_wait}
Paul Taysom00df6f62012-11-20 12:35:40 -0800248${device_mapper_args}
Will Drewrybcbf1c42010-07-03 10:23:30 -0500249${FLAGS_boot_args}
Pawel Osciaka2c23752011-11-15 15:09:45 -0800250vt.global_cursor_default=0
Doug Anderson2dd2e8e2012-01-06 09:32:24 -0800251kern_guid=%U
Will Drewrybcbf1c42010-07-03 10:23:30 -0500252EOF
253
254WORK="${WORK} ${FLAGS_working_dir}/boot.config"
255info "Emitted cross-platform boot params to ${FLAGS_working_dir}/boot.config"
256
Olof Johansson1eafb5a2012-08-01 00:04:30 -0700257# Add common boot options first.
Paul Taysom5e39bb62013-01-18 07:39:25 -0800258config="${FLAGS_working_dir}/config.txt"
259if [[ -n ${FLAGS_enable_serial} ]]; then
260 console=${FLAGS_enable_serial}
261 if [[ ${console} != *,* ]]; then
262 console+=",115200n8"
263 fi
264 cat <<EOF > "${config}"
Paul Taysom5e39bb62013-01-18 07:39:25 -0800265earlyprintk=${console}
266console=tty1
Doug Andersond65edf42014-07-09 15:00:53 -0700267console=${console}
Paul Taysom5e39bb62013-01-18 07:39:25 -0800268EOF
269else
270 cat <<EOF > "${config}"
Sameer Nanda542cb532012-08-22 16:11:12 -0700271console=
Paul Taysom5e39bb62013-01-18 07:39:25 -0800272EOF
273fi
274
275cat <<EOF - "${FLAGS_working_dir}/boot.config" >> "${config}"
Zach Reiznerf09d3d12014-09-24 10:45:19 -0700276loglevel=${FLAGS_loglevel}
Will Drewry69563b72010-06-24 16:12:58 -0500277init=/sbin/init
Olof Johansson1eafb5a2012-08-01 00:04:30 -0700278cros_secure
Sean Paul06178ec2020-08-13 13:21:38 -0400279drm.trace=0x106
Olof Johansson1eafb5a2012-08-01 00:04:30 -0700280EOF
281
282if [[ "${FLAGS_arch}" = "x86" || "${FLAGS_arch}" = "amd64" ]]; then
283 # Legacy BIOS will use the kernel in the rootfs (via syslinux), as will
284 # standard EFI BIOS (via grub, from the EFI System Partition). Chrome OS
285 # BIOS will use a separate signed kernel partition, which we'll create now.
Olof Johanssond7a8aaf2012-08-02 20:35:47 -0700286 cat <<EOF >> "${FLAGS_working_dir}/config.txt"
Will Drewry69563b72010-06-24 16:12:58 -0500287add_efi_memmap
288boot=local
Will Drewry69563b72010-06-24 16:12:58 -0500289noresume
290noswap
291i915.modeset=1
Will Drewry69563b72010-06-24 16:12:58 -0500292EOF
Will Drewrybcbf1c42010-07-03 10:23:30 -0500293 WORK="${WORK} ${FLAGS_working_dir}/config.txt"
Will Drewry69563b72010-06-24 16:12:58 -0500294
Che-Liang Chiou75ac2be2011-02-24 12:00:16 +0800295 bootloader_path="/lib64/bootstub/bootstub.efi"
296 kernel_image="${FLAGS_vmlinuz}"
Adam Kallai34b2be62018-07-06 16:44:24 +0200297elif [[ "${FLAGS_arch}" = "arm" || "${FLAGS_arch}" = "mips" || "${FLAGS_arch}" = "arm64" ]]; then
Che-Liang Chiou75ac2be2011-02-24 12:00:16 +0800298 WORK="${WORK} ${FLAGS_working_dir}/config.txt"
299
Che-Liang Chiou69faa262011-06-01 11:52:21 +0800300 # arm does not need/have a bootloader in kernel partition
301 dd if="/dev/zero" of="${FLAGS_working_dir}/bootloader.bin" bs=512 count=1
302 WORK="${WORK} ${FLAGS_working_dir}/bootloader.bin"
Che-Liang Chiou75ac2be2011-02-24 12:00:16 +0800303
Che-Liang Chiou69faa262011-06-01 11:52:21 +0800304 bootloader_path="${FLAGS_working_dir}/bootloader.bin"
Che-Liang Chiou75ac2be2011-02-24 12:00:16 +0800305 kernel_image="${FLAGS_vmlinuz/vmlinuz/vmlinux.uimg}"
Che-Liang Chiou75ac2be2011-02-24 12:00:16 +0800306else
307 error "Unknown arch: ${FLAGS_arch}"
308fi
309
David Riley345dc272015-06-22 11:04:09 -0700310# Save the kernel as a .bin to allow it to be automatically extracted as
311# an artifact by cbuildbot. Non .bin's need to be explicitly specified
312# and would require the entire set of artifacts to be specified.
313info "Saving kernel as ${FLAGS_working_dir}/vmlinuz.bin"
314cp ${kernel_image} ${FLAGS_working_dir}/vmlinuz.bin
315
Dan Ehrenbergcdac45f2015-01-16 15:16:03 -0800316for image_type in $(get_image_types); do
317 already_seen_rootfs=0
318 for partition in $(get_partitions ${image_type}); do
319 format=$(get_format ${image_type} "${partition}")
320 if [[ "${format}" == "ubi" ]]; then
321 type=$(get_type ${image_type} "${partition}")
322 # cgpt.py ensures that the rootfs partitions are compatible, in that if
323 # one is ubi then both are, and they have the same number of reserved
324 # blocks. We only want to attach one of them in boot to save time, so
325 # attach %P and get the information for whichever rootfs comes first.
326 if [[ "${type}" == "rootfs" ]]; then
327 if [[ "${already_seen_rootfs}" -ne 0 ]]; then
328 continue
329 fi
330 already_seen_rootfs=1
331 partname='%P'
332 else
333 partname="${partition}"
Dan Ehrenberg21cee6e2014-11-18 17:29:16 -0800334 fi
Dan Ehrenbergcdac45f2015-01-16 15:16:03 -0800335 reserved=$(get_reserved_erase_blocks ${image_type} "${partition}")
336 echo "ubi.mtd=${partname},0,${reserved},${partname}" \
337 >> "${FLAGS_working_dir}/config.txt"
338 fs_format=$(get_filesystem_format ${image_type} "${partition}")
339 if [[ "${fs_format}" != "ubifs" ]]; then
340 echo "ubi.block=${partname},0" >> "${FLAGS_working_dir}/config.txt"
341 fi
Dan Ehrenberg21cee6e2014-11-18 17:29:16 -0800342 fi
Dan Ehrenbergcdac45f2015-01-16 15:16:03 -0800343 done
Dan Ehrenberg21cee6e2014-11-18 17:29:16 -0800344done
345
Gabe Blacke41371c2014-07-29 15:48:40 -0700346config_file="${FLAGS_working_dir}/config.txt"
347modify_kernel_command_line "${config_file}"
348# Create and sign the kernel blob
349vbutil_kernel \
350 --pack "${FLAGS_to}" \
351 --keyblock "${FLAGS_keys_dir}/${FLAGS_keyblock}" \
352 --signprivate "${FLAGS_keys_dir}/${FLAGS_private}" \
353 --version 1 \
354 --config "${config_file}" \
355 --bootloader "${bootloader_path}" \
356 --vmlinuz "${kernel_image}" \
357 --arch "${FLAGS_arch}"
358
359# And verify it.
360vbutil_kernel \
361 --verify "${FLAGS_to}" \
362 --signpubkey "${FLAGS_keys_dir}/${FLAGS_public}"
363
364if [[ -n "${FLAGS_hd_vblock}" ]]; then
365 dd if="${FLAGS_to}" bs=65536 count=1 of="${FLAGS_hd_vblock}"
Will Drewry69563b72010-06-24 16:12:58 -0500366fi
367
368set +e # cleanup failure is a-ok
369
370if [[ ${FLAGS_keep_work} -eq ${FLAGS_FALSE} ]]; then
Will Drewrybcbf1c42010-07-03 10:23:30 -0500371 info "Cleaning up temporary files: ${WORK}"
Will Drewry69563b72010-06-24 16:12:58 -0500372 rm ${WORK}
373 rmdir ${FLAGS_working_dir}
374fi
375
Will Drewrybcbf1c42010-07-03 10:23:30 -0500376info "Kernel partition image emitted: ${FLAGS_to}"
377
378if [[ -f ${FLAGS_rootfs_hash} ]]; then
379 info "Root filesystem hash emitted: ${FLAGS_rootfs_hash}"
380fi