summaryrefslogtreecommitdiffstats
path: root/debian/_buildscripts/local/scripts/internals/_update_repositories.sh
blob: fa5a1bd74b528473717563ff08a107a20859eb79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/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