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" |
(...skipping 27 matching lines...) Expand all Loading... |
38 echo "$HEADER" > "$PACK" | 38 echo "$HEADER" > "$PACK" |
39 echo "$HEADER" > "$UNPACK" | 39 echo "$HEADER" > "$UNPACK" |
40 cat $TMP | sed -e 's/^/# /' >> "$PACK" | 40 cat $TMP | sed -e 's/^/# /' >> "$PACK" |
41 cat $TMP | sed -e 's/^/# /' >> "$UNPACK" | 41 cat $TMP | sed -e 's/^/# /' >> "$UNPACK" |
42 | 42 |
43 sort -n -k 3 $TMP | \ | 43 sort -n -k 3 $TMP | \ |
44 grep 'GPT part -' | \ | 44 grep 'GPT part -' | \ |
45 while read start size part x x x label x; do \ | 45 while read start size part x x x label x; do \ |
46 file="part_$part" | 46 file="part_$part" |
47 loc="\"\$TARGET\"" | 47 loc="\"\$TARGET\"" |
48 echo "sudo dd if=$loc of=$file bs=512 skip=$start count=$size" \ | 48 echo "dd if=$loc of=$file bs=512 skip=$start count=$size" \ |
49 >> "$UNPACK" | 49 >> "$UNPACK" |
50 echo \ | 50 echo \ |
51 "sudo dd if=$file of=$loc bs=512 seek=$start count=$size conv=notrunc" \ | 51 "dd if=$file of=$loc bs=512 seek=$start count=$size conv=notrunc" \ |
52 >> "$PACK" | 52 >> "$PACK" |
53 done | 53 done |
54 | 54 |
55 chmod +x "$PACK" "$UNPACK" | 55 chmod +x "$PACK" "$UNPACK" |
56 | 56 |
57 rm $TMP | 57 rm $TMP |
OLD | NEW |