OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 # | 4 # |
5 # This contains common constants and functions for installer scripts. This must | 5 # This contains common constants and functions for installer scripts. This must |
6 # evaluate properly for both /bin/bash and /bin/sh, since it's used both to | 6 # evaluate properly for both /bin/bash and /bin/sh, since it's used both to |
7 # create the initial image at compile time and to install or upgrade a running | 7 # create the initial image at compile time and to install or upgrade a running |
8 # image. | 8 # image. |
9 | 9 |
10 # Here are the GUIDs we'll be using to identify various partitions. NOTE: The | 10 # Here are the GUIDs we'll be using to identify various partitions. NOTE: The |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 # START_ROOTFS_B | 123 # START_ROOTFS_B |
124 # START_STATEFUL | 124 # START_STATEFUL |
125 install_gpt() { | 125 install_gpt() { |
126 local outdev=$1 | 126 local outdev=$1 |
127 local rootfs_img=$2 | 127 local rootfs_img=$2 |
128 local kernel_img=$3 | 128 local kernel_img=$3 |
129 local stateful_img=$4 | 129 local stateful_img=$4 |
130 local pmbrcode=$5 | 130 local pmbrcode=$5 |
131 local esp_img=$6 | 131 local esp_img=$6 |
132 local force_full="${7:-}" | 132 local force_full="${7:-}" |
| 133 local recovery="${8:-}" |
133 | 134 |
134 # The gpt tool requires a fixed-size target to work on, so we may have to | 135 # The gpt tool requires a fixed-size target to work on, so we may have to |
135 # create a file of the appropriate size. Let's figure out what that size is | 136 # create a file of the appropriate size. Let's figure out what that size is |
136 # now. The full partition layout will look something like this (indented | 137 # now. The full partition layout will look something like this (indented |
137 # lines indicate reserved regions that do not have any useful content at the | 138 # lines indicate reserved regions that do not have any useful content at the |
138 # moment). | 139 # moment). |
139 # | 140 # |
140 # PMBR (512 bytes) | 141 # PMBR (512 bytes) |
141 # Primary GPT Header (512 bytes) | 142 # Primary GPT Header (512 bytes) |
142 # Primary GPT Table (16K) | 143 # Primary GPT Table (16K) |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 NUM_KERN_SECTORS=$(roundup $(numsectors $kernel_img)) | 246 NUM_KERN_SECTORS=$(roundup $(numsectors $kernel_img)) |
246 local num_kern_a_sectors=$NUM_KERN_SECTORS | 247 local num_kern_a_sectors=$NUM_KERN_SECTORS |
247 local num_kern_b_sectors=1 | 248 local num_kern_b_sectors=1 |
248 NUM_ROOTFS_SECTORS=$(roundup $(numsectors $rootfs_img)) | 249 NUM_ROOTFS_SECTORS=$(roundup $(numsectors $rootfs_img)) |
249 local num_rootfs_a_sectors=$NUM_ROOTFS_SECTORS | 250 local num_rootfs_a_sectors=$NUM_ROOTFS_SECTORS |
250 local num_rootfs_b_sectors=1 | 251 local num_rootfs_b_sectors=1 |
251 NUM_OEM_SECTORS=$max_oem_sectors | 252 NUM_OEM_SECTORS=$max_oem_sectors |
252 NUM_ESP_SECTORS=$(roundup $(numsectors $esp_img)) | 253 NUM_ESP_SECTORS=$(roundup $(numsectors $esp_img)) |
253 NUM_RESERVED_SECTORS=1 | 254 NUM_RESERVED_SECTORS=1 |
254 | 255 |
| 256 # For recovery image, use max sizes and create both A & B images |
| 257 if [ ${FLAGS_recovery} -eq $FLAGS_TRUE ]; then |
| 258 NUM_KERN_SECTORS=$max_kern_sectors |
| 259 num_kern_a_sectors=$NUM_KERN_SECTORS |
| 260 num_kern_b_sectors=$NUM_KERN_SECTORS |
| 261 |
| 262 NUM_ROOTFS_SECTORS=$max_rootfs_sectors |
| 263 num_rootfs_a_sectors=$NUM_ROOTFS_SECTORS |
| 264 num_rootfs_b_sectors=$NUM_ROOTFS_SECTORS |
| 265 fi |
| 266 |
255 START_KERN_A=$start_useful | 267 START_KERN_A=$start_useful |
256 START_ROOTFS_A=$(($START_KERN_A + $NUM_KERN_SECTORS)) | 268 START_ROOTFS_A=$(($START_KERN_A + $NUM_KERN_SECTORS)) |
257 START_STATEFUL=$(($START_ROOTFS_A + $NUM_ROOTFS_SECTORS)) | 269 START_STATEFUL=$(($START_ROOTFS_A + $NUM_ROOTFS_SECTORS)) |
258 START_OEM=$(($START_STATEFUL + $NUM_STATEFUL_SECTORS)) | 270 START_OEM=$(($START_STATEFUL + $NUM_STATEFUL_SECTORS)) |
259 START_ESP=$(($START_OEM + $NUM_OEM_SECTORS)) | 271 START_ESP=$(($START_OEM + $NUM_OEM_SECTORS)) |
260 START_KERN_B=$(($START_ESP + $NUM_ESP_SECTORS)) | 272 START_KERN_B=$(($START_ESP + $NUM_ESP_SECTORS)) |
261 START_ROOTFS_B=$((START_KERN_B + $num_kern_b_sectors)) | 273 START_ROOTFS_B=$(($START_KERN_B + $num_kern_b_sectors)) |
262 START_RESERVED=$(($START_ROOTFS_B + $num_rootfs_b_sectors)) | 274 START_RESERVED=$(($START_ROOTFS_B + $num_rootfs_b_sectors)) |
263 | 275 |
264 # For minimal install, we're not worried about the secondary GPT header | 276 # For minimal install, we're not worried about the secondary GPT header |
265 # being at the end of the device because we're almost always writing to a | 277 # being at the end of the device because we're almost always writing to a |
266 # file. If that's not true, the secondary will just be invalid. | 278 # file. If that's not true, the secondary will just be invalid. |
267 local start_gpt_footer=$(($START_RESERVED + $NUM_RESERVED_SECTORS)) | 279 local start_gpt_footer=$(($START_RESERVED + $NUM_RESERVED_SECTORS)) |
268 local end_useful=$start_gpt_footer | 280 local end_useful=$start_gpt_footer |
269 | 281 |
270 local total_sectors=$(($start_gpt_footer + $num_footer_sectors)) | 282 local total_sectors=$(($start_gpt_footer + $num_footer_sectors)) |
271 | 283 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 # The scripts that source this file typically want to use the root password as | 503 # The scripts that source this file typically want to use the root password as |
492 # confirmation, unless the --run_as_root flag is given. | 504 # confirmation, unless the --run_as_root flag is given. |
493 dont_run_as_root() { | 505 dont_run_as_root() { |
494 if [ $(id -u) -eq "0" -a "${FLAGS_run_as_root}" -eq "${FLAGS_FALSE}" ] | 506 if [ $(id -u) -eq "0" -a "${FLAGS_run_as_root}" -eq "${FLAGS_FALSE}" ] |
495 then | 507 then |
496 echo "Note: You must be the 'chronos' user to run this script. Unless" | 508 echo "Note: You must be the 'chronos' user to run this script. Unless" |
497 echo "you pass --run_as_root and run as root." | 509 echo "you pass --run_as_root and run as root." |
498 exit 1 | 510 exit 1 |
499 fi | 511 fi |
500 } | 512 } |
OLD | NEW |