DEB build scripts: updated to use extra dependency repository on TGW.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/18/head
Michele Calgaro 4 years ago
parent fc4b7b4fed
commit fc2fae6cf2
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -26,28 +26,31 @@ A) Environment preparation
2_build: folder used for build preparation and for local builds 2_build: folder used for build preparation and for local builds
3_repo : local repo for package installation (to be configured in /etc/apt/sources.list) 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 buildscripts: contains a local copy of the build scripts, which can be modified as required
- in TDE_DIR/1_git: - in TDE_DIR/1_git:
edeps : contains extra dependency modules necessary to build TDE (this folder is not necessary 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) if 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. 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 Mainly used to apply patches automatically during the building process
4) Clone TDE git repositories 4) Clone TDE git repositories
- TDE main repo - TDE main repo
cd "$TDE_DIR/1_git" cd "$TDE_DIR/1_git"
git clone https://mirror.git.trinitydesktop.org/gitea/TDE/tde git clone https://mirror.git.trinitydesktop.org/gitea/TDE/tde.git
git clone https://mirror.git.trinitydesktop.org/gitea/TDE/scripts.git tde/scripts
cd tde cd tde
git submodule init -- scripts
git submodule update -- scripts
./scripts/switch_all_submodules_to_head_and_clean anonymous ./scripts/switch_all_submodules_to_head_and_clean anonymous
- If you are not using pre-built extra dependencies:
cd "$TDE_DIR/1_git"
git clone https://mirror.git.trinitydesktop.org/gitea/TDE/extra-dependencies.git edeps
5) Add your user to the sudo group (not required if you are root) 5) Add your user to the sudo group (not required if you are root)
su -c "adduser <username> sudo" su -c "adduser <username> sudo"
Logout and login again to make sure the new settings are applied. 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 * 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). (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=<new timeout>", where the value is in To do this, type "sudo visudo" and then add "Defaults timestamp_timeout=<new timeout>", where the value is in
minutes. Use a value of -1 to set an infinite timeout. 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 6) Copy the files from "TDE_DIR/1_git/tde/packaging/debian/_buildscripts/local/additional_files" folder
to the respectivily named folders. to the respectivily named folders.
@ -56,7 +59,7 @@ A) Environment preparation
sudo pbuilder create sudo pbuilder create
If you wish to build for a different distro or architecture, use the command: If you wish to build for a different distro or architecture, use the command:
sudo DISTRO_NAME=<target distro> ARCHITECTURE=<target architecture> pbuilder create sudo DISTRO_NAME=<target distro> ARCHITECTURE=<target architecture> pbuilder create
8) Setup the build scripts locally: 8) Setup the build scripts locally:
- copy build scripts from "TDE_DIR/1_git/tde/packaging/debian/_buildscripts/local" to "TDE_DIR/buildscripts" - copy build scripts from "TDE_DIR/1_git/tde/packaging/debian/_buildscripts/local" to "TDE_DIR/buildscripts"
and make sure all shell scripts are executable and make sure all shell scripts are executable
@ -67,54 +70,42 @@ A) Environment preparation
* TDE_DIR to the correct path. * TDE_DIR to the correct path.
* DISTRO, DISTRO_NAME and ARCHITECTURE to match the distro and architecture you want to build for if different * DISTRO, DISTRO_NAME and ARCHITECTURE to match the distro and architecture you want to build for if different
from your current setup. Otherwise the variables can be left empty and auto detection will be performed. from your current setup. Otherwise the variables can be left empty and auto detection will be performed.
* UPDATE_BRANCHES to the branches you want to keep updated from the main repositories. * UPDATE_BRANCHES to the branches you want to keep updated from the main repositories.
* DEFAULT_REPO_BRANCH to the branch to check out at the end of the repositories update process. * DEFAULT_REPO_BRANCH to the branch to check out at the end of the repositories update process.
9) Some additional packages (referred to as extra dependencies) are required to build and install TDE in debian/ubuntu. 9) Some additional packages (referred to as extra dependencies) are required to build and install TDE in debian/ubuntu.
These modules can be built locally, but the procedure is a bit cumbersome. Alternatively, Slavek Banko's These modules can be built locally or alternatively Slavek Banko's pre-built binaries can be used.
pre-built binaries can be used.
9.1) Using pre-built extra dependencies
9.1) Using pre-built extra dependencies (recommended option)
- open "_config.sh" and set the variable USE_PREBUILD_EXTRA_DEPS to "y" (this is the default initial setting) - open "_config.sh" and set the variable USE_PREBUILD_EXTRA_DEPS to "y" (this is the default initial setting)
- add the following lines to the /etc/apt/sources.list file. This will setup Slavek's repositories in apt for - add the following lines to the /etc/apt/sources.list file. This will setup Slavek's repositories in apt for
installing the extra dependency packages when TDE is installed. installing the extra dependency packages when TDE is installed.
* For R14.1.x series (repository branch "master") * For R14.1.x series (repository branch "master")
# --- SLAVEK BANKO'S EXTRA DEPENDENCIES REPOSITORY --- # --- SLAVEK BANKO'S EXTRA DEPENDENCIES REPOSITORY ---
# - temporarily disabled - deb http://mirror.ppa.trinitydesktop.org/trinity-testing <YOUR DISTRO> deps
# - http://mirror.ppa.trinitydesktop.org/trinity-testing/dists <YOUR DISTRO> deps * For R14.0.x series (repository branch "r14.0.x")
deb http://mirror.ppa.trinitydesktop.org/trinity-sb <YOUR DISTRO> deps-r14 # --- SLAVEK BANKO'S EXTRA DEPENDENCIES REPOSITORY ---
* For R14.0.x series (repository branch "r14.0.x") deb http://mirror.ppa.trinitydesktop.org/trinity-sb <YOUR DISTRO> deps-r14
# --- SLAVEK BANKO'S EXTRA DEPENDENCIES REPOSITORY --- For example:
deb http://mirror.ppa.trinitydesktop.org/trinity-sb <YOUR DISTRO> deps-r14 deb http://mirror.ppa.trinitydesktop.org/trinity-sb buster deps-r14
For example:
deb http://mirror.ppa.trinitydesktop.org/trinity-sb buster deps-r14 - install package dirmngr if required
- install package dirmngr if required - import TDE Archive Signing key into your apt keyring
- import TDE Archive Signing key into your apt keyring sudo apt-key adv --keyserver pool.sks-keyservers.net --recv-key C93AF1698685AD8B
sudo apt-key adv --keyserver pool.sks-keyservers.net --recv-key C93AF1698685AD8B
9.2) Building extra dependencies locally (recommended option)
9.2) Building extra dependencies locally - open "_config.sh" and set the variables USE_PREBUILD_EXTRA_DEPS to "n" and
- open "_config.sh" and set the variable USE_PREBUILD_EXTRA_DEPS to "n" CFG_EXTRA_DEPS_DIR to "edeps"
- install the following packages: links2 and required dependencies. - build the extra dependency as any other normal module
- using links2 (or another browser), download the source code for the extra dependency modules from
Slavek's PPA (usually more recently updated):
https://quickbuild.pearsoncomputing.net/~slavek-banko/+archive/deps-r14/+packages
or from the official PPA:
https://quickbuild.pearsoncomputing.net/~trinity/+archive/trinity-nightly-build-dependencies/+packages
NOTES:
* Once the page open in your browser, select your distro in the combobox near the "Filter" button and click
the button to update. You should get a list of 10-15 modules, depending on the distro.
* Click on one module at a time, it will expand (or open another page) and show a list of .deb and other files.
* Save those files (exclude .deb files. Only .orig.tar.xz, .dsc, .debian.tar.xz are required) and store
them to TDE_DIR/1_git/edeps/<MODULE NAME> folder (one folder per module).
10) Add the following lines to the /etc/apt/sources.list file. This will setup your local repo in apt. 10) Add the following lines to the /etc/apt/sources.list file. This will setup your local repo in apt.
# --- LOCAL TDE REPOSITORY --- # --- LOCAL TDE REPOSITORY ---
deb [trusted=yes] file:TDE_DIR/3_repo <YOUR DISTRO> main deb [trusted=yes] file:TDE_DIR/3_repo <YOUR DISTRO> main
For example: For example:
deb [trusted=yes] file:/home/tde_src/3_repo buster main deb [trusted=yes] file:/home/tde_src/3_repo buster main
---------------------- ----------------------
B) Notes about scripts B) Notes about scripts
---------------------- ----------------------
@ -145,7 +136,7 @@ When building sets of modules or the whole TDE, a global build summary is automa
update_git_repository.sh [options] update_git_repository.sh [options]
Options: Options:
-i (Incremental) : in case the previous update was interrupted, continue from the last known updated module. -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, (useful on slow/unstable internet connections). If the previous update had completed,
this option is ignored. this option is ignored.
-v (Verbose) : display and log more output. Useful for troubleshooting. -v (Verbose) : display and log more output. Useful for troubleshooting.
-ub "<branches>" (Update Branches) : allows to specify the branches to update. This override the variable -ub "<branches>" (Update Branches) : allows to specify the branches to update. This override the variable
@ -164,13 +155,16 @@ When building sets of modules or the whole TDE, a global build summary is automa
tdebase tdebase
applications/abakus applications/abakus
dependencies/libr dependencies/libr
edeps/imlib edeps/debian/imlib
2) by providing only the module name and let the script look up for a unique match among the known modules. 2) by providing only the module name and let the script look up for a unique match among the known modules.
Examples: Examples:
tdebase tdebase
abakus abakus
libr libr
imlib imlib
3) for extra dependencies only, by providing the repository folder and the module name without the "debian"
subfolder
edeps/imlib
Usage: Usage:
build_module.sh [options] module_name build_module.sh [options] module_name
Options: Options:
@ -183,17 +177,17 @@ When building sets of modules or the whole TDE, a global build summary is automa
doing local changes/development. The module can then be built from the modified local folder doing local changes/development. The module can then be built from the modified local folder
-d (Debug) : enable debug symbols if possible (debian/rules file must contain "RelWithDebInfo" for this to work) -d (Debug) : enable debug symbols if possible (debian/rules file must contain "RelWithDebInfo" for this to work)
-ip (Internal Pbuilder): build using internal pbuilder mode (experimental) -ip (Internal Pbuilder): build using internal pbuilder mode (experimental)
- <dd>_<set_name>.sh - <dd>_<set_name>.sh
A number of scripts used to build sets of modules. Each script builds an individual set. A number of scripts used to build sets of modules. Each script builds an individual set.
Modules are built from the git sources and the build result is automatically appended to Modules are built from the git sources and the build result is automatically appended to
TDE_DIR/0_logs/build_result.log. TDE_DIR/0_logs/build_result.log.
Usage: Usage:
<dd>_<set_name>.sh [options] set_name <dd>_<set_name>.sh [options] set_name
Options: Options:
-s N: if specified, skip first N modules from the set of modules -s N: if specified, skip first N modules from the set of modules
The sets are logically grouped as "base system", "applications" and "others" The sets are logically grouped as "base system", "applications" and "others"
00_extradeps.sh : extra dependencies modules 00_extradeps.sh : extra dependencies modules
01_base_01.sh - 03_base_03.sh : TDE base system 01_base_01.sh - 03_base_03.sh : TDE base system
04_application_01.sh - 09_application_06.sh : application modules 04_application_01.sh - 09_application_06.sh : application modules
@ -206,20 +200,20 @@ When building sets of modules or the whole TDE, a global build summary is automa
Script used to build the complete TDE at once. Calls the dd_setname.sh set scripts in order. Script used to build the complete TDE at once. Calls the dd_setname.sh set scripts in order.
Usage: Usage:
build_TDE.sh build_TDE.sh
- create_repo.sh - create_repo.sh
Creates a local repository from the .deb files currently stored in TDE_DIR/2_build/debs. Creates a local repository from the .deb files currently stored in TDE_DIR/2_build/debs.
Usage: Usage:
[sudo] create_repo.sh [options] [sudo] create_repo.sh [options]
Options: Options:
-b (Backup) : create a backup of the existing repository in TDE_DIR/CFG_REPO_DIR.backup -b (Backup) : create a backup of the existing repository in TDE_DIR/CFG_REPO_DIR.backup
3) * Building hooks * 3) * Building hooks *
Hooks are available to execute ad-hoc code before and after the build process. For example this is very useful to automatically apply patches. Hooks are available to execute ad-hoc code before and after the build process. For example this is very useful to automatically apply patches.
There are two type of hooks: There are two type of hooks:
- pre_build : applied before switching the module to quilt format and build - pre_build : applied before switching the module to quilt format and build
- post_build: applied after the build (dpkg-buildpackage or pbuilder) has terminated - post_build: applied after the build (dpkg-buildpackage or pbuilder) has terminated
To use a hook, create an executable script (pre_build.sh and/or post_build.sh) in the TDE_DIR/1_git/hooks/<MODULE NAME> folder. The scripts are executed in the build_module.sh environment, so have access to all the variables defined in that file. See the files in the "hook examples" folder for real usage samples. To use a hook, create an executable script (pre_build.sh and/or post_build.sh) in the TDE_DIR/1_git/hooks/<MODULE NAME> folder. The scripts are executed in the build_module.sh environment, so have access to all the variables defined in that file. See the files in the "hook examples" folder for real usage samples.
@ -235,7 +229,7 @@ C) How to use the scripts
the process when building several modules in sequence. the process when building several modules in sequence.
5) Build modules as per your needs. You don't need to use "sudo" directly since the scripts will do that automatically if 5) Build modules as per your needs. You don't need to use "sudo" directly since the scripts will do that automatically if
required. Just type your sudo password when prompted to do so. required. Just type your sudo password when prompted to do so.
6) Create a local repository from the packages you have just built, to be used as installation repository. 6) Create a local repository from the packages you have just built, to be used as installation repository.
[sudo] ./create_repo.sh [sudo] ./create_repo.sh
7) Install TDE as you usually do. For example as follow: 7) Install TDE as you usually do. For example as follow:
- sudo apt-get update - sudo apt-get update
@ -243,15 +237,15 @@ C) How to use the scripts
or or
sudo aptitude install tde-trinity (for a standard TDE environment) sudo aptitude install tde-trinity (for a standard TDE environment)
Examples of real usage: Examples of real usage:
1) build a single module 1) build a single module
- ./build_module.sh -g -sl "dependencies/libr" -> build libr package. This is a good test to check - ./build_module.sh -g -sl "dependencies/libr" -> build libr package. This is a good test to check
whether everything is working fine whether everything is working fine
- ./build_module.sh -g "tdelibs" -> build "tdelibs" from git sources in a clean chroot environment - ./build_module.sh -g "tdelibs" -> build "tdelibs" from git sources in a clean chroot environment
- ./build_module.sh -g -l -sl "applications/amarok" -> build "amarok" locally from git sources and - ./build_module.sh -g -l -sl "applications/amarok" -> build "amarok" locally from git sources and
display building logs during building display building logs during building
- ./build_module.sh -sh -lr "tdebase" -> build "tdebase" from the local sources (in TDE_DIR/2_build/build/tdebase) - ./build_module.sh -sh -lr "tdebase" -> build "tdebase" from the local sources (in TDE_DIR/2_build/build/tdebase)
in a clean chroot environment and launch a shell in case of building failure. in a clean chroot environment and launch a shell in case of building failure.
@ -259,13 +253,13 @@ Examples of real usage:
- ./build_module.sh -g -po "tdelibs" -> prepare "tdelibs" for building from git sources. Source code will be available - ./build_module.sh -g -po "tdelibs" -> prepare "tdelibs" for building from git sources. Source code will be available
in TDE_DIR/2_build/build/tdelibs. After you have made changes to the source and in TDE_DIR/2_build/build/tdelibs. After you have made changes to the source and
want to build the modified package, run './build_module.sh "tdelibs"' want to build the modified package, run './build_module.sh "tdelibs"'
2) build a single set 2) build a single set
(optional) delete the TDE_DIR/0_logs/build_result.log file (optional) delete the TDE_DIR/0_logs/build_result.log file
./01_base_01.sh -> build this set. ./01_base_01.sh -> build this set.
./03_base_03.sh -s 3 -> build this set but skip the first 3 modules of the set. ./03_base_03.sh -s 3 -> build this set but skip the first 3 modules of the set.
3) build all TDE 3) build all TDE
./99_build_TDE.sh -> build all TDE ./99_build_TDE.sh -> build all TDE
4) [sudo] ./create_repo.sh -> build or update your local TDE repository 4) [sudo] ./create_repo.sh -> build or update your local TDE repository

