blob: f1f2a162a46ca523a2ef39089eb21f15f3e75950 [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
Brian Harringaa13ea42012-03-15 18:31:03 -07009SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
David James359d3e12012-07-10 13:09:48 -070010. "${SCRIPT_ROOT}/common.sh" || exit 1
Will Drewry69563b72010-06-24 16:12:58 -050011
Will Drewry69563b72010-06-24 16:12:58 -050012# Flags.
13DEFINE_string arch "x86" \
Sonny Rao0679b362011-10-12 13:53:19 -070014 "The boot architecture: arm, x86, or amd64. (Default: x86)"
Albert Chaulk5d190f72013-07-12 11:42:18 -070015DEFINE_string board "${DEFAULT_BOARD}" \
16 "Board we're building for."
Will Drewry69563b72010-06-24 16:12:58 -050017DEFINE_string to "/tmp/vmlinuz.image" \
18 "The path to the kernel image to be created. (Default: /tmp/vmlinuz.image)"
Gabe Blacke41371c2014-07-29 15:48:40 -070019DEFINE_string hd_vblock "" \
20 "The path to the installed kernel's vblock"
Will Drewry69563b72010-06-24 16:12:58 -050021DEFINE_string vmlinuz "vmlinuz" \
22 "The path to the kernel (Default: vmlinuz)"
23DEFINE_string working_dir "/tmp/vmlinuz.working" \
24 "Working directory for in-progress files. (Default: /tmp/vmlinuz.working)"
25DEFINE_boolean keep_work ${FLAGS_FALSE} \
26 "Keep temporary files (*.keyblock, *.vbpubk). (Default: false)"
Mike Frysinger34808e52017-01-11 21:14:08 -050027DEFINE_string keys_dir "${VBOOT_TESTKEYS_DIR}" \
Bill Richardson2ace49e2010-07-01 10:23:27 -070028 "Directory with the RSA signing keys. (Defaults to test keys)"
Gabe Blacke41371c2014-07-29 15:48:40 -070029DEFINE_string keyblock "kernel.keyblock" \
30 "The keyblock to use. (Defaults to kernel.keyblock)"
31DEFINE_string private "kernel_data_key.vbprivk" \
32 "The private key to sign the kernel (Defaults to kernel_data_key.vbprivk)"
33DEFINE_string public "kernel_subkey.vbpubk" \
34 "The public key to verify the kernel (Defaults to kernel_subkey.vbpubk)"
Will Drewrybcbf1c42010-07-03 10:23:30 -050035# Note, to enable verified boot, the caller would manually pass:
Will Drewryb910de82011-02-23 13:26:50 -060036# --boot_args='dm="... %U+1 %U+1 ..." \
Will Drewry69563b72010-06-24 16:12:58 -050037# --root=/dev/dm-0
38DEFINE_string boot_args "noinitrd" \
39 "Additional boot arguments to pass to the commandline (Default: noinitrd)"
Will Drewrybcbf1c42010-07-03 10:23:30 -050040# If provided, will automatically add verified boot arguments.
41DEFINE_string rootfs_image "" \
42 "Optional path to the rootfs device or image.(Default: \"\")"
Alex Deymo87dced62015-03-03 12:54:58 -080043DEFINE_string rootfs_image_size "" \
44 "Optional size in bytes of the rootfs_image file. Must be a multiple of 4 \
45KiB. If omitted, the filesystem size detected from rootfs_image is used."
Will Drewrybcbf1c42010-07-03 10:23:30 -050046DEFINE_string rootfs_hash "" \
47 "Optional path to output the rootfs hash to. (Default: \"\")"
Liam McLoughline81a2322012-09-24 10:37:34 +000048DEFINE_integer verity_error_behavior 3 \
Will Drewrybcbf1c42010-07-03 10:23:30 -050049 "Verified boot error behavior [0: I/O errors, 1: reboot, 2: nothing] \
Liam McLoughline81a2322012-09-24 10:37:34 +000050(Default: 3)"
Will Drewryb910de82011-02-23 13:26:50 -060051DEFINE_integer verity_max_ios -1 \
52 "Optional number of outstanding I/O operations. (Default: -1)"
Will Drewry1670d482010-07-09 13:08:38 -070053DEFINE_string verity_hash_alg "sha1" \
54 "Cryptographic hash algorithm used for dm-verity. (Default: sha1)"
Elly Jones9ca3e4c2011-09-26 15:18:19 -040055DEFINE_string verity_salt "" \
56 "Salt to use for rootfs hash (Default: \"\")"
Paul Taysom5b2c7e92012-09-05 10:13:03 -070057DEFINE_boolean enable_rootfs_verification ${FLAGS_TRUE} \
58 "Enable kernel-based root fs integrity checking. (Default: true)"
Paul Taysom00df6f62012-11-20 12:35:40 -080059DEFINE_boolean enable_bootcache ${FLAGS_FALSE} \
60 "Enable boot cache to accelerate booting. (Default: false)"
Paul Taysom5e39bb62013-01-18 07:39:25 -080061DEFINE_string enable_serial "" \
62 "Enable serial port for printks. Example values: ttyS0"
Zach Reiznerf09d3d12014-09-24 10:45:19 -070063DEFINE_integer loglevel 7 \
64 "The loglevel to add to the kernel command line."
Will Drewrybcbf1c42010-07-03 10:23:30 -050065
Will Drewry69563b72010-06-24 16:12:58 -050066# Parse flags
67FLAGS "$@" || exit 1
68eval set -- "${FLAGS_ARGV}"
69
70# Die on error
Brian Harring7f175a52012-03-02 05:37:00 -080071switch_to_strict_mode
Will Drewry69563b72010-06-24 16:12:58 -050072
Mike Frysinger94a82df2013-11-26 14:51:50 -050073# N.B. Ordering matters for some of the libraries below, because
74# some of the files contain initialization used by later files.
75. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
Dan Ehrenberg21cee6e2014-11-18 17:29:16 -080076. "${BUILD_LIBRARY_DIR}/disk_layout_util.sh" || exit 1
Mike Frysinger94a82df2013-11-26 14:51:50 -050077
Dan Ehrenbergcdac45f2015-01-16 15:16:03 -080078
Paul Taysom00df6f62012-11-20 12:35:40 -080079rootdigest() {
80 local digest=${table#*root_hexdigest=}
81 echo ${digest% salt*}
82}
83
84salt() {
85 local salt=${table#*salt=}
86 echo ${salt%}
87}
88
89hashstart() {
90 local hash=${table#*hashstart=}
91 echo ${hash% alg*}
92}
93
94# Estimate of sectors used by verity
95# (num blocks) * 32 (bytes per hash) * 2 (overhead) / 512 (bytes per sector)
96veritysize() {
97 echo $((root_fs_blocks * 32 * 2 / 512))
98}
99
Chris Masone175a2692014-01-21 16:06:44 -0800100# Munge the kernel command line.
101# Intended to be overridden by boards that wish to add to the command line.
102# $1 - Configuration file containing boot args.
Bryan Freed17d39bd2015-07-20 14:57:28 -0700103#
104# All kernel command line changes must update the security base lines in
105# the signer. It rejects any settings it does not recognize and breaks the
106# build. So any modify_kernel_command_line() function change here or in a
107# board specific build_kernel_image.sh needs to be reflected in
108# ensure_secure_kernelparams.config.
109# See https://chrome-internal-review.googlesource.com/#/c/216896 as an example.
Chris Masone175a2692014-01-21 16:06:44 -0800110modify_kernel_command_line() {
111 :
112}
113
Dan Ehrenberg21cee6e2014-11-18 17:29:16 -0800114get_base_root() {
115 echo 'PARTUUID=%U/PARTNROFF=1'
116}
117
Steve Fung88897cc2015-03-25 13:38:38 -0700118load_board_specific_script "build_kernel_image.sh"
Albert Chaulk5d190f72013-07-12 11:42:18 -0700119
Dan Ehrenberg21cee6e2014-11-18 17:29:16 -0800120base_root=$(get_base_root)
121
Paul Taysom00df6f62012-11-20 12:35:40 -0800122device_mapper_args=
Will Drewrybcbf1c42010-07-03 10:23:30 -0500123# Even with a rootfs_image, root= is not changed unless specified.
124if [[ -n "${FLAGS_rootfs_image}" && -n "${FLAGS_rootfs_hash}" ]]; then
Will Drewrybcbf1c42010-07-03 10:23:30 -0500125 # Gets the number of blocks. 4096 byte blocks _are_ expected.
Alex Deymo87dced62015-03-03 12:54:58 -0800126 if [[ -n "${FLAGS_rootfs_image_size}" ]]; then
127 root_fs_size=${FLAGS_rootfs_image_size}
Da Zheng87465ea2011-07-30 16:25:28 -0700128 else
Alex Deymo87dced62015-03-03 12:54:58 -0800129 # We try to autodetect the rootfs_image filesystem size.
130 if [[ -f "${FLAGS_rootfs_image}" ]]; then
131 root_fs_size=$(stat -c '%s' ${FLAGS_rootfs_image})
132 elif [[ -b "${FLAGS_rootfs_image}" ]]; then
133 root_fs_type="$(awk -v rootdev="${FLAGS_rootfs_image}" \
134 '$1 == rootdev { print $3 }' /proc/mounts | head -n 1)"
135 case "${root_fs_type}" in
136 squashfs)
137 # unsquashfs returns the size in KiB as a float value with two
138 # decimals, rounded as printf() would do. To avoid corner cases like
139 # when the fractional part of the size in KiB is less than 0.005,
140 # instead of rounding up the value to the nearest 4KiB, we round it
141 # down and add 1 extra 4 KiB block.
142 root_fs_size_kib=$(sudo unsquashfs -stat "${FLAGS_rootfs_image}" |
143 grep -E -o 'Filesystem size [0-9\.]+ Kbytes' |
144 cut -f 3 -d ' ' | cut -f 1 -d '.')
145 root_fs_size=$(( (root_fs_size_kib / 4 + 1) * 4096 ))
146 ;;
147 ext[234])
148 root_fs_blocks=$(sudo dumpe2fs "${FLAGS_rootfs_image}" 2>/dev/null |
149 grep "Block count" |
150 tr -d ' ' |
151 cut -f2 -d:)
152 root_fs_block_sz=$(sudo dumpe2fs "${FLAGS_rootfs_image}" 2>/dev/null |
153 grep "Block size" |
154 tr -d ' ' |
155 cut -f2 -d:)
156 root_fs_size=$(( root_fs_blocks * root_fs_block_sz ))
157 ;;
158 *)
159 die "Unknown root filesystem type ${root_fs_type}."
160 ;;
161 esac
162 else
163 die "Couldn't determine the size of ${FLAGS_rootfs_image}, pass the size \
164with --rootfs_image_size."
165 fi
Da Zheng87465ea2011-07-30 16:25:28 -0700166 fi
Alex Deymo87dced62015-03-03 12:54:58 -0800167 # Verity assumes a 4 KiB block size.
168 if [[ ! $(( root_fs_size % 4096 )) -eq 0 ]]; then
169 die "The root filesystem size (${root_fs_size}) must be a multiple of \
1704 KiB."
Will Drewrybcbf1c42010-07-03 10:23:30 -0500171 fi
Alex Deymo87dced62015-03-03 12:54:58 -0800172 root_fs_blocks=$((root_fs_size / 4096))
173 info "rootfs is ${root_fs_blocks} blocks of 4096 bytes."
Will Drewrybcbf1c42010-07-03 10:23:30 -0500174
Elly Jones9ca3e4c2011-09-26 15:18:19 -0400175 info "Generating root fs hash tree (salt '${FLAGS_verity_salt}')."
Will Drewrybcbf1c42010-07-03 10:23:30 -0500176 # Runs as sudo in case the image is a block device.
Mandeep Singh Baines118692a2011-04-28 13:50:33 -0700177 # First argument to verity is reserved/unused and MUST be 0
Elly Jones5e7a4302011-05-27 16:08:16 -0400178 table=$(sudo verity mode=create \
179 alg=${FLAGS_verity_hash_alg} \
180 payload=${FLAGS_rootfs_image} \
181 payload_blocks=${root_fs_blocks} \
Elly Jonesf4e48332011-09-02 13:25:04 -0400182 hashtree=${FLAGS_rootfs_hash} \
Elly Jones9ca3e4c2011-09-26 15:18:19 -0400183 salt=${FLAGS_verity_salt})
Will Drewry821d07c2010-07-03 17:14:58 -0700184 if [[ -f "${FLAGS_rootfs_hash}" ]]; then
185 sudo chmod a+r "${FLAGS_rootfs_hash}"
186 fi
Paul Taysom5b2c7e92012-09-05 10:13:03 -0700187 # Don't claim the root device unless verity is enabled.
188 # Doing so will claim /dev/sdDP out from under the system.
189 if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then
Paul Taysom00df6f62012-11-20 12:35:40 -0800190 if [[ ${FLAGS_enable_bootcache} -eq ${FLAGS_TRUE} ]]; then
191 base_root='254:0' # major:minor numbers for /dev/dm-0
Paul Taysom00df6f62012-11-20 12:35:40 -0800192 fi
Kenneth Watersed54d932010-09-21 10:29:54 -0700193 table=${table//HASH_DEV/${base_root}}
194 table=${table//ROOT_DEV/${base_root}}
Will Drewrybcbf1c42010-07-03 10:23:30 -0500195 fi
Paul Taysom00df6f62012-11-20 12:35:40 -0800196 verity_dev="vroot none ro 1,${table}"
197 if [[ ${FLAGS_enable_bootcache} -eq ${FLAGS_TRUE} ]]; then
198 signature=$(rootdigest)
199 cachestart=$(($(hashstart) + $(veritysize)))
200 size_limit=512
201 max_trace=20000
202 max_pages=100000
Paul Taysoma59a0b32013-07-24 15:56:18 -0700203 bootcache_args="PARTUUID=%U/PARTNROFF=1"
204 bootcache_args+=" ${cachestart} ${signature} ${size_limit}"
205 bootcache_args+=" ${max_trace} ${max_pages}"
Paul Taysom00df6f62012-11-20 12:35:40 -0800206 bootcache_dev="vboot none ro 1,0 ${cachestart} bootcache ${bootcache_args}"
207 device_mapper_args="dm=\"2 ${bootcache_dev}, ${verity_dev}\""
208 else
209 device_mapper_args="dm=\"1 ${verity_dev}\""
210 fi
211 info "device mapper configuration: ${device_mapper_args}"
Will Drewrybcbf1c42010-07-03 10:23:30 -0500212fi
213
214mkdir -p "${FLAGS_working_dir}"
Will Drewryd6435d42010-10-20 15:37:46 -0500215
216# Only let dm-verity block if rootfs verification is configured.
Paul Taysom5b2c7e92012-09-05 10:13:03 -0700217# By default, we use a firmware enumerated value, but it isn't reliable for
218# production use. If +%d can be added upstream, then we can use:
219# root_dev=PARTUID=uuid+1
Will Drewryd6435d42010-10-20 15:37:46 -0500220dev_wait=0
Dan Ehrenberg21cee6e2014-11-18 17:29:16 -0800221root_dev=${base_root}
Paul Taysom5b2c7e92012-09-05 10:13:03 -0700222if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then
Will Drewryd6435d42010-10-20 15:37:46 -0500223 dev_wait=1
Paul Taysom00df6f62012-11-20 12:35:40 -0800224 if [[ ${FLAGS_enable_bootcache} -eq ${FLAGS_TRUE} ]]; then
225 root_dev=/dev/dm-1
226 else
227 root_dev=/dev/dm-0
228 fi
229else
230 if [[ ${FLAGS_enable_bootcache} -eq ${FLAGS_TRUE} ]]; then
231 die "Having bootcache without verity is not supported"
232 fi
Will Drewryd6435d42010-10-20 15:37:46 -0500233fi
234
Paul Taysoma59a0b32013-07-24 15:56:18 -0700235# kern_guid should eventually be changed to use PARTUUID
Will Drewrybcbf1c42010-07-03 10:23:30 -0500236cat <<EOF > "${FLAGS_working_dir}/boot.config"
Paul Taysom5b2c7e92012-09-05 10:13:03 -0700237root=${root_dev}
Olof Johanssone0b75512011-01-26 14:31:26 -0800238rootwait
239ro
Will Drewry1670d482010-07-09 13:08:38 -0700240dm_verity.error_behavior=${FLAGS_verity_error_behavior}
241dm_verity.max_bios=${FLAGS_verity_max_ios}
Will Drewryd6435d42010-10-20 15:37:46 -0500242dm_verity.dev_wait=${dev_wait}
Paul Taysom00df6f62012-11-20 12:35:40 -0800243${device_mapper_args}
Will Drewrybcbf1c42010-07-03 10:23:30 -0500244${FLAGS_boot_args}
Pawel Osciaka2c23752011-11-15 15:09:45 -0800245vt.global_cursor_default=0
Doug Anderson2dd2e8e2012-01-06 09:32:24 -0800246kern_guid=%U
Will Drewrybcbf1c42010-07-03 10:23:30 -0500247EOF
248
249WORK="${WORK} ${FLAGS_working_dir}/boot.config"
250info "Emitted cross-platform boot params to ${FLAGS_working_dir}/boot.config"
251
Olof Johansson1eafb5a2012-08-01 00:04:30 -0700252# Add common boot options first.
Paul Taysom5e39bb62013-01-18 07:39:25 -0800253config="${FLAGS_working_dir}/config.txt"
254if [[ -n ${FLAGS_enable_serial} ]]; then
255 console=${FLAGS_enable_serial}
256 if [[ ${console} != *,* ]]; then
257 console+=",115200n8"
258 fi
259 cat <<EOF > "${config}"
Paul Taysom5e39bb62013-01-18 07:39:25 -0800260earlyprintk=${console}
261console=tty1
Doug Andersond65edf42014-07-09 15:00:53 -0700262console=${console}
Paul Taysom5e39bb62013-01-18 07:39:25 -0800263EOF
264else
265 cat <<EOF > "${config}"
Sameer Nanda542cb532012-08-22 16:11:12 -0700266console=
Paul Taysom5e39bb62013-01-18 07:39:25 -0800267EOF
268fi
269
270cat <<EOF - "${FLAGS_working_dir}/boot.config" >> "${config}"
Zach Reiznerf09d3d12014-09-24 10:45:19 -0700271loglevel=${FLAGS_loglevel}
Will Drewry69563b72010-06-24 16:12:58 -0500272init=/sbin/init
Olof Johansson1eafb5a2012-08-01 00:04:30 -0700273cros_secure
Paul Taysom984acd72013-04-02 09:41:26 -0700274oops=panic
275panic=-1
Olof Johansson1eafb5a2012-08-01 00:04:30 -0700276EOF
277
278if [[ "${FLAGS_arch}" = "x86" || "${FLAGS_arch}" = "amd64" ]]; then
279 # Legacy BIOS will use the kernel in the rootfs (via syslinux), as will
280 # standard EFI BIOS (via grub, from the EFI System Partition). Chrome OS
281 # BIOS will use a separate signed kernel partition, which we'll create now.
Olof Johanssond7a8aaf2012-08-02 20:35:47 -0700282 cat <<EOF >> "${FLAGS_working_dir}/config.txt"
Will Drewry69563b72010-06-24 16:12:58 -0500283add_efi_memmap
284boot=local
Will Drewry69563b72010-06-24 16:12:58 -0500285noresume
286noswap
287i915.modeset=1
Luigi Semenzato195aebe2010-10-20 17:35:00 -0700288tpm_tis.force=1
289tpm_tis.interrupts=0
Vadim Bendebury8e623f62011-02-28 10:28:31 -0800290nmi_watchdog=panic,lapic
Will Drewry69563b72010-06-24 16:12:58 -0500291EOF
Will Drewrybcbf1c42010-07-03 10:23:30 -0500292 WORK="${WORK} ${FLAGS_working_dir}/config.txt"
Will Drewry69563b72010-06-24 16:12:58 -0500293
Che-Liang Chiou75ac2be2011-02-24 12:00:16 +0800294 bootloader_path="/lib64/bootstub/bootstub.efi"
295 kernel_image="${FLAGS_vmlinuz}"
Gaurav Shahae5d4d22014-05-14 17:10:05 -0700296elif [[ "${FLAGS_arch}" = "arm" || "${FLAGS_arch}" = "mips" ]]; then
Che-Liang Chiou75ac2be2011-02-24 12:00:16 +0800297 WORK="${WORK} ${FLAGS_working_dir}/config.txt"
298
Che-Liang Chiou69faa262011-06-01 11:52:21 +0800299 # arm does not need/have a bootloader in kernel partition
300 dd if="/dev/zero" of="${FLAGS_working_dir}/bootloader.bin" bs=512 count=1
301 WORK="${WORK} ${FLAGS_working_dir}/bootloader.bin"
Che-Liang Chiou75ac2be2011-02-24 12:00:16 +0800302
Che-Liang Chiou69faa262011-06-01 11:52:21 +0800303 bootloader_path="${FLAGS_working_dir}/bootloader.bin"
Che-Liang Chiou75ac2be2011-02-24 12:00:16 +0800304 kernel_image="${FLAGS_vmlinuz/vmlinuz/vmlinux.uimg}"
Che-Liang Chiou75ac2be2011-02-24 12:00:16 +0800305else
306 error "Unknown arch: ${FLAGS_arch}"
307fi
308
David Riley345dc272015-06-22 11:04:09 -0700309# Save the kernel as a .bin to allow it to be automatically extracted as
310# an artifact by cbuildbot. Non .bin's need to be explicitly specified
311# and would require the entire set of artifacts to be specified.
312info "Saving kernel as ${FLAGS_working_dir}/vmlinuz.bin"
313cp ${kernel_image} ${FLAGS_working_dir}/vmlinuz.bin
314
Dan Ehrenbergcdac45f2015-01-16 15:16:03 -0800315for image_type in $(get_image_types); do
316 already_seen_rootfs=0
317 for partition in $(get_partitions ${image_type}); do
318 format=$(get_format ${image_type} "${partition}")
319 if [[ "${format}" == "ubi" ]]; then
320 type=$(get_type ${image_type} "${partition}")
321 # cgpt.py ensures that the rootfs partitions are compatible, in that if
322 # one is ubi then both are, and they have the same number of reserved
323 # blocks. We only want to attach one of them in boot to save time, so
324 # attach %P and get the information for whichever rootfs comes first.
325 if [[ "${type}" == "rootfs" ]]; then
326 if [[ "${already_seen_rootfs}" -ne 0 ]]; then
327 continue
328 fi
329 already_seen_rootfs=1
330 partname='%P'
331 else
332 partname="${partition}"
Dan Ehrenberg21cee6e2014-11-18 17:29:16 -0800333 fi
Dan Ehrenbergcdac45f2015-01-16 15:16:03 -0800334 reserved=$(get_reserved_erase_blocks ${image_type} "${partition}")
335 echo "ubi.mtd=${partname},0,${reserved},${partname}" \
336 >> "${FLAGS_working_dir}/config.txt"
337 fs_format=$(get_filesystem_format ${image_type} "${partition}")
338 if [[ "${fs_format}" != "ubifs" ]]; then
339 echo "ubi.block=${partname},0" >> "${FLAGS_working_dir}/config.txt"
340 fi
Dan Ehrenberg21cee6e2014-11-18 17:29:16 -0800341 fi
Dan Ehrenbergcdac45f2015-01-16 15:16:03 -0800342 done
Dan Ehrenberg21cee6e2014-11-18 17:29:16 -0800343done
344
Gabe Blacke41371c2014-07-29 15:48:40 -0700345config_file="${FLAGS_working_dir}/config.txt"
346modify_kernel_command_line "${config_file}"
347# Create and sign the kernel blob
348vbutil_kernel \
349 --pack "${FLAGS_to}" \
350 --keyblock "${FLAGS_keys_dir}/${FLAGS_keyblock}" \
351 --signprivate "${FLAGS_keys_dir}/${FLAGS_private}" \
352 --version 1 \
353 --config "${config_file}" \
354 --bootloader "${bootloader_path}" \
355 --vmlinuz "${kernel_image}" \
356 --arch "${FLAGS_arch}"
357
358# And verify it.
359vbutil_kernel \
360 --verify "${FLAGS_to}" \
361 --signpubkey "${FLAGS_keys_dir}/${FLAGS_public}"
362
363if [[ -n "${FLAGS_hd_vblock}" ]]; then
364 dd if="${FLAGS_to}" bs=65536 count=1 of="${FLAGS_hd_vblock}"
Will Drewry69563b72010-06-24 16:12:58 -0500365fi
366
367set +e # cleanup failure is a-ok
368
369if [[ ${FLAGS_keep_work} -eq ${FLAGS_FALSE} ]]; then
Will Drewrybcbf1c42010-07-03 10:23:30 -0500370 info "Cleaning up temporary files: ${WORK}"
Will Drewry69563b72010-06-24 16:12:58 -0500371 rm ${WORK}
372 rmdir ${FLAGS_working_dir}
373fi
374
Will Drewrybcbf1c42010-07-03 10:23:30 -0500375info "Kernel partition image emitted: ${FLAGS_to}"
376
377if [[ -f ${FLAGS_rootfs_hash} ]]; then
378 info "Root filesystem hash emitted: ${FLAGS_rootfs_hash}"
379fi