diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-09-14 23:42:25 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-09-14 23:42:25 +0900 |
commit | fc2fae6cf24f7cea2374dcba2e73680305c32e53 (patch) | |
tree | 298deb3179e6cf09c3e6cb12791a0d5f9e97de29 /debian/_buildscripts/local/update_repositories.sh | |
parent | fc4b7b4fed7e3677794695cba02725acbc50a50d (diff) | |
download | tde-packaging-fc2fae6cf24f7cea2374dcba2e73680305c32e53.tar.gz tde-packaging-fc2fae6cf24f7cea2374dcba2e73680305c32e53.zip |
DEB build scripts: updated to use extra dependency repository on TGW.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'debian/_buildscripts/local/update_repositories.sh')
-rwxr-xr-x | debian/_buildscripts/local/update_repositories.sh | 342 |
1 files changed, 178 insertions, 164 deletions
diff --git a/debian/_buildscripts/local/update_repositories.sh b/debian/_buildscripts/local/update_repositories.sh index 66bf7bc6b..4e5e4b2e7 100755 --- a/debian/_buildscripts/local/update_repositories.sh +++ b/debian/_buildscripts/local/update_repositories.sh @@ -9,38 +9,38 @@ flag_SKIP_TAGS="n" OVERRIDE_DEFAULT_REPO_BRANCH="" for ((idx=1; idx<=$#; idx++)); do arg="${!idx}" - if [ "$arg" = "-i" ]; then # continue from last updated module (Incremental) - flag_INCREMENTAL="y" - elif [ "$arg" = "-v" ]; then # display and log git command output (Verbose) - flag_VERBOSE_LOG="y" - elif [ "$arg" = "-ub" ]; then # branches to update (Update Branches) - ((idx++)) - OVERRIDE_UPDATE_BRANCHES="${!idx}" - [[ -z "$OVERRIDE_DEFAULT_REPO_BRANCH" ]] && OVERRIDE_DEFAULT_REPO_BRANCH="${!idx}" - elif [ "$arg" = "-db" ]; then # default branch after update (Default Branch) - ((idx++)) - if [[ "$flag_SWITCH_ONLY" != 'y' ]]; then - # '-db' is only used if no '-so' argument is specified. If '-so <branch>' - # is given, '-db <branch> is ignored - OVERRIDE_DEFAULT_REPO_BRANCH="${!idx}" - fi - elif [ "$arg" = "-so" ]; then # switch branch only (Switch Only) - flag_SWITCH_ONLY="y" && ((idx++)) - if ! [[ "${!idx}" =~ ^- ]]; then - OVERRIDE_DEFAULT_REPO_BRANCH="${!idx}" - else - ((idx--)) - fi - elif [ "$arg" = "-st" ]; then # skip ctags generation (Skip Tags) - flag_SKIP_TAGS="y" - fi + if [ "$arg" = "-i" ]; then # continue from last updated module (Incremental) + flag_INCREMENTAL="y" + elif [ "$arg" = "-v" ]; then # display and log git command output (Verbose) + flag_VERBOSE_LOG="y" + elif [ "$arg" = "-ub" ]; then # branches to update (Update Branches) + ((idx++)) + OVERRIDE_UPDATE_BRANCHES="${!idx}" + [[ -z "$OVERRIDE_DEFAULT_REPO_BRANCH" ]] && OVERRIDE_DEFAULT_REPO_BRANCH="${!idx}" + elif [ "$arg" = "-db" ]; then # default branch after update (Default Branch) + ((idx++)) + if [[ "$flag_SWITCH_ONLY" != 'y' ]]; then + # '-db' is only used if no '-so' argument is specified. If '-so <branch>' + # is given, '-db <branch> is ignored + OVERRIDE_DEFAULT_REPO_BRANCH="${!idx}" + fi + elif [ "$arg" = "-so" ]; then # switch branch only (Switch Only) + flag_SWITCH_ONLY="y" && ((idx++)) + if ! [[ "${!idx}" =~ ^- ]]; then + OVERRIDE_DEFAULT_REPO_BRANCH="${!idx}" + else + ((idx--)) + fi + elif [ "$arg" = "-st" ]; then # skip ctags generation (Skip Tags) + flag_SKIP_TAGS="y" + fi done # Load common code . ./internals/_build_common.sh init_common -UPDATE_LOCK_FILENAME="/var/lock/TDE_update_repo_lock" # Lock file for incremental update +UPDATE_LOCK_FILENAME="/var/lock/TDE_update_repo_lock" # Lock file for incremental update declare -A RESULT_STRINGS=( [OK]="[ OK ]" @@ -65,131 +65,131 @@ declare -A COLOR_STRINGS=( # $3 - branch to update function _do_update() { - local MOD_PATH=$1 - local OP_TYPE=$2 - local BRANCH=$3 - local RESULT="" - local LINE_CTRL_SUFFIX="" - - case "$OP_TYPE" in - "fetch") - if [[ -z `grep "^$BRANCH - $MOD_PATH$" "$UPDATE_LOCK_FILENAME"` ]]; then - cd "$MOD_PATH" &>/dev/null - eval git fetch --all --prune $GIT_NO_RECURSE_SUBMODULES $OPT_VERBOSE_LOG - if [ $? -eq 0 ]; then - RESULT="OK" - else - RESULT="FAIL" - fi - echo "$BRANCH - $MOD_PATH" >> "$UPDATE_LOCK_FILENAME" - else - RESULT="SKIP" - fi - ;; - - - "update") - cd "$MOD_PATH" &>/dev/null - if [ $? -eq 0 ]; then - # Clean up any possible uncommitted changes - if [[ ! -z "`git status --porcelain $GIT_IGNORE_SUBMODULES`" ]]; then - git reset --hard HEAD &>/dev/null - git clean -dxff &>/dev/null - fi - # Make sure the local branch exists - if [[ -z `git branch | grep -E "\b$BRANCH\b"` ]]; then - eval git checkout -b \"$BRANCH\" \"origin/$BRANCH\" $OPT_VERBOSE_LOG - else - eval git checkout \"$BRANCH\" $OPT_VERBOSE_LOG - fi - # Make sure the local branch is a tracking branch - if [[ -z `git config branch."$BRANCH".remote` ]]; then - git branch -u "origin/$BRANCH" &>/dev/null #$ - git reset --hard "origin/$BRANCH" &>/dev/null - fi - # Update - eval git reset --hard HEAD $OPT_VERBOSE_LOG - eval git clean -dxff $OPT_VERBOSE_LOG - if [[ $(git rev-parse HEAD) != $(git rev-parse "origin/$BRANCH") ]]; then - eval git rebase $OPT_VERBOSE_LOG - if [[ `git rev-parse HEAD` == `git rev-parse "origin/$BRANCH"` ]]; then - RESULT="UPDATE" - else - RESULT="FAIL" - fi - else - RESULT="OK" - fi - else - RESULT="FAIL" - fi - ;; - - "switch-to") - cd "$MOD_PATH" &>/dev/null - eval git checkout \"$BRANCH\" $OPT_VERBOSE_LOG - eval git reset --hard HEAD $OPT_VERBOSE_LOG - eval git clean -dxff $OPT_VERBOSE_LOG - if [[ ! -z `git branch -v | grep -E "^\*\s+$BRANCH"` ]]; then - RESULT="OK" - else - RESULT="FAIL" - fi - ;; - - *) - RESULT="INV-OP" - ;; - esac - - if [ "$RESULT" != "OK" -o "$flag_VERBOSE_LOG" = "y" ]; then - LINE_CTRL_SUFFIX="\n" - fi - echo -ne "\033[2K\r${COLOR_STRINGS[$RESULT]}${RESULT_STRINGS[$RESULT]} $MOD_PATH${CNone}$LINE_CTRL_SUFFIX" - echo "${RESULT_STRINGS[$RESULT]} $MOD_PATH" >> "$LOG_UPDATE_REPO_FILENAME" + local MOD_PATH=$1 + local OP_TYPE=$2 + local BRANCH=$3 + local RESULT="" + local LINE_CTRL_SUFFIX="" + + case "$OP_TYPE" in + "fetch") + if [[ -z `grep "^$BRANCH - $MOD_PATH$" "$UPDATE_LOCK_FILENAME"` ]]; then + cd "$MOD_PATH" &>/dev/null + eval git fetch --all --prune $GIT_NO_RECURSE_SUBMODULES $OPT_VERBOSE_LOG + if [ $? -eq 0 ]; then + RESULT="OK" + else + RESULT="FAIL" + fi + echo "$BRANCH - $MOD_PATH" >> "$UPDATE_LOCK_FILENAME" + else + RESULT="SKIP" + fi + ;; + + + "update") + cd "$MOD_PATH" &>/dev/null + if [ $? -eq 0 ]; then + # Clean up any possible uncommitted changes + if [[ ! -z "`git status --porcelain $GIT_IGNORE_SUBMODULES`" ]]; then + git reset --hard HEAD &>/dev/null + git clean -dxff &>/dev/null + fi + # Make sure the local branch exists + if [[ -z `git branch | grep -E "\b$BRANCH\b"` ]]; then + eval git checkout -b \"$BRANCH\" \"origin/$BRANCH\" $OPT_VERBOSE_LOG + else + eval git checkout \"$BRANCH\" $OPT_VERBOSE_LOG + fi + # Make sure the local branch is a tracking branch + if [[ -z `git config branch."$BRANCH".remote` ]]; then + git branch -u "origin/$BRANCH" &>/dev/null #$ + git reset --hard "origin/$BRANCH" &>/dev/null + fi + # Update + eval git reset --hard HEAD $OPT_VERBOSE_LOG + eval git clean -dxff $OPT_VERBOSE_LOG + if [[ $(git rev-parse HEAD) != $(git rev-parse "origin/$BRANCH") ]]; then + eval git rebase $OPT_VERBOSE_LOG + if [[ `git rev-parse HEAD` == `git rev-parse "origin/$BRANCH"` ]]; then + RESULT="UPDATE" + else + RESULT="FAIL" + fi + else + RESULT="OK" + fi + else + RESULT="FAIL" + fi + ;; + + "switch-to") + cd "$MOD_PATH" &>/dev/null + eval git checkout \"$BRANCH\" $OPT_VERBOSE_LOG + eval git reset --hard HEAD $OPT_VERBOSE_LOG + eval git clean -dxff $OPT_VERBOSE_LOG + if [[ ! -z `git branch -v | grep -E "^\*\s+$BRANCH"` ]]; then + RESULT="OK" + else + RESULT="FAIL" + fi + ;; + + *) + RESULT="INV-OP" + ;; + esac + + if [ "$RESULT" != "OK" -o "$flag_VERBOSE_LOG" = "y" ]; then + LINE_CTRL_SUFFIX="\n" + fi + echo -ne "\033[2K\r${COLOR_STRINGS[$RESULT]}${RESULT_STRINGS[$RESULT]} $MOD_PATH${CNone}$LINE_CTRL_SUFFIX" + echo "${RESULT_STRINGS[$RESULT]} $MOD_PATH" >> "$LOG_UPDATE_REPO_FILENAME" } #---------------------------- # Update a given module and all submodules from the upstream repo # Parameters: # $1 - module folder -# $2 - operation type +# $2 - operation type # $3 - branch to update function _update_module() { - local MOD_PATH=$1 - local OP_TYPE=$2 - local BRANCH=$3 - - # Current module - _do_update "$@" + local MOD_PATH=$1 + local OP_TYPE=$2 + local BRANCH=$3 + + # Current module + _do_update "$@" # Submodules local SUBMOD_LIST="$MOD_PATH/.gitmodules" - if [[ -e "$SUBMOD_LIST" ]]; then - sed -n "s|^\[submodule \"\([^\"]*\)\"\]$|\1|p" <$SUBMOD_LIST |\ - while read -r SUBMOD_PATH; do - cd "$MOD_PATH" &>/dev/null - if [[ -z "`git config --get submodule.$SUBMOD_PATH.url`" ]]; then - eval git submodule init -- \"$SUBMOD_PATH\" $OPT_VERBOSE_LOG - fi - if [[ ! -e "$MOD_PATH/$SUBMOD_PATH/.git" ]]; then - eval git submodule update -- \"$SUBMOD_PATH\" $OPT_VERBOSE_LOG - fi - _update_module "$MOD_PATH/$SUBMOD_PATH" "$OP_TYPE" "$BRANCH" - done - fi + if [[ -e "$SUBMOD_LIST" ]]; then + sed -n "s|^\[submodule \"\([^\"]*\)\"\]$|\1|p" <$SUBMOD_LIST |\ + while read -r SUBMOD_PATH; do + cd "$MOD_PATH" &>/dev/null + if [[ -z "`git config --get submodule.$SUBMOD_PATH.url`" ]]; then + eval git submodule init -- \"$SUBMOD_PATH\" $OPT_VERBOSE_LOG + fi + if [[ ! -e "$MOD_PATH/$SUBMOD_PATH/.git" ]]; then + eval git submodule update -- \"$SUBMOD_PATH\" $OPT_VERBOSE_LOG + fi + _update_module "$MOD_PATH/$SUBMOD_PATH" "$OP_TYPE" "$BRANCH" + done + fi } #---------------------------- if [ "$flag_INCREMENTAL" = "y" ]; then [ ! -f "$UPDATE_LOCK_FILENAME" ] && flag_INCREMENTAL="n" else - [ -f "$UPDATE_LOCK_FILENAME" ] && rm "$UPDATE_LOCK_FILENAME" + [ -f "$UPDATE_LOCK_FILENAME" ] && rm "$UPDATE_LOCK_FILENAME" fi OPT_VERBOSE_LOG="&>/dev/null" if [[ "$flag_VERBOSE_LOG" = "y" ]]; then - OPT_VERBOSE_LOG=" |& tee -a \"$LOG_UPDATE_REPO_FILENAME\"" + OPT_VERBOSE_LOG=" |& tee -a \"$LOG_UPDATE_REPO_FILENAME\"" fi #---------------------------- @@ -205,48 +205,62 @@ fi # Start update if [ "$flag_INCREMENTAL" != "y" ]; then - echo "TDE repositories update started" > "$UPDATE_LOCK_FILENAME" + echo "TDE repositories update started" > "$UPDATE_LOCK_FILENAME" fi _LAST_BRANCH="" if [[ "$flag_SWITCH_ONLY" != "y" ]]; then - # Fetch all remotes first - echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" "y" - echo_and_tee "${CLightCyan} Fetching remotes ${CNone}" "$LOG_UPDATE_REPO_FILENAME" - echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" - - # Fetch TDE main repository - _update_module "$REPO_TDE" "fetch" - - echo -e "\033[2K" - echo "" >> "$LOG_UPDATE_REPO_FILENAME" - - # Branch update - for branch in "${BRANCHES[@]}"; do - _LAST_BRANCH="$branch" - echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" - echo_and_tee "${CLightCyan} Updating branch ${CYellow}$branch ${CNone}" "$LOG_UPDATE_REPO_FILENAME" - echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" - - # Update TDE main repository - _update_module "$REPO_TDE" "update" "$branch" - - echo -e "\033[2K" - echo "" >> "$LOG_UPDATE_REPO_FILENAME" - done + # Update extra dependency repository + if [[ "$USE_PREBUILD_EXTRA_DEPS" != "y" ]]; then + echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" "y" + echo_and_tee "${CLightCyan} Fetching extra dependencies ${CNone}" "$LOG_UPDATE_REPO_FILENAME" + echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" + + # Fetch TDE extra dependency repository + _update_module "$REPO_EXTRA_DEPENDENCIES" "fetch" + _update_module "$REPO_EXTRA_DEPENDENCIES" "update" "master" + + echo -e "\033[2K" + echo "" >> "$LOG_UPDATE_REPO_FILENAME" + fi + + # Fetch all remotes first + echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" "y" + echo_and_tee "${CLightCyan} Fetching remotes ${CNone}" "$LOG_UPDATE_REPO_FILENAME" + echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" + + # Fetch TDE main repository + _update_module "$REPO_TDE" "fetch" + + echo -e "\033[2K" + echo "" >> "$LOG_UPDATE_REPO_FILENAME" + + # Branch update + for branch in "${BRANCHES[@]}"; do + _LAST_BRANCH="$branch" + echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" + echo_and_tee "${CLightCyan} Updating branch ${CYellow}$branch ${CNone}" "$LOG_UPDATE_REPO_FILENAME" + echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" + + # Update TDE main repository + _update_module "$REPO_TDE" "update" "$branch" + + echo -e "\033[2K" + echo "" >> "$LOG_UPDATE_REPO_FILENAME" + done fi # Switch to specified branch if necessary if [[ "$DEFAULT_REPO_BRANCH" != "$_LAST_BRANCH" ]]; then - echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" "$flag_SWITCH_ONLY" - echo_and_tee "${CLightCyan} Switching to branch ${CYellow}$DEFAULT_REPO_BRANCH ${CNone}" "$LOG_UPDATE_REPO_FILENAME" - echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" - - # Switch TDE main repository - _update_module "$REPO_TDE" "switch-to" "$DEFAULT_REPO_BRANCH" - - echo -e "\033[2K" - echo "" >> "$LOG_UPDATE_REPO_FILENAME" + echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" "$flag_SWITCH_ONLY" + echo_and_tee "${CLightCyan} Switching to branch ${CYellow}$DEFAULT_REPO_BRANCH ${CNone}" "$LOG_UPDATE_REPO_FILENAME" + echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" + + # Switch TDE main repository + _update_module "$REPO_TDE" "switch-to" "$DEFAULT_REPO_BRANCH" + + echo -e "\033[2K" + echo "" >> "$LOG_UPDATE_REPO_FILENAME" fi # Update completed |