-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitbp
executable file
·152 lines (124 loc) · 5.07 KB
/
gitbp
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
# resolve $0 in case it's a symlink, then grab directory.
REALDIR="$(dirname $(realpath $0))"
# if unset, assume pbuilder-hooks is in same directory as this script.
PBUILDERHOOKSDIR="${PBUILDERHOOKSDIR:-$REALDIR/pbuilder-hooks}"
PKG=$(dpkg-parsechangelog | grep ^Source: | cut -d' ' -f2)
VER=$(dpkg-parsechangelog | grep ^Version: | cut -d' ' -f2 | cut -d- -f1)
# assume branches are specified in debian/gbp.conf if it exists.
if [ ! -e debian/gbp.conf ]; then
DEBIANBRANCH="master"
UPSTREAMBRANCH="upstream"
CURRENTBRANCH=$(git rev-parse --abbrev-ref HEAD)
DISTRIBUTION=$(dpkg-parsechangelog -S Distribution )
PRISTINETAR=""
# allow symlinks to this script for convenience to set up environment
# variables for local archive and experimental archive access.
if [ "$(basename $0)" = "gitbpl" ]; then
export ENABLE_LOCAL="1"
elif [ "$(basename $0)" = "gitbpel" ]; then
export ENABLE_LOCAL="1"
export ENABLE_EXP="1"
elif [ "$(basename $0)" = "gitbpe" ]; then
export ENABLE_EXP="1"
fi
# if current branch contains "experimental", assume it's the debian
# branch and try to find an upstream branch with the same pattern,
# just replacing debian with upstream.
if [ "$CURRENTBRANCH" != "${CURRENTBRANCH/experimental/}" ]; then
DEBIANBRANCH=$CURRENTBRANCH
if [ "$DISTRIBUTION" = "UNRELEASED" ]; then
DISTRIBUTION="experimental"
fi
UPSTREAMBRANCH=${DEBIANBRANCH/debian/upstream}
if [ "$(git show-ref refs/heads/$UPSTREAMBRANCH)" = "" ]; then
echo "Error: upstream branch $UPSTREAMBRANCH matching current (Debian?) branch $DEBIANBRANCH could not be found." >&2
exit 1
fi
# .. next, if branch contains "debian-" (ie. debian-wheezy), try
# to find a matching upstream branch name.
elif [ "$CURRENTBRANCH" != "${CURRENTBRANCH/debian-/}" ]; then
DEBIANBRANCH=$CURRENTBRANCH
UPSTREAMBRANCH=${DEBIANBRANCH/debian/upstream}
if [ "$(git show-ref refs/heads/$UPSTREAMBRANCH)" = "" ]; then
echo "Error: upstream branch $UPSTREAMBRANCH matching current (Debian?) branch $DEBIANBRANCH could not be found." >&2
exit 1
fi
# .. next, if branch contains "master-" (ie. master-wheezy) assume
# it's the debian branch and try to find a matching upstream branch.
elif [ "$CURRENTBRANCH" != "${CURRENTBRANCH/master-/}" ]; then
DEBIANBRANCH=$CURRENTBRANCH
UPSTREAMBRANCH=${DEBIANBRANCH/master/upstream}
if [ "$(git show-ref refs/heads/$UPSTREAMBRANCH)" = "" ]; then
echo "Error: upstream branch $UPSTREAMBRANCH matching current (Debian?) branch $DEBIANBRANCH could not be found." >&2
exit 1
fi
fi
GITUPSTREAMBRANCH="--git-upstream-branch=$UPSTREAMBRANCH"
GITDEBIANBRANCH="--git-debian-branch=$DEBIANBRANCH"
else
GITUPSTREAMBRANCH=""
GITDEBIANBRANCH=""
fi # ! -e debian/gbp.conf
if [ "$DISABLE_PRISTINE_TAR" = "" ]; then
# if a pristine-tar branch exists, add git-buildpackage argument to use it.
# (precondition: only if pristine-tar is not explicitly configured in gbp.conf)
if [ ! -e debian/gbp.conf ] || ! grep -q pristine-tar debian/gbp.conf ; then
if [ "$(git show-ref refs/heads/pristine-tar)" != "" ]; then
PRISTINETAR="--git-pristine-tar"
# otherwise, check if origin has a pristine-tar branch and if we just
# forgot to create the local branch, create and use it.
elif [ "$(git show-ref origin/pristine-tar)" != "" ]; then
echo "INFO: Creating local pristine-tar tracking origin...."
git branch pristine-tar origin/pristine-tar
PRISTINETAR="--git-pristine-tar"
fi
fi
else
PRISTINETAR="--git-no-pristine-tar"
fi
# if upload is targeted at experimental, enable pbuilder to fetch
# build-dependencies from debian experimental.
if [ "$DISTRIBUTION" = "experimental" ] || [ "$ENABLE_EXP" != "" ]; then
echo "INFO: Enabling experimental repository access for pbuilder"
export ENABLE_EXP=1
fi
# if specified via environment that we should include local package archive
# (/var/cache/pbuilder/mirror, as specified in pbuilder hooks),
# print out the info message to make it more visible.....
if [ "$ENABLE_LOCAL" != "" ]; then
echo "INFO: Enabling local repository access for pbuilder"
export ENABLE_LOCAL=1
LOCALBIND="--bindmounts /var/cache/pbuilder/mirror"
fi
if [ -d "../build-logs" ]; then
LOGFILE="../build-logs/$PKG-$VER.log"
else
echo "INFO: ../build-logs doesn't exist, no logging to file."
LOGFILE=""
fi
# check if we need to give pbuilder network access
if [ -n "$ENABLE_LOCAL" ] || [ -n "$ENABLE_EXP" ] || \
[ -n "$ENABLE_UNSTABLE" ] || [ -n "$ENABLE_INCOMING" ] || \
[ -n "$ENABLE_TESTING" ] || \
[ -n "$ENABLE_NETWORK" ]
then
USENETWORK="--use-network yes"
else
USENETWORK=""
fi
# show command used triggering build
set -x
if [ "$LOGFILE" != "" ]; then
gbp buildpackage \
--git-no-create-orig \
$PRISTINETAR $GITUPSTREAMBRANCH $GITDEBIANBRANCH \
--git-builder="pdebuild --debbuildopts '-i -I -j5' --pbuilder pbuilder -- $PBUILDEROPTIONS $USENETWORK --source-only-changes --hookdir $PBUILDERHOOKSDIR $LOCALBIND" \
"$@" | tee $LOGFILE
else
gbp buildpackage \
--git-no-create-orig \
$PRISTINETAR $GITUPSTREAMBRANCH $GITDEBIANBRANCH \
--git-builder="pdebuild --debbuildopts '-i -I -j5' --pbuilder pbuilder -- $PBUILDEROPTIONS $USENETWORK --source-only-changes --hookdir $PBUILDERHOOKSDIR $LOCALBIND" \
"$@"
fi