| OLD | NEW |
| (Empty) |
| 1 #!/bin/bash | |
| 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 | |
| 4 # found in the LICENSE file. | |
| 5 # | |
| 6 # Emit scripts to pack and unpack the partitions from a GPT disk image. | |
| 7 | |
| 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. | |
| 10 . "/usr/lib/crosutils/common.sh" | |
| 11 . "/usr/lib/installer/chromeos-common.sh" | |
| 12 | |
| 13 set -e | |
| 14 | |
| 15 # Usage | |
| 16 IMAGE=${1:-} | |
| 17 DIR=${2:-} | |
| 18 if [[ -z "$IMAGE" || -z "$DIR" ]]; then | |
| 19 echo "Usage: $0 GPT_DEVICE DIRECTORY" 1>&2 | |
| 20 exit 1 | |
| 21 fi | |
| 22 | |
| 23 PACK="${DIR}/pack_partitions.sh" | |
| 24 UNPACK="${DIR}/unpack_partitions.sh" | |
| 25 | |
| 26 locate_gpt | |
| 27 | |
| 28 TMP=$(mktemp) | |
| 29 $GPT show "$IMAGE" > $TMP | |
| 30 | |
| 31 HEADER='#!/bin/bash -eu | |
| 32 # File generated by cros_emit_gpt_scripts.sh. Do not edit. | |
| 33 TARGET=${1:-} | |
| 34 if [[ -z "$TARGET" ]]; then | |
| 35 echo "Usage: $0 DEVICE" 1>&2 | |
| 36 exit 1 | |
| 37 fi | |
| 38 set -x' | |
| 39 | |
| 40 echo "$HEADER" > "$PACK" | |
| 41 echo "$HEADER" > "$UNPACK" | |
| 42 cat $TMP | sed -e 's/^/# /' >> "$PACK" | |
| 43 cat $TMP | sed -e 's/^/# /' >> "$UNPACK" | |
| 44 | |
| 45 $GPT show -q "$IMAGE" | \ | |
| 46 while read start size part x; do \ | |
| 47 file="part_$part" | |
| 48 loc="\"\$TARGET\"" | |
| 49 echo "dd if=$loc of=$file bs=512 skip=$start count=$size" \ | |
| 50 >> "$UNPACK" | |
| 51 echo \ | |
| 52 "dd if=$file of=$loc bs=512 seek=$start count=$size conv=notrunc" \ | |
| 53 >> "$PACK" | |
| 54 done | |
| 55 | |
| 56 chmod +x "$PACK" "$UNPACK" | |
| 57 | |
| 58 rm $TMP | |
| OLD | NEW |