@ -17,7 +17,7 @@ exec_time_start $_BUILDMOD_TIMER_NUM
# Need sudo for non-root users # Need sudo for non-root users
SUDO_CMD="" SUDO_CMD=""
if [ "`whoami`" != "root" ]; then if [ "`whoami`" != "root" ]; then
SUDO_CMD="sudo -E" SUDO_CMD="sudo -E"
fi fi
@ -26,19 +26,19 @@ fi
# $1 - error code # $1 - error code
function do_exit() function do_exit()
{ {
cd "$SCRIPT_DIR" cd "$SCRIPT_DIR"
if [ $1 -eq 0 ]; then if [ $1 -eq 0 ]; then
echo -e "${CGreen}#### Processing module ${CLightGreen}\"$MOD_GIVEN\"${CGreen} succeeded ####${CNone}" echo -e "${CGreen}#### Processing module ${CLightGreen}\"$MOD_GIVEN\"${CGreen} succeeded ####${CNone}"
if [ "$bool_LOG_RESULT" = "y" ]; then if [ "$bool_LOG_RESULT" = "y" ]; then
echo "[ OK ] [$_BUILDMOD_TIME] \"$MOD_NAME\"" >>"$LOG_BUILD_RESULT_FILENAME" echo "[ OK ] [$_BUILDMOD_TIME] \"$MOD_NAME\"" >>"$LOG_BUILD_RESULT_FILENAME"
fi fi
else else
echo -e "${CRed}#### Processing module ${CLightRed}\"$MOD_GIVEN\"${CRed} failed ($1) ####${CNone}" echo -e "${CRed}#### Processing module ${CLightRed}\"$MOD_GIVEN\"${CRed} failed ($1) ####${CNone}"
if [ "$bool_LOG_RESULT" = "y" ]; then if [ "$bool_LOG_RESULT" = "y" ]; then
echo "[FAILED] [$_BUILDMOD_TIME] \"$MOD_NAME\"" >>"$LOG_BUILD_RESULT_FILENAME" echo "[FAILED] [$_BUILDMOD_TIME] \"$MOD_NAME\"" >>"$LOG_BUILD_RESULT_FILENAME"
fi fi
fi fi
exit $1 exit $1
} }
@ -48,35 +48,15 @@ function do_exit()
function recreate_folder() function recreate_folder()
{ {
if [ -d "$1" ]; then if [ -d "$1" ]; then
$SUDO_CMD rm -R "$1" $SUDO_CMD rm -R "$1"
fi fi
mkdir -p "$1" mkdir -p "$1"
}
#----------------------------
# Set module related path variables
# Parameters:
# $1 - module name
function set_module_paths()
{
local LOC_MOD_NAME=$1
if [ "$bool_EXTRADEP_MOD" != "y" ]; then
# Standard module
MOD_GIT_PATH="$REPO_TDE_MAIN/$LOC_MOD_NAME"
MOD_GIT_PKGING_PATH="$REPO_TDE_PACKAGING/$LOC_MOD_NAME/debian"
else
# Extra dependency module
MOD_GIT_PATH="$REPO_DIR/$LOC_MOD_NAME"
fi
export MOD_BUILD_PATH="$TDE_BUILD_DIR/$LOC_MOD_NAME"
MOD_BUILD_PKGING_PATH="$MOD_BUILD_PATH/debian"
} }
#---------------------------- #----------------------------
# Look for a module in the git repository or in the extra dependency folder. # Look for a module in the git repository or in the extra dependency folder.
# Set the new module name if found. # Set the module name and paths if found.
# Parameters: # Parameters:
# $1 - module name # $1 - module name
function search_module() function search_module()
@ -85,6 +65,7 @@ function search_module()
IFS="*" IFS="*"
local LOC_MOD_NAME=$1 local LOC_MOD_NAME=$1
local LOC_MATCH local LOC_MATCH
MODULE_FOUND="n" MODULE_FOUND="n"
# Search in GIT repository # Search in GIT repository
@ -93,18 +74,23 @@ function search_module()
# Unique module found in GIT # Unique module found in GIT
MODULE_FOUND="y" MODULE_FOUND="y"
MOD_NAME=$LOC_MATCH MOD_NAME=$LOC_MATCH
set_module_paths $MOD_NAME MOD_GIT_PATH="$REPO_TDE_MAIN/$MOD_NAME"
else MOD_GIT_PKGING_PATH="$REPO_TDE_PACKAGING/$MOD_NAME/debian"
MOD_BUILD_PATH="$TDE_BUILD_DIR/$MOD_NAME"
else
# Search in extra dependency folder # Search in extra dependency folder
LOC_MATCH=`ls "$REPO_EXTRA_DEPENDENCIES" | grep "^$LOC_MOD_NAME$"` LOC_BASENAME=`echo "$LOC_MOD_NAME" | sed -r "s|^${CFG_EXTRA_DEPS_DIR}/(debian/)?||"`
LOC_MATCH=`ls "$REPO_EXTRA_DEPENDENCIES/debian" | grep "^$LOC_BASENAME"`
if [ "$LOC_MATCH" != "" -a "`echo $LOC_MATCH | wc -l`" = "1" ]; then if [ "$LOC_MATCH" != "" -a "`echo $LOC_MATCH | wc -l`" = "1" ]; then
# Unique module found in extra dependency folder # Unique module found in extra dependency folder
MODULE_FOUND="y" MODULE_FOUND="y"
bool_EXTRADEP_MOD="y" bool_EXTRADEP_MOD="y"
MOD_NAME="$CFG_EXTRA_DEPS_DIR/$LOC_MATCH" MOD_NAME="$CFG_EXTRA_DEPS_DIR/$LOC_MATCH"
set_module_paths $MOD_NAME MOD_GIT_PATH="$REPO_EXTRA_DEPENDENCIES/debian/$LOC_BASENAME"
MOD_BUILD_PATH="$TDE_BUILD_DIR/$CFG_EXTRA_DEPS_DIR/$LOC_BASENAME"
fi fi
fi fi
MOD_BUILD_PKGING_PATH="$MOD_BUILD_PATH/debian"
IFS=$OLDIFS IFS=$OLDIFS
} }
@ -123,27 +109,27 @@ bool_PREPARE_ONLY="n"
bool_DEBUG_MODE="n" bool_DEBUG_MODE="n"
bool_INTERNAL_PBUILDER="n" bool_INTERNAL_PBUILDER="n"
for arg in $@; do for arg in $@; do
if [ "$arg" = "-g" ]; then # select code to build from Git repo (-g) or from local build copy if [ "$arg" = "-g" ]; then # select code to build from Git repo (-g) or from local build copy
bool_BUILD_FROM_GIT="y" bool_BUILD_FROM_GIT="y"
elif [ "$arg" = "-l" ]; then # build module Locally instead of in a clean chroot environment elif [ "$arg" = "-l" ]; then # build module Locally instead of in a clean chroot environment
bool_BUILD_LOCALLY="y" bool_BUILD_LOCALLY="y"
elif [ "$arg" = "-sl" ]; then # output the building logs to terminal (ShowLog) elif [ "$arg" = "-sl" ]; then # output the building logs to terminal (ShowLog)
bool_SHOW_BUILD_LOGS="y" bool_SHOW_BUILD_LOGS="y"
elif [ "$arg" = "-lr" ]; then # Log build Result to file elif [ "$arg" = "-lr" ]; then # Log build Result to file
bool_LOG_RESULT="y" bool_LOG_RESULT="y"
elif [ "$arg" = "-sh" ]; then # install Shell Hook for failing builds (only valid if NOT building locally) elif [ "$arg" = "-sh" ]; then # install Shell Hook for failing builds (only valid if NOT building locally)
bool_SHELL_HOOK="y" bool_SHELL_HOOK="y"
elif [ "$arg" = "-po" ]; then # Prepare build folder Only but do not build elif [ "$arg" = "-po" ]; then # Prepare build folder Only but do not build
bool_PREPARE_ONLY="y" bool_PREPARE_ONLY="y"
elif [ "$arg" = "-d" ]; then # build with Debug symbols (used in hook scripts) elif [ "$arg" = "-d" ]; then # build with Debug symbols (used in hook scripts)
bool_DEBUG_MODE="y" bool_DEBUG_MODE="y"
elif [ "$arg" = "-ip" ]; then # build using Internal Pbuilder (experimental) elif [ "$arg" = "-ip" ]; then # build using Internal Pbuilder (experimental)
bool_INTERNAL_PBUILDER="y" bool_INTERNAL_PBUILDER="y"
elif [ "$MOD_GIVEN" = "" ]; then # module to be built elif [ "$MOD_GIVEN" = "" ]; then # module to be built
MOD_GIVEN="$arg" MOD_GIVEN="$arg"
fi fi
done done
MOD_NAME=$MOD_GIVEN # the actal module to be built MOD_NAME=$MOD_GIVEN # the actal module to be built
echo -e "${CLightCyan}#### Processing module \"$MOD_GIVEN\" ####${CNone}" echo -e "${CLightCyan}#### Processing module \"$MOD_GIVEN\" ####${CNone}"
@ -167,19 +153,19 @@ OPT_SIGN_PKG_LOCAL="--no-sign"
# - show logs # - show logs
OPT_SHOW_LOGS="&>" OPT_SHOW_LOGS="&>"
if [ "$bool_SHOW_BUILD_LOGS" = "y" ]; then if [ "$bool_SHOW_BUILD_LOGS" = "y" ]; then
OPT_SHOW_LOGS=" | tee " OPT_SHOW_LOGS=" | tee "
fi fi
export OPT_SHOW_LOGS export OPT_SHOW_LOGS
# This folders must exists # This folders must exists
BASE_DIRS=("REPO_DIR" "BUILD_DIR" "SCRIPT_DIR" "REPO_TDE_MAIN" "REPO_TDE_PACKAGING" "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 if [[ "$USE_PREBUILD_EXTRA_DEPS" != "y" ]]; then
BASE_DIRS+=("REPO_EXTRA_DEPENDENCIES") BASE_DIRS+=("REPO_EXTRA_DEPENDENCIES")
fi fi
for var_name in ${BASE_DIRS[@]}; do for var_name in ${BASE_DIRS[@]}; do
if [ ! -d "${!var_name}" ]; then if [ ! -d "${!var_name}" ]; then
echo -e "${CYellow}$var_name${CNone} folder missing (${CLightPurple}${!var_name}${CNone}). 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 do_exit 4
fi fi
done done
@ -204,24 +190,22 @@ if [[ $MOD_NAME =~ ^$CFG_EXTRA_DEPS_DIR/ ]]; then
bool_EXTRADEP_MOD="y" bool_EXTRADEP_MOD="y"
fi fi
set_module_paths $MOD_NAME # 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
fi
if [ "$bool_BUILD_FROM_GIT" = "y" ]; then if [ "$bool_BUILD_FROM_GIT" = "y" ]; then
echo -e "${CYellow}> Building from GIT repo${CNone}" echo -e "${CYellow}> Building from GIT repo${CNone}"
# source files # source files
if [ ! -d "$MOD_GIT_PATH" ]; then
MODULE_FOUND="n"
search_module $MOD_NAME
if [ "$MODULE_FOUND" != "y" -o ! -d "$MOD_GIT_PATH" ]; then
echo "Module \"$MOD_NAME\" not found in GIT"
do_exit 5
fi
fi
bool_COPY_MOD_SRC="y" bool_COPY_MOD_SRC="y"
# packaging scripts # packaging scripts
if [ "$bool_EXTRADEP_MOD" != "y" -a ! -d "$MOD_GIT_PKGING_PATH" ]; then if [ "$bool_EXTRADEP_MOD" != "y" -a ! -d "$MOD_GIT_PKGING_PATH" ]; then
echo "Packaging for \"$MOD_NAME\" not found in GIT" echo "Packaging for \"$MOD_NAME\" not found in GIT"
do_exit 6 do_exit 6
fi fi
bool_COPY_PKGING_FILES="y" bool_COPY_PKGING_FILES="y"
# #
@ -230,17 +214,7 @@ else
# source files # source files
bool_COPY_MOD_SRC="n" bool_COPY_MOD_SRC="n"
if [ ! -d "$MOD_BUILD_PATH" ]; then if [ ! -d "$MOD_BUILD_PATH" ]; then
if [ ! -d "$MOD_GIT_PATH" ]; then bool_COPY_MOD_SRC="y"
MODULE_FOUND="n"
search_module $MOD_NAME
if [ "$MODULE_FOUND" != "y" -o ! -d "$MOD_GIT_PATH" ]; then
echo "Module \"$MOD_NAME\" not found neither in BUILD nor in GIT"
do_exit 7
fi
fi
if [ ! -d "$MOD_BUILD_PATH" ]; then
bool_COPY_MOD_SRC="y"
fi
fi fi
# packaging scripts # packaging scripts
@ -266,7 +240,7 @@ fi
# copy main repo source files, if needed # copy main repo source files, if needed
if [ "$bool_COPY_MOD_SRC" = "y" ]; then if [ "$bool_COPY_MOD_SRC" = "y" ]; then
bool_COPY_PKGING_FILES="y" bool_COPY_PKGING_FILES="y"
recreate_folder "$MOD_BUILD_PATH" recreate_folder "$MOD_BUILD_PATH"
if [ "$bool_EXTRADEP_MOD" != "y" ]; then if [ "$bool_EXTRADEP_MOD" != "y" ]; then
# Normal module # Normal module
@ -275,27 +249,28 @@ if [ "$bool_COPY_MOD_SRC" = "y" ]; then
echo "# TDE SCM module information" > "$MOD_BUILD_PATH/.tdescminfo" echo "# TDE SCM module information" > "$MOD_BUILD_PATH/.tdescminfo"
echo "Name: $MOD_NAME" >> "$MOD_BUILD_PATH/.tdescminfo" echo "Name: $MOD_NAME" >> "$MOD_BUILD_PATH/.tdescminfo"
cd "$MOD_GIT_PATH" cd "$MOD_GIT_PATH"
MOD_BRANCH=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"` MOD_BRANCH=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"`
if [[ -z "$MOD_BRANCH" ]]; then if [[ -z "$MOD_BRANCH" ]]; then
MOD_BRANCH=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-` MOD_BRANCH=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-`
fi fi
COMMIT_HASH=`git rev-parse HEAD` COMMIT_HASH=`git rev-parse HEAD`
echo "Revision: $MOD_BRANCH-$COMMIT_HASH" >> "$MOD_BUILD_PATH/.tdescminfo" echo "Revision: $MOD_BRANCH-$COMMIT_HASH" >> "$MOD_BUILD_PATH/.tdescminfo"
git log -1 --pretty=format:"DateTime: %cd%n" --date=format:"%m/%d/%Y %H:%M" >> "$MOD_BUILD_PATH/.tdescminfo" git log -1 --pretty=format:"DateTime: %cd%n" --date=format:"%m/%d/%Y %H:%M" >> "$MOD_BUILD_PATH/.tdescminfo"
else else
# Extra dependency module # Extra dependency module: copy and apply patches
if [ `find "$MOD_GIT_PATH" -name '*.dsc' | wc -l` == 1 ]; then # -- move to the correct folder
if [ -d "$MOD_BUILD_PATH" ]; then cd "$MOD_GIT_PATH"
$SUDO_CMD rm -R "$MOD_BUILD_PATH" if [ `ls -d */ | wc -l` == 1 ]; then
fi cd `ls -d */`
eval dpkg-source --no-copy --no-check -x `find "$MOD_GIT_PATH" -name '*.dsc'` \ cp -R "." "$MOD_BUILD_PATH"
\"$MOD_BUILD_PATH\" $OPT_SHOW_LOGS/dev/null cd $MOD_BUILD_PATH
QUILT_PATCHES="debian/patches" quilt push -a >/dev/null
# Make sure patches are not reapplied in future local builds. This could stop pdebuild from working. # Make sure patches are not reapplied in future local builds. This could stop pdebuild from working.
if [ -f "$MOD_BUILD_PATH/debian/patches/series" ]; then if [ -f "$MOD_BUILD_PATH/debian/patches/series" ]; then
cp /dev/null "$MOD_BUILD_PATH/debian/patches/series" cp /dev/null "$MOD_BUILD_PATH/debian/patches/series"
fi fi
else else
echo "There must be one and only one .dsc file in \"$MOD_GIT_PATH\"" echo "There must be one and only one module folder in \"$MOD_GIT_PATH\""
do_exit 9 do_exit 9
fi fi
fi fi
@ -304,59 +279,59 @@ fi
# copying packaging scripts, if needed # copying packaging scripts, if needed
if [ "$bool_EXTRADEP_MOD" != "y" -a "$bool_COPY_PKGING_FILES" = "y" ]; then if [ "$bool_EXTRADEP_MOD" != "y" -a "$bool_COPY_PKGING_FILES" = "y" ]; then
if [ -d "$MOD_BUILD_PKGING_PATH" ]; then if [ -d "$MOD_BUILD_PKGING_PATH" ]; then
$SUDO_CMD rm -R $MOD_BUILD_PKGING_PATH $SUDO_CMD rm -R $MOD_BUILD_PKGING_PATH
fi fi
cp -R "$MOD_GIT_PKGING_PATH" "$MOD_BUILD_PKGING_PATH" cp -R "$MOD_GIT_PKGING_PATH" "$MOD_BUILD_PKGING_PATH"
# TODO metapackage support # TODO metapackage support
# Default package name # Default package name
# Calculate package version # Calculate package version
cd $MOD_GIT_PATH cd $MOD_GIT_PATH
branch=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"` branch=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"`
if [[ -z "$branch" ]]; then if [[ -z "$branch" ]]; then
branch=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-` branch=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-`
fi fi
target_tag=`git tag | grep -F "$TDE_RELEASE" | head -n1` target_tag=`git tag | grep -F "$TDE_RELEASE" | head -n1`
tag=`git tag | \ tag=`git tag | \
sed "s|^\([^0-9]\)|\1.|" | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr -k 5,5nr | sed "s|^\([^0-9]\)\.|\1|" | \ sed "s|^\([^0-9]\)|\1.|" | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr -k 5,5nr | sed "s|^\([^0-9]\)\.|\1|" | \
while read t; do \ while read t; do \
git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \ git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \
echo "$t..HEAD" && break; done` echo "$t..HEAD" && break; done`
count=`git log $tag --pretty=oneline | wc -l` count=`git log $tag --pretty=oneline | wc -l`
package=$(basename $PWD)-trinity-$TDE_RELEASE package=$(basename $PWD)-trinity-$TDE_RELEASE
if [[ "$count" -gt 0 ]] || [[ -z "$target_tag" ]]; then if [[ "$count" -gt 0 ]] || [[ -z "$target_tag" ]]; then
package=$package~pre$count+$(git rev-parse HEAD | cut -c 1-8) package=$package~pre$count+$(git rev-parse HEAD | cut -c 1-8)
fi fi
REL=4:$TDE_RELEASE${package#*$TDE_RELEASE} REL=4:$TDE_RELEASE${package#*$TDE_RELEASE}
REL=${REL%+*} REL=${REL%+*}
REL=${REL/4:14.0.0/4:14.0.0-s} REL=${REL/4:14.0.0/4:14.0.0-s}
REL=${REL/4:14.0.0-s~pre/4:14.0.0-s~} REL=${REL/4:14.0.0-s~pre/4:14.0.0-s~}
REL=${REL/.0~pre/.0~s} REL=${REL/.0~pre/.0~s}
# Get package name and packaging release # Get package name and packaging release
PKG_NAME=$(head -n1 $MOD_BUILD_PKGING_PATH/changelog) PKG_NAME=$(head -n1 $MOD_BUILD_PKGING_PATH/changelog)
PKG_NAME=${PKG_NAME%% *} PKG_NAME=${PKG_NAME%% *}
PKG_TAG=$(cd "$REPO_TDE_PACKAGING/$MOD_NAME" && PKG_TAG=$(cd "$REPO_TDE_PACKAGING/$MOD_NAME" &&
git tag | \ git tag | \
sed "s|^\([^0-9]\)|\1.|" | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr -k 5,5nr | sed "s|^\([^0-9]\)\.|\1|" | \ sed "s|^\([^0-9]\)|\1.|" | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr -k 5,5nr | sed "s|^\([^0-9]\)\.|\1|" | \
while read t; do \ while read t; do \
git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \ git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \
echo "$t..HEAD" && break; done) echo "$t..HEAD" && break; done)
PKG_REL=$(cd "$REPO_TDE_PACKAGING/$MOD_NAME" && PKG_REL=$(cd "$REPO_TDE_PACKAGING/$MOD_NAME" &&
git log $PKG_TAG --pretty=oneline . | wc -l) git log $PKG_TAG --pretty=oneline . | wc -l)
if [ -n "$REL_SUFFIX" ]; then if [ -n "$REL_SUFFIX" ]; then
PKG_REL="${PKG_REL}${REL_SUFFIX}" PKG_REL="${PKG_REL}${REL_SUFFIX}"
fi fi
# TODO add relative patch count # TODO add relative patch count
ADD_REL=0 ADD_REL=0
# Update changelog # Update changelog
REPO_DATE=`git log -1 --pretty=format:"%cd%n" --date=rfc` REPO_DATE=`git log -1 --pretty=format:"%cd%n" --date=rfc`
GITUSER="$(git config --get user.name) <$(git config --get user.email)>" GITUSER="$(git config --get user.name) <$(git config --get user.email)>"
echo "$PKG_NAME ($REL-0$DISTRO$DISTRO_VERSION.$ADD_REL+$PKG_REL) $DISTRO_NAME; urgency=low" > "$MOD_BUILD_PKGING_PATH/changelog" echo "$PKG_NAME ($REL-0$DISTRO$DISTRO_VERSION.$ADD_REL+$PKG_REL) $DISTRO_NAME; urgency=low" > "$MOD_BUILD_PKGING_PATH/changelog"
echo -e "\n * Automated git build\n\n -- $GITUSER $REPO_DATE\n" >> "$MOD_BUILD_PKGING_PATH/changelog" echo -e "\n * Automated git build\n\n -- $GITUSER $REPO_DATE\n" >> "$MOD_BUILD_PKGING_PATH/changelog"
cat "$REPO_TDE_PACKAGING/$MOD_NAME/debian/changelog" >> "$MOD_BUILD_PKGING_PATH/changelog" cat "$REPO_TDE_PACKAGING/$MOD_NAME/debian/changelog" >> "$MOD_BUILD_PKGING_PATH/changelog"
touch -d "$REPO_DATE" "$MOD_BUILD_PKGING_PATH/changelog" touch -d "$REPO_DATE" "$MOD_BUILD_PKGING_PATH/changelog"
fi fi
# prepare destination directory for building # prepare destination directory for building
@ -372,24 +347,26 @@ recreate_folder "$MOD_DEBSRC_PATH"
if [ -x "$HOOK_DIR/$MOD_NAME/pre_build.sh" ]; then if [ -x "$HOOK_DIR/$MOD_NAME/pre_build.sh" ]; then
echo -e "${CYellow}> Applying pre-build hook${CNone}" echo -e "${CYellow}> Applying pre-build hook${CNone}"
. "$HOOK_DIR/$MOD_NAME/pre_build.sh" . "$HOOK_DIR/$MOD_NAME/pre_build.sh"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo -e "> ${CBrown}Pre-build hook applied successfully${CNone}" echo -e "> ${CBrown}Pre-build hook applied successfully${CNone}"
else else
echo -e "> ${CLightBlue}Pre-build hook failed${CNone}" echo -e "> ${CLightBlue}Pre-build hook failed${CNone}"
fi fi
fi fi
#---------------------------- #----------------------------
# Switch to 3.0(quilt) format # Switch to 3.0(quilt) format
#---------------------------- #----------------------------
# create orig tarball # create orig tarball
cd "$MOD_BUILD_PATH" cd "$MOD_BUILD_PATH"
MOD_BASENAME=`head -n 1 "$MOD_BUILD_PKGING_PATH/changelog" | sed -r "s/^([^ ]+).*/\1/"` MOD_BASENAME=`head -n 1 "$MOD_BUILD_PKGING_PATH/changelog" | sed -r "s/^([^ ]+).*/\1/"`
MOD_MAJOR_VER=`head -n 1 "$MOD_BUILD_PKGING_PATH/changelog" | sed -r "s/^[^ ]+ \(([^:]+:)?.*/\1/"` MOD_MAJOR_VER=`head -n 1 "$MOD_BUILD_PKGING_PATH/changelog" | sed -r "s/^[^ ]+ \(([^:]+:)?.*/\1/"`
MOD_UP_VER=`head -n 1 "$MOD_BUILD_PKGING_PATH/changelog" | sed -r "s/^[^ ]+ \(([^:]+:)?(.*+)-.*/\2/"` MOD_UP_VER=`head -n 1 "$MOD_BUILD_PKGING_PATH/changelog" | sed -r "s/^[^ ]+ \(([^:]+:)?(.*+)-.*/\2/"`
MOD_DEB_VER=`head -n 1 "$MOD_BUILD_PKGING_PATH/changelog" | sed -r "s/^[^ ]+ \(.*+-([^\)]+).*/\1/"` MOD_DEB_VER=`head -n 1 "$MOD_BUILD_PKGING_PATH/changelog" | sed -r "s/^[^ ]+ \(.*+-([^\)]+).*/\1/"`
REPO_DATE=`dpkg-parsechangelog -l "$MOD_BUILD_PATH/debian/changelog" | sed -n -e 's|^Date: ||p'` REPO_DATE=`dpkg-parsechangelog -l "$MOD_BUILD_PKGING_PATH/changelog" | sed -n -e 's|^Date: ||p'`
tar cJf "../${MOD_BASENAME}_${MOD_UP_VER}.orig.tar.xz" --exclude="debian" --exclude=".git*" \ tar cJf "../${MOD_BASENAME}_${MOD_UP_VER}.orig.tar.xz" --exclude="debian" --exclude=".git*" \
--mtime "$REPO_DATE" --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime . --mtime "$REPO_DATE" --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime .
touch -d "$REPO_DATE" "../${MOD_BASENAME}_${MOD_UP_VER}.orig.tar.xz" touch -d "$REPO_DATE" "../${MOD_BASENAME}_${MOD_UP_VER}.orig.tar.xz"
@ -439,19 +416,19 @@ if [ "$bool_BUILD_LOCALLY" = "y" ]; then
if [ $build_retval -eq 0 ]; then if [ $build_retval -eq 0 ]; then
eval dpkg-buildpackage -b $OPT_SIGN_PKG_LOCAL $OPT_SHOW_LOGS\"$BUILDING_LOG_FILE\" eval dpkg-buildpackage -b $OPT_SIGN_PKG_LOCAL $OPT_SHOW_LOGS\"$BUILDING_LOG_FILE\"
fi fi
build_retval=$? build_retval=$?
else else
## Build module in a clean chroot environment using pbuilder ## Build module in a clean chroot environment using pbuilder
$SUDO_CMD "$SCRIPT_DIR/internals/_pbuilder.sh" $SUDO_CMD "$SCRIPT_DIR/internals/_pbuilder.sh"
build_retval=$? build_retval=$?
if [ "`whoami`" != "root" ]; then if [ "`whoami`" != "root" ]; then
cd "$MOD_DEB_PATH" cd "$MOD_DEB_PATH"
$SUDO_CMD chown -R `id -u -n`:`id -g -n` . &>/dev/null $SUDO_CMD chown -R `id -u -n`:`id -g -n` . &>/dev/null
cd "$MOD_BUILD_PATH/.." cd "$MOD_BUILD_PATH/.."
$SUDO_CMD chown `id -u -n`:`id -g -n` *.dsc *.changes *.tar.xz *.tar.bz2 *.tar.gz *.buildinfo &>/dev/null $SUDO_CMD chown `id -u -n`:`id -g -n` *.dsc *.changes *.tar.xz *.tar.bz2 *.tar.gz *.buildinfo &>/dev/null
$SUDO_CMD chown `id -u -n`:`id -g -n` "$TDE_DEBS_DIR/Packages" &>/dev/null $SUDO_CMD chown `id -u -n`:`id -g -n` "$TDE_DEBS_DIR/Packages" &>/dev/null
cd "$MOD_BUILD_PATH" cd "$MOD_BUILD_PATH"
fi fi
fi fi
if [ $build_retval -eq 0 ]; then if [ $build_retval -eq 0 ]; then
@ -467,11 +444,11 @@ fi
if [ -x "$HOOK_DIR/$MOD_NAME/post_build.sh" ]; then if [ -x "$HOOK_DIR/$MOD_NAME/post_build.sh" ]; then
echo -e "${CYellow}> Applying post-build hook${CNone}" echo -e "${CYellow}> Applying post-build hook${CNone}"
. "$HOOK_DIR/$MOD_NAME/post_build.sh" . "$HOOK_DIR/$MOD_NAME/post_build.sh"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo -e "${CBrown}Post-build hook applied successfully${CNone}" echo -e "${CBrown}Post-build hook applied successfully${CNone}"
else else
echo -e "${CLightBlue}Post-build hook failed${CNone}" echo -e "${CLightBlue}Post-build hook failed${CNone}"
fi fi
fi fi
#---------------------------- #----------------------------

@ -9,38 +9,38 @@ flag_SKIP_TAGS="n"
OVERRIDE_DEFAULT_REPO_BRANCH="" OVERRIDE_DEFAULT_REPO_BRANCH=""
for ((idx=1; idx<=$#; idx++)); do for ((idx=1; idx<=$#; idx++)); do
arg="${!idx}" arg="${!idx}"
if [ "$arg" = "-i" ]; then # continue from last updated module (Incremental) if [ "$arg" = "-i" ]; then # continue from last updated module (Incremental)
flag_INCREMENTAL="y" flag_INCREMENTAL="y"
elif [ "$arg" = "-v" ]; then # display and log git command output (Verbose) elif [ "$arg" = "-v" ]; then # display and log git command output (Verbose)
flag_VERBOSE_LOG="y" flag_VERBOSE_LOG="y"
elif [ "$arg" = "-ub" ]; then # branches to update (Update Branches) elif [ "$arg" = "-ub" ]; then # branches to update (Update Branches)
((idx++)) ((idx++))
OVERRIDE_UPDATE_BRANCHES="${!idx}" OVERRIDE_UPDATE_BRANCHES="${!idx}"
[[ -z "$OVERRIDE_DEFAULT_REPO_BRANCH" ]] && OVERRIDE_DEFAULT_REPO_BRANCH="${!idx}" [[ -z "$OVERRIDE_DEFAULT_REPO_BRANCH" ]] && OVERRIDE_DEFAULT_REPO_BRANCH="${!idx}"
elif [ "$arg" = "-db" ]; then # default branch after update (Default Branch) elif [ "$arg" = "-db" ]; then # default branch after update (Default Branch)
((idx++)) ((idx++))
if [[ "$flag_SWITCH_ONLY" != 'y' ]]; then if [[ "$flag_SWITCH_ONLY" != 'y' ]]; then
# '-db' is only used if no '-so' argument is specified. If '-so <branch>' # '-db' is only used if no '-so' argument is specified. If '-so <branch>'
# is given, '-db <branch> is ignored # is given, '-db <branch> is ignored
OVERRIDE_DEFAULT_REPO_BRANCH="${!idx}" OVERRIDE_DEFAULT_REPO_BRANCH="${!idx}"
fi fi
elif [ "$arg" = "-so" ]; then # switch branch only (Switch Only) elif [ "$arg" = "-so" ]; then # switch branch only (Switch Only)
flag_SWITCH_ONLY="y" && ((idx++)) flag_SWITCH_ONLY="y" && ((idx++))
if ! [[ "${!idx}" =~ ^- ]]; then if ! [[ "${!idx}" =~ ^- ]]; then
OVERRIDE_DEFAULT_REPO_BRANCH="${!idx}" OVERRIDE_DEFAULT_REPO_BRANCH="${!idx}"
else else
((idx--)) ((idx--))
fi fi
elif [ "$arg" = "-st" ]; then # skip ctags generation (Skip Tags) elif [ "$arg" = "-st" ]; then # skip ctags generation (Skip Tags)
flag_SKIP_TAGS="y" flag_SKIP_TAGS="y"
fi fi
done done
# Load common code # Load common code
. ./internals/_build_common.sh . ./internals/_build_common.sh
init_common 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=( declare -A RESULT_STRINGS=(
[OK]="[ OK ]" [OK]="[ OK ]"
@ -65,131 +65,131 @@ declare -A COLOR_STRINGS=(
# $3 - branch to update # $3 - branch to update
function _do_update() function _do_update()
{ {
local MOD_PATH=$1 local MOD_PATH=$1
local OP_TYPE=$2 local OP_TYPE=$2
local BRANCH=$3 local BRANCH=$3
local RESULT="" local RESULT=""
local LINE_CTRL_SUFFIX="" local LINE_CTRL_SUFFIX=""
case "$OP_TYPE" in case "$OP_TYPE" in
"fetch") "fetch")
if [[ -z `grep "^$BRANCH - $MOD_PATH$" "$UPDATE_LOCK_FILENAME"` ]]; then if [[ -z `grep "^$BRANCH - $MOD_PATH$" "$UPDATE_LOCK_FILENAME"` ]]; then
cd "$MOD_PATH" &>/dev/null cd "$MOD_PATH" &>/dev/null
eval git fetch --all --prune $GIT_NO_RECURSE_SUBMODULES $OPT_VERBOSE_LOG eval git fetch --all --prune $GIT_NO_RECURSE_SUBMODULES $OPT_VERBOSE_LOG
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
RESULT="OK" RESULT="OK"
else else
RESULT="FAIL" RESULT="FAIL"
fi fi
echo "$BRANCH - $MOD_PATH" >> "$UPDATE_LOCK_FILENAME" echo "$BRANCH - $MOD_PATH" >> "$UPDATE_LOCK_FILENAME"
else else
RESULT="SKIP" RESULT="SKIP"
fi fi
;; ;;
"update") "update")
cd "$MOD_PATH" &>/dev/null cd "$MOD_PATH" &>/dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
# Clean up any possible uncommitted changes # Clean up any possible uncommitted changes
if [[ ! -z "`git status --porcelain $GIT_IGNORE_SUBMODULES`" ]]; then if [[ ! -z "`git status --porcelain $GIT_IGNORE_SUBMODULES`" ]]; then
git reset --hard HEAD &>/dev/null git reset --hard HEAD &>/dev/null
git clean -dxff &>/dev/null git clean -dxff &>/dev/null
fi fi
# Make sure the local branch exists # Make sure the local branch exists
if [[ -z `git branch | grep -E "\b$BRANCH\b"` ]]; then if [[ -z `git branch | grep -E "\b$BRANCH\b"` ]]; then
eval git checkout -b \"$BRANCH\" \"origin/$BRANCH\" $OPT_VERBOSE_LOG eval git checkout -b \"$BRANCH\" \"origin/$BRANCH\" $OPT_VERBOSE_LOG
else else
eval git checkout \"$BRANCH\" $OPT_VERBOSE_LOG eval git checkout \"$BRANCH\" $OPT_VERBOSE_LOG
fi fi
# Make sure the local branch is a tracking branch # Make sure the local branch is a tracking branch
if [[ -z `git config branch."$BRANCH".remote` ]]; then if [[ -z `git config branch."$BRANCH".remote` ]]; then
git branch -u "origin/$BRANCH" &>/dev/null #$ git branch -u "origin/$BRANCH" &>/dev/null #$
git reset --hard "origin/$BRANCH" &>/dev/null git reset --hard "origin/$BRANCH" &>/dev/null
fi fi
# Update # Update
eval git reset --hard HEAD $OPT_VERBOSE_LOG eval git reset --hard HEAD $OPT_VERBOSE_LOG
eval git clean -dxff $OPT_VERBOSE_LOG eval git clean -dxff $OPT_VERBOSE_LOG
if [[ $(git rev-parse HEAD) != $(git rev-parse "origin/$BRANCH") ]]; then if [[ $(git rev-parse HEAD) != $(git rev-parse "origin/$BRANCH") ]]; then
eval git rebase $OPT_VERBOSE_LOG eval git rebase $OPT_VERBOSE_LOG
if [[ `git rev-parse HEAD` == `git rev-parse "origin/$BRANCH"` ]]; then if [[ `git rev-parse HEAD` == `git rev-parse "origin/$BRANCH"` ]]; then
RESULT="UPDATE" RESULT="UPDATE"
else else
RESULT="FAIL" RESULT="FAIL"
fi fi
else else
RESULT="OK" RESULT="OK"
fi fi
else else
RESULT="FAIL" RESULT="FAIL"
fi fi
;; ;;
"switch-to") "switch-to")
cd "$MOD_PATH" &>/dev/null cd "$MOD_PATH" &>/dev/null
eval git checkout \"$BRANCH\" $OPT_VERBOSE_LOG eval git checkout \"$BRANCH\" $OPT_VERBOSE_LOG
eval git reset --hard HEAD $OPT_VERBOSE_LOG eval git reset --hard HEAD $OPT_VERBOSE_LOG
eval git clean -dxff $OPT_VERBOSE_LOG eval git clean -dxff $OPT_VERBOSE_LOG
if [[ ! -z `git branch -v | grep -E "^\*\s+$BRANCH"` ]]; then if [[ ! -z `git branch -v | grep -E "^\*\s+$BRANCH"` ]]; then
RESULT="OK" RESULT="OK"
else else
RESULT="FAIL" RESULT="FAIL"
fi fi
;; ;;
*) *)
RESULT="INV-OP" RESULT="INV-OP"
;; ;;
esac esac
if [ "$RESULT" != "OK" -o "$flag_VERBOSE_LOG" = "y" ]; then if [ "$RESULT" != "OK" -o "$flag_VERBOSE_LOG" = "y" ]; then
LINE_CTRL_SUFFIX="\n" LINE_CTRL_SUFFIX="\n"
fi fi
echo -ne "\033[2K\r${COLOR_STRINGS[$RESULT]}${RESULT_STRINGS[$RESULT]} $MOD_PATH${CNone}$LINE_CTRL_SUFFIX" 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" echo "${RESULT_STRINGS[$RESULT]} $MOD_PATH" >> "$LOG_UPDATE_REPO_FILENAME"
} }
#---------------------------- #----------------------------
# Update a given module and all submodules from the upstream repo # Update a given module and all submodules from the upstream repo
# Parameters: # Parameters:
# $1 - module folder # $1 - module folder
# $2 - operation type # $2 - operation type
# $3 - branch to update # $3 - branch to update
function _update_module() function _update_module()
{ {
local MOD_PATH=$1 local MOD_PATH=$1
local OP_TYPE=$2 local OP_TYPE=$2
local BRANCH=$3 local BRANCH=$3
# Current module # Current module
_do_update "$@" _do_update "$@"
# Submodules # Submodules
local SUBMOD_LIST="$MOD_PATH/.gitmodules" local SUBMOD_LIST="$MOD_PATH/.gitmodules"
if [[ -e "$SUBMOD_LIST" ]]; then if [[ -e "$SUBMOD_LIST" ]]; then
sed -n "s|^\[submodule \"\([^\"]*\)\"\]$|\1|p" <$SUBMOD_LIST |\ sed -n "s|^\[submodule \"\([^\"]*\)\"\]$|\1|p" <$SUBMOD_LIST |\
while read -r SUBMOD_PATH; do while read -r SUBMOD_PATH; do
cd "$MOD_PATH" &>/dev/null cd "$MOD_PATH" &>/dev/null
if [[ -z "`git config --get submodule.$SUBMOD_PATH.url`" ]]; then if [[ -z "`git config --get submodule.$SUBMOD_PATH.url`" ]]; then
eval git submodule init -- \"$SUBMOD_PATH\" $OPT_VERBOSE_LOG eval git submodule init -- \"$SUBMOD_PATH\" $OPT_VERBOSE_LOG
fi fi
if [[ ! -e "$MOD_PATH/$SUBMOD_PATH/.git" ]]; then if [[ ! -e "$MOD_PATH/$SUBMOD_PATH/.git" ]]; then
eval git submodule update -- \"$SUBMOD_PATH\" $OPT_VERBOSE_LOG eval git submodule update -- \"$SUBMOD_PATH\" $OPT_VERBOSE_LOG
fi fi
_update_module "$MOD_PATH/$SUBMOD_PATH" "$OP_TYPE" "$BRANCH" _update_module "$MOD_PATH/$SUBMOD_PATH" "$OP_TYPE" "$BRANCH"
done done
fi fi
} }
#---------------------------- #----------------------------
if [ "$flag_INCREMENTAL" = "y" ]; then if [ "$flag_INCREMENTAL" = "y" ]; then
[ ! -f "$UPDATE_LOCK_FILENAME" ] && flag_INCREMENTAL="n" [ ! -f "$UPDATE_LOCK_FILENAME" ] && flag_INCREMENTAL="n"
else else
[ -f "$UPDATE_LOCK_FILENAME" ] && rm "$UPDATE_LOCK_FILENAME" [ -f "$UPDATE_LOCK_FILENAME" ] && rm "$UPDATE_LOCK_FILENAME"
fi fi
OPT_VERBOSE_LOG="&>/dev/null" OPT_VERBOSE_LOG="&>/dev/null"
if [[ "$flag_VERBOSE_LOG" = "y" ]]; then 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 fi
#---------------------------- #----------------------------
@ -205,48 +205,62 @@ fi
# Start update # Start update
if [ "$flag_INCREMENTAL" != "y" ]; then if [ "$flag_INCREMENTAL" != "y" ]; then
echo "TDE repositories update started" > "$UPDATE_LOCK_FILENAME" echo "TDE repositories update started" > "$UPDATE_LOCK_FILENAME"
fi fi
_LAST_BRANCH="" _LAST_BRANCH=""
if [[ "$flag_SWITCH_ONLY" != "y" ]]; then if [[ "$flag_SWITCH_ONLY" != "y" ]]; then
# Fetch all remotes first # Update extra dependency repository
echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" "y" if [[ "$USE_PREBUILD_EXTRA_DEPS" != "y" ]]; then
echo_and_tee "${CLightCyan} Fetching remotes ${CNone}" "$LOG_UPDATE_REPO_FILENAME" echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" "y"
echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" echo_and_tee "${CLightCyan} Fetching extra dependencies ${CNone}" "$LOG_UPDATE_REPO_FILENAME"
echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME"
# Fetch TDE main repository
_update_module "$REPO_TDE" "fetch" # Fetch TDE extra dependency repository
_update_module "$REPO_EXTRA_DEPENDENCIES" "fetch"
echo -e "\033[2K" _update_module "$REPO_EXTRA_DEPENDENCIES" "update" "master"
echo "" >> "$LOG_UPDATE_REPO_FILENAME"
echo -e "\033[2K"
# Branch update echo "" >> "$LOG_UPDATE_REPO_FILENAME"
for branch in "${BRANCHES[@]}"; do fi
_LAST_BRANCH="$branch"
echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" # Fetch all remotes first
echo_and_tee "${CLightCyan} Updating branch ${CYellow}$branch ${CNone}" "$LOG_UPDATE_REPO_FILENAME" echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" "y"
echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" echo_and_tee "${CLightCyan} Fetching remotes ${CNone}" "$LOG_UPDATE_REPO_FILENAME"
echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME"
# Update TDE main repository
_update_module "$REPO_TDE" "update" "$branch" # Fetch TDE main repository
_update_module "$REPO_TDE" "fetch"
echo -e "\033[2K"
echo "" >> "$LOG_UPDATE_REPO_FILENAME" echo -e "\033[2K"
done 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 fi
# Switch to specified branch if necessary # Switch to specified branch if necessary
if [[ "$DEFAULT_REPO_BRANCH" != "$_LAST_BRANCH" ]]; then if [[ "$DEFAULT_REPO_BRANCH" != "$_LAST_BRANCH" ]]; then
echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" "$flag_SWITCH_ONLY" 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} Switching to branch ${CYellow}$DEFAULT_REPO_BRANCH ${CNone}" "$LOG_UPDATE_REPO_FILENAME"
echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME"
# Switch TDE main repository # Switch TDE main repository
_update_module "$REPO_TDE" "switch-to" "$DEFAULT_REPO_BRANCH" _update_module "$REPO_TDE" "switch-to" "$DEFAULT_REPO_BRANCH"
echo -e "\033[2K" echo -e "\033[2K"
echo "" >> "$LOG_UPDATE_REPO_FILENAME" echo "" >> "$LOG_UPDATE_REPO_FILENAME"
fi fi
# Update completed # Update completed

Loading…
Cancel
Save