-
Notifications
You must be signed in to change notification settings - Fork 5
/
bumppkg
executable file
·157 lines (127 loc) · 3.51 KB
/
bumppkg
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
153
154
155
156
157
#!/bin/bash
set -e
_repo=$1
case $_repo in
s)
_suffix=staging
shift
;;
t)
_suffix=testing
shift
;;
*)
# Stable
_suffix=
;;
esac
_pkgbase=$1
_pkgver=$2
_pkgrel=$3
_msg="$4"
_build=1
if [[ -z "$_pkgrel" ]]; then
_pkgrel=1
fi
if [[ "$_pkgrel" == "0" ]]; then
_build=0
fi
[[ -d "$_pkgbase" ]] || pkgctl repo clone "$_pkgbase"
pushd $_pkgbase/
git pull --ff-only || :
_pkgname=$(. PKGBUILD; echo $pkgname)
for _repo in core extra multilib; do
if pacman -Sql $_repo | grep "^$_pkgname$" >/dev/null; then
_target=$_repo
break
fi
done
if [[ -n "$_suffix" ]]; then
_target=$_target-$_suffix
_suffix=--$_suffix
fi
if [[ -z "$_target" ]]; then
echo "Cannot find package in x86 repo."
exit 1
fi
_oldpkgver=$(. PKGBUILD; echo $pkgver)
if [[ "$_pkgver" == "rebuild" ]]; then
_rebuild="--rebuild"
_msg="$3"
else
if [[ "$_pkgver" != "head" ]]; then
setconf PKGBUILD pkgver $_pkgver
fi
setconf PKGBUILD pkgrel $_pkgrel
if grep '^_commit=' PKGBUILD >/dev/null; then
if [[ -n "$COMMIT" ]]; then
setconf PKGBUILD _commit $COMMIT
else
# Attempt to update _commit
_oldcommit=$(. PKGBUILD; echo $_commit)
for _source in $(. PKGBUILD; echo ${source[@]}); do
if [[ $_source =~ git\+(https://.*)\#commit=$_oldcommit ]]; then
_gitrepo=${BASH_REMATCH[1]}
if [[ $_pkgver == "HEAD" ]]; then
_commit="$(git ls-remote $_gitrepo | grep HEAD | cut -f1)"
else
tags="$(git ls-remote --tags $_gitrepo)"
_guess_tag_prefix=$(echo "$tags" | grep ^$_oldcommit | sed "s|.*refs/tags/||;s|$_oldpkgver.*||" | head -n1)
if echo "$tags" | grep refs/tags/$_guess_tag_prefix$_pkgver$ >/dev/null; then
_newtag=$_guess_tag_prefix$_pkgver
elif echo "$tags" | grep refs/tags/$_pkgver$ >/dev/null; then
_newtag=$_pkgver
elif echo "$tags" | grep refs/tags/v$_pkgver$ >/dev/null; then
_newtag=v$_pkgver
elif echo "$tags" | grep refs/tags/V$_pkgver$ >/dev/null; then
_newtag=V$_pkgver
else
echo "Unable to find tag for $_pkgver"
exit 1
fi
if echo "$tags" | grep $_newtag^{}$ >/dev/null; then
_commit=$(echo "$tags" | grep refs/tags/$_newtag^{}$ | cut -f1)
else
_commit=$(echo "$tags" | grep refs/tags/$_newtag$ | cut -f1)
fi
fi
setconf PKGBUILD _commit $_commit
break
fi
done
fi
fi
fi
# Autofixes
grep -E "^sha256sums=|^sha512sums=|^b2sums=" PKGBUILD >/dev/null || \
sed -e 's|^sha1sums=|sha256sums=|' \
-e 's|^md5sums=|sha256sums=|' \
-i PKGBUILD
sed -e 's|http://github.com/|https://github.com/|' \
-e "s|arch=('i686' 'x86_64')|arch=('x86_64')|" \
-e "s|arch=(\"i686\" \"x86_64\")|arch=('x86_64')|" \
-i PKGBUILD
if [[ "$_pkgver" == "HEAD" ]]; then
if [[ "${EUID:-$(id -u)}" -eq 0 ]]; then
env EUID=1000 makepkg -o
else
makepkg -o
fi
fi
# root workaround
if [[ "${EUID:-$(id -u)}" -eq 0 ]]; then
env EUID=1000 updpkgsums
else
updpkgsums
fi
git --no-pager diff
if [[ "$_build" -eq 1 ]]; then
_buildserver=$(felixbuild-server-select)
SYNCBACKPKGBUILD=1 felixbuild $_buildserver pkgctl build $_suffix $_rebuild
BUILDHOST=$_buildserver PKGBASE=$_pkgbase felix-rsync-wrapper pkgctl release $_suffix -m "$_msg"
while ! db-update; do
echo "db-update failed, retrying after 5s..."
sleep 5
done
cleanpkg
fi