root / devtools / autopkg.sh @ 7260959d
History | View | Annotate | Download (2.6 kB)
1 |
#!/bin/bash |
---|---|
2 |
|
3 |
if [ $# -ne 3 ]; then |
4 |
echo "$0 localbranch remotedebian remoteupstream" |
5 |
exit 1 |
6 |
fi |
7 |
|
8 |
|
9 |
LOCALBRANCH=$1 |
10 |
REMOTEDEBIAN=$2 |
11 |
REMOTEUPSTREAM=$3 |
12 |
BUILDAREA=~/build-area |
13 |
PKGAREA=~/packages |
14 |
BACKUPAREA=~/backup |
15 |
|
16 |
PACKAGES=" |
17 |
snf-astakos-app |
18 |
snf-common |
19 |
snf-webproject |
20 |
snf-cyclades-app |
21 |
snf-cyclades-gtools |
22 |
snf-tools |
23 |
snf-pithos-app |
24 |
snf-pithos-backend |
25 |
snf-pithos-tools" |
26 |
|
27 |
|
28 |
set -e |
29 |
|
30 |
test -d $BUILDAREA |
31 |
test -d $PKGAREA |
32 |
test -d $BACKUPAREA |
33 |
|
34 |
|
35 |
|
36 |
#TODO: check for up-to-date branches |
37 |
git checkout $LOCALBRANCH |
38 |
git checkout $REMOTEUPSTREAM |
39 |
git checkout $REMOTEDEBIAN |
40 |
|
41 |
TMPDEBIAN=$(mktemp -u debian.XXX) |
42 |
|
43 |
|
44 |
# create tmp debian branch to do everything |
45 |
git checkout --track $REMOTEDEBIAN -b $TMPDEBIAN |
46 |
|
47 |
mrgextra=-m |
48 |
mrgmsg="Merge branch '$REMOTEUPSTREAM' into $REMOTEDEBIAN" |
49 |
dchextra=-R |
50 |
|
51 |
# whether we are in snapshot or release mode |
52 |
snap=false |
53 |
|
54 |
tcdialog --defaultno --yesno "Create Snapshot?" 5 20 && snap=true && dchextra=-S && mrgextra= && mrgmsg= |
55 |
|
56 |
|
57 |
# merge local branch to tmp branch with correct msg so that it can be pushes as is to upstream debian |
58 |
git merge --no-edit $mrgextra ${mrgextra:+"$mrgmsg"} $LOCALBRANCH |
59 |
|
60 |
|
61 |
# auto edit changlog depending on Snapshot or Release mode |
62 |
export EDITOR=/usr/bin/vim |
63 |
git-dch --debian-branch=$TMPDEBIAN --git-author --ignore-regex=".*" --multimaint-merge --since=HEAD $dchextra |
64 |
git add debian/changelog |
65 |
|
66 |
|
67 |
# get version from the changelog |
68 |
# we tag here in order sdist to work as expexted. |
69 |
version=$(IFS="()" ; read x v x < debian/changelog ; echo $v) |
70 |
if ! $snap; then |
71 |
git commit -s -a -m "Bump new upstream version" |
72 |
TAGFILE=$(mktemp -t tag.XXX) |
73 |
tcdialog --inputbox "New Debian Tag: " 5 30 "debian/$version" 2>$TAGFILE |
74 |
git tag $(<$TAGFILE) |
75 |
fi |
76 |
|
77 |
rm -rf $BUILDAREA/* |
78 |
|
79 |
for p in $PACKAGES; do |
80 |
|
81 |
cd $p |
82 |
python setup.py sdist |
83 |
grep "__version_vcs" -r . -l -I | xargs git add -f |
84 |
cd - |
85 |
|
86 |
done |
87 |
|
88 |
|
89 |
git-buildpackage --git-export-dir=$BUILDAREA \ |
90 |
--git-upstream-branch=$REMOTEUPSTREAM \ |
91 |
--git-debian-branch=$TMPDEBIAN \ |
92 |
--git-export=INDEX \ |
93 |
--git-ignore-new -sa |
94 |
|
95 |
# do some dirty backup |
96 |
# pkgarea might be needed by auto-deploy tool |
97 |
rm -f $PKGAREA/* || true |
98 |
cp -v $BUILDAREA/*deb $PKGAREA/ || true |
99 |
|
100 |
cp -v $BUILDAREA/* $BACKUPAREA/ || true |
101 |
|
102 |
|
103 |
git reset --hard HEAD |
104 |
if $snap ; then |
105 |
git checkout $LOCALBRANCH |
106 |
git branch -D $TMPDEBIAN |
107 |
else |
108 |
# here we can push as is the commits in remote debian branch |
109 |
echo "########### All OK #####################" |
110 |
echo "git push origin $REMOTEDEBIAN" |
111 |
echo "git checkout $LOCALBRANCH" |
112 |
echo |
113 |
echo "############ Revert ######################" |
114 |
echo "git tag -d " $(<$TAGFILE) |
115 |
rm $TAGFILE |
116 |
fi |
117 |
|
118 |
|