diff --git a/debian/_buildscripts/local/00_extradeps.sh b/debian/_buildscripts/local/00_extradeps.sh new file mode 100755 index 000000000..3a101d049 --- /dev/null +++ b/debian/_buildscripts/local/00_extradeps.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +. ./internals/_build_set_common.sh + +#---------------------------- +set_log_start + +if [[ "$USE_PREBUILD_EXTRA_DEPS" = "y" ]]; then + echo -e "${CBrown}#### Use of pre-built extra dependency packages is currently configured. Nothing to do. ####\n${CNone}" + echo "Use of pre-built extra dependency packages is currently configured. Nothing to do." >>"$LOG_BUILD_RESULT_FILENAME" +else + build_module "edeps/gettext-kde" + build_module "edeps/fireflies" + build_module "edeps/imlib" + build_module "edeps/opensync" + build_module "edeps/libbeagle" + build_module "edeps/pcsc-lite-nodbus" + build_module "edeps/lcms" + build_module "edeps/wv2" + build_module "edeps/jasper" + build_module "edeps/openslp-dfsg" +fi + +set_log_end diff --git a/debian/_buildscripts/local/scripts/01_base_01.sh b/debian/_buildscripts/local/01_base_01.sh similarity index 89% rename from debian/_buildscripts/local/scripts/01_base_01.sh rename to debian/_buildscripts/local/01_base_01.sh index d9611d13d..4b7979475 100755 --- a/debian/_buildscripts/local/scripts/01_base_01.sh +++ b/debian/_buildscripts/local/01_base_01.sh @@ -5,6 +5,8 @@ #---------------------------- set_log_start +build_module "dependencies/libr" +build_module "dependencies/akode" build_module "dependencies/tqt3" build_module "dependencies/tqtinterface" build_module "dependencies/arts" diff --git a/debian/_buildscripts/local/scripts/02_base_02.sh b/debian/_buildscripts/local/02_base_02.sh similarity index 100% rename from debian/_buildscripts/local/scripts/02_base_02.sh rename to debian/_buildscripts/local/02_base_02.sh diff --git a/debian/_buildscripts/local/scripts/03_base_03.sh b/debian/_buildscripts/local/03_base_03.sh similarity index 100% rename from debian/_buildscripts/local/scripts/03_base_03.sh rename to debian/_buildscripts/local/03_base_03.sh diff --git a/debian/_buildscripts/local/scripts/04_applications_01.sh b/debian/_buildscripts/local/04_applications_01.sh similarity index 100% rename from debian/_buildscripts/local/scripts/04_applications_01.sh rename to debian/_buildscripts/local/04_applications_01.sh diff --git a/debian/_buildscripts/local/scripts/05_applications_02.sh b/debian/_buildscripts/local/05_applications_02.sh similarity index 100% rename from debian/_buildscripts/local/scripts/05_applications_02.sh rename to debian/_buildscripts/local/05_applications_02.sh diff --git a/debian/_buildscripts/local/scripts/06_applications_03.sh b/debian/_buildscripts/local/06_applications_03.sh similarity index 100% rename from debian/_buildscripts/local/scripts/06_applications_03.sh rename to debian/_buildscripts/local/06_applications_03.sh diff --git a/debian/_buildscripts/local/07_applications_04.sh b/debian/_buildscripts/local/07_applications_04.sh new file mode 100755 index 000000000..2dda86fe4 --- /dev/null +++ b/debian/_buildscripts/local/07_applications_04.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +. ./internals/_build_set_common.sh + +#---------------------------- +set_log_start + +build_module "applications/koffice" +build_module "applications/koffice-i18n" +build_module "applications/keximdb" +build_module "applications/konversation" +build_module "applications/kooldock" +build_module "applications/kopete-otr" +build_module "applications/kpicosim" +build_module "applications/kpilot" +build_module "applications/kplayer" + +set_log_end + diff --git a/debian/_buildscripts/local/scripts/07_applications_04.sh b/debian/_buildscripts/local/08_applications_05.sh similarity index 68% rename from debian/_buildscripts/local/scripts/07_applications_04.sh rename to debian/_buildscripts/local/08_applications_05.sh index f21a6e24f..aae147370 100755 --- a/debian/_buildscripts/local/scripts/07_applications_04.sh +++ b/debian/_buildscripts/local/08_applications_05.sh @@ -5,15 +5,6 @@ #---------------------------- set_log_start -build_module "applications/koffice" -build_module "applications/koffice-i18n" -build_module "applications/keximdb" -build_module "applications/konversation" -build_module "applications/kooldock" -build_module "applications/kopete-otr" -build_module "applications/kpicosim" -build_module "applications/kpilot" -build_module "applications/kplayer" build_module "applications/krecipes" build_module "applications/krename" build_module "applications/krusader" @@ -31,6 +22,10 @@ build_module "applications/kvirc" build_module "applications/kvkbd" build_module "applications/kvpnc" build_module "applications/kxmleditor" +build_module "applications/mplayerthumbs" +build_module "applications/qalculate-tde" +build_module "applications/piklab" +build_module "applications/potracegui" +build_module "applications/soundkonverter" set_log_end - diff --git a/debian/_buildscripts/local/scripts/08_applications_05.sh b/debian/_buildscripts/local/09_applications_06.sh similarity index 82% rename from debian/_buildscripts/local/scripts/08_applications_05.sh rename to debian/_buildscripts/local/09_applications_06.sh index 2d7622b15..25ad95a60 100755 --- a/debian/_buildscripts/local/scripts/08_applications_05.sh +++ b/debian/_buildscripts/local/09_applications_06.sh @@ -5,11 +5,6 @@ #---------------------------- set_log_start -build_module "applications/mplayerthumbs" -build_module "applications/qalculate-tde" -build_module "applications/piklab" -build_module "applications/potracegui" -build_module "applications/soundkonverter" build_module "applications/tastymenu" build_module "applications/tde-guidance" build_module "applications/tdeio-apt" diff --git a/debian/_buildscripts/local/scripts/09_others_01.sh b/debian/_buildscripts/local/10_others_01.sh similarity index 100% rename from debian/_buildscripts/local/scripts/09_others_01.sh rename to debian/_buildscripts/local/10_others_01.sh diff --git a/debian/_buildscripts/local/11_others_02.sh b/debian/_buildscripts/local/11_others_02.sh new file mode 100755 index 000000000..6c98710a5 --- /dev/null +++ b/debian/_buildscripts/local/11_others_02.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +. ./internals/_build_set_common.sh + +#---------------------------- +set_log_start + +build_module "tde-i18n" +if [[ "$USE_PREBUILD_EXTRA_DEPS" != "y" ]]; then + build_module "edeps/compiz-trinity" + build_module "edeps/libcompizconfig-trinity" + build_module "edeps/compiz-fusion-bcop-trinity" + build_module "edeps/compiz-fusion-plugins-main-trinity" + build_module "edeps/compiz-fusion-plugins-extra-trinity" + build_module "edeps/compizconfig-python-trinity" +fi +build_module "applications/compizconfig-backend-tdeconfig" + +set_log_end diff --git a/debian/_buildscripts/local/91_build_base.sh b/debian/_buildscripts/local/91_build_base.sh new file mode 100755 index 000000000..7dbec8316 --- /dev/null +++ b/debian/_buildscripts/local/91_build_base.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [[ "$USE_PREBUILD_EXTRA_DEPS" != "y" ]]; then + ./00_extradeps.sh +fi +./01_base_01.sh +./02_base_02.sh +./03_base_03.sh diff --git a/debian/_buildscripts/local/scripts/92_build_applications.sh b/debian/_buildscripts/local/92_build_applications.sh similarity index 84% rename from debian/_buildscripts/local/scripts/92_build_applications.sh rename to debian/_buildscripts/local/92_build_applications.sh index 174464c41..45b26a5f1 100755 --- a/debian/_buildscripts/local/scripts/92_build_applications.sh +++ b/debian/_buildscripts/local/92_build_applications.sh @@ -5,4 +5,5 @@ ./06_applications_03.sh ./07_applications_04.sh ./08_applications_05.sh +./09_applications_06.sh diff --git a/debian/_buildscripts/local/93_build_others.sh b/debian/_buildscripts/local/93_build_others.sh new file mode 100755 index 000000000..870f22a61 --- /dev/null +++ b/debian/_buildscripts/local/93_build_others.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +./10_others_01.sh +./11_others_02.sh \ No newline at end of file diff --git a/debian/_buildscripts/local/99_build_TDE.sh b/debian/_buildscripts/local/99_build_TDE.sh new file mode 100755 index 000000000..99b72ce05 --- /dev/null +++ b/debian/_buildscripts/local/99_build_TDE.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Load common code and initialization +. ./internals/_build_common.sh +init_common + +_BUILDALL_TIMER=2 +_BUILDALL_TIME="--/--:--:--:---" + + +#---------------------------- +# do_exit for set building +function do_exit() +{ + cd "$SCRIPT_DIR" + if [ $1 -eq 0 ]; then + echo -e "${CGray}#### Building process for TDE completed ####${CNone}" + else + echo -e "${CGray}#### Building process for TDE interrupted ($1) ####${CNone}" + fi + exit $1 +} + + +#---------------------------- +function set_log_start() +{ + echo -e "${CGray}#### Starting building process for TDE ####${CNone}" + echo + echo "********** TDE **********" >>"$LOG_BUILD_RESULT_FILENAME" + exec_time_start $_BUILDALL_TIMER +} + + +#---------------------------- +function set_log_end() +{ + exec_time_stop $_BUILDALL_TIMER "_BUILDALL_TIME" + echo " [$_BUILDALL_TIME] All TDE " >>"$LOG_BUILD_RESULT_FILENAME" + echo >>"$LOG_BUILD_RESULT_FILENAME" + do_exit 0 +} + + +#---------------------------- +# Build TDE +#---------------------------- +set_log_start + +./91_build_base.sh +./92_build_applications.sh +./93_build_others.sh + +set_log_end diff --git a/debian/_buildscripts/local/scripts/README.txt b/debian/_buildscripts/local/README.txt similarity index 62% rename from debian/_buildscripts/local/scripts/README.txt rename to debian/_buildscripts/local/README.txt index 8d8a248c7..cbe44130a 100644 --- a/debian/_buildscripts/local/scripts/README.txt +++ b/debian/_buildscripts/local/README.txt @@ -15,7 +15,7 @@ A) Environment preparation here and there. - you can change folder names below, as long as you update the "_config.sh" file accordingly. -1) Install following packages: bc, cdbs, git, links2, pbuilder, rsync and required dependencies. +1) Install following packages: bc, cdbs, git, pbuilder, rsync and required dependencies. NOTE: sudo should already be installed. If not, install sudo as well. 2) Create a base folder for TDE, hereafter referred to as TDE_DIR (for example $HOME/tde_src) @@ -31,7 +31,7 @@ A) Environment preparation 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 -4) Clone TDE git repositories and extra dependency modules: +4) Clone TDE git repositories - TDE main repo cd "TDE_DIR/1_git" git clone https://mirror.git.trinitydesktop.org/gitea/TDE/tde @@ -42,26 +42,16 @@ A) Environment preparation - TDE packaging repo cd "TDE_DIR/1_git" git clone https://mirror.git.trinitydesktop.org/gitea/TDE/tde-packaging - - extra dependency packages - using a browser, download the source code for 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/ folder (one folder per module). 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). - Logout and login again to make sure the setting is 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. + Logout and login again to make sure the new settings are applied. -6) Copy the files from "TDE_DIR/1_git/tde-packaging/debian/_buildscripts/local/buildscripts/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. 7) Create pbuilder base package with the command: @@ -70,15 +60,57 @@ A) Environment preparation sudo DIST= ARCH= pbuilder --create 8) Setup the build scripts locally: - - copy build scripts from "TDE_DIR/1_git/tde-packaging/debian/_buildscripts/local/buildscripts" 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 - cd "TDE_DIR/buildscripts" - cp ./internals/_config_template.sh _config.sh - edit "_config.sh" to set your preferences and check that the various folder names match the structure on your disk. - Make sure to set the variable TDE_DIR to the correct path and the variables DISTRO, DISTRO_NAME and ARCHITECTURE to - match the distro and architecture you want to build for. - - + Make sure to set the following variables: + * TDE_DIR to the correct path. + * DISTRO, DISTRO_NAME and ARCHITECTURE to match the distro and architecture you want to build for. + * 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. + +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 + pre-built binaries can be used. + + 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) + - 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. + * For R14.1.x series (repository branch "master") + # --- SLAVEK BANKO'S EXTRA DEPENDENCIES REPOSITORY --- + deb http://mirror.xcer.cz/trinity-tb deps + * 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 + For example: + deb http://mirror.xcer.cz/trinity-tb 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 + + 9.2) Building extra dependencies locally + - open "_config.sh" and set the variable USE_PREBUILD_EXTRA_DEPS to "n" + - install the following packages: links2 and required dependencies. + - 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/ 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. + # --- LOCAL TDE REPOSITORY --- + deb [trusted=yes] file:TDE_DIR/3_repo main + For example: + deb [trusted=yes] file:/home/tde_src/3_repo buster main ---------------------- B) Notes about scripts @@ -101,9 +133,18 @@ When building sets of modules or the whole TDE, a global build summary is automa Scripts used intenally by other scripts. No need for invoking these directly. - update_git_repository.sh: - Scripts used to update the local clone of the git repositories. + 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. Usage: - update_git_repository.sh + [OVERRIDE_DEFAULT_REPO_BRANCH=""] 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. - build_module.sh Build a single module. @@ -132,23 +173,21 @@ When building sets of modules or the whole TDE, a global build summary is automa The sets are logically grouped as "base system", "applications" and "others" 00_extradeps.sh : extra dependencies modules 01_base_01.sh - 03_base_03.sh : TDE base system - 04_application_01.sh - 08_application_05.sh : application modules - 09_others_01.sh - 10_others_02.sh : other modules that either fail to build/install or that are somehow less used - 91_build_base.sh : whole TDE base system - 92_build_applications.sh : all TDE applications in 04_application_01.sh - 08_application_05.sh - 93_build_others.sh : all modules in 09_others_01.sh - 10_others_02.sh + 04_application_01.sh - 09_application_06.sh : application modules + 10_others_01.sh - 11_others_02.sh : other modules that are somehow less used + 91_build_base.sh : whole TDE base system in 00_extradeps.sh - 03_base_03.sh + 92_build_applications.sh : all TDE applications in 04_application_01.sh - 09_application_06.sh + 93_build_others.sh : all modules in 10_others_01.sh - 11_others_02.sh - 99_build_TDE.sh - Script used to build the whole 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: - build_TDE.sh [options] - Options: - -s N: if specified, skip first N sets from the list of sets + build_TDE.sh - create_repo.sh Creates a local repository from the .deb files currently stored in TDE_DIR/2_build/debs. Usage: - create_repo.sh [options] + [sudo] create_repo.sh [options] Options: -b (Backup) : create a backup of the existing repository in TDE_DIR/CFG_REPO_DIR.backup @@ -168,18 +207,19 @@ C) How to use the scripts 1) Follow the steps in section "A) Environment preparation" (only required the first time). 2) cd "TDE_DIR/buildscripts" 3) Update to latest git repository using - ./update_repositories.sh - Wait until "Update completed" is printed out. Check log in TDE_DIR/0_logs/ if you wish. + ./update_repositories.sh 4) Run "sudo pbuilder update" at the beginning of the day to update the base package to the latest version. This will speed up 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 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. - Add the following lines to /etc/apt/sources.list and follow the usual way to install TDE. - # --- LOCAL TDE REPOSITORY --- - deb [arch= trusted=yes] file:TDE_DIR/3_repo main - For example: - deb [arch=amd64 trusted=yes] file:/home/tde_src/3_repo buster main + [sudo] ./create_repo.sh +7) Install TDE as you usually do. For example as follow: + - sudo apt-get update + - sudo aptitude install tdebase-trinity (for a minimalistic TDE environment) + or + sudo aptitude install tde-trinity (for a standard TDE environment) + Examples of real usage: @@ -199,9 +239,10 @@ Examples of real usage: 2) build a single set (optional) delete the TDE_DIR/0_logs/build_result.log file - ./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. + ./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. 3) build all TDE - ./99_build_TDE.sh : build all TDE - ./99_build_TDE.sh -s 4 : build all TDE, but skip the first 4 sets + ./99_build_TDE.sh -> build all TDE + +4) [sudo] ./create_repo.sh -> build or update your local TDE repository \ No newline at end of file diff --git a/debian/_buildscripts/local/scripts/additional files/etc/pbuilderrc b/debian/_buildscripts/local/additional_files/etc/pbuilderrc similarity index 98% rename from debian/_buildscripts/local/scripts/additional files/etc/pbuilderrc rename to debian/_buildscripts/local/additional_files/etc/pbuilderrc index 81e7894c4..fde052b35 100644 --- a/debian/_buildscripts/local/scripts/additional files/etc/pbuilderrc +++ b/debian/_buildscripts/local/additional_files/etc/pbuilderrc @@ -145,9 +145,6 @@ if [ -z "$(stat -L --print "%d\n" $APTCACHE/. /var/cache/pbuilder/build/. | uniq APTCACHE="" fi -# default PKGNAME_LOGFILE -PKGNAME_LOGFILE="__build__.log" - #-- extra options DEBBUILDOPTS="-B" if [ "$ARCHITECTURE" == "amd64" ]; then diff --git a/debian/_buildscripts/local/scripts/build_module.sh b/debian/_buildscripts/local/build_module.sh similarity index 78% rename from debian/_buildscripts/local/scripts/build_module.sh rename to debian/_buildscripts/local/build_module.sh index adfc4172e..18d55d778 100755 --- a/debian/_buildscripts/local/scripts/build_module.sh +++ b/debian/_buildscripts/local/build_module.sh @@ -30,12 +30,12 @@ function do_exit() if [ $1 -eq 0 ]; then echo -e "${CGreen}#### Processing module ${CLightGreen}\"$MOD_NAME\"${CGreen} succeeded ####${CNone}" if [ "$bool_LOG_RESULT" = "y" ]; then - echo "[ OK ] [$_BUILDMOD_TIME] \"$MOD_NAME\"" >>"$LOG_RESULT_FILENAME" + echo "[ OK ] [$_BUILDMOD_TIME] \"$MOD_NAME\"" >>"$LOG_BUILD_RESULT_FILENAME" fi else echo -e "${CRed}#### Processing module ${CLightRed}\"$MOD_NAME\"${CRed} failed ($1) ####${CNone}" if [ "$bool_LOG_RESULT" = "y" ]; then - echo "[FAILED] [$_BUILDMOD_TIME] \"$MOD_NAME\"" >>"$LOG_RESULT_FILENAME" + echo "[FAILED] [$_BUILDMOD_TIME] \"$MOD_NAME\"" >>"$LOG_BUILD_RESULT_FILENAME" fi fi exit $1 @@ -121,19 +121,8 @@ export OPT_SHOW_LOGS # Log start echo -e "${CLightCyan}#### Processing module \"$MOD_NAME\" ####${CNone}" - -#---------------------------- -# Base directories -#---------------------------- -GIT_DIR="$TDE_DIR/$CFG_GIT_DIR" -BUILD_DIR="$TDE_DIR/$CFG_BUILD_DIR" -GIT_TDE_MAIN="$TDE_DIR/$CFG_GIT_TDE_MAIN" -GIT_TDE_PACKAGING="$TDE_DIR/$CFG_GIT_TDE_PACKAGING" -GIT_EXTRA_DEPENDENCIES="$TDE_DIR/$CFG_GIT_EXTRA_DEPENDENCIES" -HOOK_DIR="$TDE_DIR/$CFG_HOOK_DIR" - # This folders must exists -BASE_DIRS=("GIT_DIR" "BUILD_DIR" "SCRIPT_DIR" "GIT_TDE_MAIN" "GIT_TDE_PACKAGING" "GIT_EXTRA_DEPENDENCIES" "HOOK_DIR") +BASE_DIRS=("REPO_DIR" "BUILD_DIR" "SCRIPT_DIR" "REPO_TDE_MAIN" "REPO_TDE_PACKAGING" "REPO_EXTRA_DEPENDENCIES" "HOOK_DIR") for var_name in ${BASE_DIRS[@]}; do if [ ! -d "${!var_name}" ]; then @@ -146,9 +135,6 @@ done #---------------------------- # Build output directories #---------------------------- -TDE_BUILD_DIR="$TDE_DIR/$CFG_TDE_BUILD_DIR" -export TDE_DEBS_DIR="$TDE_DIR/$CFG_TDE_DEBS_DIR" - BUILD_DIRS=("TDE_BUILD_DIR" "TDE_DEBS_DIR") for var_name in ${BUILD_DIRS[@]}; do @@ -163,13 +149,13 @@ done #---------------------------- if [ "$bool_EXTRADEP_MOD" != "y" ]; then # Standard module - MOD_GIT_PATH="$GIT_TDE_MAIN/$MOD_NAME" - MOD_GIT_PKGING_PATH="$GIT_TDE_PACKAGING/$MOD_NAME/debian" + MOD_GIT_PATH="$REPO_TDE_MAIN/$MOD_NAME" + MOD_GIT_PKGING_PATH="$REPO_TDE_PACKAGING/$MOD_NAME/debian" else # Extra dependency module - MOD_GIT_PATH="$GIT_DIR/$MOD_NAME" + MOD_GIT_PATH="$REPO_DIR/$MOD_NAME" fi -MOD_BUILD_PATH="$TDE_BUILD_DIR/$MOD_NAME" +export MOD_BUILD_PATH="$TDE_BUILD_DIR/$MOD_NAME" MOD_BUILD_PKGING_PATH="$MOD_BUILD_PATH/debian" if [ "$bool_BUILD_FROM_GIT" = "y" ]; then @@ -265,57 +251,48 @@ if [ "$bool_EXTRADEP_MOD" != "y" -a "$bool_COPY_PKGING_FILES" = "y" ]; then # TODO metapackage support - if [ "$USE_LOCAL_BUILD_NUMBER" != "y" ]; then - # Default package name (Slavek's repo style) - # Calculate package version - cd $MOD_GIT_PATH - branch=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-` - target_tag=`git tag | grep -F "$TDE_RELEASE" | head -n1` - 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|" | \ - while read t; do \ - git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \ - echo "$t..HEAD" && break; done` - count=`git log $tag --pretty=oneline | wc -l` - package=$(basename $PWD)-trinity-$TDE_RELEASE - if [[ "$count" -gt 0 ]] || [[ -z "$target_tag" ]]; then - package=$package~pre$count+$(git rev-parse HEAD | cut -c 1-8) - fi - REL=4:$TDE_RELEASE${package#*$TDE_RELEASE} - REL=${REL%+*} - 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/.0~pre/.0~s} - # Get package name and packaging release - PKG_NAME=$(head -n1 $MOD_BUILD_PKGING_PATH/changelog) - PKG_NAME=${PKG_NAME%% *} - PKG_TAG=$(cd "$GIT_TDE_PACKAGING/$MOD_NAME" && - 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|" | \ - while read t; do \ - git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \ - echo "$t..HEAD" && break; done) - PKG_REL=$(cd "$GIT_TDE_PACKAGING/$MOD_NAME" && - git log $PKG_TAG --pretty=oneline . | wc -l) - if [ -n "$REL_SUFFIX" ]; then - PKG_REL="${PKG_REL}${REL_SUFFIX}" - fi - # TODO add relative patch count - ADD_REL=0 - - DATE=$(date -R) - 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 -e "\n * Automated git build\n\n -- $GITUSER $DATE\n" >> "$MOD_BUILD_PKGING_PATH/changelog" - cat "$GIT_TDE_PACKAGING/$MOD_NAME/debian/changelog" >> "$MOD_BUILD_PKGING_PATH/changelog" - else - # Local build version - if [ "$BUILD_DATE" = "" ]; then - BUILD_DATE=`date +%Y%m%d+%H%M` - fi - BUILDISTRO_NAME="4:$TDE_RELEASE-${BUILD_NUMBER}+$BUILD_DATE" # Module build version number (quilt format) - dch -b -v "$BUILDISTRO_NAME" -D "$DISTRO_NAME" -c "$MOD_BUILD_PKGING_PATH/changelog" "Autogenerated by building script" &>/dev/null - fi + # Default package name (Slavek's repo style) + # Calculate package version + cd $MOD_GIT_PATH + branch=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-` + target_tag=`git tag | grep -F "$TDE_RELEASE" | head -n1` + 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|" | \ + while read t; do \ + git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \ + echo "$t..HEAD" && break; done` + count=`git log $tag --pretty=oneline | wc -l` + package=$(basename $PWD)-trinity-$TDE_RELEASE + if [[ "$count" -gt 0 ]] || [[ -z "$target_tag" ]]; then + package=$package~pre$count+$(git rev-parse HEAD | cut -c 1-8) + fi + REL=4:$TDE_RELEASE${package#*$TDE_RELEASE} + REL=${REL%+*} + 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/.0~pre/.0~s} + # Get package name and packaging release + PKG_NAME=$(head -n1 $MOD_BUILD_PKGING_PATH/changelog) + PKG_NAME=${PKG_NAME%% *} + PKG_TAG=$(cd "$REPO_TDE_PACKAGING/$MOD_NAME" && + 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|" | \ + while read t; do \ + git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \ + echo "$t..HEAD" && break; done) + PKG_REL=$(cd "$REPO_TDE_PACKAGING/$MOD_NAME" && + git log $PKG_TAG --pretty=oneline . | wc -l) + if [ -n "$REL_SUFFIX" ]; then + PKG_REL="${PKG_REL}${REL_SUFFIX}" + fi + # TODO add relative patch count + ADD_REL=0 + + DATE=$(date -R) + 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 -e "\n * Automated git build\n\n -- $GITUSER $DATE\n" >> "$MOD_BUILD_PKGING_PATH/changelog" + cat "$REPO_TDE_PACKAGING/$MOD_NAME/debian/changelog" >> "$MOD_BUILD_PKGING_PATH/changelog" fi # prepare destination directory for building diff --git a/debian/_buildscripts/local/scripts/create_repo.sh b/debian/_buildscripts/local/create_repo.sh similarity index 97% rename from debian/_buildscripts/local/scripts/create_repo.sh rename to debian/_buildscripts/local/create_repo.sh index 1f1e1cb0f..f03f92e84 100755 --- a/debian/_buildscripts/local/scripts/create_repo.sh +++ b/debian/_buildscripts/local/create_repo.sh @@ -24,7 +24,6 @@ ARCH_PATH="dists/$DISTRO_NAME/main/binary-$ARCHITECTURE" REPO_DIR="$TDE_DIR/$CFG_REPO_DIR" REPO_DIR_BACKUP="$REPO_DIR.backup" REPO_PKG_DIR="$REPO_DIR/$ARCH_PATH" -TDE_DEBS_DIR="$TDE_DIR/$CFG_TDE_DEBS_DIR" # Backup if [ "$parm_MAKE_BACKUP" = "y" ] && [ -d "$REPO_DIR" ]; then diff --git a/debian/_buildscripts/local/scripts/hook examples/applications/kaffeine/kaffeine-wizard.diff b/debian/_buildscripts/local/hook_examples/applications/kaffeine/kaffeine-wizard.diff similarity index 100% rename from debian/_buildscripts/local/scripts/hook examples/applications/kaffeine/kaffeine-wizard.diff rename to debian/_buildscripts/local/hook_examples/applications/kaffeine/kaffeine-wizard.diff diff --git a/debian/_buildscripts/local/scripts/hook examples/applications/kaffeine/pre_build.sh b/debian/_buildscripts/local/hook_examples/applications/kaffeine/pre_build.sh similarity index 100% rename from debian/_buildscripts/local/scripts/hook examples/applications/kaffeine/pre_build.sh rename to debian/_buildscripts/local/hook_examples/applications/kaffeine/pre_build.sh diff --git a/debian/_buildscripts/local/scripts/hook examples/tdebase/018_kate_save_all.diff b/debian/_buildscripts/local/hook_examples/tdebase/018_kate_save_all.diff similarity index 100% rename from debian/_buildscripts/local/scripts/hook examples/tdebase/018_kate_save_all.diff rename to debian/_buildscripts/local/hook_examples/tdebase/018_kate_save_all.diff diff --git a/debian/_buildscripts/local/scripts/hook examples/tdebase/pre_build.sh b/debian/_buildscripts/local/hook_examples/tdebase/pre_build.sh similarity index 100% rename from debian/_buildscripts/local/scripts/hook examples/tdebase/pre_build.sh rename to debian/_buildscripts/local/hook_examples/tdebase/pre_build.sh diff --git a/debian/_buildscripts/local/scripts/hook examples/tdebase/tdebase-usesak.diff b/debian/_buildscripts/local/hook_examples/tdebase/tdebase-usesak.diff similarity index 100% rename from debian/_buildscripts/local/scripts/hook examples/tdebase/tdebase-usesak.diff rename to debian/_buildscripts/local/hook_examples/tdebase/tdebase-usesak.diff diff --git a/debian/_buildscripts/local/scripts/hook examples/tdelibs/038_placeholder.diff b/debian/_buildscripts/local/hook_examples/tdelibs/038_placeholder.diff similarity index 100% rename from debian/_buildscripts/local/scripts/hook examples/tdelibs/038_placeholder.diff rename to debian/_buildscripts/local/hook_examples/tdelibs/038_placeholder.diff diff --git a/debian/_buildscripts/local/scripts/hook examples/tdelibs/pre_build.sh b/debian/_buildscripts/local/hook_examples/tdelibs/pre_build.sh similarity index 100% rename from debian/_buildscripts/local/scripts/hook examples/tdelibs/pre_build.sh rename to debian/_buildscripts/local/hook_examples/tdelibs/pre_build.sh diff --git a/debian/_buildscripts/local/scripts/internals/C10shell b/debian/_buildscripts/local/internals/C10shell similarity index 100% rename from debian/_buildscripts/local/scripts/internals/C10shell rename to debian/_buildscripts/local/internals/C10shell diff --git a/debian/_buildscripts/local/internals/_build_common.sh b/debian/_buildscripts/local/internals/_build_common.sh new file mode 100755 index 000000000..5e4ba67fe --- /dev/null +++ b/debian/_buildscripts/local/internals/_build_common.sh @@ -0,0 +1,248 @@ +#!/bin/bash + +set -a + +#---------------------------- +# Color table +# Black 0;30 Dark Gray 1;30 +# Blue 0;34 Light Blue 1;34 +# Green 0;32 Light Green 1;32 +# Cyan 0;36 Light Cyan 1;36 +# Red 0;31 Light Red 1;31 +# Purple 0;35 Light Purple 1;35 +# Brown 0;33 Yellow 1;33 +# Light Gray 0;37 White 1;37 +# No Color 0 +#---------------------------- +CBlack='\e[0;30m' +CDarkGray='\e[1;30m' +CBlue='\e[0;34m' +CLightBlue='\e[1;34m' +CGreen='\e[0;32m' +CLightGreen='\e[1;32m' +CCyan='\e[0;36m' +CLightCyan='\e[1;36m' +CRed='\e[0;31m' +CLightRed='\e[1;31m' +CPurple='\e[0;35m' +CLightPurple='\e[1;35m' +CBrown='\e[0;33m' +CYellow='\e[1;33m' +CGray='\e[0;37m' +CWhite='\e[1;37m' +CNone='\e[0m' + +set +a + +#---------------------------- +# Echo a colored string to tty and tee-append it to a file without color codes +# Parameters: +# $1 - string to echo +# $2 - log filename +# $3 - if "y" create a new file. +function echo_and_tee() +{ + if [ "$3" = "y" ]; then + echo -e "$1" | tee /dev/tty | sed -r "s|\x1b\[[0-9]+(;[0-9]+)?m||g" >"$2" + else + echo -e "$1" | tee /dev/tty | sed -r "s|\x1b\[[0-9]+(;[0-9]+)?m||g" >>"$2" + fi +} + +#---------------------------- +function _set_path_varables() +{ + # Set useful path variables + set -a + REPO_DIR="$TDE_DIR/$CFG_GIT_DIR" + REPO_TDE="$TDE_DIR/$CFG_GIT_DIR/tde" + REPO_TDE_MAIN="$REPO_TDE/main" + REPO_TDE_PACKAGING="$TDE_DIR/$CFG_GIT_DIR/tde-packaging/$DISTRO/$DISTRO_NAME" + REPO_EXTRA_DEPENDENCIES="$TDE_DIR/$CFG_GIT_DIR/$CFG_EXTRA_DEPS_DIR" + + BUILD_DIR="$TDE_DIR/$CFG_BUILD_DIR" + TDE_BUILD_DIR="$TDE_DIR/$CFG_BUILD_DIR/build" + TDE_DEBS_DIR="$TDE_DIR/$CFG_BUILD_DIR/debs" + + HOOK_DIR="$TDE_DIR/$CFG_GIT_DIR/$CFG_HOOKS_DIR" + + SCRIPT_LOG_DIR="$TDE_DIR/$CFG_SCRIPT_LOG_DIR" + LOG_BUILD_RESULT_FILENAME="$SCRIPT_LOG_DIR/build_result.log" # Common build logfile + LOG_UPDATE_REPO_FILENAME="$SCRIPT_LOG_DIR/update_repo.log" # Update repository logfile + set +a +} + +#---------------------------- +function init_common() +{ + # Check script folder + export SCRIPT_DIR=$(dirname $(readlink -f "$0")) + + # Prevent the script to be run from TDE packaging repo + REPO_URL=$(git config --get remote.origin.url 2>/dev/null) + if [ ! -z "$REPO_URL" ] && [ -z "${REPO_URL##*tde-packaging}" ]; then + echo -e "${CLightRed} --- ERROR ---${CNone}" + echo "This script cannot be run from the TDE packaging repository." + echo "Please follow the instructions provided, then rerun this script." + exit 1 + fi + + # Read config settings + CFG_FILE=$SCRIPT_DIR/_config.sh + if [ -f "$CFG_FILE" ]; then + . "$CFG_FILE" + _set_path_varables + else + echo -e "${CLightRed} --- NOTE ---${CNone}" + echo -e "Creating TDE build configuration file from template as ${CLightPurple}$CFG_FILE${CNone}." + echo "Please check and modify as required, then rerun this script." + cp "$SCRIPT_DIR/internals/_config_template.sh" "$CFG_FILE" + exit 2 + fi + + # Make sure we have selected a supported distribution + DISTS_FILE="$SCRIPT_DIR/internals/distro_list.txt" + if [ ! -f "$DISTS_FILE" ]; then + echo -e "${CLightRed} --- ERROR ---${CNone}" + echo "Could not find the list of supported distributions." + echo -e "Please check the file ${CLightPurple}$DISTS_FILE${CNone} exists, then rerun this script." + exit 3 + fi + # -- 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 + if [ "$l_distro" = "$DISTRO" -a "$l_name" = "$DISTRO_NAME" ]; then + DISTRO_FOUND="y" + export DISTRO_VERSION="$l_version" + export REL_SUFFIX="$l_rel_suffix" + break + fi + done <<< $(cat $DISTS_FILE | grep -E "^(\s*[^#\s]+\s+[^\s]+.*)$") + if [ "$DISTRO_FOUND" != "y" ]; then + echo -e "${CLightRed} --- ERROR ---${CNone}" + echo -e "The specified distribution (${CYellow}$DISTRO $DISTRO_NAME${CNone}) is not supported." + echo -e "Something is wrong with your configuration (${CLightPurple}$CFG_FILE${CNone})" + echo -e "or with the list of supported distributions (${CLightPurple}$DISTS_FILE${CNone})." + echo -e "Please check the ${CLightCyan}DISTRO${CNone} and ${CLightCyan}DISTRO_NAME${CNone} variables, then rerun this script." + exit 4 + fi + + # TDE root folder must exist + if [ ! -d "$TDE_DIR" ]; then + echo -e "${CLightRed} --- ERROR ---${CNone}" + echo "A valid TDE root folder could not be located. Something is wrong with your configuration" + echo -e "in the config file ${CLightPurple}$CFG_FILE${CNone}" + echo -e "Please check and modify the ${CLightCyan}TDE_DIR${CNone} variable as required, then rerun this script." + exit 5 + fi + + # Search for main TDE repo + CURR_DIR="" + [ -d "$REPO_TDE_MAIN" ] && cd "$REPO_TDE_MAIN" &>/dev/null && \ + CURR_DIR=$(git rev-parse --show-toplevel 2>/dev/null) + if [ -z "$CURR_DIR" ]; then + echo -e "${CLightRed} --- ERROR ---${CNone}" + echo "The main TDE repo could not be located. Something is wrong with your configuration" + echo -e "in the config file ${CLightPurple}$CFG_FILE${CNone}" + echo -e "Please check and modify the ${CLightCyan}TDE_DIR${CNone} variable as required, then rerun this script." + exit 6 + fi + + # Search for TDE packaging repo + CURR_DIR="" + [ -d "$REPO_TDE_PACKAGING" ] && cd "$REPO_TDE_PACKAGING" &>/dev/null && \ + CURR_DIR=$(git rev-parse --show-toplevel 2>/dev/null) + if [ -z "$CURR_DIR" ]; then + echo -e "${CLightRed} --- ERROR ---${CNone}" + echo "The TDE packaging repo could not be located. Something is wrong with your configuration" + echo -e "in the config file ${CLightPurple}$CFG_FILE${CNone}" + echo -e "Please check and modify the ${CLightCyan}TDE_DIR${CNone} variable as required, then rerun this script." + exit 7 + fi + + # Check branch configuration + # - branch existance + cd "$REPO_TDE" + BRANCHES=() + REMOTE_BRANCHES=(`git branch --remote | grep -v "HEAD" | sed "s|origin/||g"`) + for br in $UPDATE_BRANCHES; do + branch=`echo "$br" | sed -e "s|^[[:space:]]*||" -e "s|[[:space:]]*$||"` + found=0 + for rem_br in "${REMOTE_BRANCHES[@]}"; do + if [[ "$rem_br" == "$branch" ]]; then + found=1 + break + fi + done + if [[ found -eq 1 ]]; then + BRANCHES+=($branch) + else + echo -e "${CLightRed} --- ERROR ---${CNone}" + echo -e "Invalid branch specified (${CYellow}$branch${CNone}). Something is wrong with your configuration" + echo -e "in the config file ${CLightPurple}$CFG_FILE${CNone}" + echo -e "Please check and modify the ${CLightCyan}UPDATE_BRANCHES${CNone} variable as required, then rerun this script." + exit 8 + fi + done + if [ ${#BRANCHES[@]} -eq 0 ]; then + echo -e "${CLightRed} --- ERROR ---${CNone}" + echo -e "No valid branch was specified. Something is wrong with your configuration" + echo -e "in the config file ${CLightPurple}$CFG_FILE${CNone}" + echo -e "Please check and modify the ${CLightCyan}UPDATE_BRANCHES${CNone} variable as required, then rerun this script." + exit 9 + fi + export BRANCHES + # - default branch + DEFAULT_REPO_BRANCH=${OVERRIDE_DEFAULT_REPO_BRANCH:-"$DEFAULT_REPO_BRANCH"} + found=0 + for branch in "${BRANCHES[@]}"; do + if [[ "$DEFAULT_REPO_BRANCH" == "$branch" ]]; then + found=1 + break + fi + done + if [[ found -ne 1 ]]; then + echo -e "${CLightRed} --- ERROR ---${CNone}" + echo -e "Invalid default repo branch specified (${CYellow}$DEFAULT_REPO_BRANCH${CNone}). Something is wrong with your configuration" + echo -e "in the config file ${CLightPurple}$CFG_FILE${CNone}" + echo -e "Please check and modify the ${CLightCyan}DEFAULT_REPO_BRANCH${CNone} variable as required, then rerun this script." + exit 10 + fi + + cd "$SCRIPT_DIR" +} + + +#---------------------------- +# Save execution start time +# Parameters: +# $1 - timer number +function exec_time_start() +{ + _ET_start_var="_ET_start_$1" + eval "$_ET_start_var=`date +%s.%N`" +} + + +#---------------------------- +# Save execution stop time and set $2 to the execution time +# in the format: dd/hh:mm:ss.mmm +# Parameters: +# $1 - timer number +# $2 - result variable name +function exec_time_stop() +{ + _ET_start_var="_ET_start_$1" + _ET_stop_var="_ET_stop_$1" + eval "$_ET_stop_var=`date +%s.%N`" + _ET_diff=`echo "${!_ET_stop_var} - ${!_ET_start_var}" | bc` + _ET_days=`echo "$_ET_diff/86400" | bc` + _ET_diff_day=`echo "$_ET_diff-86400*$_ET_days" | bc` + _ET_hours=`echo "$_ET_diff_day/3600" | bc` + _ET_diff_hour=`echo "$_ET_diff_day-3600*$_ET_hours" | bc` + _ET_mins=`echo "$_ET_diff_hour/60" | bc` + _ET_secs=`echo "$_ET_diff_hour-60*$_ET_mins" | bc` + local _resultvar=$2 + eval "$_resultvar=`printf \"%02d/%02d:%02d:%06.3f\" $_ET_days $_ET_hours $_ET_mins $_ET_secs`" +} diff --git a/debian/_buildscripts/local/scripts/internals/_build_set_common.sh b/debian/_buildscripts/local/internals/_build_set_common.sh similarity index 89% rename from debian/_buildscripts/local/scripts/internals/_build_set_common.sh rename to debian/_buildscripts/local/internals/_build_set_common.sh index 7d28736b0..4bc1ea3e8 100755 --- a/debian/_buildscripts/local/scripts/internals/_build_set_common.sh +++ b/debian/_buildscripts/local/internals/_build_set_common.sh @@ -31,7 +31,7 @@ function set_log_start() { echo -e "${CGray}#### Starting building process for set \"${0##*/}\" ####${CNone}" echo - echo "---------- ${0##*/} ----------" >>"$LOG_RESULT_FILENAME" + echo "---------- ${0##*/} ----------" >>"$LOG_BUILD_RESULT_FILENAME" exec_time_start $_BUILDSET_TIMER } @@ -40,8 +40,8 @@ function set_log_start() function set_log_end() { exec_time_stop $_BUILDSET_TIMER "_BUILDSET_TIME" - echo " [$_BUILDSET_TIME] SET ${0##*/}" >>"$LOG_RESULT_FILENAME" - echo >>"$LOG_RESULT_FILENAME" + echo " [$_BUILDSET_TIME] SET ${0##*/}" >>"$LOG_BUILD_RESULT_FILENAME" + echo >>"$LOG_BUILD_RESULT_FILENAME" do_exit 0 } diff --git a/debian/_buildscripts/local/internals/_config_template.sh b/debian/_buildscripts/local/internals/_config_template.sh new file mode 100644 index 000000000..be992d297 --- /dev/null +++ b/debian/_buildscripts/local/internals/_config_template.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -a + +#---------------------------- +# Repo information +#---------------------------- +TDE_DIR="" # TDE root folder +UPDATE_BRANCHES="master" # Space separated list. Available choices: master, r14.0.x +DEFAULT_REPO_BRANCH="master" # After update in completed, switch repo to this branch. Must be + # one of the branches specified in UPDATE_BRANCHES + +#---------------------------- +# Build information +#---------------------------- +TDE_RELEASE="14.1.0" # TDE release number +DISTRO="debian" # Distro family +DISTRO_NAME="buster" # Distro name of specific version +ARCHITECTURE="amd64" # Build for this architecture +USE_PREBUILD_EXTRA_DEPS="y" # If == "y", use pre-built extra dependency packages +BUILD_DEFAULT_OPTIONS="-g -lr" # Default building options (pbuilder) +GPG_SIGN_KEYID="" # Use this GPG key to sign packages. If null, packages will not be signed + +#---------------------------- +# Base directories +#---------------------------- +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_HOOKS_DIR="hooks" # Relative to CFG_GIT_DIR folder + +set +a diff --git a/debian/_buildscripts/local/scripts/internals/_pbuilder.sh b/debian/_buildscripts/local/internals/_pbuilder.sh similarity index 74% rename from debian/_buildscripts/local/scripts/internals/_pbuilder.sh rename to debian/_buildscripts/local/internals/_pbuilder.sh index 9b6ffb7b5..931fba56f 100755 --- a/debian/_buildscripts/local/scripts/internals/_pbuilder.sh +++ b/debian/_buildscripts/local/internals/_pbuilder.sh @@ -38,12 +38,28 @@ function run_pdebuild() echo -e "${CYellow}> Building using pbuilder${CNone}" # Create pbuilder hook to make sure all available packages are scanned # Store any existing D05 hook as a temporary file, this will be reinstated at the end - cat < "$PBUILDER_DEPS_HOOK" + cat < "$PBUILDER_DEPS_HOOK" #!/bin/sh (cd "$TDE_DEBS_DIR"; apt-ftparchive packages . > Packages) -echo "deb [trusted=yes] file://$TDE_DEBS_DIR ./" >> /etc/apt/sources.list +echo "deb [trusted=yes] file:$TDE_DEBS_DIR ./" >> /etc/apt/sources.list +END_D05_01 + if [[ "$USE_PREBUILD_EXTRA_DEPS" = "y" ]]; then + # Get building branch from .tdescmrevision file + if [[ -f "$MOD_BUILD_PATH/.tdescmrevision" ]]; then + BUILD_BRANCH=`sed -r "s/([^-]+)-.*/\1/" "$MOD_BUILD_PATH/.tdescmrevision"` + while read l_branch l_repo l_component; do + if [ "$l_branch" = "$BUILD_BRANCH" ]; then + cat <> "$PBUILDER_DEPS_HOOK" +echo "deb [trusted=yes] $l_repo $DISTRO_NAME $l_component" >> /etc/apt/sources.list +END_D05_02 + break + fi + done <<< $(cat "$SCRIPT_DIR/internals/extra_deps.txt" | grep -E "^[[:space:]]*[^#[:space:]]+[[:space:]]+[^[:space:]]+.*$") + fi + fi + cat <> "$PBUILDER_DEPS_HOOK" apt-get update -END_D05 +END_D05_03 chmod a+x "$PBUILDER_DEPS_HOOK" # Build eval pdebuild $OPT_INTERNAL_PBUILDER $OPT_SIGN_PKG_PBUILDER \ diff --git a/debian/_buildscripts/local/scripts/internals/distro_list.txt b/debian/_buildscripts/local/internals/distro_list.txt similarity index 100% rename from debian/_buildscripts/local/scripts/internals/distro_list.txt rename to debian/_buildscripts/local/internals/distro_list.txt diff --git a/debian/_buildscripts/local/internals/extra_deps.txt b/debian/_buildscripts/local/internals/extra_deps.txt new file mode 100644 index 000000000..12cd3b395 --- /dev/null +++ b/debian/_buildscripts/local/internals/extra_deps.txt @@ -0,0 +1,7 @@ +#!/bin/bash + +# 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 +" diff --git a/debian/_buildscripts/local/scripts/00_extradeps.sh b/debian/_buildscripts/local/scripts/00_extradeps.sh deleted file mode 100755 index 4764dbc4c..000000000 --- a/debian/_buildscripts/local/scripts/00_extradeps.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -. ./internals/_build_set_common.sh - -#---------------------------- -set_log_start - -build_module "dependencies/libr" -build_module "edeps/gettext-kde" -build_module "dependencies/akode" -build_module "edeps/fireflies" -build_module "edeps/imlib" -build_module "edeps/opensync" -build_module "edeps/libbeagle" -build_module "edeps/pcsc-lite-nodbus" -build_module "edeps/lcms" -build_module "edeps/wv2" -build_module "edeps/jasper" -build_module "edeps/openslp-dfsg" - -set_log_end diff --git a/debian/_buildscripts/local/scripts/10_others_02.sh b/debian/_buildscripts/local/scripts/10_others_02.sh deleted file mode 100755 index aa21f8dd1..000000000 --- a/debian/_buildscripts/local/scripts/10_others_02.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -. ./internals/_build_set_common.sh - -#---------------------------- -set_log_start - -build_module "tde-i18n" -build_module "edeps/compiz-trinity" -build_module "edeps/libcompizconfig-trinity" -build_module "edeps/compiz-fusion-bcop-trinity" -build_module "edeps/compiz-fusion-plugins-main-trinity" -build_module "edeps/compiz-fusion-plugins-extra-trinity" -build_module "edeps/compizconfig-python-trinity" -build_module "applications/compizconfig-backend-tdeconfig" - -set_log_end diff --git a/debian/_buildscripts/local/scripts/91_build_base.sh b/debian/_buildscripts/local/scripts/91_build_base.sh deleted file mode 100755 index a631a814f..000000000 --- a/debian/_buildscripts/local/scripts/91_build_base.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -./00_extradeps.sh -./01_base_01.sh -./02_base_02.sh -./03_base_03.sh diff --git a/debian/_buildscripts/local/scripts/93_build_others.sh b/debian/_buildscripts/local/scripts/93_build_others.sh deleted file mode 100755 index c1222f8b0..000000000 --- a/debian/_buildscripts/local/scripts/93_build_others.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -./09_others_01.sh -./10_others_02.sh \ No newline at end of file diff --git a/debian/_buildscripts/local/scripts/99_build_TDE.sh b/debian/_buildscripts/local/scripts/99_build_TDE.sh deleted file mode 100755 index 32d4e4375..000000000 --- a/debian/_buildscripts/local/scripts/99_build_TDE.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash - -# Load common code and initialization -. ./internals/_build_common.sh -init_common - -_BUILDALL_TIMER=2 -_BUILDALL_TIME="--/--:--:--:---" - -parm_SKIP_FETCH="n" # if "y" skips N packages from the list -parm_SKIP_N=0 # this argument represents the number of packages to skip -SKIP_cnt=0 - - -#---------------------------- -# do_exit for set building -function do_exit() -{ - cd "$SCRIPT_DIR" - if [ $1 -eq 0 ]; then - echo -e "${CGray}#### Building process for TDE completed ####${CNone}" - else - echo -e "${CGray}#### Building process for TDE interrupted ($1) ####${CNone}" - fi - exit $1 -} - - -#---------------------------- -function set_log_start() -{ - echo -e "${CGray}#### Starting building process for TDE ####${CNone}" - echo - echo "********** TDE **********" >>"$LOG_RESULT_FILENAME" - exec_time_start $_BUILDALL_TIMER -} - - -#---------------------------- -function set_log_end() -{ - exec_time_stop $_BUILDALL_TIMER "_BUILDALL_TIME" - echo " [$_BUILDALL_TIME] All TDE " >>"$LOG_RESULT_FILENAME" - echo >>"$LOG_RESULT_FILENAME" - do_exit 0 -} - - -#---------------------------- -function build_set() -{ - if [ $parm_SKIP_N -gt 0 -a $SKIP_cnt -lt $parm_SKIP_N ]; then - SKIP_cnt=$((SKIP_cnt+1)) - else - ./build_module.sh -g -lr "$@" - echo - fi -} - - -#---------------------------- -# Check command line arguments -#---------------------------- -for arg in $@; do - if [ "$parm_SKIP_FETCH" = "y" ]; then - parm_SKIP_N=$arg - parm_SKIP_FETCH="n" - elif [ "$arg" = "-s" ]; then # skip first N packages - parm_SKIP_FETCH="y" - fi -done -if [ "$parm_SKIP_FETCH" = "y" ]; then - echo "Invalid command line arguments ($@)" - do_exit 3 -fi - - -#---------------------------- -# Build TDE -#---------------------------- -set_log_start -for setname in `find . -maxdepth 1 -type f -iname '[01]*' | sort`; do - if [ $parm_SKIP_N -gt 0 -a $SKIP_cnt -lt $parm_SKIP_N ]; then - SKIP_cnt=$((SKIP_cnt+1)) - else - $setname - fi -done -set_log_end diff --git a/debian/_buildscripts/local/scripts/internals/_build_common.sh b/debian/_buildscripts/local/scripts/internals/_build_common.sh deleted file mode 100755 index c692ac26c..000000000 --- a/debian/_buildscripts/local/scripts/internals/_build_common.sh +++ /dev/null @@ -1,162 +0,0 @@ -#!/bin/bash - - -#---------------------------- -#---------------------------- -# Color table -# Black 0;30 Dark Gray 1;30 -# Blue 0;34 Light Blue 1;34 -# Green 0;32 Light Green 1;32 -# Cyan 0;36 Light Cyan 1;36 -# Red 0;31 Light Red 1;31 -# Purple 0;35 Light Purple 1;35 -# Brown 0;33 Yellow 1;33 -# Light Gray 0;37 White 1;37 -# No Color 0 -set -a -CBlack='\e[0;30m' -CDarkGray='\e[1;30m' -CBlue='\e[0;34m' -CLightBlue='\e[1;34m' -CGreen='\e[0;32m' -CLightGreen='\e[1;32m' -CCyan='\e[0;36m' -CLightCyan='\e[1;36m' -CRed='\e[0;31m' -CLightRed='\e[1;31m' -CPurple='\e[0;35m' -CLightPurple='\e[1;35m' -CBrown='\e[0;33m' -CYellow='\e[1;33m' -CGray='\e[0;37m' -CWhite='\e[1;37m' -CNone='\e[0m' -set +a - -#---------------------------- -function init_common() -{ - # Check script folder - export SCRIPT_DIR=$(dirname $(readlink -f "$0")) - - # Prevent the script to be run from TDE packaging repo - REPO_URL=$(git config --get remote.origin.url 2>/dev/null) - if [ ! -z "$REPO_URL" ] && [ -z "${REPO_URL##*tde-packaging}" ]; then - echo -e "${CYellow} --- ERROR ---${CNone}" - echo "This script cannot be run from the TDE packaging repository." - echo "Please follow the instructions provided, then rerun this script." - exit 1 - fi - - # Read config settings - CFG_FILE=$SCRIPT_DIR/_config.sh - if [ -f "$CFG_FILE" ]; then - . "$CFG_FILE" - else - echo -e "${CYellow} --- NOTE ---${CNone}" - echo "Creating TDE build configuration file from template as $CFG_FILE." - echo "Please check and modify as required, then rerun this script." - cp "$SCRIPT_DIR/internals/_config_template.sh" "$CFG_FILE" - exit 2 - fi - - # TDE root folder must exist - if [ ! -d "$TDE_DIR" ]; then - echo -e "${CYellow} --- ERROR ---${CNone}" - echo "A valid TDE root folder could not be located. Something is wrong with your configuration" - echo "in the config file $CFG_FILE" - echo "Please check and modify the TDE_DIR variable as required, then rerun this script." - exit 3 - fi - - # Search for main TDE repo - cd "$TDE_DIR/$CFG_GIT_TDE_MAIN" &>/dev/null - CURR_DIR=$(git rev-parse --show-toplevel 2>/dev/null) - if [ -z "$CURR_DIR" ]; then - echo -e "${CYellow} --- ERROR ---${CNone}" - echo "Main TDE repo could not be located. Something is wrong with your configuration" - echo "in the config file $CFG_FILE" - echo "Please check and modify the TDE_DIR variable as required, then rerun this script." - exit 4 - fi - - # Search for TDE packaging repo - cd "$TDE_DIR/$CFG_GIT_TDE_PACKAGING" &>/dev/null - CURR_DIR=$(git rev-parse --show-toplevel 2>/dev/null) - if [ -z "$CURR_DIR" ]; then - echo -e "${CYellow} --- ERROR ---${CNone}" - echo "TDE packaging repo could not be located. Something is wrong with your configuration" - echo "in the config file $CFG_FILE" - echo "Please check and modify the TDE_DIR variable as required, then rerun this script." - exit 5 - fi - - # Make sure we have selected a supported distribution - DISTS_FILE=$SCRIPT_DIR/internals/distro_list.txt - if [ ! -f "$DISTS_FILE" ]; then - echo -e "${CYellow} --- NOTE ---${CNone}" - echo "Could not find the list of supported distributions." - echo "Please check the file $DISTS_FILE exists, then rerun this script." - exit 6 - fi - export DISTRO_FOUND=${DISTRO_FOUND:-"n"} - if [ "$DISTRO_FOUND" != "y" ]; then - # 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. - while read l_distro l_version l_name l_rel_suffix; do - if [ "$l_distro" = "$DISTRO" -a "$l_name" = "$DISTRO_NAME" ]; then - export DISTRO_FOUND="y" - export DISTRO_VERSION="$l_version" - export REL_SUFFIX="$l_rel_suffix" - break - fi - done <<< $(cat $DISTS_FILE | grep -E "^(\s*[^#\s]+\s+[^\s]+.*)$") - fi - if [ "$DISTRO_FOUND" != "y" ]; then - echo -e "${CYellow} --- NOTE ---${CNone}" - echo "The specified distribution ($DISTRO $DISTRO_NAME) is not supported." - echo "Something is wrong with your configuration ($CFG_FILE)" - echo "or with the list of supported distributions ($DISTS_FILE)." - echo "Please check the DISTRO and DISTRO_NAME variables, then rerun this script." - exit 7 - fi - - export SCRIPT_LOG_DIR=$TDE_DIR/$CFG_SCRIPT_LOG_DIR - export LOG_RESULT_FILENAME="$SCRIPT_LOG_DIR/build_result.log" # Log result into the common build logfile - - cd "$SCRIPT_DIR" -} - - -#---------------------------- -# Save execution start time -# Parameters: -# $1 - timer number -function exec_time_start() -{ - _ET_start_var="_ET_start_$1" - eval "$_ET_start_var=`date +%s.%N`" -} - - -#---------------------------- -# Save execution stop time and set $2 to the execution time -# in the format: dd/hh:mm:ss.mmm -# Parameters: -# $1 - timer number -# $2 - result variable name -function exec_time_stop() -{ - _ET_start_var="_ET_start_$1" - _ET_stop_var="_ET_stop_$1" - eval "$_ET_stop_var=`date +%s.%N`" - _ET_diff=`echo "${!_ET_stop_var} - ${!_ET_start_var}" | bc` - _ET_days=`echo "$_ET_diff/86400" | bc` - _ET_diff_day=`echo "$_ET_diff-86400*$_ET_days" | bc` - _ET_hours=`echo "$_ET_diff_day/3600" | bc` - _ET_diff_hour=`echo "$_ET_diff_day-3600*$_ET_hours" | bc` - _ET_mins=`echo "$_ET_diff_hour/60" | bc` - _ET_secs=`echo "$_ET_diff_hour-60*$_ET_mins" | bc` - local _resultvar=$2 - eval "$_resultvar=`printf \"%02d/%02d:%02d:%06.3f\" $_ET_days $_ET_hours $_ET_mins $_ET_secs`" -} diff --git a/debian/_buildscripts/local/scripts/internals/_config_template.sh b/debian/_buildscripts/local/scripts/internals/_config_template.sh deleted file mode 100644 index ea8f438ba..000000000 --- a/debian/_buildscripts/local/scripts/internals/_config_template.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -set -a - -#---------------------------- -# Build information -#---------------------------- -TDE_RELEASE="14.1.0" # TDE release number -DISTRO="debian" # Distro family -DISTRO_NAME="buster" # Distro name of specific version -ARCHITECTURE="amd64" # Build for this architecture -USE_LOCAL_BUILD_NUMBER="n" # If == "y", use local build numbering for modules -BUILD_NUMBER="b001" # TDE build number -BUILD_DATE="" # Module build date (automatic if "" or fixed otherwise, ex 20171201) -BUILD_DEFAULT_OPTIONS="-g -lr" # Default building options (pbuilder) -GPG_SIGN_KEYID="" # Use this GPG key to sign packages. If null, packages will not be signed - -#---------------------------- -# Base directories -#---------------------------- -# TDE root folder -TDE_DIR="" -# Relative paths -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_HOOKS_DIR="hooks" # Relative to CFG_GIT_DIR folder -# Composite paths -CFG_GIT_TDE_MAIN="$CFG_GIT_DIR/tde/main" -CFG_GIT_TDE_PACKAGING="$CFG_GIT_DIR/tde-packaging/$DISTRO/$DISTRO_NAME" -CFG_GIT_EXTRA_DEPENDENCIES="$CFG_GIT_DIR/$CFG_EXTRA_DEPS_DIR" -CFG_HOOK_DIR="$CFG_GIT_DIR/$CFG_HOOKS_DIR" - -#---------------------------- -# Build output directories -#---------------------------- -CFG_TDE_BUILD_DIR="$CFG_BUILD_DIR/build" -CFG_TDE_DEBS_DIR="$CFG_BUILD_DIR/debs" - -#---------------------------- -set +a diff --git a/debian/_buildscripts/local/scripts/internals/_update_repositories.sh b/debian/_buildscripts/local/scripts/internals/_update_repositories.sh deleted file mode 100755 index fa5a1bd74..000000000 --- a/debian/_buildscripts/local/scripts/internals/_update_repositories.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -#---------------------------- -# Update TDE main repository -echo -e "\n---- Updating main TDE GIT repo ----\n" - -cd "$TDE_DIR/$CFG_GIT_DIR/tde" -if [[ ! -e .git ]] || [[ -z "`git rev-parse --git-dir 2>/dev/null`" ]]; then - echo "Current directory does not contain a .git folder. Exiting..." - cd $SCRIPT_DIR - exit 1 -fi - -branch=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"` -if [[ -z "$branch" ]] || [[ -z "`git rev-parse --symbolic-full-name --remotes=\"*/$branch\"`" ]]; then - echo "There is not active upstream branch. Exiting..." - cd $SCRIPT_DIR - exit 1 -fi - -touch /var/lock/update-tde-git-submodules - -PARENTDIR=$PWD -echo "---- Main repo ----" -git pull --rebase -if [[ ! -z "`git status --porcelain --ignore-submodules`" ]]; then - git reset --hard HEAD - git clean -dxff -fi - -exec 3< submodules -while read <&3 -do - cd $PARENTDIR - DIR2UPDATE=$REPLY - if [[ $DIR2UPDATE != "" ]]; then - echo -e "\n---- Submodule $DIR2UPDATE ----" - cd $PARENTDIR/$DIR2UPDATE/.. - cd `git rev-parse --show-toplevel` - if [[ -z "`grep \"^Updated: $PWD$\" /var/lock/update-tde-git-submodules`" ]]; then - echo "Updated: $PWD" >>/var/lock/update-tde-git-submodules - git submodule init - git submodule update - fi - cd $PARENTDIR/$DIR2UPDATE - if [[ ! -z "`git status --porcelain --ignore-submodules`" ]]; then - git reset --hard HEAD - git clean -dxff - fi - git checkout $branch - git pull --rebase - cd .. - cd `git rev-parse --show-toplevel` - fi -done -exec 3>&- - -rm /var/lock/update-tde-git-submodules - - -#------------------------------ -# Update TDE-packaging repository -echo -e "\n----------------------------------------" -echo -e "\n--- Updating TDE-packaging GIT repo ----\n" - -cd "$TDE_DIR/$CFG_GIT_DIR/tde-packaging" -git pull --rebase - - -#------------------------------ -# Done -cd $SCRIPT_DIR diff --git a/debian/_buildscripts/local/scripts/update_repositories.sh b/debian/_buildscripts/local/scripts/update_repositories.sh deleted file mode 100755 index efa739aa6..000000000 --- a/debian/_buildscripts/local/scripts/update_repositories.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# Load common code -. ./internals/_build_common.sh -init_common - -#---------------------------- -# Run real update script -if [ ! -d "$SCRIPT_LOG_DIR" ]; then - echo -e "\"$SCRIPT_LOG_DIR\" folder is missing. Check your config or create it." - exit 1 -fi -echo "Update in progress..." -. ./internals/_update_repositories.sh &>"$SCRIPT_LOG_DIR/update-repos.log" -echo "Update completed." - diff --git a/debian/_buildscripts/local/update_repositories.sh b/debian/_buildscripts/local/update_repositories.sh new file mode 100755 index 000000000..a9d2fef12 --- /dev/null +++ b/debian/_buildscripts/local/update_repositories.sh @@ -0,0 +1,188 @@ +#!/bin/bash + +# Load common code +. ./internals/_build_common.sh +init_common + +UPDATE_LOCK_FILENAME="/var/lock/TDE_update_repo_lock" # Lock file for incremental update + +#---------------------------- +# Update a given module from the upstream repo +# Parameters: +# $1 - module folder +# $2 - operation type +# $3 - branch to update +function _do_update() +{ + local MOD_PATH=$1 + local OP_TYPE=$2 + local BRANCH=$3 + local RESULT="" + + case "$OP_TYPE" in + "update") + if [[ -z `grep "^$BRANCH - $MOD_PATH$" "$UPDATE_LOCK_FILENAME"` ]]; then + 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 and is a tracking branch + 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 + 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 + fi + # Update + eval git reset --hard HEAD $OPT_VERBOSE_LOG + eval git clean -dxff $OPT_VERBOSE_LOG + eval git fetch $OPT_VERBOSE_LOG + if [[ $(git rev-parse HEAD) != $(git rev-parse "origin/$BRANCH") ]]; then + eval git pull --rebase $GIT_NO_RECURSE_SUBMODULES $OPT_VERBOSE_LOG + if [[ `git rev-parse HEAD` == `git rev-parse "origin/$BRANCH"` ]]; then + RESULT="${CLightGreen}[ UPDATE ]" + else + RESULT="${CLightRed}[ FAIL ]" + fi + else + RESULT="[ OK ]" + fi + else + RESULT="${CLightRed}[ FAIL ]" + fi + echo "$BRANCH - $MOD_PATH" >> "$UPDATE_LOCK_FILENAME" + else + RESULT="${CBrown}[ SKIP ]" + fi + ;; + + "switch-to") + cd "$MOD_PATH" &>/dev/null + eval git checkout \"$BRANCH\" $OPT_VERBOSE_LOG + if [[ ! -z `git branch -v | grep -E "^\*\s+$BRANCH"` ]]; then + RESULT="[ OK ]" + else + RESULT="${CLightRed}[ FAIL ]" + fi + ;; + + *) + RESULT="[ INV-OP ]" + ;; + esac + + echo_and_tee "$RESULT $MOD_PATH${CNone}" "$LOG_UPDATE_REPO_FILENAME" +} + +#---------------------------- +# Update a given module and all submodules from the upstream repo +# Parameters: +# $1 - module folder +# $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 "$@" + # 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 +} + +#---------------------------- +# 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 + [ -f "$UPDATE_LOCK_FILENAME" ] && rm "$UPDATE_LOCK_FILENAME" +fi + +OPT_VERBOSE_LOG="&>/dev/null" +if [[ "$bool_VERBOSE_LOG" = "y" ]]; then + OPT_VERBOSE_LOG=" |& tee -a \"$LOG_UPDATE_REPO_FILENAME\"" +fi + +#---------------------------- +# Check git abilities +GIT_IGNORE_SUBMODULES="" +if [[ -n "`git status --help 2>/dev/null|grep -- '--ignore-submodules'`" ]]; then + GIT_IGNORE_SUBMODULES="--ignore-submodules" +fi +GIT_NO_RECURSE_SUBMODULES="" +if [[ -n "`git pull --help |grep -- '--\[no-\]recurse-submodules'`" ]]; then + GIT_NO_RECURSE_SUBMODULES="--no-recurse-submodules" +fi + +# Start update +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" + + # 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" + + echo_and_tee "" "$LOG_UPDATE_REPO_FILENAME" +done + +# Switch to specified branch if necessary +if [[ "$DEFAULT_REPO_BRANCH" != "$_LAST_BRANCH" ]]; then + echo_and_tee "${CLightCyan}---------------------------------------${CNone}" "$LOG_UPDATE_REPO_FILENAME" "y" + 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" + + # Switch TDE packaging repository + _update_module "$TDE_DIR/$CFG_GIT_DIR/tde-packaging" "switch-to" "$DEFAULT_REPO_BRANCH" + + echo_and_tee "" "$LOG_UPDATE_REPO_FILENAME" +fi + +# Update completed +[ -f "$UPDATE_LOCK_FILENAME" ] && rm "$UPDATE_LOCK_FILENAME" +cd $SCRIPT_DIR