Compare commits

...

27 Commits

Author SHA1 Message Date
Slávek Banko 63362e5037
create_tarball: Fix excluded items processing.
The list of items to the tarball package is now passed as output from
find and therefore does not work using --exclude option for tar. Items
that is desirable to exclude are now removed from the list using grep.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit eecedb7d61)
4 years ago
Slávek Banko d45dd62365
create_all_tarballs: Listing individual common modules to be skipped
to not be omitted to create tarball for common cmake module.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit ee19be5f9e)
4 years ago
Slávek Banko 26adf9d607
Update switch_all_submodules_to_head_and_clean
+ Ensure checkout for new upstream branch in worktree mode of tree.
+ To test the availability of repository use curl if it is present.
+ Sign commits using GPG during rebase if the signing key is set.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 9545e31f18)
4 years ago
Slávek Banko 23145430b1
create_tarball: Force file permissions in the tarball.
It addresses independence from UMASK to ensure a reproducible build.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 807378eeb2)
5 years ago
Slávek Banko 3bff5cbf91
create_tarball: Convert to UTC the date of the last commit,
which is written to '.tdescminfo'.

Because formatting a date using 'git log' does not return results in UTC,
the unix timestamp is used for git log, and conversion to UTC is done
using 'date'.

It addresses time zone independence to ensure a reproducible build.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 517a783020)
5 years ago
Slávek Banko f2c0ac2aa5
create_tarball: Adapted to new 'core' folder for core modules.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 9db84075a0)
5 years ago
Slávek Banko f7a155f1a9
switch_all_submodules_to_head_and_clean: Clean up abandoned worktrees
before adding a new worktree.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 5b81e0aa93)
5 years ago
Michele Calgaro 9df5b598ec
Removed style scripts, they are still available on master branch.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
6 years ago
Slávek Banko 444f4bbf72
create_tarball: Modify the tarball creation so that it is reproducible.
Note: If gzip or pigz is used, it is necessary to use the "-n" option.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 428c2d88b4)
6 years ago
Slávek Banko 6d5bbbe14b
create_tarball: Create one .tdescminfo file containing all the data,
including the git repository date, instead of individual .tdescm* files.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 5c39eb0954)
6 years ago
Slávek Banko 9d96d333d3
Update switch_all_submodules_to_head_and_clean
+ better detection of whether a branch is remote tracked
+ instead of git pull --rebase is used git fetch and git rebase
+ added verification whether the remote server is available
+ do a git checkout only if the required branch is not active
+ added support for creating a 'tde' submodules tree using git worktree

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 065e9e0936)
7 years ago
Slávek Banko 3ee3a5a70b
Update switch_all_submodules_to_head_and_clean
+ cleaning of temporary branches combined into one operation along with pull
+ this prevents additional communication with the remote server
+ all remote servers will be fetched and also pruned

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 9bb83bf90c)
7 years ago
Slávek Banko 9be6e5e6f0 Update switch_all_submodules_to_head_and_clean:
+ add support for cloning repositories via ssh

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit f50efa7e80)
7 years ago
Slávek Banko c58fea6319 Update switch_all_submodules_to_head_and_clean
+ add cleaning of potential temporary branches from remote server

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit a04af55867)
7 years ago
Slávek Banko d356f38213 Revamp switch_all_submodules_to_head_and_clean
+ script revised according to update_all_submodules
+ files .gitmodules are processed instead of call git submodule foreach
+ modules are initialized during processing instead of at the beginning
+ initialize submodules only if they have not yet been initialized
+ use --no-recurse-submodules at git pull for better overview of the update progress

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 8fb500ce46)
7 years ago
Slávek Banko d46100143d Update update_all_submodules
+ create lock specific by branch
+ initialize submodules only if they have not yet been initialized
+ use --no-recurse-submodules at git pull for better overview of the update progress

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit b0d74087e5)
7 years ago
Slávek Banko c0339738cf Update create_tarball and create_all_tarballs
+ default TARGET is now detected from the TDE core header
+ added check if TARGET is valid for the branch

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit a4ee973238)
7 years ago
Slávek Banko 9982b4a55e Update version number for new target R14.0.5 9 years ago
Slávek Banko 558e70b263 Revamp update_all_submodules
+ submodules file is no longer needed
+ list of submodules is loaded from .gitmodules
+ order of the submodules is determined by .gitmodules
+ nested submodules are processed recursively by .gitmodules
+ all submodules, including nested, are updated in one cycle

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 9f54f58809)
10 years ago
Slávek Banko 0e9786f3a5 Allow to create tarballs on detached branch
For example, for a particular git tag

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 2c76932134)
10 years ago
Slávek Banko 2b30dcc138 Update version number for new target R14.0.4 10 years ago
Slávek Banko 8eb2ea0f54 switch_all_submodules_to_head_and_clean: Add support to clone from mirror
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 980d8ea3f8)
10 years ago
Slávek Banko 6d53459401 switch_all_submodules_to_head_and_clean: Use --rebase on git pull
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 916d3c9355)
10 years ago
Slávek Banko 5097cbe74c Update version number for new target R14.0.3 10 years ago
Slávek Banko 4b764e3a1f Update version number for new target R14.0.2 10 years ago
Slávek Banko 41bd09eab9 Update default target release to R14.0.1
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
11 years ago
Slávek Banko 580cb8e6f8 create_tarball: Split initial character in tag while sorting by version
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 0a16bdf260)
11 years ago

