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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 firmware_hash=`cat firmware.gz | openssl sha1 -binary | openssl base64` | 159 firmware_hash=`cat firmware.gz | openssl sha1 -binary | openssl base64` |
160 mv firmware.gz ${OMAHA_DATA_DIR} | 160 mv firmware.gz ${OMAHA_DATA_DIR} |
161 echo "firmware: ${firmware_hash}" | 161 echo "firmware: ${firmware_hash}" |
162 fi | 162 fi |
163 | 163 |
164 # If the file does exist and we are using the subfolder flag we are going to | 164 # If the file does exist and we are using the subfolder flag we are going to |
165 # append another config. | 165 # append another config. |
166 if [ -n "${FLAGS_subfolder}" ] && \ | 166 if [ -n "${FLAGS_subfolder}" ] && \ |
167 [ -f "${OMAHA_DIR}"/miniomaha.conf"" ] ; then | 167 [ -f "${OMAHA_DIR}"/miniomaha.conf"" ] ; then |
168 # Remove the ']' from the last line of the file so we can add another config. | 168 # Remove the ']' from the last line of the file so we can add another config. |
169 sed -i '$d' ${OMAHA_DIR}/miniomaha.conf | 169 while [ -s "${OMAHA_DIR}/miniomaha.conf" ]; do |
170 # If the last line is null | |
171 if [ -z "$(tail -1 "${OMAHA_DIR}/miniomaha.conf")" ]; then | |
172 sed -i '$d' "${OMAHA_DIR}/miniomaha.conf" | |
173 elif [ "$(tail -1 "${OMAHA_DIR}/miniomaha.conf")" != ']' ]; then | |
174 sed -i '$d' "${OMAHA_DIR}/miniomaha.conf" | |
175 else | |
176 break | |
177 fi | |
178 done | |
179 | |
180 # Remove the last ] | |
181 if [ "$(tail -1 "${OMAHA_DIR}/miniomaha.conf")" '=' ']' ]; then | |
Hung-Te
2010/11/12 00:27:12
You don't need the single quote for the =
| |
182 sed -i '$d' "${OMAHA_DIR}/miniomaha.conf" | |
183 fi | |
184 | |
185 # If the file is empty, create it from scratch | |
186 if [ ! -s "${OMAHA_DIR}/miniomaha.conf" ]; then | |
187 echo "config = [" > "${OMAHA_DIR}/miniomaha.conf" | |
188 fi | |
170 else | 189 else |
171 echo -e "config = [" > ${OMAHA_DIR}/miniomaha.conf | 190 echo "config = [" > "${OMAHA_DIR}/miniomaha.conf" |
172 fi | 191 fi |
173 | 192 |
174 if [ -n "${FLAGS_subfolder}" ] ; then | 193 if [ -n "${FLAGS_subfolder}" ] ; then |
175 subfolder="${FLAGS_subfolder}/" | 194 subfolder="${FLAGS_subfolder}/" |
176 fi | 195 fi |
177 | 196 |
178 echo -n "{ | 197 echo -n "{ |
179 'qual_ids': set([\"${FLAGS_board}\"]), | 198 'qual_ids': set([\"${FLAGS_board}\"]), |
180 'factory_image': '"${subfolder}"rootfs-test.gz', | 199 'factory_image': '"${subfolder}"rootfs-test.gz', |
181 'factory_checksum': '${test_hash}', | 200 'factory_checksum': '${test_hash}', |
(...skipping 16 matching lines...) Expand all Loading... | |
198 }, | 217 }, |
199 ] | 218 ] |
200 " >> ${OMAHA_DIR}/miniomaha.conf | 219 " >> ${OMAHA_DIR}/miniomaha.conf |
201 | 220 |
202 echo "The miniomaha server lives in src/platform/dev" | 221 echo "The miniomaha server lives in src/platform/dev" |
203 echo "to validate the configutarion, run:" | 222 echo "to validate the configutarion, run:" |
204 echo " python2.6 devserver.py --factory_config miniomaha.conf \ | 223 echo " python2.6 devserver.py --factory_config miniomaha.conf \ |
205 --validate_factory_config" | 224 --validate_factory_config" |
206 echo "To run the server:" | 225 echo "To run the server:" |
207 echo " python2.6 devserver.py --factory_config miniomaha.conf" | 226 echo " python2.6 devserver.py --factory_config miniomaha.conf" |
OLD | NEW |