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

Side by Side Diff: src/scripts/emit_gpt_scripts.sh

Issue 1567013: Clean up temporary files and directories left by build_image, etc. (Closed)
Patch Set: Emit scripts to pack/unpack the image. Created 10 years, 8 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 | « src/scripts/build_image ('k') | src/scripts/image_to_usb.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash -x
adlr 2010/04/01 02:14:12 take out -x
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 . "$(dirname "$0")/common.sh"
11
12 set -e
13
14 # Usage
15 IMAGE=${1:-}
16 DIR=${2:-}
17 if [[ -z "$IMAGE" || -z "$DIR" ]]; then
18 echo "Usage: $0 GPT_DEVICE DIRECTORY" 1>&2
19 exit 1
20 fi
21
22 # We need to locate the gpt tool. It should already be installed in the build
adlr 2010/04/01 02:14:12 can you just include chromeos-common.sh to get thi
23 # chroot, but some of these functions may be invoked outside the chroot (by
24 # image_to_usb or similar), so we need to find it.
25 GPT=$(which gpt 2>/dev/null) || /bin/true
26 if [ -z "$GPT" ]; then
27 if [ -x "${DEFAULT_CHROOT_DIR:-}/usr/bin/gpt" ]; then
28 GPT="${DEFAULT_CHROOT_DIR:-}/usr/bin/gpt"
29 else
30 echo "can't find gpt tool" 1>&2
31 exit 1
32 fi
33 fi
34
35 PACK="${DIR}/pack_partitions.sh"
36 UNPACK="${DIR}/unpack_partitions.sh"
37
38 TMP=$(mktemp)
39 sudo $GPT -r show -l "$IMAGE" > $TMP
40
41 HEADER='#!/bin/sh -eu
42 # generated file. do not edit.
adlr 2010/04/01 02:14:12 perhaps say, "File generated by emit_gpt_scripts.s
43 TARGET=${1:-}
44 if [[ -z "$TARGET" ]]; then
45 echo "Usage: $0 DEVICE" 1>&2
46 exit 1
47 fi
48 set -x'
49
50 echo "$HEADER" > "$PACK"
51 echo "$HEADER" > "$UNPACK"
52 cat $TMP | sed -e 's/^/# /' >> "$PACK"
53 cat $TMP | sed -e 's/^/# /' >> "$UNPACK"
54
55 sort -n -k 3 $TMP | \
56 grep 'GPT part -' | \
57 while read start size part x x x label x; do \
58 file="part_$part"
59 loc="\"\$TARGET\""
60 echo "sudo dd if=$loc of=$file bs=512 skip=$start count=$size" \
61 >> "$UNPACK"
62 echo "sudo dd if=$file of=$loc bs=512 seek=$start count=$size conv=notrunc" \
adlr 2010/04/01 02:14:12 80 cols
63 >> "$PACK"
64 done
65
66 chmod +x "$PACK" "$UNPACK"
67
68 rm $TMP
OLDNEW
« no previous file with comments | « src/scripts/build_image ('k') | src/scripts/image_to_usb.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698