Index: make_factory_package.sh |
diff --git a/make_factory_package.sh b/make_factory_package.sh |
index 9a44f71dd24d6d9e8a4a48495365578492c13b6d..3a7f9fdc76bf1b55e12d7612da64ab976977fbc5 100755 |
--- a/make_factory_package.sh |
+++ b/make_factory_package.sh |
@@ -166,9 +166,33 @@ fi |
if [ -n "${FLAGS_subfolder}" ] && \ |
[ -f "${OMAHA_DIR}"/miniomaha.conf"" ] ; then |
# Remove the ']' from the last line of the file so we can add another config. |
- sed -i '$d' ${OMAHA_DIR}/miniomaha.conf |
+ while true |
Hung-Te
2010/11/10 08:41:10
If the checking condition is always true here, I t
|
+ do |
+ # If the last line is null |
+ if [ -z "$(tail -1 "${OMAHA_DIR}/miniomaha.conf")" ]; then |
+ sed -i '$d' ${OMAHA_DIR}/miniomaha.conf |
Hung-Te
2010/11/10 08:41:10
Please quote the file as "${OMAHA_DIR}/miniomana.c
|
+ else |
Hung-Te
2010/11/10 08:41:10
This else can be merged with next if as "elif", wh
|
+ # If the last line is some other string that is not ] then it is |
+ # garbage and we don't need it |
+ if [ `tail -1 ${OMAHA_DIR}/miniomaha.conf` != ']' ]; then |
Hung-Te
2010/11/10 08:41:10
Please change `tail ... conf` with $(tail ..."${OM
|
+ sed -i '$d' ${OMAHA_DIR}/miniomaha.conf |
+ else |
+ break |
+ fi |
+ fi |
+ done |
+ |
+ # Remove the last ] |
+ if [ `tail -1 ${OMAHA_DIR}/miniomaha.conf` == ']' ]; then |
Hung-Te
2010/11/10 08:41:10
== is bash special syntax and not POSIX compatible
|
+ sed -i '$d' ${OMAHA_DIR}/miniomaha.conf |
+ fi |
+ |
+ # If the file is empty, create it from scratch |
+ if [ ! -s ${OMAHA_DIR}/miniomaha.conf ]; then |
+ echo "config = [" > ${OMAHA_DIR}/miniomaha.conf |
+ fi |
else |
- echo -e "config = [" > ${OMAHA_DIR}/miniomaha.conf |
+ echo "config = [" > ${OMAHA_DIR}/miniomaha.conf |
fi |
if [ -n "${FLAGS_subfolder}" ] ; then |