| 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 # Load common constants. This should be the first executable line. |
| 9 # The path to common.sh should be relative to your script's location. | 9 # The path to common.sh should be relative to your script's location. |
| 10 . "$(dirname "$0")/common.sh" | 10 . "$(dirname "$0")/common.sh" |
| 11 . "$(dirname "$0")/chromeos-common.sh" | 11 . "$(dirname "$0")/chromeos-common.sh" |
| 12 | 12 |
| 13 set -e | 13 set -e |
| 14 | 14 |
| 15 # Usage | 15 # Usage |
| 16 IMAGE=${1:-} | 16 IMAGE=${1:-} |
| 17 DIR=${2:-} | 17 DIR=${2:-} |
| 18 if [[ -z "$IMAGE" || -z "$DIR" ]]; then | 18 if [[ -z "$IMAGE" || -z "$DIR" ]]; then |
| 19 echo "Usage: $0 GPT_DEVICE DIRECTORY" 1>&2 | 19 echo "Usage: $0 GPT_DEVICE DIRECTORY" 1>&2 |
| 20 exit 1 | 20 exit 1 |
| 21 fi | 21 fi |
| 22 | 22 |
| 23 PACK="${DIR}/pack_partitions.sh" | 23 PACK="${DIR}/pack_partitions.sh" |
| 24 UNPACK="${DIR}/unpack_partitions.sh" | 24 UNPACK="${DIR}/unpack_partitions.sh" |
| 25 | 25 |
| 26 locate_gpt |
| 27 |
| 26 TMP=$(mktemp) | 28 TMP=$(mktemp) |
| 27 sudo $GPT -r show -l "$IMAGE" > $TMP | 29 sudo $GPT -r show -l "$IMAGE" > $TMP |
| 28 | 30 |
| 29 HEADER='#!/bin/sh -eu | 31 HEADER='#!/bin/sh -eu |
| 30 # File generated by emit_gpt_scripts.sh. Do not edit. | 32 # File generated by emit_gpt_scripts.sh. Do not edit. |
| 31 TARGET=${1:-} | 33 TARGET=${1:-} |
| 32 if [[ -z "$TARGET" ]]; then | 34 if [[ -z "$TARGET" ]]; then |
| 33 echo "Usage: $0 DEVICE" 1>&2 | 35 echo "Usage: $0 DEVICE" 1>&2 |
| 34 exit 1 | 36 exit 1 |
| 35 fi | 37 fi |
| (...skipping 12 matching lines...) Expand all Loading... |
| 48 echo "dd if=$loc of=$file bs=512 skip=$start count=$size" \ | 50 echo "dd if=$loc of=$file bs=512 skip=$start count=$size" \ |
| 49 >> "$UNPACK" | 51 >> "$UNPACK" |
| 50 echo \ | 52 echo \ |
| 51 "dd if=$file of=$loc bs=512 seek=$start count=$size conv=notrunc" \ | 53 "dd if=$file of=$loc bs=512 seek=$start count=$size conv=notrunc" \ |
| 52 >> "$PACK" | 54 >> "$PACK" |
| 53 done | 55 done |
| 54 | 56 |
| 55 chmod +x "$PACK" "$UNPACK" | 57 chmod +x "$PACK" "$UNPACK" |
| 56 | 58 |
| 57 rm $TMP | 59 rm $TMP |
| OLD | NEW |