Turn the combining of scripts into a function
This commit is contained in:
parent
423fdcad5e
commit
fb2a839bc0
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
#
|
||||
# .---. . .
|
||||
# | | |
|
||||
|
@ -34,6 +34,12 @@ PROJECT_NAME='freedombone'
|
|||
export TEXTDOMAIN=${PROJECT_NAME}-image-make
|
||||
export TEXTDOMAINDIR="/usr/share/locale"
|
||||
|
||||
PROJECT_INSTALL_DIR=/usr/local/bin
|
||||
if [ -f /usr/bin/${PROJECT_NAME} ]; then
|
||||
PROJECT_INSTALL_DIR=/usr/bin
|
||||
fi
|
||||
source $PROJECT_INSTALL_DIR/${PROJECT_NAME}-vars
|
||||
|
||||
#set -x # Enable debugging
|
||||
|
||||
IMAGE=$1
|
||||
|
@ -180,27 +186,11 @@ TEMP_CUSTOMISE3=/tmp/${PROJECT_NAME}-image-customise3
|
|||
TEMP_CUSTOMISE4=/tmp/${PROJECT_NAME}-image-customise4
|
||||
|
||||
# cat all the things together
|
||||
cp $PROJECT_INSTALL_DIR/${PROJECT_NAME}-vars $TEMP_CUSTOMISE2
|
||||
echo $'Adding utilities to customised customisation script'
|
||||
UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
|
||||
for f in $UTILS_FILES
|
||||
do
|
||||
cat $f >> $TEMP_CUSTOMISE2
|
||||
done
|
||||
echo $'Adding base system to customised customisation script'
|
||||
BASE_SYSTEM_FILES=/usr/share/${PROJECT_NAME}/base/${PROJECT_NAME}-base-*
|
||||
for f in $BASE_SYSTEM_FILES
|
||||
do
|
||||
cat $f >> $TEMP_CUSTOMISE2
|
||||
done
|
||||
echo $'Adding apps to customised customisation script'
|
||||
APP_FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
|
||||
for f in $APP_FILES
|
||||
do
|
||||
cat $f >> $TEMP_CUSTOMISE2
|
||||
done
|
||||
echo $'Removing headers from customised customisation script'
|
||||
sed -i 's|#!/bin/bash||g' $TEMP_CUSTOMISE2
|
||||
combine_all_scripts $TEMP_CUSTOMISE2
|
||||
if [ ! -f $TEMP_CUSTOMISE2 ]; then
|
||||
echo $'Could not combine scripts'
|
||||
exit 627219
|
||||
fi
|
||||
|
||||
echo $'Changing values within customised customisation script'
|
||||
cp $PROJECT_INSTALL_DIR/${PROJECT_NAME}-image-customise $TEMP_CUSTOMISE3
|
||||
|
|
|
@ -361,4 +361,33 @@ function setup_apps {
|
|||
install_apps
|
||||
}
|
||||
|
||||
function combine_all_scripts {
|
||||
combined_filename=$1
|
||||
|
||||
# initial variables
|
||||
cp $PROJECT_INSTALL_DIR/${PROJECT_NAME}-vars $combined_filename
|
||||
|
||||
# utilities
|
||||
UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
|
||||
for f in $UTILS_FILES
|
||||
do
|
||||
# this removes the first line, which is #!/bin/bash
|
||||
tail -n +2 "$f" >> $combined_filename
|
||||
done
|
||||
|
||||
# base system
|
||||
BASE_SYSTEM_FILES=/usr/share/${PROJECT_NAME}/base/${PROJECT_NAME}-base-*
|
||||
for f in $BASE_SYSTEM_FILES
|
||||
do
|
||||
tail -n +2 "$f" >> $combined_filename
|
||||
done
|
||||
|
||||
# apps
|
||||
APP_FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
|
||||
for f in $APP_FILES
|
||||
do
|
||||
tail -n +2 "$f" >> $combined_filename
|
||||
done
|
||||
}
|
||||
|
||||
# NOTE: deliberately no exit 0
|
||||
|
|
Loading…
Reference in New Issue