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

Side by Side Diff: mk_memento_images.sh

Issue 3135024: AU: make mk_memento_images not change rootfs (Closed) Base URL: ssh://git@chromiumos-git/crosutils.git
Patch Set: Created 10 years, 4 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 | « cros_generate_update_payload ('k') | no next file » | 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 2
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # This script takes a path to a rootfs.ext2 which was generated by 7 # This script takes a path to a rootfs.ext2 which was generated by
8 # build_image.sh and generates an image that can be used for auto 8 # build_image.sh and generates an image that can be used for auto
9 # update. 9 # update.
10 10
11 set -e 11 set -e
12 12
13 if [ -z "$2" -o -z "$1" ]; then 13 if [ -z "$2" -o -z "$1" ]; then
14 echo "usage: $0 path/to/kernel_partition_img path/to/rootfs_partition_img" 14 echo "usage: $0 path/to/kernel_partition_img path/to/rootfs_partition_img"
15 exit 1 15 exit 1
16 fi 16 fi
17 17
18 if [ "$CROS_GENERATE_UPDATE_PAYLOAD_CALLED" != "1" ]; then
Nick Sanders 2010/08/16 22:28:59 Please don't check this in, it will break the fact
19 echo "This script should only be called from cros_generate_update_payload"
20 echo "Please run that script with --help to see how to use it."
21 exit 1
22 fi
23
18 if [ $(whoami) = "root" ]; then 24 if [ $(whoami) = "root" ]; then
19 echo "running $0 as root which is unneccessary" 25 echo "running $0 as root which is unneccessary"
20 fi 26 fi
21 27
22 KPART="$1" 28 KPART="$1"
23 ROOT_PART="$2" 29 ROOT_PART="$2"
24 30
25 KPART_SIZE=$(stat -c%s "$KPART") 31 KPART_SIZE=$(stat -c%s "$KPART")
26 32
27 # Sanity check size. 33 # Sanity check size.
(...skipping 16 matching lines...) Expand all
44 50
45 # Next, write kernel partition to the out file 51 # Next, write kernel partition to the out file
46 cat "$KPART" >> "$UNCOMPRESSED_OUT_FILE" 52 cat "$KPART" >> "$UNCOMPRESSED_OUT_FILE"
47 53
48 # Sanity check size of output file now 54 # Sanity check size of output file now
49 if [ $(stat -c%s "$UNCOMPRESSED_OUT_FILE") -ne $((8 + $KPART_SIZE)) ]; then 55 if [ $(stat -c%s "$UNCOMPRESSED_OUT_FILE") -ne $((8 + $KPART_SIZE)) ]; then
50 echo "Kernel partition changed size during image generation. Aborting." 56 echo "Kernel partition changed size during image generation. Aborting."
51 exit 1 57 exit 1
52 fi 58 fi
53 59
54 # Copy rootfs aside
55 TMP_ROOTFS=$(mktemp)
56 cp "$ROOT_PART" "$TMP_ROOTFS"
57 ORIGINAL_LABEL=$(/sbin/e2label "$TMP_ROOTFS")
58 NEW_LABEL="A${ORIGINAL_LABEL}"
59 /sbin/tune2fs -L "$NEW_LABEL" "$TMP_ROOTFS"
60
61 # TODO(adlr): Sign TMP_ROOTFS w/ OS vendor's private key
62
63 # Put rootfs into the out file 60 # Put rootfs into the out file
64 cat "$TMP_ROOTFS" >> "$UNCOMPRESSED_OUT_FILE" 61 cat "$ROOT_PART" >> "$UNCOMPRESSED_OUT_FILE"
65
66 rm "$TMP_ROOTFS"
67 62
68 # compress and hash 63 # compress and hash
69 CS_AND_RET_CODES=$(gzip -c "$UNCOMPRESSED_OUT_FILE" | \ 64 CS_AND_RET_CODES=$(gzip -c "$UNCOMPRESSED_OUT_FILE" | \
70 tee "$FINAL_OUT_FILE" | openssl sha1 -binary | \ 65 tee "$FINAL_OUT_FILE" | openssl sha1 -binary | \
71 openssl base64 | tr '\n' ' '; \ 66 openssl base64 | tr '\n' ' '; \
72 echo ${PIPESTATUS[*]}) 67 echo ${PIPESTATUS[*]})
73 EXPECTED_RET_CODES="0 0 0 0 0" 68 EXPECTED_RET_CODES="0 0 0 0 0"
74 set -- $CS_AND_RET_CODES 69 set -- $CS_AND_RET_CODES
75 CALC_CS="$1" 70 CALC_CS="$1"
76 shift 71 shift
77 RET_CODES="$@" 72 RET_CODES="$@"
78 if [ "$RET_CODES" != "$EXPECTED_RET_CODES" ]; then 73 if [ "$RET_CODES" != "$EXPECTED_RET_CODES" ]; then
79 echo compression/hash failed. $RET_CODES 74 echo compression/hash failed. $RET_CODES
80 exit 1 75 exit 1
81 fi 76 fi
82 77
83 rm "$UNCOMPRESSED_OUT_FILE" 78 rm "$UNCOMPRESSED_OUT_FILE"
84 79
85 echo Success. hash is "$CALC_CS" 80 echo Success. hash is "$CALC_CS"
OLDNEW
« no previous file with comments | « cros_generate_update_payload ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698