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

Side by Side Diff: make_factory_package.sh

Issue 4688004: Make removing the last ] more full-proof (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git@master
Patch Set: Broke up the while loop, cleaned up the sed's 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 | « no previous file | 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 # 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
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 true
Hung-Te 2010/11/10 08:41:10 If the checking condition is always true here, I t
170 do
171 # If the last line is null
172 if [ -z "$(tail -1 "${OMAHA_DIR}/miniomaha.conf")" ]; then
173 sed -i '$d' ${OMAHA_DIR}/miniomaha.conf
Hung-Te 2010/11/10 08:41:10 Please quote the file as "${OMAHA_DIR}/miniomana.c
174 else
Hung-Te 2010/11/10 08:41:10 This else can be merged with next if as "elif", wh
175 # If the last line is some other string that is not ] then it is
176 # garbage and we don't need it
177 if [ `tail -1 ${OMAHA_DIR}/miniomaha.conf` != ']' ]; then
Hung-Te 2010/11/10 08:41:10 Please change `tail ... conf` with $(tail ..."${OM
178 sed -i '$d' ${OMAHA_DIR}/miniomaha.conf
179 else
180 break
181 fi
182 fi
183 done
184
185 # Remove the last ]
186 if [ `tail -1 ${OMAHA_DIR}/miniomaha.conf` == ']' ]; then
Hung-Te 2010/11/10 08:41:10 == is bash special syntax and not POSIX compatible
187 sed -i '$d' ${OMAHA_DIR}/miniomaha.conf
188 fi
189
190 # If the file is empty, create it from scratch
191 if [ ! -s ${OMAHA_DIR}/miniomaha.conf ]; then
192 echo "config = [" > ${OMAHA_DIR}/miniomaha.conf
193 fi
170 else 194 else
171 echo -e "config = [" > ${OMAHA_DIR}/miniomaha.conf 195 echo "config = [" > ${OMAHA_DIR}/miniomaha.conf
172 fi 196 fi
173 197
174 if [ -n "${FLAGS_subfolder}" ] ; then 198 if [ -n "${FLAGS_subfolder}" ] ; then
175 subfolder="${FLAGS_subfolder}/" 199 subfolder="${FLAGS_subfolder}/"
176 fi 200 fi
177 201
178 echo -n "{ 202 echo -n "{
179 'qual_ids': set([\"${FLAGS_board}\"]), 203 'qual_ids': set([\"${FLAGS_board}\"]),
180 'factory_image': '"${subfolder}"rootfs-test.gz', 204 'factory_image': '"${subfolder}"rootfs-test.gz',
181 'factory_checksum': '${test_hash}', 205 'factory_checksum': '${test_hash}',
(...skipping 16 matching lines...) Expand all
198 }, 222 },
199 ] 223 ]
200 " >> ${OMAHA_DIR}/miniomaha.conf 224 " >> ${OMAHA_DIR}/miniomaha.conf
201 225
202 echo "The miniomaha server lives in src/platform/dev" 226 echo "The miniomaha server lives in src/platform/dev"
203 echo "to validate the configutarion, run:" 227 echo "to validate the configutarion, run:"
204 echo " python2.6 devserver.py --factory_config miniomaha.conf \ 228 echo " python2.6 devserver.py --factory_config miniomaha.conf \
205 --validate_factory_config" 229 --validate_factory_config"
206 echo "To run the server:" 230 echo "To run the server:"
207 echo " python2.6 devserver.py --factory_config miniomaha.conf" 231 echo " python2.6 devserver.py --factory_config miniomaha.conf"
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698