OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 # | 5 # |
6 # Emit scripts to pack and unpack the partitions from a GPT disk image. | 6 # Emit scripts to pack and unpack the partitions from a GPT disk image. |
7 | 7 |
8 # Load common constants. This should be the first executable line. | 8 # --- BEGIN COMMON.SH BOILERPLATE --- |
9 # The path to common.sh should be relative to your script's location. | 9 # Load common CrOS utilities. Inside the chroot this file is installed in |
10 . "$(dirname "$0")/common.sh" | 10 # /usr/lib/crosutils. Outside the chroot we find it relative to the script's |
11 . "$(dirname "$0")/chromeos-common.sh" | 11 # location. |
| 12 find_common_sh() { |
| 13 local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) |
| 14 local path |
| 15 |
| 16 SCRIPT_ROOT= |
| 17 for path in "${common_paths[@]}"; do |
| 18 if [ -r "${path}/common.sh" ]; then |
| 19 SCRIPT_ROOT=${path} |
| 20 break |
| 21 fi |
| 22 done |
| 23 } |
| 24 |
| 25 find_common_sh |
| 26 . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) |
| 27 # --- END COMMON.SH BOILERPLATE --- |
| 28 |
| 29 # Need to be inside the chroot to load chromeos-common.sh |
| 30 assert_inside_chroot |
| 31 |
| 32 # Load functions and constants for chromeos-install |
| 33 . "/usr/lib/installer/chromeos-common.sh" || \ |
| 34 die "Unable to load /usr/lib/installer/chromeos-common.sh" |
12 | 35 |
13 set -e | 36 set -e |
14 | 37 |
15 # Usage | 38 # Usage |
16 IMAGE=${1:-} | 39 IMAGE=${1:-} |
17 DIR=${2:-} | 40 DIR=${2:-} |
18 if [[ -z "$IMAGE" || -z "$DIR" ]]; then | 41 if [[ -z "$IMAGE" || -z "$DIR" ]]; then |
19 echo "Usage: $0 GPT_DEVICE DIRECTORY" 1>&2 | 42 echo "Usage: $0 GPT_DEVICE DIRECTORY" 1>&2 |
20 exit 1 | 43 exit 1 |
21 fi | 44 fi |
(...skipping 27 matching lines...) Expand all Loading... |
49 echo "dd if=$loc of=$file bs=512 skip=$start count=$size" \ | 72 echo "dd if=$loc of=$file bs=512 skip=$start count=$size" \ |
50 >> "$UNPACK" | 73 >> "$UNPACK" |
51 echo \ | 74 echo \ |
52 "dd if=$file of=$loc bs=512 seek=$start count=$size conv=notrunc" \ | 75 "dd if=$file of=$loc bs=512 seek=$start count=$size conv=notrunc" \ |
53 >> "$PACK" | 76 >> "$PACK" |
54 done | 77 done |
55 | 78 |
56 chmod +x "$PACK" "$UNPACK" | 79 chmod +x "$PACK" "$UNPACK" |
57 | 80 |
58 rm $TMP | 81 rm $TMP |
OLD | NEW |