-
Notifications
You must be signed in to change notification settings - Fork 1
/
update
executable file
·224 lines (212 loc) · 6.58 KB
/
update
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/bin/sh
# Usage: update project version [startfrom]
# project: Project to build (ls *.buildlist for available projects)
# version: Version to update to
# startfrom: Package to start from (e.g. to continue where
# a previous build left off because of a patch rebase
# or file list issue)
#
# (C) 2015 Bernhard Rosenkränzer <[email protected]>
# Released under the terms of the GPLv3
error() {
echo "$1 failed to build -- please see above and fix."
exit 1
}
keepsudoauthcache() {
sudo -v
(sleep 4m ; keepsudoauthcache) &
}
if [ "$#" -lt 1 ]; then
echo "Specify the version to update to"
exit 1
fi
AFTER=false
PRERELEASE=false
BETA=""
while [ "$(echo $1 |cut -b1)" = "-" ]; do
case $1 in
-a|--after)
AFTER=true
;;
-b|--beta)
shift
BETA="$1"
;;
-p|--prerelease)
PRERELEASE=true
;;
*)
echo "WARNING: Unknown option $1"
;;
esac
shift
done
PROJECT="$1"
VERSION="$2"
PACKAGES="$(cat $(dirname $0)/$PROJECT.buildlist |grep -vE '^#' |sed -e 's,openmandriva/,,g')"
REALVERSION="${VERSION}"
if [ "$#" -ge 3 ]; then
P=""
RELEVANT=0
for i in $PACKAGES; do
if [ "$i" = "$3" ]; then
RELEVANT=1
if $AFTER; then
continue
fi
fi
[ "$RELEVANT" = "1" ] && P="$P $i"
done
PACKAGES="$P"
fi
echo "Sudo privileges required for 'dnf builddep'"
keepsudoauthcache
for i in $PACKAGES; do
rm -rf ${i}
RETRIES=0
while ! git clone [email protected]:OpenMandrivaAssociation/${i}.git; do
sleep 5s
RETRIES=$((RETRIES+1))
if [ "$RETRIES" -gt 10 ]; then
error $i
fi
done
cd ${i}
if grep -q '^%define git ' *.spec; then
WAS_GIT=true
else
WAS_GIT=false
fi
if [ "${VERSION:0:3}" = "git" ]; then
DATE="$(date +%Y%m%d)"
OLDDATE="$(grep -i '^%define[[:space:]]*git[[:space:]]*' *.spec |head -n1 |awk '{ print $3; }')"
OLDEXP=${OLDDATE}
fi
if [ "${VERSION}" != "git" ]; then
OLDVERSION="$(grep -i '^Version[[:space:]]*:' *.spec |head -n1 |cut -d: -f2 |xargs echo)"
OLDEXP="$(echo ${OLDVERSION} |sed -e 's,\.,\\.,g')"
if grep -q "^%define beta " *.spec; then
OLDBETA="$(cat *.spec |grep "^%define beta " |sed -e 's,^%define beta ,,')"
if [ "${OLDBETA}" != "%{nil}" ]; then
OLDEXP="${OLDEXP}-${OLDBETA}"
fi
else
OLDBETA=""
fi
fi
sed -i -e "/${OLDEXP}\.tar/d" .abf.yml
if [ "$PROJECT" = "qt" ]; then
# Qt often can't decide if it's "beta" or "beta1", and "rc" or "rc1"...
# Let's adjust the specs accordingly...
#sed -i -e 's#/%{version}-%{beta}/#/%{version}-%(echo %{beta} |sed -e "s,1$,,")/#' *.spec
sed -i -e 's#%{version}-%(echo %{beta} |sed -e "s,1$,,")/#%{version}-%{beta}/#' *.spec
fi
# Ideally PKGVERSION would always be the same as VERSION, but in the real
# world, some packages don't follow the same versioning scheme - e.g. in
# LXQt, libsysstat is 1 major version behind the rest etc.
if [ "$i" = "libsysstat" -o "$i" = "lxqt-archiver" ]; then
PKGVERSION="$(($(echo ${VERSION}|cut -d. -f1)-1)).$(echo ${VERSION}|cut -d. -f2-)"; echo $PKGVERSION
elif [ "$i" = "lxqt-wayland-session" ]; then
PKGVERSION="$(($(echo ${VERSION}|cut -d. -f1)-2)).$(echo ${VERSION}|cut -d. -f2-)"; echo $PKGVERSION
elif [ "$i" = "libqtxdg" -o "$i" = "qtxdg-tools" ]; then
PKGVERSION="$(($(echo ${VERSION}|cut -d. -f1)+2)).$(echo ${VERSION}|cut -d. -f2-)"; echo $PKGVERSION
elif [ "$i" = "libdbusmenu-lxqt" ]; then
# libdbusmenu-lxqt is released with lxqt, but its versioning scheme is
# very much unpredictable
PKGVERSION="$(git ls-remote https://github.com/lxqt/libdbusmenu-lxqt |awk '{print $2}' |grep 'refs/tags/' |sed -e 's,.*refs/tags/,,;s,\^{},,' |sort -V |tail -n1)"
else
PKGVERSION=${VERSION}
fi
if [ "${VERSION:0:3}" = "git" ]; then
if $WAS_GIT; then
if [ "${OLDDATE}" = "${DATE}" ]; then
echo "$i seems to be up to date already, skipping"
cd ..
continue
fi
else
sed -i -e 's,#define git ,%define git ,' *.spec
fi
if [ "${VERSION}" != "git" ]; then
PKGVERSION="${VERSION:4}"
fi
fi
if [ "${VERSION}" != "git" ]; then
if $WAS_GIT && [ "${VERSION:0:3}" != "git" ]; then
sed -i -e 's,^%define git ,#define git ,' *.spec
elif grep -q '^%define beta' *.spec; then
if [ -n "$BETA" ] && grep -q "^%define beta $BETA\$" *.spec; then
echo "$i seems to be up to date already, skipping"
cd ..
continue
elif grep -q '^%define beta %{nil}' *.spec; then
echo "$i seems to be up to date already, skipping"
cd ..
continue
fi
elif [ "${OLDVERSION}" = "${PKGVERSION}" ]; then
echo "$i seems to be up to date already, skipping"
cd ..
continue
fi
fi
if [ "${VERSION:0:3}" = "git" ]; then
sed -i -e "s,^%define git .*,%define git ${DATE}," *.spec
fi
if [ "${VERSION}" != "git" ]; then
sed -i -e "s,^\(Version.*:.*\)${OLDEXP},\1${PKGVERSION}," *.spec
fi
sed -i -e "s,^\(Release.*:\s*\)[0-9]*$,\11," *.spec
sed -i -E 's,^(Release.*:\s.*}).*,\11,' *.spec
if [ -n "$BETA" ]; then
sed -i -e "s,^#define beta .*,%define beta $BETA," -e "s,^%define beta .*,%define beta $BETA," *.spec
else
sed -i -e "s,^%define beta ,#define beta ," *.spec
fi
sudo dnf builddep -y --nogpgcheck *.spec
if ${PRERELEASE} && [ "${VERSION}" != "git" ]; then
STABLE=stable
[ $(echo $VERSION |cut -d. -f3) -ge 70 ] && STABLE=unstable
[email protected]:/srv/archives/ftp/${STABLE}
if [ "$(echo $i |cut -b1-4)" = "kf6-" ]; then
TARNAME="$(echo $i |cut -b5-)"
elif [ "$(echo $i |cut -b1-8)" = "plasma6-" ]; then
TARNAME="$(echo $i |cut -b9-)"
elif [ "${i}" = "oxygen-icons" ]; then
TARNAME=${i}5
elif [ "${i}" = "kgamma5" ]; then
TARNAME=${i}
elif [ "${i}" = "kirigami" ]; then
TARNAME=${i}2
elif [ "${i}" = "kdeconnect" ]; then
TARNAME="kdeconnect-kde"
else
TARNAME=$(echo ${i} |sed -e 's,5$,,')
fi
if [ "${PROJECT}" = "kf" -o "${PROJECT}" = "kf6" ]; then
SCPDIR=$SCPDIR/frameworks/$(echo ${VERSION} |sed -e 's,\.0$,,')
grep -q portingAids *.spec && SCPDIR="${SCPDIR}/portingAids"
elif [ "${PROJECT}" = "pd" -o "${PROJECT}" = "plasma6" ]; then
SCPDIR=$SCPDIR/plasma/${VERSION}
elif [ "${PROJECT}" = "kapps" -o "${PROJECT}" = "kapps6" ]; then
SCPDIR=$SCPDIR/release-service/${VERSION}/src
fi
scp ${SCPDIR}/${TARNAME}-${PKGVERSION}.tar.xz . || :
fi
abb build || error $i
ls RPMS/*/* &>/dev/null || error $i
if [ -n "$BETA" ]; then
PKGVERSION="${PKGVERSION}-${BETA}"
fi
if [ "${VERSION:0:3}" = "git" ]; then
abb store *${DATE}.tar* || error $i
else
abb store *${PKGVERSION}.tar* || error $i
fi
git commit -am "Update to ${PKGVERSION}" || error $i
git push origin master
sudo dnf install -y --nogpgcheck RPMS/*/*.rpm
cd ..
VERSION="${REALVERSION}"
done
abf chain_build -a znver1 -a aarch64 -a x86_64 -b master --no-extra-tests --update-type enhancement -i $PROJECT.buildlist