OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # | 2 # |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 # | 6 # |
7 # Script which ensures that a given image has an up-to-date | 7 # Script which ensures that a given image has an up-to-date |
8 # kernel partition, rootfs integrity hashes, and legacy bootloader configs. | 8 # kernel partition, rootfs integrity hashes, and legacy bootloader configs. |
9 | 9 |
10 # Load common constants. This should be the first executable line. | 10 # Load common constants. This should be the first executable line. |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 --vmlinuz="${FLAGS_rootfs_mountpoint}"/boot/vmlinuz \ | 243 --vmlinuz="${FLAGS_rootfs_mountpoint}"/boot/vmlinuz \ |
244 --usb_disk="${usb_disk}" \ | 244 --usb_disk="${usb_disk}" \ |
245 ${bootloader_to_flags} \ | 245 ${bootloader_to_flags} \ |
246 $kernel_part | 246 $kernel_part |
247 | 247 |
248 trap - EXIT | 248 trap - EXIT |
249 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${FLAGS_rootfs_mountpoint}" \ | 249 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${FLAGS_rootfs_mountpoint}" \ |
250 -s "${FLAGS_statefulfs_mountpoint}" | 250 -s "${FLAGS_statefulfs_mountpoint}" |
251 } | 251 } |
252 | 252 |
| 253 verify_image_rootfs() { |
| 254 local image=$1 |
| 255 local rootfs_offset="$(partoffset ${image} 3)" |
| 256 local rootfs_size="$(partsize ${image} 3)" |
| 257 |
| 258 local rootfs_tmp_file=$(mktemp) |
| 259 trap "rm ${rootfs_tmp_file}" EXIT |
| 260 sudo dd if="${image}" of="${rootfs_tmp_file}" bs=512 skip="${rootfs_offset}" |
| 261 |
| 262 # This flips the read-only compatibility flag, so that |
| 263 # e2fsck does not complain about unknown file system capabilities. |
| 264 enable_rw_mount "${rootfs_tmp_file}" |
| 265 info "Running e2fsck to check root file system for errors" |
| 266 sudo e2fsck -fn "${rootfs_tmp_file}" || |
| 267 die "Root file system has errors, please ensure boot.desc and/or \ |
| 268 command line parameters are correct" |
| 269 } |
| 270 |
253 # Use default of current image location if the output dir doesn't exist. | 271 # Use default of current image location if the output dir doesn't exist. |
254 if [ ! -d ${FLAGS_output_dir} ]; then | 272 if [ ! -d ${FLAGS_output_dir} ]; then |
255 warn "Output dir not found, using ${IMAGE_DIR}." | 273 warn "Output dir not found, using ${IMAGE_DIR}." |
256 FLAGS_output_dir="${IMAGE_DIR}" | 274 FLAGS_output_dir="${IMAGE_DIR}" |
257 FLAGS_rootfs_hash="${IMAGE_DIR}/rootfs.hash" | 275 FLAGS_rootfs_hash="${IMAGE_DIR}/rootfs.hash" |
258 FLAGS_rootfs_mountpoint="${IMAGE_DIR}/rootfs_dir" | 276 FLAGS_rootfs_mountpoint="${IMAGE_DIR}/rootfs_dir" |
259 FLAGS_statefulfs_mountpoint="${IMAGE_DIR}/stateful_dir" | 277 FLAGS_statefulfs_mountpoint="${IMAGE_DIR}/stateful_dir" |
260 FLAGS_espfs_mountpoint="${IMAGE_DIR}/esp" | 278 FLAGS_espfs_mountpoint="${IMAGE_DIR}/esp" |
261 fi | 279 fi |
262 | 280 |
263 # Create the directories if they don't exist. | 281 # Create the directories if they don't exist. |
264 mkdir -p ${FLAGS_rootfs_mountpoint} | 282 mkdir -p ${FLAGS_rootfs_mountpoint} |
265 mkdir -p ${FLAGS_statefulfs_mountpoint} | 283 mkdir -p ${FLAGS_statefulfs_mountpoint} |
266 mkdir -p ${FLAGS_espfs_mountpoint} | 284 mkdir -p ${FLAGS_espfs_mountpoint} |
267 | 285 |
268 make_image_bootable ${IMAGE} | 286 make_image_bootable "${IMAGE}" |
| 287 verify_image_rootfs "${IMAGE}" |
269 | 288 |
270 if [ ${FLAGS_cleanup_dirs} -eq ${FLAGS_TRUE} ]; then | 289 if [ ${FLAGS_cleanup_dirs} -eq ${FLAGS_TRUE} ]; then |
271 rmdir ${FLAGS_rootfs_mountpoint} | 290 rmdir ${FLAGS_rootfs_mountpoint} |
272 rmdir ${FLAGS_statefulfs_mountpoint} | 291 rmdir ${FLAGS_statefulfs_mountpoint} |
273 rmdir ${FLAGS_espfs_mountpoint} | 292 rmdir ${FLAGS_espfs_mountpoint} |
274 fi | 293 fi |
OLD | NEW |