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

Side by Side Diff: make_factory_package.sh

Issue 4824003: crosutils: refine memento image / factory package creation (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git@master
Patch Set: Created 10 years, 1 month 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 | « image_common.sh ('k') | mk_memento_images.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 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 # Script to generate a factory install partition set and miniomaha.conf 7 # Script to generate a factory install partition set and miniomaha.conf
8 # file from a release image and a factory image. This creates a server 8 # file from a release image and a factory image. This creates a server
9 # configuration that can be installed using a factory install shim. 9 # configuration that can be installed using a factory install shim.
10 # 10 #
11 # miniomaha lives in src/platform/dev/ and miniomaha partition sets live 11 # miniomaha lives in src/platform/dev/ and miniomaha partition sets live
12 # in src/platform/dev/static. 12 # in src/platform/dev/static.
13 13
14 # Load common constants. This should be the first executable line. 14 # Load common constants. This should be the first executable line.
15 # The path to common.sh should be relative to your script's location. 15 # The path to common.sh should be relative to your script's location.
16 . "$(dirname "$0")/common.sh" 16 . "$(dirname "$0")/common.sh"
17 17
18 # Load functions and constants for chromeos-install 18 # Load functions and constants for chromeos-install
19 . "$(dirname "$0")/chromeos-common.sh" 19 . "$(dirname "$0")/chromeos-common.sh"
20 20
21 # Load functions designed for image processing
22 . "$(dirname "$0")/image_common.sh"
23
21 get_default_board 24 get_default_board
22 25
23 # Flags 26 # Flags
24 DEFINE_string board "${DEFAULT_BOARD}" "Board for which the image was built" 27 DEFINE_string board "${DEFAULT_BOARD}" "Board for which the image was built"
25 DEFINE_string factory "" \ 28 DEFINE_string factory "" \
26 "Directory and file containing factory image: /path/chromiumos_test_image.bin" 29 "Directory and file containing factory image: /path/chromiumos_test_image.bin"
27 DEFINE_string firmware_updater "" \ 30 DEFINE_string firmware_updater "" \
28 "If set, include the firmware shellball into the server configuration" 31 "If set, include the firmware shellball into the server configuration"
29 DEFINE_string release "" \ 32 DEFINE_string release "" \
30 "Directory and file containing release image: /path/chromiumos_image.bin" 33 "Directory and file containing release image: /path/chromiumos_image.bin"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 91 }
89 92
90 prepare_dir() { 93 prepare_dir() {
91 sudo rm -rf rootfs-test.gz 94 sudo rm -rf rootfs-test.gz
92 sudo rm -rf rootfs-release.gz 95 sudo rm -rf rootfs-release.gz
93 rm -rf efi.gz 96 rm -rf efi.gz
94 rm -rf oem.gz 97 rm -rf oem.gz
95 rm -rf state.gz 98 rm -rf state.gz
96 } 99 }
97 100
101 compress_and_hash_memento_image() {
102 local input_file="$1"
103
104 if has_part_tools; then
105 sudo "${SCRIPTS_DIR}/mk_memento_images.sh" "$input_file" 2 3 |
106 grep hash |
107 awk '{print $4}'
108 else
109 sudo "${SCRIPTS_DIR}/mk_memento_images.sh" part_2 part_3 |
110 grep hash |
111 awk '{print $4}'
112 fi
113 }
114
115 compress_and_hash_file() {
116 local input_file="$1"
117 local output_file="$2"
118
119 if [ -z "$input_file" ]; then
120 # Runs as a pipe processor
121 gzip_compress -c -9 |
122 tee "$output_file" |
123 openssl sha1 -binary |
124 openssl base64
125 else
126 gzip_compress -c -9 "$input_file" |
127 tee "$output_file" |
128 openssl sha1 -binary |
129 openssl base64
130 fi
131 }
132
133 compress_and_hash_partition() {
134 local input_file="$1"
135 local part_num="$2"
136 local output_file="$3"
137
138 if has_part_tools; then
139 dump_partition "$input_file" "$part_num" |
140 compress_and_hash_file "" "$output_file"
141 else
142 gzip_compress -c -9 "part_$part_num" |
143 compress_and_hash_file "" "$output_file"
144 fi
145 }
98 146
99 # Clean up stale config and data files. 147 # Clean up stale config and data files.
100 prepare_omaha 148 prepare_omaha
101 149
102 # Get the release image. 150 # Get the release image.
103 pushd ${RELEASE_DIR} > /dev/null 151 pushd ${RELEASE_DIR} > /dev/null
104 echo "Generating omaha release image from ${FLAGS_release}" 152 echo "Generating omaha release image from ${FLAGS_release}"
105 echo "Generating omaha factory image from ${FLAGS_factory}" 153 echo "Generating omaha factory image from ${FLAGS_factory}"
106 echo "Output omaha image to ${OMAHA_DATA_DIR}" 154 echo "Output omaha image to ${OMAHA_DATA_DIR}"
107 echo "Output omaha config to ${OMAHA_DIR}/miniomaha.conf" 155 echo "Output omaha config to ${OMAHA_DIR}/miniomaha.conf"
108 156
109 prepare_dir 157 prepare_dir
110 158
111 sudo ./unpack_partitions.sh ${RELEASE_IMAGE} &> /dev/null 159 if ! has_part_tools; then
Nick Sanders 2010/11/12 18:05:41 FYI You can avoid running unpack partitions with c
112 release_hash=`sudo ${SCRIPTS_DIR}/mk_memento_images.sh part_2 part_3 \ 160 echo "Unpacking image ${RELEASE_IMAGE} ..." >&2
113 | grep hash | awk '{print $4}'` 161 sudo ./unpack_partitions.sh "${RELEASE_IMAGE}" 2>/dev/null
162 fi
163
164 release_hash="$(compress_and_hash_memento_image "${RELEASE_IMAGE}")"
114 sudo chmod a+rw update.gz 165 sudo chmod a+rw update.gz
115 mv update.gz rootfs-release.gz 166 mv update.gz rootfs-release.gz
116 mv rootfs-release.gz ${OMAHA_DATA_DIR} 167 mv rootfs-release.gz ${OMAHA_DATA_DIR}
117 echo "release: ${release_hash}" 168 echo "release: ${release_hash}"
118 169
119 cat part_8 | gzip -9 > oem.gz 170 oem_hash="$(compress_and_hash_partition "${RELEASE_IMAGE}" 8 "oem.gz")"
120 oem_hash=`cat oem.gz | openssl sha1 -binary | openssl base64`
121 mv oem.gz ${OMAHA_DATA_DIR} 171 mv oem.gz ${OMAHA_DATA_DIR}
122 echo "oem: ${oem_hash}" 172 echo "oem: ${oem_hash}"
123 173
124 cat part_12 | gzip -9 > efi.gz 174 efi_hash="$(compress_and_hash_partition "${RELEASE_IMAGE}" 12 "efi.gz")"
125 efi_hash=`cat efi.gz | openssl sha1 -binary | openssl base64`
126 mv efi.gz ${OMAHA_DATA_DIR} 175 mv efi.gz ${OMAHA_DATA_DIR}
127 echo "efi: ${efi_hash}" 176 echo "efi: ${efi_hash}"
128 177
129 popd > /dev/null 178 popd > /dev/null
130 179
131 # Go to retrieve the factory test image. 180 # Go to retrieve the factory test image.
132 pushd ${FACTORY_DIR} > /dev/null 181 pushd ${FACTORY_DIR} > /dev/null
133 prepare_dir 182 prepare_dir
134 183
184 if ! has_part_tools; then
185 echo "Unpacking image ${FACTORY_IMAGE} ..." >&2
186 sudo ./unpack_partitions.sh "${FACTORY_IMAGE}" 2>/dev/null
187 fi
135 188
136 sudo ./unpack_partitions.sh ${FACTORY_IMAGE} &> /dev/null 189 test_hash="$(compress_and_hash_memento_image "${FACTORY_IMAGE}")"
137 test_hash=`sudo ${SCRIPTS_DIR}//mk_memento_images.sh part_2 part_3 \
138 | grep hash | awk '{print $4}'`
139 sudo chmod a+rw update.gz 190 sudo chmod a+rw update.gz
140 mv update.gz rootfs-test.gz 191 mv update.gz rootfs-test.gz
141 mv rootfs-test.gz ${OMAHA_DATA_DIR} 192 mv rootfs-test.gz ${OMAHA_DATA_DIR}
142 echo "test: ${test_hash}" 193 echo "test: ${test_hash}"
143 194
144 cat part_1 | gzip -9 > state.gz 195 state_hash="$(compress_and_hash_partition "${FACTORY_IMAGE}" 1 "state.gz")"
145 state_hash=`cat state.gz | openssl sha1 -binary | openssl base64`
146 mv state.gz ${OMAHA_DATA_DIR} 196 mv state.gz ${OMAHA_DATA_DIR}
147 echo "state: ${state_hash}" 197 echo "state: ${state_hash}"
148 198
149 popd > /dev/null 199 popd > /dev/null
150 200
151 if [ ! -z ${FLAGS_firmware_updater} ] ; then 201 if [ ! -z ${FLAGS_firmware_updater} ] ; then
152 SHELLBALL="${FLAGS_firmware_updater}" 202 SHELLBALL="${FLAGS_firmware_updater}"
153 if [ ! -f "$SHELLBALL" ]; then 203 if [ ! -f "$SHELLBALL" ]; then
154 echo "Failed to find firmware updater: $SHELLBALL." 204 echo "Failed to find firmware updater: $SHELLBALL."
155 exit 1 205 exit 1
156 fi 206 fi
157 207
158 cat $SHELLBALL | gzip -9 > firmware.gz 208 firmware_hash="$(compress_and_hash_file "$SHELLBALL" "firmware.gz")"
159 firmware_hash=`cat firmware.gz | openssl sha1 -binary | openssl base64`
160 mv firmware.gz ${OMAHA_DATA_DIR} 209 mv firmware.gz ${OMAHA_DATA_DIR}
161 echo "firmware: ${firmware_hash}" 210 echo "firmware: ${firmware_hash}"
162 fi 211 fi
163 212
164 # If the file does exist and we are using the subfolder flag we are going to 213 # If the file does exist and we are using the subfolder flag we are going to
165 # append another config. 214 # append another config.
166 if [ -n "${FLAGS_subfolder}" ] && \ 215 if [ -n "${FLAGS_subfolder}" ] && \
167 [ -f "${OMAHA_DIR}"/miniomaha.conf"" ] ; then 216 [ -f "${OMAHA_DIR}"/miniomaha.conf"" ] ; then
168 # Remove the ']' from the last line of the file so we can add another config. 217 # Remove the ']' from the last line of the file so we can add another config.
169 sed -i '$d' ${OMAHA_DIR}/miniomaha.conf 218 sed -i '$d' ${OMAHA_DIR}/miniomaha.conf
(...skipping 28 matching lines...) Expand all
198 }, 247 },
199 ] 248 ]
200 " >> ${OMAHA_DIR}/miniomaha.conf 249 " >> ${OMAHA_DIR}/miniomaha.conf
201 250
202 echo "The miniomaha server lives in src/platform/dev" 251 echo "The miniomaha server lives in src/platform/dev"
203 echo "to validate the configutarion, run:" 252 echo "to validate the configutarion, run:"
204 echo " python2.6 devserver.py --factory_config miniomaha.conf \ 253 echo " python2.6 devserver.py --factory_config miniomaha.conf \
205 --validate_factory_config" 254 --validate_factory_config"
206 echo "To run the server:" 255 echo "To run the server:"
207 echo " python2.6 devserver.py --factory_config miniomaha.conf" 256 echo " python2.6 devserver.py --factory_config miniomaha.conf"
OLDNEW
« no previous file with comments | « image_common.sh ('k') | mk_memento_images.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698