Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: emit_gpt_scripts.sh

Issue 2792011: Use new cgpt tool when creating images and the pack/unpack scripts. (Closed) Base URL: ssh://git@chromiumos-git//crosutils.git
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos_version.sh ('k') | mount_gpt_image.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 26 locate_gpt
27 27
28 TMP=$(mktemp) 28 TMP=$(mktemp)
29 sudo $GPT -r show -l "$IMAGE" > $TMP 29 $GPT show "$IMAGE" > $TMP
30 30
31 HEADER='#!/bin/sh -eu 31 HEADER='#!/bin/sh -eu
32 # File generated by emit_gpt_scripts.sh. Do not edit. 32 # File generated by emit_gpt_scripts.sh. Do not edit.
33 TARGET=${1:-} 33 TARGET=${1:-}
34 if [[ -z "$TARGET" ]]; then 34 if [[ -z "$TARGET" ]]; then
35 echo "Usage: $0 DEVICE" 1>&2 35 echo "Usage: $0 DEVICE" 1>&2
36 exit 1 36 exit 1
37 fi 37 fi
38 set -x' 38 set -x'
39 39
40 echo "$HEADER" > "$PACK" 40 echo "$HEADER" > "$PACK"
41 echo "$HEADER" > "$UNPACK" 41 echo "$HEADER" > "$UNPACK"
42 cat $TMP | sed -e 's/^/# /' >> "$PACK" 42 cat $TMP | sed -e 's/^/# /' >> "$PACK"
43 cat $TMP | sed -e 's/^/# /' >> "$UNPACK" 43 cat $TMP | sed -e 's/^/# /' >> "$UNPACK"
44 44
45 sort -n -k 3 $TMP | \ 45 $GPT show -q "$IMAGE" | \
46 grep 'GPT part -' | \ 46 while read start size part x; do \
47 while read start size part x x x label x; do \
48 file="part_$part" 47 file="part_$part"
49 loc="\"\$TARGET\"" 48 loc="\"\$TARGET\""
50 echo "dd if=$loc of=$file bs=512 skip=$start count=$size" \ 49 echo "dd if=$loc of=$file bs=512 skip=$start count=$size" \
51 >> "$UNPACK" 50 >> "$UNPACK"
52 echo \ 51 echo \
53 "dd if=$file of=$loc bs=512 seek=$start count=$size conv=notrunc" \ 52 "dd if=$file of=$loc bs=512 seek=$start count=$size conv=notrunc" \
54 >> "$PACK" 53 >> "$PACK"
55 done 54 done
56 55
57 chmod +x "$PACK" "$UNPACK" 56 chmod +x "$PACK" "$UNPACK"
58 57
59 rm $TMP 58 rm $TMP
OLDNEW
« no previous file with comments | « chromeos_version.sh ('k') | mount_gpt_image.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698