Bläddra i källkod

Turn the combining of scripts into a function

Bob Mottram 9 år sedan
förälder
incheckning
fb2a839bc0
No account linked to committer's email
2 ändrade filer med 41 tillägg och 22 borttagningar
  1. 12
    22
      src/freedombone-image-make
  2. 29
    0
      src/freedombone-utils-setup

+ 12
- 22
src/freedombone-image-make Visa fil

1
-#!/bin/sh
1
+#!/bin/bash
2
 #
2
 #
3
 # .---.                  .              .
3
 # .---.                  .              .
4
 # |                      |              |
4
 # |                      |              |
34
 export TEXTDOMAIN=${PROJECT_NAME}-image-make
34
 export TEXTDOMAIN=${PROJECT_NAME}-image-make
35
 export TEXTDOMAINDIR="/usr/share/locale"
35
 export TEXTDOMAINDIR="/usr/share/locale"
36
 
36
 
37
+PROJECT_INSTALL_DIR=/usr/local/bin
38
+if [ -f /usr/bin/${PROJECT_NAME} ]; then
39
+	PROJECT_INSTALL_DIR=/usr/bin
40
+fi
41
+source $PROJECT_INSTALL_DIR/${PROJECT_NAME}-vars
42
+
37
 #set -x # Enable debugging
43
 #set -x # Enable debugging
38
 
44
 
39
 IMAGE=$1
45
 IMAGE=$1
180
 TEMP_CUSTOMISE4=/tmp/${PROJECT_NAME}-image-customise4
186
 TEMP_CUSTOMISE4=/tmp/${PROJECT_NAME}-image-customise4
181
 
187
 
182
 # cat all the things together
188
 # cat all the things together
183
-cp $PROJECT_INSTALL_DIR/${PROJECT_NAME}-vars $TEMP_CUSTOMISE2
184
-echo $'Adding utilities to customised customisation script'
185
-UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
186
-for f in $UTILS_FILES
187
-do
188
-  cat $f >> $TEMP_CUSTOMISE2
189
-done
190
-echo $'Adding base system to customised customisation script'
191
-BASE_SYSTEM_FILES=/usr/share/${PROJECT_NAME}/base/${PROJECT_NAME}-base-*
192
-for f in $BASE_SYSTEM_FILES
193
-do
194
-  cat $f >> $TEMP_CUSTOMISE2
195
-done
196
-echo $'Adding apps to customised customisation script'
197
-APP_FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
198
-for f in $APP_FILES
199
-do
200
-  cat $f >> $TEMP_CUSTOMISE2
201
-done
202
-echo $'Removing headers from customised customisation script'
203
-sed -i 's|#!/bin/bash||g' $TEMP_CUSTOMISE2
189
+combine_all_scripts $TEMP_CUSTOMISE2
190
+if [ ! -f $TEMP_CUSTOMISE2 ]; then
191
+	echo $'Could not combine scripts'
192
+	exit 627219
193
+fi
204
 
194
 
205
 echo $'Changing values within customised customisation script'
195
 echo $'Changing values within customised customisation script'
206
 cp $PROJECT_INSTALL_DIR/${PROJECT_NAME}-image-customise $TEMP_CUSTOMISE3
196
 cp $PROJECT_INSTALL_DIR/${PROJECT_NAME}-image-customise $TEMP_CUSTOMISE3

+ 29
- 0
src/freedombone-utils-setup Visa fil

361
 	install_apps
361
 	install_apps
362
 }
362
 }
363
 
363
 
364
+function combine_all_scripts {
365
+	combined_filename=$1
366
+
367
+	# initial variables
368
+	cp $PROJECT_INSTALL_DIR/${PROJECT_NAME}-vars $combined_filename
369
+
370
+	# utilities
371
+	UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
372
+	for f in $UTILS_FILES
373
+	do
374
+		# this removes the first line, which is #!/bin/bash
375
+		tail -n +2 "$f" >> $combined_filename
376
+	done
377
+
378
+	# base system
379
+	BASE_SYSTEM_FILES=/usr/share/${PROJECT_NAME}/base/${PROJECT_NAME}-base-*
380
+	for f in $BASE_SYSTEM_FILES
381
+	do
382
+		tail -n +2 "$f" >> $combined_filename
383
+	done
384
+
385
+	# apps
386
+	APP_FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
387
+	for f in $APP_FILES
388
+	do
389
+		tail -n +2 "$f" >> $combined_filename
390
+	done
391
+}
392
+
364
 # NOTE: deliberately no exit 0
393
 # NOTE: deliberately no exit 0