diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2021-08-23 11:12:47 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2021-08-23 11:12:47 +0900 |
commit | f1f0f187ab68bac4d9f5402f64d887a539a92218 (patch) | |
tree | 86dfdf33e68a4b649d67bc97d8c1571a22f57bf5 /debian/_buildscripts/local/build_module.sh | |
parent | 684553c8146c7f379581fb51664f09abe2fa1aa5 (diff) | |
download | tde-packaging-f1f0f187ab68bac4d9f5402f64d887a539a92218.tar.gz tde-packaging-f1f0f187ab68bac4d9f5402f64d887a539a92218.zip |
DEB build scripts: added ability to build from a specified folder.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'debian/_buildscripts/local/build_module.sh')
-rwxr-xr-x | debian/_buildscripts/local/build_module.sh | 84 |
1 files changed, 60 insertions, 24 deletions
diff --git a/debian/_buildscripts/local/build_module.sh b/debian/_buildscripts/local/build_module.sh index c7c6cec0f..920e49716 100755 --- a/debian/_buildscripts/local/build_module.sh +++ b/debian/_buildscripts/local/build_module.sh @@ -4,7 +4,8 @@ # # Load common code and initialization -. ./internals/_build_common.sh +export SCRIPT_DIR=$(dirname $(readlink -f "$0")) +. ${SCRIPT_DIR}/internals/_build_common.sh init_common @@ -74,8 +75,12 @@ function search_module() # Unique module MODULE_FOUND="y" MOD_NAME=$LOC_MATCH - MOD_GIT_PATH="$REPO_TDE_MAIN/$MOD_NAME" - MOD_GIT_PKGING_PATH="$REPO_TDE_PACKAGING/$MOD_NAME/debian" + if [ "${bool_BUILD_FROM_PATH}" = "y" ]; then + MOD_GIT_PATH="$MOD_PATH" + else + MOD_GIT_PATH="$REPO_TDE_MAIN/$MOD_NAME" + fi + MOD_GIT_PKGING_PATH="$REPO_TDE_PACKAGING/$MOD_NAME/debian" MOD_BUILD_PATH="$TDE_BUILD_DIR/$MOD_NAME" else # Search for a unique folder with the same name @@ -122,9 +127,10 @@ function search_module() #---------------------------- MOD_NAME="" # the name of the specified module bool_BUILD_FROM_GIT="n" +bool_BUILD_FROM_PATH="n" +bool_BUILD_LOCALLY="n" bool_EXTRADEP_MOD="n" bool_SHOW_BUILD_LOGS="n" -bool_BUILD_LOCALLY="n" bool_LOG_RESULT="n" bool_SHELL_HOOK="n" bool_PREPARE_ONLY="n" @@ -144,6 +150,15 @@ while [ $# -gt 0 ]; do -lr) # Log build Result to file bool_LOG_RESULT="y" ;; + -p) # build from specific Path + if [ -z "$MOD_NAME" ]; then + shift + MOD_NAME="$1" + bool_BUILD_FROM_PATH="y" + else + bool_INVALID_PARAMETERS="y" + fi + ;; -po) # Prepare build folder Only but do not build bool_PREPARE_ONLY="y" ;; @@ -163,12 +178,42 @@ while [ $# -gt 0 ]; do shift done +if [ "${bool_BUILD_FROM_GIT}" = "y" -a "${bool_BUILD_FROM_PATH}" = "y" ]; then + bool_INVALID_PARAMETERS="y" +fi if [ "$bool_INVALID_PARAMETERS" != "n" ]; then echo "Invalid arguments." MOD_NAME="N/A" do_exit 1 fi +# If building from a given path, look up the module name +if [ "${bool_BUILD_FROM_PATH}" = "y" ]; then + if [ -d "${MOD_NAME}" ]; then + cd "${MOD_NAME}" + MOD_PATH=`pwd` + if [ "${USE_GIT_WORKTREES}" = "y" ]; then + MOD_NAME=`git rev-parse --git-dir 2>/dev/null | sed "s|.*/\([^\/]\+\)\.git.*|\1|"` + else + MOD_NAME=`basename "${MOD_PATH}"` + fi + if [ "${MOD_NAME}" != "" -a "${MOD_NAME}" != "tde" -a "${MOD_NAME}" != ".git" ]; then + # Valid git module + if [[ "${MOD_PATH}" =~ ${TDE_BUILD_DIR} ]]; then + # Module from build folder + bool_BUILD_FROM_GIT="n" + else + # Module from git repo + bool_BUILD_FROM_GIT="y" + fi + else + MOD_NAME="" + fi + else + MOD_NAME="" + fi +fi + echo -e "${CLightCyan}#### Processing module \"$MOD_NAME\" ####${CNone}" if [ "$MOD_NAME" = "" ]; then @@ -176,7 +221,7 @@ if [ "$MOD_NAME" = "" ]; then do_exit 3 fi -# Shell hook is only valid if not building locally +# Shell hooks are only valid if not building locally if [ "bool_BUILD_LOCALLY" = "y" ]; then bool_SHELL_HOOK="n" fi @@ -222,45 +267,36 @@ done #---------------------------- # Check if module is an extra dependency if [[ $MOD_NAME =~ ^$CFG_EXTRA_DEPS_DIR/ ]]; then - bool_EXTRADEP_MOD="y" + bool_EXTRADEP_MOD="y" fi # Make sure the module exists search_module $MOD_NAME if [ "$MODULE_FOUND" != "y" ]; then - echo "Module \"$MOD_NAME\" not found in GIT" - do_exit 5 + echo "Module \"$MOD_NAME\" not found" + do_exit 5 fi if [ "$bool_BUILD_FROM_GIT" = "y" ]; then echo -e "${CYellow}> Building from GIT repo${CNone}" - # source files + bool_COPY_MOD_SRC="y" + bool_COPY_PKGING_FILES="y" # packaging scripts if [ "$bool_EXTRADEP_MOD" != "y" -a ! -d "$MOD_GIT_PKGING_PATH" ]; then echo "Packaging for \"$MOD_NAME\" not found in GIT" do_exit 6 fi - bool_COPY_PKGING_FILES="y" - # else echo -e "${CYellow}> Building from BUILD folder${CNone}" - # source files - bool_COPY_MOD_SRC="n" + if [ ! -d "$MOD_BUILD_PATH" ]; then - bool_COPY_MOD_SRC="y" + echo "Build folder for \"$MOD_NAME\" not found" + do_exit 7 fi - - # packaging scripts + bool_COPY_MOD_SRC="n" bool_COPY_PKGING_FILES="n" - if [ "$bool_EXTRADEP_MOD" != "y" -a ! -d "$MOD_BUILD_PKGING_PATH" ]; then - if [ ! -d "$MOD_GIT_PKGING_PATH" ]; then - echo "Packaging for \"$MOD_NAME\" not found neither in BUILD nor in GIT" - do_exit 8 - fi - bool_COPY_PKGING_FILES="y" - fi fi @@ -279,7 +315,7 @@ if [ "$bool_COPY_MOD_SRC" = "y" ]; then recreate_folder "$MOD_BUILD_PATH" if [ "$bool_EXTRADEP_MOD" != "y" ]; then # Normal module - cp -R "$MOD_GIT_PATH" "$MOD_BUILD_PATH/.." + cp -R "$MOD_GIT_PATH/." "$MOD_BUILD_PATH" # Add GIT information echo "# TDE SCM module information" > "$MOD_BUILD_PATH/.tdescminfo" echo "Name: $MOD_NAME" >> "$MOD_BUILD_PATH/.tdescminfo" |