OLD | NEW |
---|---|
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 # |
(...skipping 10 matching lines...) Expand all Loading... | |
21 get_default_board | 21 get_default_board |
22 | 22 |
23 # Flags | 23 # Flags |
24 DEFINE_string board "${DEFAULT_BOARD}" "Board for which the image was built" | 24 DEFINE_string board "${DEFAULT_BOARD}" "Board for which the image was built" |
25 DEFINE_string factory "" \ | 25 DEFINE_string factory "" \ |
26 "Directory and file containing factory image: /path/chromiumos_test_image.bin" | 26 "Directory and file containing factory image: /path/chromiumos_test_image.bin" |
27 DEFINE_string firmware_updater "" \ | 27 DEFINE_string firmware_updater "" \ |
28 "If set, include the firmware shellball into the server configuration" | 28 "If set, include the firmware shellball into the server configuration" |
29 DEFINE_string release "" \ | 29 DEFINE_string release "" \ |
30 "Directory and file containing release image: /path/chromiumos_image.bin" | 30 "Directory and file containing release image: /path/chromiumos_image.bin" |
31 | 31 DEFINE_string subfolder "" \ |
Nick Sanders
2010/10/22 18:06:08
Can you add a comment somewhere in the file that m
| |
32 "If set, the name of the subfolder to put the payload items inside" | |
32 | 33 |
33 # Parse command line | 34 # Parse command line |
34 FLAGS "$@" || exit 1 | 35 FLAGS "$@" || exit 1 |
35 eval set -- "${FLAGS_ARGV}" | 36 eval set -- "${FLAGS_ARGV}" |
36 | 37 |
37 if [ ! -f "${FLAGS_release}" ] ; then | 38 if [ ! -f "${FLAGS_release}" ] ; then |
38 echo "Cannot find image file ${FLAGS_release}" | 39 echo "Cannot find image file ${FLAGS_release}" |
39 exit 1 | 40 exit 1 |
40 fi | 41 fi |
41 | 42 |
42 if [ ! -f "${FLAGS_factory}" ] ; then | 43 if [ ! -f "${FLAGS_factory}" ] ; then |
43 echo "Cannot find image file ${FLAGS_factory}" | 44 echo "Cannot find image file ${FLAGS_factory}" |
44 exit 1 | 45 exit 1 |
45 fi | 46 fi |
46 | 47 |
47 if [ ! -z "${FLAGS_firmware_updater}" ] && \ | 48 if [ ! -z "${FLAGS_firmware_updater}" ] && \ |
48 [ ! -f "${FLAGS_firmware_updater}" ] ; then | 49 [ ! -f "${FLAGS_firmware_updater}" ] ; then |
49 echo "Cannot find firmware file ${FLAGS_firmware_updater}" | 50 echo "Cannot find firmware file ${FLAGS_firmware_updater}" |
50 exit 1 | 51 exit 1 |
51 fi | 52 fi |
52 | 53 |
53 # Convert args to paths. Need eval to un-quote the string so that shell | 54 # Convert args to paths. Need eval to un-quote the string so that shell |
54 # chars like ~ are processed; just doing FOO=`readlink -f ${FOO}` won't work. | 55 # chars like ~ are processed; just doing FOO=`readlink -f ${FOO}` won't work. |
55 OMAHA_DIR=${SRC_ROOT}/platform/dev | 56 OMAHA_DIR=${SRC_ROOT}/platform/dev |
56 OMAHA_DATA_DIR=${OMAHA_DIR}/static/ | 57 OMAHA_DATA_DIR=${OMAHA_DIR}/static/ |
57 | 58 |
59 if [ ! -z "${FLAGS_subfolder}" ] ; then | |
Hung-Te
2010/10/22 09:18:12
"! -z" should be replaced by "-n"
| |
60 OMAHA_DATA_DIR=${OMAHA_DIR}/static/${FLAGS_subfolder}/ | |
61 fi | |
62 | |
58 if [ ${INSIDE_CHROOT} -eq 0 ]; then | 63 if [ ${INSIDE_CHROOT} -eq 0 ]; then |
59 echo "Caching sudo authentication" | 64 echo "Caching sudo authentication" |
60 sudo -v | 65 sudo -v |
61 echo "Done" | 66 echo "Done" |
62 fi | 67 fi |
63 | 68 |
64 # Use this image as the source image to copy | 69 # Use this image as the source image to copy |
65 RELEASE_DIR=`dirname ${FLAGS_release}` | 70 RELEASE_DIR=`dirname ${FLAGS_release}` |
66 FACTORY_DIR=`dirname ${FLAGS_factory}` | 71 FACTORY_DIR=`dirname ${FLAGS_factory}` |
67 RELEASE_IMAGE=`basename ${FLAGS_release}` | 72 RELEASE_IMAGE=`basename ${FLAGS_release}` |
68 FACTORY_IMAGE=`basename ${FLAGS_factory}` | 73 FACTORY_IMAGE=`basename ${FLAGS_factory}` |
69 | 74 |
Hung-Te
2010/10/22 09:18:12
looks like no need of the blank line here
| |
70 | 75 |
76 | |
71 prepare_omaha() { | 77 prepare_omaha() { |
72 sudo rm -rf ${OMAHA_DATA_DIR}/rootfs-test.gz | 78 sudo rm -rf ${OMAHA_DATA_DIR}/rootfs-test.gz |
73 sudo rm -rf ${OMAHA_DATA_DIR}/rootfs-release.gz | 79 sudo rm -rf ${OMAHA_DATA_DIR}/rootfs-release.gz |
74 rm -rf ${OMAHA_DATA_DIR}/efi.gz | 80 rm -rf ${OMAHA_DATA_DIR}/efi.gz |
75 rm -rf ${OMAHA_DATA_DIR}/oem.gz | 81 rm -rf ${OMAHA_DATA_DIR}/oem.gz |
76 rm -rf ${OMAHA_DATA_DIR}/state.gz | 82 rm -rf ${OMAHA_DATA_DIR}/state.gz |
77 rm -rf ${OMAHA_DIR}/miniomaha.conf | 83 if [ ! -f "${OMAHA_DATA_DIR}" ] ; then |
84 mkdir -p ${OMAHA_DATA_DIR} | |
85 fi | |
78 } | 86 } |
79 | 87 |
80 prepare_dir() { | 88 prepare_dir() { |
81 sudo rm -rf rootfs-test.gz | 89 sudo rm -rf rootfs-test.gz |
82 sudo rm -rf rootfs-release.gz | 90 sudo rm -rf rootfs-release.gz |
83 rm -rf efi.gz | 91 rm -rf efi.gz |
84 rm -rf oem.gz | 92 rm -rf oem.gz |
85 rm -rf state.gz | 93 rm -rf state.gz |
86 } | 94 } |
87 | 95 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 echo "Failed to find firmware updater: $SHELLBALL." | 152 echo "Failed to find firmware updater: $SHELLBALL." |
145 exit 1 | 153 exit 1 |
146 fi | 154 fi |
147 | 155 |
148 cat $SHELLBALL | gzip -9 > firmware.gz | 156 cat $SHELLBALL | gzip -9 > firmware.gz |
149 firmware_hash=`cat firmware.gz | openssl sha1 -binary | openssl base64` | 157 firmware_hash=`cat firmware.gz | openssl sha1 -binary | openssl base64` |
150 mv firmware.gz ${OMAHA_DATA_DIR} | 158 mv firmware.gz ${OMAHA_DATA_DIR} |
151 echo "firmware: ${firmware_hash}" | 159 echo "firmware: ${firmware_hash}" |
152 fi | 160 fi |
153 | 161 |
154 echo -n " | 162 # Are we appending another config? |
155 config = [ | 163 if [ ! -z "${FLAGS_subfolder}" ] && \ |
Hung-Te
2010/10/22 09:18:12
No need the trailing \ . The && implies line conca
| |
156 { | 164 [ -f ${OMAHA_DIR}"/miniomaha.conf" ] ; then |
Hung-Te
2010/10/22 09:18:12
Please include the variable in quote, like
-f "${
| |
165 sed '$d' < ${OMAHA_DIR}/miniomaha.conf > ${OMAHA_DIR}/miniomaha_tmp.conf | |
Nick Sanders
2010/10/22 18:06:08
Can you also comment that this is deleting the las
| |
166 mv ${OMAHA_DIR}/miniomaha_tmp.conf ${OMAHA_DIR}/miniomaha.conf | |
Hung-Te
2010/10/22 09:18:12
The sed + mv can be changed to
sed -i '$d' "${OMA
| |
167 subfolder=${FLAGS_subfolder}"/" | |
Hung-Te
2010/10/22 09:18:12
I'd prefer to write this as subfolder="${FLAGS_sub
| |
168 else | |
169 echo -e "config = [\n" > ${OMAHA_DIR}/miniomaha.conf | |
Hung-Te
2010/10/22 09:18:12
This will create one more extra line.
I think 'ech
| |
170 fi | |
171 | |
172 echo -n "{ | |
157 'qual_ids': set([\"${FLAGS_board}\"]), | 173 'qual_ids': set([\"${FLAGS_board}\"]), |
158 'factory_image': 'rootfs-test.gz', | 174 'factory_image': '"$subfolder"rootfs-test.gz', |
Nick Sanders
2010/10/22 18:06:08
Can you add curly braces around ${subfolder}
| |
159 'factory_checksum': '${test_hash}', | 175 'factory_checksum': '${test_hash}', |
160 'release_image': 'rootfs-release.gz', | 176 'release_image': '"$subfolder"rootfs-release.gz', |
161 'release_checksum': '${release_hash}', | 177 'release_checksum': '${release_hash}', |
162 'oempartitionimg_image': 'oem.gz', | 178 'oempartitionimg_image': '"$subfolder"oem.gz', |
163 'oempartitionimg_checksum': '${oem_hash}', | 179 'oempartitionimg_checksum': '${oem_hash}', |
164 'efipartitionimg_image': 'efi.gz', | 180 'efipartitionimg_image': '"$subfolder"efi.gz', |
165 'efipartitionimg_checksum': '${efi_hash}', | 181 'efipartitionimg_checksum': '${efi_hash}', |
166 'stateimg_image': 'state.gz', | 182 'stateimg_image': '"$subfolder"state.gz', |
167 'stateimg_checksum': '${state_hash}'," > ${OMAHA_DIR}/miniomaha.conf | 183 'stateimg_checksum': '${state_hash}'," >> ${OMAHA_DIR}/miniomaha.conf |
168 | 184 |
169 if [ ! -z "${FLAGS_firmware_updater}" ] ; then | 185 if [ ! -z "${FLAGS_firmware_updater}" ] ; then |
170 echo -n " | 186 echo -n " |
171 'firmware_image': 'firmware.gz', | 187 'firmware_image': 'firmware.gz', |
172 'firmware_checksum': '${firmware_hash}'," >> ${OMAHA_DIR}/miniomaha.conf | 188 'firmware_checksum': '${firmware_hash}'," >> ${OMAHA_DIR}/miniomaha.conf |
173 fi | 189 fi |
174 | 190 |
175 echo -n " | 191 echo -n " |
176 }, | 192 }, |
177 ] | 193 ] |
178 " >> ${OMAHA_DIR}/miniomaha.conf | 194 " >> ${OMAHA_DIR}/miniomaha.conf |
179 | 195 |
180 echo "The miniomaha server lives in src/platform/dev" | 196 echo "The miniomaha server lives in src/platform/dev" |
181 echo "to validate the configutarion, run:" | 197 echo "to validate the configutarion, run:" |
182 echo " python2.6 devserver.py --factory_config miniomaha.conf \ | 198 echo " python2.6 devserver.py --factory_config miniomaha.conf \ |
183 --validate_factory_config" | 199 --validate_factory_config" |
184 echo "To run the server:" | 200 echo "To run the server:" |
185 echo " python2.6 devserver.py --factory_config miniomaha.conf" | 201 echo " python2.6 devserver.py --factory_config miniomaha.conf" |
OLD | NEW |