@ -1,29 +0,0 @@
#!/bin/bash
if [[ $1 == "" ]]; then
echo "Please specify the source directory to beautify"
exit 1
fi
ASTYLEARGS=$( cat <<EOF
--indent=tab \
--indent-classes \
--indent-switches \
--indent-cases \
--indent-namespaces \
--indent-labels \
--indent-col1-comments \
\
--unpad-paren \
\
--style=java \
--add-brackets \
--break-closing-brackets \
--keep-one-line-statements
EOF
)
astyle $ASTYLEARGS --recursive $1/*.c || true
astyle $ASTYLEARGS --recursive $1/*.cc || true
astyle $ASTYLEARGS --recursive $1/*.cpp || true
astyle $ASTYLEARGS --recursive $1/*.h || true

@ -1,14 +0,0 @@
--indent=tab
--indent-classes
--indent-switches
--indent-cases
--indent-namespaces
--indent-labels
--indent-col1-comments
--unpad-paren
--style=java
--add-brackets
--break-closing-brackets
--keep-one-line-statements

@ -1,7 +1,8 @@
#!/bin/bash
# Set the current target version
export TARGET=${TARGET:-"14.0.0"}
# The default is the version detected from TDE core header.
export TARGET=${TARGET:-}
# When $SUFFIX = true then the package tarball name will be $package-trinity.
# When $SUFFIX != true then the package tarball name will be trinity-$package.
@ -11,11 +12,14 @@ export SUFFIX=${SUFFIX:-"true"}
# Setting base path for tarballs. Tarballs for indivitual modules
# will be created into folders in same structure, as is in 'tde'.
# The default is 'tde-tarballs' in parent directory.
TARBALLS_BASE=${TARBALLS_BASE:-"$(dirname $PWD)/tde-tarballs/$TARGET"}
TARBALLS_BASE=${TARBALLS_BASE:-}
# List of modules to be omitted during creating tarballs.
SKIP_MODULES="
common
common/admin
common/libltdl
common/libtdevnc
common/other
defaultsettins
experimental
infrastructure
@ -31,27 +35,99 @@ skip_module() {
return 1
}
# Check git-dir
if [[ ! -e .git ]] ||
[[ -z "`git rev-parse --git-dir 2>/dev/null`" ]]; then
echo "This script can only be run from a top level git directory. Exiting..."
# echo in bold
echobd () {
if [ -p /dev/stdout ]; then
echo "$1"
else
echo -ne "\033[1m"
echo -n "$1"
echo -e "\033[0m"
fi
}
# Move to main tde folder
REMOTE_URL=$(git config --get remote.origin.url 2>/dev/null)
if [ "$REMOTE_URL" != "${REMOTE_URL%/tde-packaging}" ]; then
# Switch from tde-packaging into main tde folder
cd `git rev-parse --show-toplevel`
cd ../tde
REMOTE_URL=$(git config --get remote.origin.url 2>/dev/null)
fi
while [ -n "$REMOTE_URL" ] && [ "$REMOTE_URL" = "${REMOTE_URL%/tde}" ]; do
# Switch from submodule to parent
cd `git rev-parse --show-toplevel`
cd ..
REMOTE_URL=$(git config --get remote.origin.url 2>/dev/null)
done
if [ "$REMOTE_URL" = "${REMOTE_URL%/tde}" ]; then
# Main tde folder not found
echo "This script can only be run from TDE git directory. Exiting."
exit 1
fi
cd `git rev-parse --show-toplevel`
# Check remote branch
branch=`git branch --contains HEAD | grep -v "no branch" | head -n1 | cut -c 3-`
branch=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"`
if [[ -z "$branch" ]]; then
branch=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-`
fi
if [[ -z "$branch" ]] ||
[[ -z "`git rev-parse --symbolic-full-name --remotes=\"*/$branch\"`" ]]; then
echo "There is not active upstream branch. Exiting..."
exit 1
fi
# Set target version
if [ -z "$TARGET" ]; then
if [ -f main/core/tdelibs/tdecore/tdeversion.h ]; then
tdeversionHeader=main/core/tdelibs/tdecore/tdeversion.h
elif [ -f main/core/tdelibs/kdecore/kdeversion.h ]; then
tdeversionHeader=main/core/tdelibs/kdecore/kdeversion.h
elif [ -f main/tdelibs/tdecore/tdeversion.h ]; then
tdeversionHeader=main/tdelibs/tdecore/tdeversion.h
elif [ -f main/tdelibs/kdecore/kdeversion.h ]; then
tdeversionHeader=main/tdelibs/kdecore/kdeversion.h
fi
if [ -z "$tdeversionHeader" ]; then
echo "Cannot find TDE core headers. Exiting."
exit 1
fi
TARGET=`sed -n 's|#define [KT]DE_VERSION_STRING "[^0-9]\?\([^ "]*\).*|\1|p' $tdeversionHeader`
fi
export TARGET
# Check branch by target
if [ "$TARGET" != "${TARGET#3.5.}" ]; then
if [ "$TARGET" != "${TARGET#3.5.13.}" ]; then
targetBranch=v3.5.13-sru
else
targetBranch=master
fi
else
if [ "$TARGET" != "${TARGET%.0}" ]; then
targetBranch=master
else
targetBranch=r${TARGET%.*}.x
fi
fi
if [ "$branch" != "$targetBranch" ]; then
echo "Target $TARGET is not valid on $branch branch. Exiting."
exit 1
fi
# Setting base path for tarballs
TARBALLS_BASE=${TARBALLS_BASE:-"$(dirname $PWD)/tde-tarballs/$TARGET"}
# Create tarballs for submodules
echobd "Create tarballs for $(basename "$PWD") $branch branch"
echobd "Working in $PWD"
if [[ -e .gitmodules ]]; then
create_tarball=$(dirname $(readlink -f "$0"))/create_tarball
sed -n "s|^\[submodule \"\([^\"]*\)\"\]$|\1|p" <.gitmodules | \
while read submodule; do
skip_module "$submodule" && continue
echobd "Module ${submodule}"
if [[ ! -e "$submodule/.git" ]]; then
git submodule init -- "$submodule"
git submodule update -- "$submodule"
@ -63,3 +139,4 @@ if [[ -e .gitmodules ]]; then
(cd "$submodule" && "$create_tarball")
done
fi
echobd "Done in $PWD"

