mirror of
https://github.com/deajan/obackup.git
synced 2024-12-24 14:33:41 +01:00
Made merge and bootstrap program agonstic
This commit is contained in:
parent
c7eb51f8a3
commit
bd06dfe397
@ -1,30 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
## dev pre-processor bootstrap rev 2016121302
|
||||
## dev pre-processor bootstrap rev 2017062001
|
||||
## Yeah !!! A really tech sounding name... In fact it's just include emulation in bash
|
||||
|
||||
function Usage {
|
||||
echo "$0 - Quick and dirty preprocessor for including ofunctions into programs"
|
||||
echo "Creates and executes $0.tmp.sh"
|
||||
echo "Usage:"
|
||||
echo ""
|
||||
echo "$0 --program=osync|osync_target_helper|obackup|pmocr [options to pass to program]"
|
||||
}
|
||||
|
||||
|
||||
if [ ! -f "./merge.sh" ]; then
|
||||
echo "Plrase run bootstrap.sh from osync/dev directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
bootstrapProgram=""
|
||||
opts=""
|
||||
outputFileName="$0"
|
||||
|
||||
source "merge.sh"
|
||||
__PREPROCESSOR_PROGRAM=obackup
|
||||
__PREPROCESSOR_Constants
|
||||
for i in "$@"; do
|
||||
case $i in
|
||||
--program=*)
|
||||
bootstrapProgram="${i##*=}"
|
||||
;;
|
||||
*)
|
||||
opts=$opts" $i"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
cp "n_$__PREPROCESSOR_PROGRAM.sh" "$outputFileName.tmp.sh"
|
||||
if [ "$bootstrapProgram" == "" ]; then
|
||||
Usage
|
||||
exit 128
|
||||
else
|
||||
source "merge.sh"
|
||||
|
||||
__PREPROCESSOR_PROGRAM=$bootstrapProgram
|
||||
__PREPROCESSOR_PROGRAM_EXEC="n_$bootstrapProgram.sh"
|
||||
__PREPROCESSOR_Constants
|
||||
|
||||
if [ ! -f "$__PREPROCESSOR_PROGRAM_EXEC" ]; then
|
||||
echo "Cannot find file [n_$bootstrapProgram.sh]."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
cp "$__PREPROCESSOR_PROGRAM_EXEC" "$outputFileName.tmp.sh"
|
||||
if [ $? != 0 ]; then
|
||||
echo "Cannot copy original file [n_$__PREPROCESSOR_PROGRAM.sh] to [$outputFileName.tmp.sh]."
|
||||
echo "Cannot copy original file [$__PREPROCESSOR_PROGRAM_EXEC] to [$outputFileName.tmp.sh]."
|
||||
exit 1
|
||||
fi
|
||||
for subset in "${__PREPROCESSOR_SUBSETS[@]}"; do
|
||||
__PREPROCESSOR_MergeSubset "$subset" "${subset//SUBSET/SUBSET END}" "ofunctions.sh" "$outputFileName.tmp.sh"
|
||||
done
|
||||
chmod +x "$0.tmp.sh"
|
||||
chmod +x "$outputFileName.tmp.sh"
|
||||
if [ $? != 0 ]; then
|
||||
echo "Cannot make [$outputFileName] executable.."
|
||||
echo "Cannot make [$outputFileName] executable."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -33,4 +67,4 @@ if type termux-fix-shebang > /dev/null 2>&1; then
|
||||
termux-fix-shebang "$outputFileName.tmp.sh"
|
||||
fi
|
||||
|
||||
"$outputFileName.tmp.sh" "$@"
|
||||
"$outputFileName.tmp.sh" $opts
|
||||
|
33
dev/merge.sh
33
dev/merge.sh
@ -1,12 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
## MERGE 2017040901
|
||||
## MERGE 2017061901
|
||||
|
||||
## Merges ofunctions.sh and n_program.sh into program.sh
|
||||
## Adds installer
|
||||
|
||||
function Usage {
|
||||
echo "Merges ofunctions.sh and n_program.sh into debug_program.sh and ../program.sh"
|
||||
echo "Usage"
|
||||
echo "$0 osync|obackup|pmocr"
|
||||
}
|
||||
|
||||
function __PREPROCESSOR_Merge {
|
||||
PROGRAM=obackup
|
||||
local PROGRAM="$1"
|
||||
|
||||
VERSION=$(grep "PROGRAM_VERSION=" n_$PROGRAM.sh)
|
||||
VERSION=${VERSION#*=}
|
||||
@ -24,8 +30,7 @@ function __PREPROCESSOR_Merge {
|
||||
__PREPROCESSOR_MergeSubset "$subset" "${subset//SUBSET/SUBSET END}" "ofunctions.sh" "debug_$PROGRAM.sh"
|
||||
done
|
||||
|
||||
__PREPROCESSOR_CleanDebug
|
||||
__PREPROCESSOR_CopyCommons
|
||||
__PREPROCESSOR_CleanDebug "$PROGRAM"
|
||||
rm -f tmp_$PROGRAM.sh
|
||||
if [ $? != 0 ]; then
|
||||
QuickLogger "Cannot remove tmp_$PROGRAM.sh"
|
||||
@ -104,6 +109,8 @@ function __PREPROCESSOR_MergeSubset {
|
||||
}
|
||||
|
||||
function __PREPROCESSOR_CleanDebug {
|
||||
local PROGRAM="$1"
|
||||
|
||||
sed '/'$PARANOIA_DEBUG_BEGIN'/,/'$PARANOIA_DEBUG_END'/d' debug_$PROGRAM.sh | grep -v "$PARANOIA_DEBUG_LINE" > ../$PROGRAM.sh
|
||||
if [ $? != 0 ]; then
|
||||
QuickLogger "Cannot remove PARANOIA_DEBUG code from standard build."
|
||||
@ -127,6 +134,8 @@ function __PREPROCESSOR_CleanDebug {
|
||||
}
|
||||
|
||||
function __PREPROCESSOR_CopyCommons {
|
||||
local PROGRAM="$1"
|
||||
|
||||
sed "s/\[prgname\]/$PROGRAM/g" common_install.sh > ../install.sh
|
||||
if [ $? != 0 ]; then
|
||||
QuickLogger "Cannot assemble install."
|
||||
@ -172,5 +181,19 @@ function __PREPROCESSOR_CopyCommons {
|
||||
|
||||
# If sourced don't do anything
|
||||
if [ "$(basename $0)" == "merge.sh" ]; then
|
||||
__PREPROCESSOR_Merge
|
||||
if [ "$1" == "osync" ]; then
|
||||
|
||||
__PREPROCESSOR_Merge osync
|
||||
__PREPROCESSOR_Merge osync_target_helper
|
||||
__PREPROCESSOR_CopyCommons osync
|
||||
elif [ "$1" == "obackup" ]; then
|
||||
__PREPROCESSOR_Merge obackup
|
||||
__PREPROCESSOR_CopyCommons obackup
|
||||
elif [ "$1" == "pmocr" ]; then
|
||||
__PREPROCESSOR_Merge pmocr
|
||||
__PREPROCESSOR_CopyCommons pmocr
|
||||
else
|
||||
echo "No valid program given."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user