From 7e05a8b13a137f60600a3694c7a9091752cd7162 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Tue, 24 Jul 2018 18:40:18 +0900 Subject: DEB/UBU build scripts. 1) added support for Devuan distros 2) added more command line options for update_repositories.sh 3) bug fixes and improved user feedback 4) added link inside ubuntu distro Signed-off-by: Michele Calgaro --- debian/_buildscripts/local/README.txt | 33 ++++--- debian/_buildscripts/local/build_module.sh | 8 +- .../_buildscripts/local/internals/_build_common.sh | 12 ++- .../local/internals/_config_template.sh | 2 +- .../_buildscripts/local/internals/distro_list.txt | 69 ++++++++------ .../_buildscripts/local/internals/extra_deps.txt | 6 +- debian/_buildscripts/local/update_repositories.sh | 103 ++++++++++++++------- 7 files changed, 153 insertions(+), 80 deletions(-) (limited to 'debian/_buildscripts') diff --git a/debian/_buildscripts/local/README.txt b/debian/_buildscripts/local/README.txt index cbe44130a..1e12a01b9 100644 --- a/debian/_buildscripts/local/README.txt +++ b/debian/_buildscripts/local/README.txt @@ -27,7 +27,8 @@ A) Environment preparation 3_repo : local repo for package installation (to be configured in /etc/apt/sources.list) buildscripts: contains a local copy of the build scripts, which can be modified as required - in TDE_DIR/1_git: - edeps : contains extra dependency modules necessary to build TDE + edeps : contains extra dependency modules necessary to build TDE (this folder is not necessary + is pre-built extra dependencies are used - see point 9 for more info) hooks : contains build hook scripts to execute ad-hoc code before and after the building process. Mainly used to apply patches automatically during the building process @@ -45,11 +46,11 @@ A) Environment preparation 5) Add your user to the sudo group (not required if you are root) su -c "adduser sudo" - Optionally, consider extending your sudo timeout interval to avoid having to type your password too often - (this could be quite painful especially during long builds, which would not be able to complete if unattended). - To do this, type "sudo visudo" and then add "Defaults timestamp_timeout=", where the value is in - minutes. Use a value of -1 to set an infinite timeout. Logout and login again to make sure the new settings are applied. + * Optionally, consider extending your sudo timeout interval to avoid having to type your password too often + (this could be quite painful especially during long builds, which would not be able to complete if unattended). + To do this, type "sudo visudo" and then add "Defaults timestamp_timeout=", where the value is in + minutes. Use a value of -1 to set an infinite timeout. 6) Copy the files from "TDE_DIR/1_git/tde-packaging/debian/_buildscripts/local/additional_files" folder to the respectivily named folders. @@ -81,12 +82,14 @@ A) Environment preparation installing the extra dependency packages when TDE is installed. * For R14.1.x series (repository branch "master") # --- SLAVEK BANKO'S EXTRA DEPENDENCIES REPOSITORY --- - deb http://mirror.xcer.cz/trinity-tb deps + # - temporarily disabled - + # - http://mirror.ppa.trinitydesktop.org/trinity-testing/dists deps + deb http://mirror.ppa.trinitydesktop.org/trinity-sb deps-r14 * For R14.0.x series (repository branch "r14.0.x") # --- SLAVEK BANKO'S EXTRA DEPENDENCIES REPOSITORY --- - deb http://mirror.xcer.cz/trinity-sb deps-r14 + deb http://mirror.ppa.trinitydesktop.org/trinity-sb deps-r14 For example: - deb http://mirror.xcer.cz/trinity-tb buster deps + deb http://mirror.ppa.trinitydesktop.org/trinity-sb buster deps - install package dirmngr if required - import Slavek's GPG key into your apt keyring sudo apt-key adv --keyserver pool.sks-keyservers.net --recv-key A04BE668 @@ -136,15 +139,23 @@ When building sets of modules or the whole TDE, a global build summary is automa Script used to update the local clone of the git repositories. It is possible to update multiple branches as specified by the variable UPDATE_BRANCHES in the configuration file. After the update is completed, the local repositories will be switched to the branch specified by the - DEFAULT_REPO_BRANCH variable. The default branch can be overridden by using OVERRIDE_DEFAULT_REPO_BRANCH when - invoking the script. + DEFAULT_REPO_BRANCH variable. + The script can also be used to switch the local repositories to a particular branch, without performing any update. Usage: - [OVERRIDE_DEFAULT_REPO_BRANCH=""] update_git_repository.sh [options] + update_git_repository.sh [options] Options: -i (Incremental) : in case the previous update was interrupted, continue from the last known updated module. (useful on slow/unstable internet connections). If the previous update had completed, this option is ignored. -v (Verbose) : display and log more output. Useful for troubleshooting. + -ub "" (Update Branches) : allows to specify the branches to update. This override the variable + UPDATE_BRANCHES in the configuration file. If a single branch is specified and the + '-db'/'-sb' paraemters are not used, '-ub' can be used to update and switch a single branch. + -db (Default Branch) : allows to specify the default branch. This override the variable + DEFAULT_REPO_BRANCH in the configuration file. + This option is only used if the argument '-so' is not specified. + -so (Switch Only) : switch the local repositories to the specified branch, without doing any update. + If '-ub' is used, the '-so' branch name must be one of those specified in the 'ub' branches. - build_module.sh Build a single module. diff --git a/debian/_buildscripts/local/build_module.sh b/debian/_buildscripts/local/build_module.sh index 18d55d778..50c9c3a14 100755 --- a/debian/_buildscripts/local/build_module.sh +++ b/debian/_buildscripts/local/build_module.sh @@ -122,11 +122,13 @@ export OPT_SHOW_LOGS echo -e "${CLightCyan}#### Processing module \"$MOD_NAME\" ####${CNone}" # This folders must exists -BASE_DIRS=("REPO_DIR" "BUILD_DIR" "SCRIPT_DIR" "REPO_TDE_MAIN" "REPO_TDE_PACKAGING" "REPO_EXTRA_DEPENDENCIES" "HOOK_DIR") - +BASE_DIRS=("REPO_DIR" "BUILD_DIR" "SCRIPT_DIR" "REPO_TDE_MAIN" "REPO_TDE_PACKAGING" "HOOK_DIR") +if [[ "$USE_PREBUILD_EXTRA_DEPS" != "y" ]]; then + BASE_DIRS+=("REPO_EXTRA_DEPENDENCIES") +fi for var_name in ${BASE_DIRS[@]}; do if [ ! -d "${!var_name}" ]; then - echo -e "$var_name directory missing. Value is \"${!var_name}\". Check your config or create it." + echo -e "${CYellow}$var_name${CNone} folder missing (${CLightPurple}${!var_name}${CNone}). Check your config or create it." do_exit 4 fi done diff --git a/debian/_buildscripts/local/internals/_build_common.sh b/debian/_buildscripts/local/internals/_build_common.sh index 5e4ba67fe..8b048a635 100755 --- a/debian/_buildscripts/local/internals/_build_common.sh +++ b/debian/_buildscripts/local/internals/_build_common.sh @@ -50,7 +50,7 @@ function echo_and_tee() } #---------------------------- -function _set_path_varables() +function _set_path_variables() { # Set useful path variables set -a @@ -91,7 +91,7 @@ function init_common() CFG_FILE=$SCRIPT_DIR/_config.sh if [ -f "$CFG_FILE" ]; then . "$CFG_FILE" - _set_path_varables + _set_path_variables else echo -e "${CLightRed} --- NOTE ---${CNone}" echo -e "Creating TDE build configuration file from template as ${CLightPurple}$CFG_FILE${CNone}." @@ -111,11 +111,16 @@ function init_common() # -- Need to use a "here string" otherwise if the DISTRO_FOUND value is modified # -- inside the while loop, this would not remember after the loop. DISTRO_FOUND="n" - while read l_distro l_version l_name l_rel_suffix; do + while read l_distro l_version l_name l_rel_suffix l_packaging_path; do if [ "$l_distro" = "$DISTRO" -a "$l_name" = "$DISTRO_NAME" ]; then DISTRO_FOUND="y" + l_rel_suffix=`echo "$l_rel_suffix" | perl -pe "s|^[\"']?(.*?)[\"']?$|\1|g"` + l_packaging_path=`echo "$l_packaging_path" | perl -pe "s|^[\"']?(.*?)[\"']?$|\1|g"` export DISTRO_VERSION="$l_version" export REL_SUFFIX="$l_rel_suffix" + if [[ ! -z "$l_packaging_path" ]]; then + REPO_TDE_PACKAGING="$TDE_DIR/$CFG_GIT_DIR/tde-packaging/$l_packaging_path" + fi break fi done <<< $(cat $DISTS_FILE | grep -E "^(\s*[^#\s]+\s+[^\s]+.*)$") @@ -163,6 +168,7 @@ function init_common() # Check branch configuration # - branch existance + UPDATE_BRANCHES="${OVERRIDE_UPDATE_BRANCHES:-$UPDATE_BRANCHES}" cd "$REPO_TDE" BRANCHES=() REMOTE_BRANCHES=(`git branch --remote | grep -v "HEAD" | sed "s|origin/||g"`) diff --git a/debian/_buildscripts/local/internals/_config_template.sh b/debian/_buildscripts/local/internals/_config_template.sh index be992d297..00d25e315 100644 --- a/debian/_buildscripts/local/internals/_config_template.sh +++ b/debian/_buildscripts/local/internals/_config_template.sh @@ -28,7 +28,7 @@ CFG_SCRIPT_LOG_DIR="0_logs" CFG_GIT_DIR="1_git" CFG_BUILD_DIR="2_build" CFG_REPO_DIR="3_repo" -CFG_EXTRA_DEPS_DIR="edeps" # Relative to CFG_GIT_DIR folder +CFG_EXTRA_DEPS_DIR="edeps" # Relative to CFG_GIT_DIR folder. Only required if USE_PREBUILD_EXTRA_DEPS != "y" CFG_HOOKS_DIR="hooks" # Relative to CFG_GIT_DIR folder set +a diff --git a/debian/_buildscripts/local/internals/distro_list.txt b/debian/_buildscripts/local/internals/distro_list.txt index 0ca037eb0..9d2707e7b 100644 --- a/debian/_buildscripts/local/internals/distro_list.txt +++ b/debian/_buildscripts/local/internals/distro_list.txt @@ -1,31 +1,48 @@ #!/bin/bash # List of supported distributions +# +# Format: +# distro name +# distro version number +# distro version name +# package suffix if required +# tde-packaging corresponding path if required +# DISTROS=" - debian 5.0 lenny - debian 6.0 squeeze - debian 7.0 wheezy - debian 8.0 jessie - debian 9.0 stretch - debian 10.0 buster ~a - debian 10.0 sid ~b - raspbian 7.0 raspbian-wheezy - raspbian 8.0 raspbian-jessie - ubuntu 10.04 lucid - ubuntu 10.10 maverick - ubuntu 11.04 natty - ubuntu 11.10 oneiric - ubuntu 12.04 precise - ubuntu 12.10 quantal - ubuntu 13.04 raring - ubuntu 13.10 saucy - ubuntu 14.04 trusty - ubuntu 14.10 utopic - ubuntu 15.04 vivid - ubuntu 15.10 wily - ubuntu 16.04 xenial - ubuntu 16.10 yakkety - ubuntu 17.04 zesty - ubuntu 17.10 artful - ubuntu 18.04 bionic ~a + # -- debian -- + debian 5.0 lenny '' '' + debian 6.0 squeeze '' '' + debian 7.0 wheezy '' '' + debian 8.0 jessie '' '' + debian 9.0 stretch '' '' + debian 10.0 buster ~a '' + debian 11.0 sid ~b '' + # -- devuan -- + devuan 1.0 jessie '' debian/jessie + devuan 2.0 ascii '' debian/stretch + devuan 3.0 beowulf ~a debian/buster + devuan 4.0 ceres ~b debian/sid + # -- raspbian -- + raspbian 7.0 raspbian-wheezy '' '' + raspbian 8.0 raspbian-jessie '' '' + raspbian 9.0 raspbian-stretch '' '' + # -- ubuntu -- + ubuntu 10.04 lucid '' '' + ubuntu 10.10 maverick '' '' + ubuntu 11.04 natty '' '' + ubuntu 11.10 oneiric '' '' + ubuntu 12.04 precise '' '' + ubuntu 12.10 quantal '' '' + ubuntu 13.04 raring '' '' + ubuntu 13.10 saucy '' '' + ubuntu 14.04 trusty '' '' + ubuntu 14.10 utopic '' '' + ubuntu 15.04 vivid '' '' + ubuntu 15.10 wily '' '' + ubuntu 16.04 xenial '' '' + ubuntu 16.10 yakkety '' '' + ubuntu 17.04 zesty '' '' + ubuntu 17.10 artful '' '' + ubuntu 18.04 bionic ~a '' " diff --git a/debian/_buildscripts/local/internals/extra_deps.txt b/debian/_buildscripts/local/internals/extra_deps.txt index 12cd3b395..0a764d9bc 100644 --- a/debian/_buildscripts/local/internals/extra_deps.txt +++ b/debian/_buildscripts/local/internals/extra_deps.txt @@ -2,6 +2,8 @@ # List of repositories for extra dependency packages EDEPS_REPO=" - master http://mirror.xcer.cz/trinity-tb deps - r14.0.x http://mirror.xcer.cz/trinity-sb deps-r14 +# - For the time being use stable builds for extra dependencies +# master http://mirror.ppa.trinitydesktop.org/trinity-testing deps + master http://mirror.ppa.trinitydesktop.org/trinity-sb deps-r14 + r14.0.x http://mirror.ppa.trinitydesktop.org/trinity-sb deps-r14 " diff --git a/debian/_buildscripts/local/update_repositories.sh b/debian/_buildscripts/local/update_repositories.sh index a9d2fef12..5c0f5aa45 100755 --- a/debian/_buildscripts/local/update_repositories.sh +++ b/debian/_buildscripts/local/update_repositories.sh @@ -1,5 +1,34 @@ #!/bin/bash +# Check command line arguments and set options +# Run before loading configuration, to allow branch overriding +bool_INCREMENTAL="n" +bool_VERBOSE_LOG="n" +bool_SWITCH_ONLY="n" +OVERRIDE_DEFAULT_REPO_BRANCH="" +for ((idx=1; idx<=$#; idx++)); do + arg="${!idx}" + if [ "$arg" = "-i" ]; then # continue from last updated module (Incremental) + bool_INCREMENTAL="y" + elif [ "$arg" = "-v" ]; then # display and log git command output (Verbose) + bool_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 [[ "$bool_SWITCH_ONLY" != 'y' ]]; then + # '-db' is only used if no '-so' argument is specified. If '-so ' + # is given, '-db is ignored + OVERRIDE_DEFAULT_REPO_BRANCH="${!idx}" + fi + elif [ "$arg" = "-so" ]; then # switch branch only (Switch Only) + bool_SWITCH_ONLY="y" && ((idx++)) + OVERRIDE_DEFAULT_REPO_BRANCH="${!idx}" + fi +done + # Load common code . ./internals/_build_common.sh init_common @@ -12,11 +41,13 @@ UPDATE_LOCK_FILENAME="/var/lock/TDE_update_repo_lock" # Lock file for incremen # $1 - module folder # $2 - operation type # $3 - branch to update +# $4 - new branch flag (only for reporting) function _do_update() { local MOD_PATH=$1 local OP_TYPE=$2 local BRANCH=$3 + local NEW_BRANCH=$4 local RESULT="" case "$OP_TYPE" in @@ -29,17 +60,18 @@ function _do_update() git reset --hard HEAD &>/dev/null git clean -dxff &>/dev/null fi - # Make sure the local branch exists and is a tracking branch + # Make sure the local branch exists if [[ -z `git branch | grep -E "\b$BRANCH\b"` ]]; then + NEW_BRANCH="y" eval git checkout -b \"$BRANCH\" \"origin/$BRANCH\" $OPT_VERBOSE_LOG else eval git checkout \"$BRANCH\" $OPT_VERBOSE_LOG fi - if [[ ! -z `git branch -v | grep -E "^\*\s+$BRANCH"` ]]; then - if [[ -z `git branch -vv | grep "origin/$BRANCH"` ]]; then - git branch -u "origin/$BRANCH" &>/dev/null #$ - git reset --hard "origin/$BRANCH" &>/dev/null - fi + # Make sure the local branch is a tracking branch + if [[ -z `git config branch."$BRANCH".remote` ]]; then + NEW_BRANCH="y" + git branch -u "origin/$BRANCH" &>/dev/null #$ + git reset --hard "origin/$BRANCH" &>/dev/null fi # Update eval git reset --hard HEAD $OPT_VERBOSE_LOG @@ -53,7 +85,11 @@ function _do_update() RESULT="${CLightRed}[ FAIL ]" fi else - RESULT="[ OK ]" + if [[ "$NEW_BRANCH" = "y" ]]; then + RESULT="${CLightGreen}[ UPDATE ]" + else + RESULT="[ OK ]" + fi fi else RESULT="${CLightRed}[ FAIL ]" @@ -67,6 +103,8 @@ function _do_update() "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 @@ -88,42 +126,37 @@ function _do_update() # $1 - module folder # $2 - operation type # $3 - branch to update +# $4 - new branch flag (only for reporting) function _update_module() { local MOD_PATH=$1 local OP_TYPE=$2 local BRANCH=$3 + # Current module _do_update "$@" # Submodules + local NEW_BRANCH="n" 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 + NEW_BRANCH="n" cd "$MOD_PATH" &>/dev/null if [[ -z "`git config --get submodule.$SUBMOD_PATH.url`" ]]; then + NEW_BRANCH="y" # if a submodule is missing, need to report "update" status eval git submodule init -- \"$SUBMOD_PATH\" $OPT_VERBOSE_LOG fi if [[ ! -e "$MOD_PATH/$SUBMOD_PATH/.git" ]]; then + NEW_BRANCH="y" # if a submodule is incomplete, need to report "update" status eval git submodule update -- \"$SUBMOD_PATH\" $OPT_VERBOSE_LOG fi - _update_module "$MOD_PATH/$SUBMOD_PATH" "$OP_TYPE" "$BRANCH" + _update_module "$MOD_PATH/$SUBMOD_PATH" "$OP_TYPE" "$BRANCH" "$NEW_BRANCH" done fi } #---------------------------- -# Check command line arguments and set options -bool_INCREMENTAL="n" -bool_VERBOSE_LOG="n" -for arg in $@; do - if [ "$arg" = "-i" ]; then # continue from last updated module (Incremental) - bool_INCREMENTAL="y" - elif [ "$arg" = "-v" ]; then # display and log git command output - bool_VERBOSE_LOG="y" - fi -done - if [ "$bool_INCREMENTAL" = "y" ]; then [ ! -f "$UPDATE_LOCK_FILENAME" ] && bool_INCREMENTAL="n" else @@ -151,22 +184,24 @@ if [ "$bool_INCREMENTAL" != "y" ]; then echo "TDE repositories update started" > "$UPDATE_LOCK_FILENAME" fi -# Branch update _LAST_BRANCH="" -for branch in "${BRANCHES[@]}"; do - _LAST_BRANCH="$branch" - echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" "y" - echo_and_tee "${CLightCyan} Updating branch ${CYellow}$branch ${CNone}" "$LOG_UPDATE_REPO_FILENAME" - echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" +if [[ "$bool_SWITCH_ONLY" != 'y' ]]; then + # Branch update + for branch in "${BRANCHES[@]}"; do + _LAST_BRANCH="$branch" + echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" "y" + 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" "n" - # Update TDE main repository - _update_module "$REPO_TDE" "update" "$branch" - - # Update TDE packaging repository - _update_module "$TDE_DIR/$CFG_GIT_DIR/tde-packaging" "update" "$branch" + # Update TDE packaging repository + _update_module "$TDE_DIR/$CFG_GIT_DIR/tde-packaging" "update" "$branch" "n" - echo_and_tee "" "$LOG_UPDATE_REPO_FILENAME" -done + echo_and_tee "" "$LOG_UPDATE_REPO_FILENAME" + done +fi # Switch to specified branch if necessary if [[ "$DEFAULT_REPO_BRANCH" != "$_LAST_BRANCH" ]]; then @@ -175,10 +210,10 @@ if [[ "$DEFAULT_REPO_BRANCH" != "$_LAST_BRANCH" ]]; then echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" # Switch TDE main repository - _update_module "$REPO_TDE" "switch-to" "$DEFAULT_REPO_BRANCH" + _update_module "$REPO_TDE" "switch-to" "$DEFAULT_REPO_BRANCH" "n" # Switch TDE packaging repository - _update_module "$TDE_DIR/$CFG_GIT_DIR/tde-packaging" "switch-to" "$DEFAULT_REPO_BRANCH" + _update_module "$TDE_DIR/$CFG_GIT_DIR/tde-packaging" "switch-to" "$DEFAULT_REPO_BRANCH" "n" echo_and_tee "" "$LOG_UPDATE_REPO_FILENAME" fi -- cgit v1.2.1