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 # This script modifies a base image to act as a recovery installer. | 7 # This script modifies a base image to act as a recovery installer. |
8 # If a developer payload is supplied, it will be used. | 8 # If a developer payload is supplied, it will be used. |
9 # It is very straight forward, top to bottom to show clearly what is | 9 # It is very straight forward, top to bottom to show clearly what is |
10 # little is needed to create a developer shim to run a signed script. | 10 # little is needed to create a developer shim to run a signed script. |
11 | 11 |
12 # Load common constants. This should be the first executable line. | 12 # --- BEGIN COMMON.SH BOILERPLATE --- |
13 # The path to common.sh should be relative to your script's location. | 13 # Load common CrOS utilities. Inside the chroot this file is installed in |
14 . "$(dirname "$0")/common.sh" | 14 # /usr/lib/crosutils. Outside the chroot we find it relative to the script's |
| 15 # location. |
| 16 find_common_sh() { |
| 17 local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) |
| 18 local path |
| 19 |
| 20 SCRIPT_ROOT= |
| 21 for path in "${common_paths[@]}"; do |
| 22 if [ -r "${path}/common.sh" ]; then |
| 23 SCRIPT_ROOT=${path} |
| 24 break |
| 25 fi |
| 26 done |
| 27 } |
| 28 |
| 29 find_common_sh |
| 30 . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) |
| 31 # --- END COMMON.SH BOILERPLATE --- |
| 32 |
| 33 # Need to be inside the chroot to load chromeos-common.sh |
| 34 assert_inside_chroot |
15 | 35 |
16 # Load functions and constants for chromeos-install | 36 # Load functions and constants for chromeos-install |
17 . "$(dirname "$0")/chromeos-common.sh" | 37 . "/usr/lib/installer/chromeos-common.sh" || \ |
| 38 die "Unable to load /usr/lib/installer/chromeos-common.sh" |
18 | 39 |
19 DEFINE_integer statefulfs_size 2 \ | 40 DEFINE_integer statefulfs_size 2 \ |
20 "Number of mebibytes to use for the stateful filesystem" | 41 "Number of mebibytes to use for the stateful filesystem" |
21 DEFINE_string developer_private_key \ | 42 DEFINE_string developer_private_key \ |
22 "/usr/share/vboot/devkeys/kernel_data_key.vbprivk" \ | 43 "/usr/share/vboot/devkeys/kernel_data_key.vbprivk" \ |
23 "Path to the developer's private key" | 44 "Path to the developer's private key" |
24 DEFINE_string developer_keyblock \ | 45 DEFINE_string developer_keyblock \ |
25 "/usr/share/vboot/devkeys/kernel.keyblock" \ | 46 "/usr/share/vboot/devkeys/kernel.keyblock" \ |
26 "Path to the developer's keyblock" | 47 "Path to the developer's keyblock" |
27 DEFINE_string developer_script "" \ | 48 DEFINE_string developer_script "" \ |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 $sudo dd if=$FLAGS_kernel_image of=$FLAGS_image bs=512 conv=notrunc \ | 134 $sudo dd if=$FLAGS_kernel_image of=$FLAGS_image bs=512 conv=notrunc \ |
114 seek=$offset count=$kernel_sectors | 135 seek=$offset count=$kernel_sectors |
115 # The kernel will ignore GPT without a legacymbr. | 136 # The kernel will ignore GPT without a legacymbr. |
116 PMBRCODE=$(readlink -f /usr/share/syslinux/gptmbr.bin) | 137 PMBRCODE=$(readlink -f /usr/share/syslinux/gptmbr.bin) |
117 # Have it legacy boot off of stateful, not that it should matter. | 138 # Have it legacy boot off of stateful, not that it should matter. |
118 $sudo $GPT boot -p -b "$PMBRCODE" -i 1 $FLAGS_image 1>&2 | 139 $sudo $GPT boot -p -b "$PMBRCODE" -i 1 $FLAGS_image 1>&2 |
119 | 140 |
120 $sudo $GPT show $FLAGS_image | 141 $sudo $GPT show $FLAGS_image |
121 | 142 |
122 echo "Emitted $FLAGS_image successfully!" | 143 echo "Emitted $FLAGS_image successfully!" |
OLD | NEW |