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

Side by Side Diff: bin/cros_mk_memento_images.sh

Issue 6413012: chromeos-installer: delete unused files (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/installer.git@master
Patch Set: Created 9 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « bin/cros_make_image_bootable ('k') | bin/cros_mod_image_for_dev_recovery.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
2
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
5 # found in the LICENSE file.
6
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
9 # update.
10
11 set -e
12
13 if [ -z "$2" -o -z "$1" ]; then
14 echo "usage: $0 path/to/kernel_partition_img path/to/rootfs_partition_img"
15 exit 1
16 fi
17
18 if [ "$CROS_GENERATE_UPDATE_PAYLOAD_CALLED" != "1" ]; then
19 echo "WARNING:"
20 echo "This script should only be called from cros_generate_update_payload"
21 echo "Please run that script with --help to see how to use it."
22 fi
23
24 if [ $(whoami) = "root" ]; then
25 echo "running $0 as root which is unneccessary"
26 fi
27
28 KPART="$1"
29 ROOT_PART="$2"
30
31 KPART_SIZE=$(stat -c%s "$KPART")
32
33 # Sanity check size.
34 if [ "$KPART_SIZE" -gt $((16 * 1024 * 1024)) ]; then
35 echo "Kernel partition size ($KPART_SIZE bytes) greater than 16 MiB."
36 echo "That's too big."
37 exit 1
38 fi
39
40 FINAL_OUT_FILE=$(dirname "$1")/update.gz
41 UNCOMPRESSED_OUT_FILE="$FINAL_OUT_FILE.uncompressed"
42
43 # First, write size of kernel partition in big endian as uint64 to out file
44 # printf converts it to a number like 00000000003d0900. sed converts it to:
45 # \\x00\\x00\\x00\\x00\\x00\\x3d\\x09\\x00, then xargs converts it to binary
46 # with echo.
47 printf %016x "$KPART_SIZE" | \
48 sed 's/\([0-9a-f][0-9a-f]\)/\\\\x\1/g' | \
49 xargs echo -ne > "$UNCOMPRESSED_OUT_FILE"
50
51 # Next, write kernel partition to the out file
52 cat "$KPART" >> "$UNCOMPRESSED_OUT_FILE"
53
54 # Sanity check size of output file now
55 if [ $(stat -c%s "$UNCOMPRESSED_OUT_FILE") -ne $((8 + $KPART_SIZE)) ]; then
56 echo "Kernel partition changed size during image generation. Aborting."
57 exit 1
58 fi
59
60 # Put rootfs into the out file
61 cat "$ROOT_PART" >> "$UNCOMPRESSED_OUT_FILE"
62
63 # compress and hash
64 CS_AND_RET_CODES=$(gzip -c "$UNCOMPRESSED_OUT_FILE" | \
65 tee "$FINAL_OUT_FILE" | openssl sha1 -binary | \
66 openssl base64 | tr '\n' ' '; \
67 echo ${PIPESTATUS[*]})
68 EXPECTED_RET_CODES="0 0 0 0 0"
69 set -- $CS_AND_RET_CODES
70 CALC_CS="$1"
71 shift
72 RET_CODES="$@"
73 if [ "$RET_CODES" != "$EXPECTED_RET_CODES" ]; then
74 echo compression/hash failed. $RET_CODES
75 exit 1
76 fi
77
78 rm "$UNCOMPRESSED_OUT_FILE"
79
80 echo Success. hash is "$CALC_CS"
OLDNEW
« no previous file with comments | « bin/cros_make_image_bootable ('k') | bin/cros_mod_image_for_dev_recovery.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698