From 2038a2ecb94a879af4553e8ff759b47bc3e7a394 Mon Sep 17 00:00:00 2001 From: deajan Date: Mon, 19 Jun 2017 16:01:16 +0200 Subject: [PATCH] Made bootstrap and merge program agnostic --- dev/bootstrap.sh | 36 +++++++++++++++++++++++++++++------- dev/merge.sh | 27 ++++++++++++++++++++++----- 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/dev/bootstrap.sh b/dev/bootstrap.sh index a953f30..a99ff24 100755 --- a/dev/bootstrap.sh +++ b/dev/bootstrap.sh @@ -1,23 +1,45 @@ #!/usr/bin/env bash -## dev pre-processor bootstrap rev 2017061801 +## dev pre-processor bootstrap rev 2017061901 ## 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" -if [ "$1" == "" ]; then - PRG=osync -else - PRG="$1" + +for i in "$@"; do + case $i in + --program=*) + bootstrapProgram="${i##*=}" + ;; + *) + opts=$opts" $i" + ;; + esac +done + +if [ "$bootstrapProgram" == "" ]; then + Usage + exit 128 fi source "merge.sh" -__PREPROCESSOR_PROGRAM=$PRG +__PREPROCESSOR_PROGRAM=$bootstrapProgram __PREPROCESSOR_Constants cp "n_$__PREPROCESSOR_PROGRAM.sh" "$outputFileName.tmp.sh" @@ -39,4 +61,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 diff --git a/dev/merge.sh b/dev/merge.sh index 3476eb5..b2eec78 100755 --- a/dev/merge.sh +++ b/dev/merge.sh @@ -1,10 +1,16 @@ #!/usr/bin/env bash -## MERGE 2017061801 +## 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 { local PROGRAM="$1" @@ -175,8 +181,19 @@ function __PREPROCESSOR_CopyCommons { # If sourced don't do anything if [ "$(basename $0)" == "merge.sh" ]; then - __PREPROCESSOR_Merge osync - __PREPROCESSOR_Merge osync_target_helper - __PREPROCESSOR_CopyCommons osync - + 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