@ -1,7 +1,8 @@
#!/bin/bash
# Set the current target version
TARGET=${TARGET:-"14.0.0"}
# The default is the version detected from TDE core header.
TARGET=${TARGET:-}
# When $SUFFIX = true then the package tarball name will be $package-trinity.
# When $SUFFIX != true then the package tarball name will be trinity-$package.
@ -14,9 +15,9 @@ TARBALL_DIR=${TARBALL_DIR:-".."}
# Set compression method
case ${COMPRESS:="xz"} in
"gzip"|"pigz") TAR_SUFFIX="gz";;
"bzip2"|"pbzip2") TAR_SUFFIX="bz2";;
"xz"|"pxz") TAR_SUFFIX="xz";;
"gzip"*|"pigz"*) TAR_SUFFIX=".gz";;
"bzip2"|"pbzip2") TAR_SUFFIX=".bz2";;
"xz"|"pxz") TAR_SUFFIX=".xz";;
esac
# Check git-dir
@ -27,13 +28,70 @@ if [[ ! -e .git ]] ||
fi
# Check remote branch
branch=`git branch --contains HEAD | grep -v "no branch" | head -n1 | cut -c 3-`
branch=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"`
if [[ -z "$branch" ]]; then
branch=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-`
fi
if [[ -z "$branch" ]] ||
[[ -z "`git rev-parse --symbolic-full-name --remotes=\"*/$branch\"`" ]]; then
echo "There is not active upstream branch. Exiting..."
exit 1
fi
# Get submodule name
REMOTE_URL=$(git config --get remote.origin.url)
if [ "$REMOTE_URL" = "${REMOTE_URL%/tde}" ]; then
TDEROOT=$( cd `git rev-parse --show-toplevel` &&
cd .. &&
cd `git rev-parse --show-toplevel` &&
pwd )
SUBROOT=$( cd `git rev-parse --show-toplevel` &&
pwd )
elif [ -f .gitignore ]; then
TDEROOT=$( cd `git rev-parse --show-toplevel` &&
pwd )
SUBROOT=$PWD
METAPACKAGE=true
fi
MODULE=${SUBROOT#$TDEROOT/main/}
# Set target version
if [ -z "$TARGET" ]; then
if [ -f $TDEROOT/main/core/tdelibs/tdecore/tdeversion.h ]; then
tdeversionHeader=$TDEROOT/main/core/tdelibs/tdecore/tdeversion.h
elif [ -f $TDEROOT/main/core/tdelibs/kdecore/kdeversion.h ]; then
tdeversionHeader=$TDEROOT/main/core/tdelibs/kdecore/kdeversion.h
elif [ -f $TDEROOT/main/tdelibs/tdecore/tdeversion.h ]; then
tdeversionHeader=$TDEROOT/main/tdelibs/tdecore/tdeversion.h
elif [ -f $TDEROOT/main/tdelibs/kdecore/kdeversion.h ]; then
tdeversionHeader=$TDEROOT/main/tdelibs/kdecore/kdeversion.h
fi
if [ -z "$tdeversionHeader" ]; then
echo "Cannot find TDE core headers. Exiting."
exit 1
fi
TARGET=`sed -n 's|#define [KT]DE_VERSION_STRING "[^0-9]\?\([^ "]*\).*|\1|p' $tdeversionHeader`
fi
# Check branch by target
if [ "$TARGET" != "${TARGET#3.5.}" ]; then
if [ "$TARGET" != "${TARGET#3.5.13.}" ]; then
targetBranch=v3.5.13-sru
else
targetBranch=master
fi
else
if [ "$TARGET" != "${TARGET%.0}" ]; then
targetBranch=master
else
targetBranch=r${TARGET%.*}.x
fi
fi
if [ "$branch" != "$targetBranch" ]; then
echo "Target $TARGET is not valid on $branch branch. Exiting."
exit 1
fi
# Check submodules
if [[ -e .gitmodules ]]; then
sed -n "s|^\[submodule \"\([^\"]*\)\"\]$|\1|p" <.gitmodules | \
@ -67,25 +125,10 @@ if [[ -n "$target_tag" ]] && \
exit 1
fi
# Get submodule name
REMOTE_URL=$(git config --get remote.origin.url)
if [ "$REMOTE_URL" = "${REMOTE_URL%/tde}" ]; then
TDEROOT=$( cd `git rev-parse --show-toplevel` &&
cd .. &&
cd `git rev-parse --show-toplevel` &&
pwd )
SUBROOT=$( cd `git rev-parse --show-toplevel` &&
pwd )
elif [ -f .gitignore ]; then
TDEROOT=$( cd `git rev-parse --show-toplevel` &&
pwd )
SUBROOT=$PWD
METAPACKAGE=true
fi
MODULE=${SUBROOT#$TDEROOT/main/}
# Calculate version
tag=`git tag | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr | while read t; do \
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`
@ -102,16 +145,27 @@ fi
# Create tarball
echo "Package name: $package"
if [ ! -e $TARBALL_DIR/$package.tar.$TAR_SUFFIX ]; then
if [ ! -e $TARBALL_DIR/$package.tar$TAR_SUFFIX ]; then
echo "Creating tarball in $TARBALL_DIR."
echo $MODULE > .tdescmmodule
echo $branch-$(git rev-parse HEAD) > .tdescmrevision
trap "rm $TARBALL_DIR/tar-$$; rm .tdescmmodule .tdescmrevision; exit 1" INT
tar c --owner=root --group=users --exclude .git --exclude .gitmodules --transform "s|^\.\(/\|$\)|$package\1|" ./ | \
echo "# TDE SCM module information" > .tdescminfo
echo "Name: $MODULE" >> .tdescminfo
echo "Revision: $branch-$(git rev-parse HEAD)" >> .tdescminfo
date +"DateTime: %m/%d/%Y %H:%M" -u -d "@$(git log -1 --pretty=format:"%ct")" >> .tdescminfo
trap "rm $TARBALL_DIR/tar-$$; rm .tdescminfo; exit 1" INT
find ./ | LC_ALL=C sort | \
egrep -v '(^|/)(\.git|\.gitmodules)(/|$)' | tr "\n" "\0" | \
tar c --no-recursion --null -T - \
--mode=u+rw,go=rX,a-s \
--owner=root --group=users \
--mtime "@$(git log -1 --pretty=format:"%ct")" \
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
--transform "s|^\.\(/\|$\)|$package\1|" | \
$COMPRESS -9 >$TARBALL_DIR/tar-$$ && \
mv $TARBALL_DIR/tar-$$ $TARBALL_DIR/$package.tar.$TAR_SUFFIX || \
mv $TARBALL_DIR/tar-$$ $TARBALL_DIR/$package.tar$TAR_SUFFIX || \
rm $TARBALL_DIR/tar-$$
rm .tdescmmodule .tdescmrevision
rm .tdescminfo
[ -f $TARBALL_DIR/$package.tar$TAR_SUFFIX ] && \
touch -d "@$(git log -1 --pretty=format:"%ct")" $TARBALL_DIR/$package.tar$TAR_SUFFIX
else
echo "Unchanged tarball in $TARBALL_DIR."
exit 2

@ -1,26 +1,41 @@
#!/bin/bash
if [[ ! -e .git ]] ||
# echo in bold
echobd () {
if [ -p /dev/stdout ]; then
echo "$1"
else
echo -ne "\033[1m"
echo -n "$1"
echo -e "\033[0m"
fi
}
# verify git directory and branch
if [[ ! -e .git ]] &&
[[ -z "`git rev-parse --git-dir 2>/dev/null`" ]]; then
echo "This script can only be run from a top level git directory. Exiting..."
echo "Current directory does not contain a .git folder. Exiting..."
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..."
if [[ -z "$branch" ]]; then
branch=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-`
fi
if [[ -z "$branch" ]]; then
echo "There is not active branch. Exiting..."
exit 1
fi
# check git abilities
if [[ -n "`git status --help 2>/dev/null|grep -- '--ignore-submodules'`" ]]; then
GIT_IGNORE_SUBMODULES="--ignore-submodules"
remote=`git config branch."$branch".remote`
if [[ -z "$remote" ]]; then
echo "Active branch is not remote tracked. Exiting..."
exit 1
fi
echo "Preparing $PWD for development use"
# get git user
echobd "Preparing $(git rev-parse --show-toplevel | xargs -r basename) on $branch branch for development use"
if [[ $1 == "" ]]; then
gituser=`sed -n "/^\[remote \"origin\"\]/,/url/s/\turl = http:\/\/\([^@]*\)@.*/\1/p" <\`git rev-parse --git-dir\`/config | grep -v "\(anonymous\|system\)"`
gituser=`git config --local remote.$remote.url | sed -n "s|\(https\?://\)\?\([^@]*\)@.*|\2|p" | grep -v "\(anonymous\|system\)"`
else
gituser=$1
fi
@ -33,33 +48,123 @@ if [[ $gituser == "" ]]; then
gituser="anonymous"
fi
THISSCRIPT=$(readlink -f $0)
if [[ -n "$(git config --get user.signingkey)" ]]; then
GIT_SIGN="-S"
fi
if [[ ! -e "$THISSCRIPT" ]]; then
echo "Unable to find myself! Exiting..."
exit 1
# check git abilities
if [[ -n "`git status --help 2>/dev/null|grep -- '--ignore-submodules'`" ]]; then
GIT_IGNORE_SUBMODULES="--ignore-submodules"
fi
if [[ -n "`git pull --help |grep -- '--\[no-\]recurse-submodules'`" ]]; then
GIT_NO_RECURSE_SUBMODULES="--no-recurse-submodules"
fi
# update module and submodules
updateModule() {
local MODULE
local REPO_URL
local REPO_PROTO
local REPO_MODULE
local REPO_WORKTREE
if [[ "$1" != "" ]]; then
MODULE=$1/
else
MODULE=""
fi
cd $PARENTDIR/$MODULE
if [[ ! -z "`git status --porcelain $GIT_IGNORE_SUBMODULES`" ]]; then
git reset --hard HEAD
git clean -dxff
fi
git pull
git remote |
while read REMOTE; do
REPO_URL=$(git config remote."$REMOTE".url)
REPO_SERVER=$(echo "$REPO_URL" |
sed -n "s|^http[^/]*/*\([^@]*@\)\?\([^/]*\)/.*|\2|p")
if [ -x /usr/bin/curl ] && [ "${REPO_URL}" != "${REPO_URL#http}" ]; then
curl --silent --connect-timeout 10 --max-time 15 --location --netrc \
$REPO_URL/info/refs?service=git-upload-pack >/dev/null || continue
elif [ -x /usr/bin/fping ] && [ -n "$REPO_SERVER" ]; then
fping -q -r1 "$REPO_SERVER" || continue
fi
echo Fetching $REMOTE
git fetch $REMOTE --prune $GIT_NO_RECURSE_SUBMODULES
done
git branch | grep -x "* $branch" >/dev/null || \
git checkout $branch
remote=`git config branch."$branch".remote`
[[ -n "$remote" ]] || return
git rebase $GIT_SIGN $remote/$branch $branch
if [[ ! -z "`git status --porcelain $GIT_IGNORE_SUBMODULES`" ]]; then
git reset --hard HEAD
git clean -dxff
fi
if [[ -e .gitmodules ]]; then
if [[ -e $PARENTDIR/$MODULE.gitmodules ]]; then
if [[ $gituser == "anonymous" ]]; then
sed -i 's/system@//g' .gitmodules
sed -i 's/system@//g' $PARENTDIR/$MODULE.gitmodules
else
sed -i "s/system@/$gituser@/g" .gitmodules
sed -i "s/system@/$gituser@/g" $PARENTDIR/$MODULE.gitmodules
fi
git submodule init
git submodule update
git submodule foreach "git checkout $branch && $THISSCRIPT $gituser"
git checkout -- .gitmodules
REPO_URL=$(git config --get remote.$remote.url |\
sed "s|\(https\?://\)\?\([^@]*@\)\?\(.*\)/[^/]*$|\3|")
REPO_PROTO=$(git config --get remote.$remote.url |\
sed "s|\(https\?://\)\?\([^@]*@\)\?\(.*\)/[^/]*$|\1|")
REPO_MASTER=scm.trinitydesktop.org/scm/git
REPO_MODULE=$(git config --get remote.$remote.url |\
sed -e "s|\(https\?://\)\?\([^@]*@\)\?\(.*\)/\([^/]*\)$|\4|" -e "s|\.git$||")
REPO_GITDIR=$(git rev-parse --git-dir)
if [[ "${REPO_GITDIR/worktrees//}" != "$REPO_GITDIR" ]]; then
REPO_WORKTREE=${REPO_GITDIR%/[^/]*/worktrees/[^/]*}
fi
if [[ "$REPO_URL" != "$REPO_MASTER" ]]; then
sed -i "s#https\?://\([^@]*@\)\?$REPO_MASTER#$REPO_PROTO\1$REPO_URL#g" $PARENTDIR/$MODULE.gitmodules
fi
sed -n "s|^\[submodule \"\([^\"]*\)\"\]$|\1|p" <$PARENTDIR/$MODULE.gitmodules |\
while read submodule; do
echobd "Attempting to switch submodule ${MODULE}${submodule}"
cd $PARENTDIR/$MODULE
if [[ -n "$REPO_WORKTREE" ]] && [[ ! -e "$submodule/.git" ]]; then
REPO_LOCALTREE=$(git config --file .gitmodules --get submodule.$submodule.url | \
sed "s#^\(https\?://\)\?\([^@]*@\)\?$REPO_URL#$REPO_WORKTREE#g")
if [[ ! -d "$REPO_LOCALTREE" ]]; then
REPO_LOCALTREE=$REPO_LOCALTREE.git
fi
if [[ ! -d "$REPO_LOCALTREE" ]]; then
git clone --bare --config "remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*" \
"$(git config --file .gitmodules --get submodule.$submodule.url)" "$REPO_LOCALTREE"
fi
if [[ "$REPO_MODULE" != "tde" ]]; then
git config --file .gitmodules submodule.$submodule.url "$REPO_LOCALTREE"
else
(
cd $REPO_LOCALTREE &&
git fetch &&
git worktree prune &&
git worktree add $PARENTDIR/$MODULE$submodule origin/$branch &&
cd $PARENTDIR/$MODULE$submodule &&
git checkout $branch &&
git branch --set-upstream-to=origin/$branch
) || continue
fi
fi
if [[ -z "`git config --get submodule.$submodule.url`" ]]; then
git submodule init -- $submodule
fi
if [[ ! -e "$submodule/.git" ]]; then
git submodule update -- $submodule
fi
updateModule ${MODULE}${submodule}
done
git checkout -- $PARENTDIR/$MODULE.gitmodules
fi
}
# Update from top module
cd `git rev-parse --show-toplevel`
PARENTDIR=$PWD
echobd "Working in $PARENTDIR"
updateModule
echobd "Done in $PARENTDIR"

@ -1,75 +1,122 @@
#!/bin/bash
if [[ -e /var/lock/update-tde-git-submodules ]]; then
echo "TDE GIT submodules are currently being updated"
echo "If this is not the case, please remove the lockfile /var/lock/update-tde-git-submodules"
exit 0
# echo in bold
echobd () {
if [ -p /dev/stdout ]; then
echo "$1"
else
echo -ne "\033[1m"
echo -n "$1"
echo -e "\033[0m"
fi
}
if [[ ! -e .git ]] ||
# verify git directory and branch
if [[ ! -e .git ]] &&
[[ -z "`git rev-parse --git-dir 2>/dev/null`" ]]; then
echo "Current directory does not contain a .git folder. Exiting..."
exit 1
fi
branch=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"`
if [[ -z "$branch" ]]; then
branch=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-`
fi
if [[ -z "$branch" ]] ||
[[ -z "`git rev-parse --symbolic-full-name --remotes=\"*/$branch\"`" ]]; then
echo "There is not active upstream branch. Exiting..."
exit 1
fi
# get git user
GITUSER="Automated System <$(git config --get user.email)>"
# check git abilities
if [[ -n "`git status --help 2>/dev/null|grep -- '--ignore-submodules'`" ]]; then
GIT_IGNORE_SUBMODULES="--ignore-submodules"
fi
if [[ -n "`git pull --help |grep -- '--\[no-\]recurse-submodules'`" ]]; then
GIT_NO_RECURSE_SUBMODULES="--no-recurse-submodules"
fi
touch /var/lock/update-tde-git-submodules
PARENTDIR=$PWD
echo "Working in $PARENTDIR"
git pull
if [[ ! -z "`git status --porcelain $GIT_IGNORE_SUBMODULES`" ]]; then
git reset --hard HEAD
git clean -dxff
# commmit changed module
commitModule() {
if [[ "$1" == "" ]]; then
return
fi
local MODULE=$1
exec 3< submodules
while read <&3
do
cd $PARENTDIR
DIR2UPDATE=$REPLY
if [[ $DIR2UPDATE != "" ]]; then
echo "Attempting to reset submodule $DIR2UPDATE"
cd $PARENTDIR/$DIR2UPDATE/..
cd $PARENTDIR/$MODULE/..
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
if [[ ! -z "`git status --porcelain $PARENTDIR/$MODULE`" ]]; then
echo "Committing changes to $PWD"
git add $PARENTDIR/$MODULE
git commit $PARENTDIR/$MODULE --author "$GITUSER" -m "Reset submodule $MODULE to latest HEAD"
fi
if [[ "`git rev-parse HEAD`" != "`git rev-parse origin/$branch`" ]]; then
echo "Push changes for $PWD"
git pull --rebase $GIT_NO_RECURSE_SUBMODULES
git push origin HEAD
fi
}
# update module and submodules
updateModule() {
local MODULE
if [[ "$1" != "" ]]; then
MODULE=$1/
else
MODULE=""
fi
cd $PARENTDIR/$DIR2UPDATE
cd $PARENTDIR/$MODULE
if [[ ! -z "`git status --porcelain $GIT_IGNORE_SUBMODULES`" ]]; then
git reset --hard HEAD
git clean -dxff
fi
if [[ "$1" != "" ]]; then
git checkout $branch
git pull
cd ..
cd `git rev-parse --show-toplevel`
echo "Committing changes to $PWD"
if [[ ! -z "`git status --porcelain $PARENTDIR/$DIR2UPDATE`" ]]; then
git add $PARENTDIR/$DIR2UPDATE
git commit $PARENTDIR/$DIR2UPDATE -m "Reset submodule $DIR2UPDATE to latest HEAD"
fi
git pull --rebase $GIT_NO_RECURSE_SUBMODULES
if [[ "`git rev-parse HEAD`" != "`git rev-parse origin/$branch`" ]]; then
echo "Push changes for $PWD"
git push origin HEAD
fi
if [[ "$1" != "" ]]; then
commitModule $1
fi
done
exec 3>&-
# Let the disk subsystem recover
sleep 60
if [[ -e $PARENTDIR/$MODULE.gitmodules ]]; then
sed -n "s|^\[submodule \"\([^\"]*\)\"\]$|\1|p" <$PARENTDIR/$MODULE.gitmodules |\
while read submodule; do
echobd "Attempting to reset submodule ${MODULE}${submodule}"
cd $PARENTDIR/$MODULE
if [[ -z "`git config --get submodule.$submodule.url`" ]]; then
git submodule init -- $submodule
fi
if [[ ! -e "$submodule/.git" ]]; then
git submodule update -- $submodule
fi
updateModule ${MODULE}${submodule}
done
if [[ "$1" != "" ]]; then
commitModule $1
fi
fi
}
rm /var/lock/update-tde-git-submodules
# Update from top module
if [[ -e /var/lock/update-tde-git-submodules-$branch ]]; then
echo "TDE GIT submodules are currently being updated"
echo "If this is not the case, please remove the lockfile"
echo "/var/lock/update-tde-git-submodules-$branch"
exit 0
fi
touch /var/lock/update-tde-git-submodules-$branch
echobd "Updating submodules in $(git rev-parse --show-toplevel | xargs -r basename) $branch branch"
cd `git rev-parse --show-toplevel`
PARENTDIR=$PWD
echobd "Working in $PARENTDIR"
updateModule
echobd "Done in $PARENTDIR"
rm /var/lock/update-tde-git-submodules-$branch

Loading…
Cancel
Save