mirror of
https://github.com/deajan/obackup.git
synced 2024-11-15 04:03: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
|
#!/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
|
## 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
|
if [ ! -f "./merge.sh" ]; then
|
||||||
echo "Plrase run bootstrap.sh from osync/dev directory."
|
echo "Plrase run bootstrap.sh from osync/dev directory."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
bootstrapProgram=""
|
||||||
|
opts=""
|
||||||
outputFileName="$0"
|
outputFileName="$0"
|
||||||
|
|
||||||
|
for i in "$@"; do
|
||||||
|
case $i in
|
||||||
|
--program=*)
|
||||||
|
bootstrapProgram="${i##*=}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
opts=$opts" $i"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$bootstrapProgram" == "" ]; then
|
||||||
|
Usage
|
||||||
|
exit 128
|
||||||
|
else
|
||||||
source "merge.sh"
|
source "merge.sh"
|
||||||
__PREPROCESSOR_PROGRAM=obackup
|
|
||||||
|
__PREPROCESSOR_PROGRAM=$bootstrapProgram
|
||||||
|
__PREPROCESSOR_PROGRAM_EXEC="n_$bootstrapProgram.sh"
|
||||||
__PREPROCESSOR_Constants
|
__PREPROCESSOR_Constants
|
||||||
|
|
||||||
cp "n_$__PREPROCESSOR_PROGRAM.sh" "$outputFileName.tmp.sh"
|
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
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
for subset in "${__PREPROCESSOR_SUBSETS[@]}"; do
|
for subset in "${__PREPROCESSOR_SUBSETS[@]}"; do
|
||||||
__PREPROCESSOR_MergeSubset "$subset" "${subset//SUBSET/SUBSET END}" "ofunctions.sh" "$outputFileName.tmp.sh"
|
__PREPROCESSOR_MergeSubset "$subset" "${subset//SUBSET/SUBSET END}" "ofunctions.sh" "$outputFileName.tmp.sh"
|
||||||
done
|
done
|
||||||
chmod +x "$0.tmp.sh"
|
chmod +x "$outputFileName.tmp.sh"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "Cannot make [$outputFileName] executable.."
|
echo "Cannot make [$outputFileName] executable."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -33,4 +67,4 @@ if type termux-fix-shebang > /dev/null 2>&1; then
|
|||||||
termux-fix-shebang "$outputFileName.tmp.sh"
|
termux-fix-shebang "$outputFileName.tmp.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
"$outputFileName.tmp.sh" "$@"
|
"$outputFileName.tmp.sh" $opts
|
||||||
|
33
dev/merge.sh
33
dev/merge.sh
@ -1,12 +1,18 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
## MERGE 2017040901
|
## MERGE 2017061901
|
||||||
|
|
||||||
## Merges ofunctions.sh and n_program.sh into program.sh
|
## Merges ofunctions.sh and n_program.sh into program.sh
|
||||||
## Adds installer
|
## 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 {
|
function __PREPROCESSOR_Merge {
|
||||||
PROGRAM=obackup
|
local PROGRAM="$1"
|
||||||
|
|
||||||
VERSION=$(grep "PROGRAM_VERSION=" n_$PROGRAM.sh)
|
VERSION=$(grep "PROGRAM_VERSION=" n_$PROGRAM.sh)
|
||||||
VERSION=${VERSION#*=}
|
VERSION=${VERSION#*=}
|
||||||
@ -24,8 +30,7 @@ function __PREPROCESSOR_Merge {
|
|||||||
__PREPROCESSOR_MergeSubset "$subset" "${subset//SUBSET/SUBSET END}" "ofunctions.sh" "debug_$PROGRAM.sh"
|
__PREPROCESSOR_MergeSubset "$subset" "${subset//SUBSET/SUBSET END}" "ofunctions.sh" "debug_$PROGRAM.sh"
|
||||||
done
|
done
|
||||||
|
|
||||||
__PREPROCESSOR_CleanDebug
|
__PREPROCESSOR_CleanDebug "$PROGRAM"
|
||||||
__PREPROCESSOR_CopyCommons
|
|
||||||
rm -f tmp_$PROGRAM.sh
|
rm -f tmp_$PROGRAM.sh
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
QuickLogger "Cannot remove tmp_$PROGRAM.sh"
|
QuickLogger "Cannot remove tmp_$PROGRAM.sh"
|
||||||
@ -104,6 +109,8 @@ function __PREPROCESSOR_MergeSubset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function __PREPROCESSOR_CleanDebug {
|
function __PREPROCESSOR_CleanDebug {
|
||||||
|
local PROGRAM="$1"
|
||||||
|
|
||||||
sed '/'$PARANOIA_DEBUG_BEGIN'/,/'$PARANOIA_DEBUG_END'/d' debug_$PROGRAM.sh | grep -v "$PARANOIA_DEBUG_LINE" > ../$PROGRAM.sh
|
sed '/'$PARANOIA_DEBUG_BEGIN'/,/'$PARANOIA_DEBUG_END'/d' debug_$PROGRAM.sh | grep -v "$PARANOIA_DEBUG_LINE" > ../$PROGRAM.sh
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
QuickLogger "Cannot remove PARANOIA_DEBUG code from standard build."
|
QuickLogger "Cannot remove PARANOIA_DEBUG code from standard build."
|
||||||
@ -127,6 +134,8 @@ function __PREPROCESSOR_CleanDebug {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function __PREPROCESSOR_CopyCommons {
|
function __PREPROCESSOR_CopyCommons {
|
||||||
|
local PROGRAM="$1"
|
||||||
|
|
||||||
sed "s/\[prgname\]/$PROGRAM/g" common_install.sh > ../install.sh
|
sed "s/\[prgname\]/$PROGRAM/g" common_install.sh > ../install.sh
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
QuickLogger "Cannot assemble install."
|
QuickLogger "Cannot assemble install."
|
||||||
@ -172,5 +181,19 @@ function __PREPROCESSOR_CopyCommons {
|
|||||||
|
|
||||||
# If sourced don't do anything
|
# If sourced don't do anything
|
||||||
if [ "$(basename $0)" == "merge.sh" ]; then
|
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
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user