-
Notifications
You must be signed in to change notification settings - Fork 1
/
auto-update
executable file
·600 lines (583 loc) · 20.3 KB
/
auto-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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
#!/bin/sh
# Expand $2 to $1 digits
# Example: digits 3 4
# Result: 004
digits() {
local i
echo -n $(
( for i in $(seq 1 $1); do
echo -n 0;
done ; echo -n $2 ) | rev | cut -b1-$1 | rev)
}
debug() {
[ -n "$DEBUG" ] && echo "$@" >&2
}
json() {
python -c "
import json,sys
try:
print(json.load(sys.stdin)$@)
except IndexError:
pass
"
}
keepsudoalive() {
# Keep sudo timestamp alive so we don't get timeouts
# just because someone doesn't want to sit through a
# package build that takes > $SUDO_TIMESTAMP_TIMEOUT
(sudo -v; sleep 4m; keepsudoalive) &>/dev/null &
}
# Determine the latest of a list of versions
# Current assumptions for simplicity that might cause problems
# in the future: Version numbers are fully numeric (no 1.2.3a),
# and consist of at most 4 components of at most 3 digits each.
#
# Example: latest 1.2.3 1.2.3.1 1.1.4.99 0.99 1
# Result: 1.2.3.1
latest() {
(for i in "$@"; do
echo $i
done) |sort -V |tail -n1
}
specname() {
case $1 in
NetworkManager|ModemManager)
echo -n $(echo $1 |tr A-Z a-z)
;;
imagemagick6)
echo -n ImageMagick6
;;
*)
echo -n $1
;;
esac
}
ourVersion() {
local VERSION
case $1 in
*)
# default: Assume Version: is set to a real number and not some
# macro magic in the spec file...
VERSION=$(curl -s -L https://github.com/OpenMandrivaAssociation/$1/raw/master/$(specname $1).spec |grep -iE '^Version[[:space:]]*:' |head -n1 |cut -d: -f2- |xargs echo -n)
if [ -z "$VERSION" ] || echo $VERSION |grep -q '%'; then
# If there's some macro mess, let's check the file name...
local i
for i in main unsupported restricted non-free; do
VERSION="$(curl -s -L http://abf-downloads.openmandriva.org/cooker/repository/SRPMS/$i/release |grep -E ">$1-[0-9]" |sed -e 's,[^/]*>,,;s,<.*,,' |rev |cut -d- -f2 |rev |sort -V |head -n1)"
if [ -n "$VERSION" ]; then
echo -n "$VERSION"
return 0
fi
done
echo -n ERROR
else
echo -n $VERSION
fi
;;
esac
}
upstreamVersion() {
local SOURCE
local PKGNAME
local NAME
local EXCLUDE
local VERSIONS
local IGNOREODD
local SFPROJECT=""
local EXPR=""
local EXTRA=""
rm -f check-update.sh
curl --fail -o check-update.sh -s -L https://github.com/OpenMandrivaAssociation/$1/raw/master/check-update.sh &>/dev/null
[ -e check-update.sh ] || curl --fail -o check-update.sh -s -L https://github.com/OpenMandrivaAssociation/$1/raw/master/check_update.sh &>/dev/null
if [ -e check-update.sh ]; then
chmod +x check-update.sh
./check-update.sh
rm -f check-update.sh
return 0
fi
case $1 in
chromium-browser-*)
local CHANNEL=$(echo $1 |cut -d- -f3)
VERSIONS=$(curl -s -L "https://omahaproxy.appspot.com/all?os=linux&channel=$CHANNEL" |tail -n1 |cut -d, -f3)
echo -n $VERSIONS
;;
python-*)
local pypiName="$(echo $1 |cut -d- -f2-)"
curl --fail -o /tmp/$pypiName.$$ https://pypi.org/pypi/$pypiName/json &>/dev/null
# e.g. python-curl -> pycurl
[ -e /tmp/$pypiName.$$ ] || curl --fail -o /tmp/$pypiName.$$ https://pypi.org/pypi/py$pypiName/json &>/dev/null
# e.g. python-twisted -> Twisted
[ -e /tmp/$pypiName.$$ ] || curl --fail -o /tmp/$pypiName.$$ https://pypi.org/pypi/$(echo $pypiName |cut -b1 |tr a-z A-Z)$(echo $pypiName |cut -b2-)/json &>/dev/null
if [ -e /tmp/$pypiName.$$ ]; then
cat /tmp/$pypiName.$$ |json "['info']['version']"
rm -f /tmp/$pypiName.$$
return 0
fi
;;
perl-*)
local cpanName="$(echo $1 |cut -d- -f2- |sed -e 's,-,::,g')"
V="$(curl --fail -L https://metacpan.org/pod/$cpanName 2>/dev/null |grep "Module version" |cut -d: -f2 |xargs echo)"
if [ -n "$V" ]; then
echo -n $V
return 0
fi
;;
texlive-*)
local tlName="$(echo $1 |cut -d- -f2-)"
curl -L http://mirrors.ctan.org/systems/texlive/tlnet/archive/ 2>/dev/null |grep -E "\"${tlName}.r[0-9]*\.tar" |sed -e "s,.*${tlName}\.r,,;s,\.tar.*,," |sort -V |tail -n1
;;
octave-*)
local octName="$(echo $1 |cut -d- -f2-)"
V=$(curl --fail -s -L https://raw.githubusercontent.com/gnu-octave/packages/main/packages/$octName.yaml |grep -A 100 'versions:' |grep -m1 "id:" |sed -ne 's|.*\"\(.*\)\"|\1|p')
if [ -n "$V" ]; then
echo -n $V
return 0
fi
;;
*)
# default: Assume Source0: or Source: points at a file in a
# listable directory containing all available versions
# Unless it's sourceforge, in which case we have to look for
# the download link while faking a desktop browser
# (sourceforge sends links to Windows files unless it
# sees a Linux desktop browser)
EXCLUDE=nothing
case $1 in
abuse_sdl)
PKGNAME=abuse
;;
atk1.0|glibmm|gtkmm3.0|glib2.0|libcroco0.6)
PKGNAME=$(echo $1 |sed -e 's,[0-9].*,,')
IGNOREODD=true
;;
atkmm|at-spi2-*|dconf|gedit|librsvg|NetworkManager|ModemManager|gjs|gvfs|gtksourceview|libpeas|yelp|pangomm|evolution-data-server)
IGNOREODD=true
;;
bmake)
# Their script must have gone wrong -- one zero too
# much in the 2009/10/07 snapshot, causes version
# comparison to mess up
EXCLUDE=200910007
;;
imagemagick|imagemagick6)
PKGNAME=ImageMagick
EXTRA='s,([0-9]+)-([0-9]+),\1.\2,'
[ "$1" = "imagemagick6" ] && EXCLUDE='^[7-9].*'
;;
joe)
SFPROJECT=joe-editor
;;
ladspa)
PKGNAME=ladspa_sdk
EXPR=${PKGNAME}_
;;
libsigc-2.0)
PKGNAME=libsigc\\+\\+
IGNOREODD=true
;;
libtiff)
PKGNAME=tiff
;;
nano)
SOURCE=https://nano-editor.org/download.php
;;
suitesparse)
PKGNAME=SuiteSparse
;;
x11-driver-*)
PKGNAME=xf86-$(echo $1 |cut -d- -f3-)
;;
x11-data-bitmaps)
PKGNAME=xbitmaps
;;
libfs|libice|libsm)
PKGNAME=lib$(echo $1 |cut -b4- |tr 'a-z' 'A-Z')
;;
libxvmc)
PKGNAME=libXvMC
;;
libxtrap)
PKGNAME=libXTrap
;;
libxscrnsaver)
PKGNAME=libXScrnSaver
;;
libxkb*|libxcb*|libxshmfence)
# just make sure it doesn't get into the libx* transformations
;;
libx*)
PKGNAME=libX$(echo $1 |cut -b5-)
;;
live)
EXPR="$1\."
;;
x11-util-macros)
PKGNAME=util-macros
;;
x11-xtrans-devel)
PKGNAME=xtrans
;;
x11-util-cf-files)
PKGNAME=xorg-cf-files
;;
x11-server)
PKGNAME=xorg-server
;;
esac
[ -z "$SPECNAME" ] && SPECNAME=$1
[ -z "$SOURCE" ] && SOURCE=$(curl -s -L https://github.com/OpenMandrivaAssociation/$1/raw/master/$(specname $1).spec |grep -iE '^Source0?:' |grep :// |head -n1 |cut -d: -f2- |rev |cut -d/ -f2- |rev |sed -e "s,%{name},$1,g;s,%name,$1,g")/
[ -z "$PKGNAME" ] && PKGNAME=$1
[ -z "$EXPR" ] && EXPR="$PKGNAME-"
if [ -z "$SOURCE" ]; then
echo -n ERROR
return
fi
debug "Versions of $PKGNAME at $SOURCE"
if echo "$SOURCE" |grep -qE '(videolan\.org/pub|openttd|nasm\.us)'; then
# May also be useful for other projects: Versions live in a
# subdirectory named after the version...
SOURCE="$(echo $SOURCE |rev |cut -d/ -f3- |rev)/"
debug "Checking latest versions at $SOURCE"
latest $(curl -s -L $SOURCE |sed -e 's,</a>,</a>\n,g;s,<a ,\n<a ,g' |grep "href=" |cut -d'"' -f2 |grep -v '//' |grep -v '\.\.' |grep -vE '^[a-zA-Z]' |grep -vE "(sha256|sha512|win32|\.asc|\.sign)" |sed -E 's,/(index.html)?$,,' |grep -v '[a-zA-Z]')
return
elif echo $SOURCE |grep -q '^ftp:'; then
VERSIONS=$(curl -s -L $SOURCE | \
awk '{ print $9; }' | \
grep -vE "(md5|sha256|sha512|win32|\.asc|\.sign)" | \
sed -E "$EXTRA" | \
grep -E "^${EXPR}.*\.(tar|tgz|tbz2|txz|zip)" | \
sed -e "s,^${EXPR},," | \
sed -E 's,\.(tar|tgz|tbz2|txz|zip).*,,' | \
grep -E '^[0-9.]+$' |
grep -v "$EXCLUDE")
elif [ "$PKGNAME" = "firefox" ]; then
# Need to strip off %{version}/source/
SOURCE="$(echo $SOURCE |rev |cut -d/ -f4- |rev)/"
EXPR=""
latest $(curl -s -L $SOURCE |sed -e 's,</a>,</a>\n,g' |grep "href=" |cut -d'"' -f2 |cut -d/ -f5 |grep -v '//' |grep -v '\.\.' |grep -vE '[^0-9.]')
return
elif echo $SOURCE |grep -qE '(gnome|gtk|gimp|twistedmatrix|acc\.umu)\.(com|org|se)'; then
# Gjunk tends to follow a directory structure of
# major_version/file-minor_version.tar.*
# Also major_version sometimes, but not always, is
# unstable if it's odd-numbered...
SOURCE="$(echo $SOURCE |rev |cut -d/ -f3- |rev)/"
local NOODD="grep -v nothing"
if [ -n "$IGNOREODD" ]; then
NOODD="grep -v [13579]$"
fi
local MAJOR_VERSIONS=$(curl -s -L $SOURCE | \
grep -o -E "href=[\"'](.*)[\"']" | \
sed -e "s,^href=.,,;s,[\"'].*,," | \
grep -v "^?" | \
grep -E "^[0-9].*/$" |
sed -e 's,/$,,' |
$NOODD)
# ") <--- Just a workaround for a bug in the vim syntax highlighter
debug "Major versions available for $PKGNAME at $SOURCE: $MAJOR_VERSIONS"
local MAJOR=$(latest $MAJOR_VERSIONS)
debug "Latest major version: $MAJOR"
SOURCE="$SOURCE$MAJOR/"
elif echo $SOURCE |grep -qE '(sourceforge|sf)\.net'; then
[ -z "$SFPROJECT" ] && SFPROJECT=$1
VERSIONS=$(echo -n $(curl -s -L -A 'Mozilla/5.0 (X11; Linux x86_64)' https://sourceforge.net/projects/$SFPROJECT/files/ |grep -b1 'Download Latest Version' |tail -n1 |sed -e "s,.*>$PKGNAME-,,;s,\.tar.*,,"))
elif echo $SOURCE |grep -qE 'pythonhosted\.org'; then
NAME="`echo $SOURCE |cut -d/ -f7`"
if [ -z "$NAME" ] || (echo $NAME |grep -q %); then
NAME=`echo $PKGNAME |sed -e 's,^python-,,'`
fi
curl https://pypi.org/pypi/$NAME/json >/tmp/$NAME.$$
if [ -e /tmp/$NAME.$$ ]; then
VERSIONS=`cat /tmp/$NAME.$$ |json "['info']['version']"`
rm -f /tmp/$NAME.$$
fi
elif echo $SOURCE |grep -qE 'git'; then
if echo "$SOURCE" |grep -q '/-/'; then
# This is an URL in the form of e.g.
# https://gitlab.linphone.org/BC/public/liblinphone/-/archive/%{version}/lib%{name}-%{version}.tar.bz2
# So it's clear how many levels of subdirectories we have to strip...
VERSIONS=$(git ls-remote --tags $(echo $SOURCE |sed -e 's,/-/.*,,') 2>/dev/null|awk '{ print $2; }' |sed -e "s,refs/tags/,,;s,_,.,g;s,-,.,g;s,^v\.,,;s,^v,,;s,^$PKGNAME\.,," |grep -E '^[0-9.]+$')
else
# No clear indicator of repository nesting, so let's assume it's
# organization/repository like for most gitlab.com/github.com projects
VERSIONS=$(git ls-remote --tags $(echo $SOURCE |cut -d/ -f1-5) 2>/dev/null|awk '{ print $2; }' |sed -e "s,refs/tags/,,;s,_,.,g;s,-,.,g;s,^v\.,,;s,^v,,;s,^$PKGNAME\.,," |grep -E '^[0-9.]+$')
fi
fi
if [ -z "$VERSIONS" ]; then
# This is intentionally a separate if instead of another
# elif: Some special cases above, e.g. gnome.org, manipulate
# $SOURCE and then use the "default" way of determining the
# latest version.
debug looking for latest $PKGNAME in $SOURCE
[ -n "$DEBUG" ] && set -x
if echo $SOURCE |grep -qE '/(%{)?version(})?/$'; then
SOURCE="`echo $SOURCE |rev |cut -d/ -f3- |rev`"
VERSIONS=$(curl -s -L $SOURCE | \
grep -oE 'href="(.*")' | \
sed -E "s,^href=[\"']?,,;s,[\"'>].*,," | \
sed -E "s,/$,," | \
sed -E "$EXTRA" | \
grep -v "^?" | \
grep -vE "(md5|sha256|sha512|win32|\.asc|\.sign)" | \
grep -E '^[0-9.]+$' |
grep -v "$EXCLUDE")
else
VERSIONS=$(curl -s -L $SOURCE | \
grep -oE "href=(.*)" | \
sed -E "s,^href=[\"']?,,;s,[\"'>].*,," | \
sed -E "$EXTRA" | \
grep -v "^?" | \
grep -vE "(md5|sha256|sha512|win32|\.asc|\.sign)" | \
grep -E "^${EXPR}[0-9].*\.(tar|tgz|tbz2|txz|zip)" | \
sed -E "s,^${EXPR},," | \
sed -E 's,\.(tar|tgz|tbz2|txz|zip).*,,' | \
grep -E '^[0-9.]+$' |
grep -v "$EXCLUDE")
fi
[ -n "$DEBUG" ] && set +x
fi
if [ -z "$VERSIONS" ]; then
# As a last resort, see if repology knows something we don't...
VERSIONS="$(curl -s -A 'OpenMandriva auto-update https://github.com/OpenMandrivaSoftware/packaging-tools/issues/new' "https://repology.org/api/v1/project/$PKGNAME" |sed -e 's|{|\n|g' |grep newest |head -n1 |sed -e 's,.*"version":",,;s,".*,,')"
fi
debug "$VERSIONS"
if [ -z "$VERSIONS" ]; then
echo -n ERROR
return
fi
latest $VERSIONS
;;
esac
}
update() {
local D=$(mktemp -d /tmp/autoupdate-$1.XXXXXX)
if [ -z "$D" ]; then
echo "$1: Error creating temporary directory"
return 1
fi
pushd "$D"
git clone [email protected]:OpenMandrivaAssociation/$1.git
cd $1
if grep -qiE '^version[[:space:]]*:.*%' *.spec; then
echo "$1: Version contains macro"
return 1
fi
local ORIGFILES="`cat .abf.yml |grep '^[[:space:]]' |cut -d: -f1 |xargs echo`"
sed -i -E "/$(echo $2 |sed -e 's,\.,\\.,g')\.(tar|tgz|tbz2|txz|zip)/d" .abf.yml
sed -i -E "/$(echo $2 |sed -e 's,\.,\\.,g')\.source\.(tar|tgz|tbz2|txz|zip)/d" .abf.yml
# gitlab.com-ism -- Downloads from git tags are always called archive.tar.{gz,bz2}
sed -i -E "/archive.tar.(gz|bz2)/d" .abf.yml
local REMAININGFILES="`cat .abf.yml |grep '^[[:space:]]' |cut -d: -f1 |xargs echo`"
local REMOVEDFILES="`echo $ORIGFILES $REMAININGFILES |sed -e 's, ,\n,g' |sort |uniq -u`"
if echo $REMOVEDFILES |grep -q /; then
echo "WARNING: INVALID .abf.yml THAT MAY BE DESIGNED TO DO DAMAGE!"
return 1
fi
if echo $REMOVEDFILES |grep -q -- ';'; then
echo "WARNING: INVALID .abf.yml THAT MAY BE DESIGNED TO DO DAMAGE!"
return 1
fi
[ -n "$REMOVEDFILES" ] && rm -f $REMOVEDFILES
case "$1" in
microcode-intel)
# Special fun because they change URLs with every new download...
# Also got to find the new downloadcenter ID...
local URL=$(curl -s -L https://github.com/OpenMandrivaAssociation/microcode-intel/raw/master/microcode-intel.spec |grep -iE '^Url[[:space:]]*:' |head -n1 |cut -d: -f2- |xargs echo -n)
local ORIGURL="$URL"
while curl -s -L "$URL" |grep -q alert-link; do
URL=https://downloadcenter.intel.com$(curl -s -L "$URL" |grep alert-link |sed -e 's,.*href=\",,;s,".*,,')
done
if [ "$URL" != "$ORIGURL" ]; then
sed -i -e "s,^\(URL.*:\s*\)[0-9]*,\1$URL," *.spec
fi
;;
firefox)
# Get rid of translation files for older versions...
sed -i -e "/.*\.xpi/d" .abf.yml
;;
virtualbox)
# Make sure we update the user manual as well...
# (Name is unversioned, but content changes...)
sed -i -e "/UserManual\.pdf/d" .abf.yml
;;
esac
# Output redirected to /dev/null so we don't get an obscure Python error
# if .abf.yml doesn't actually list any files anymore after removing
# obsolete ones
abf fetch &>/dev/null
sed -i -e "s,^\(Version\s*:.*\)$2,\1$3," *.spec
sed -i -e "s,^\(Release.*:\s*\)[0-9]*$,\11," *.spec
sed -i -E 's,^(Release.*:\s.*}).*,\11,' *.spec
sudo dnf --refresh builddep -y --nogpgcheck --best --allowerasing *.spec
# Make sure rpm can download the files we need
if [ "$(rpm --eval '%{_disable_source_fetch}')" != 0 ]; then
echo '%_disable_source_fetch 0' >>~/.rpmmacros
REMOVE_DISABLE_SOURCE_FETCH=1
fi
ls -AF |grep -vE '/$' >files-before-rpm
[ -e package-source.sh ] && sh package-source.sh
case "$1" in
wine)
# Remove winetricks and wisotool from the directory so rpm
# downloads the current version
rm -f winetricks wisotool
;;
esac
abb build 2>&1 |tee BUILD.LOG
ls -AF |grep -vE '(BUILD.LOG|files-after-rpm|\.buildlog|/)$' >files-after-rpm
if [ "$REMOVE_DISABLE_SOURCE_FETCH" = 1 ]; then
sed -i -e "/^%_disable_source_fetch 0$/d" ~/.rpmmacros
fi
if ls RPMS/*/*.rpm &>/dev/null; then
case "$1" in
wine)
# Restore permissions on updated winetricks and wisotool
chmod +x winetricks wisotool
;;
esac
abb store $(diff -c files-before-rpm files-after-rpm |grep -E '^\+' |cut -b3- |grep -vE 'files-(before|after)-rpm')
git commit -am "Update to $3"
git push origin master
echo "$1: successfully updated from $2 to $3"
if ! abf chain_build -b master --no-cached-chroot --auto-publish --update-type enhancement openmandriva/"$1"; then
echo "$1: succeeded locally but failed to build in abf"
else
echo "$1: OK"
fi
else
echo "$1: failed updating from $2 to $3"
mkdir -p ~/failed-builds
[ -d ~/failed-builds/"$1" ] || mv "$D"/"$1" ~/failed-builds/
fi
popd
rm -rf "$D"
}
keepsudoalive
if [ "$1" = "-a" -o "$1" = "--all" ]; then
# This is now the default behavior and the switch is
# deprecated. Ignore it for now.
shift
fi
DOWNGRADE=false
if [ "$1" = "-d" -o "$1" = "--downgrade" ]; then
# If upstream version < our package version, downgrade
# sometimes useful if a project switched versioning
# schemes, e.g. 2022.11.16 < 1.0
DOWNGRADE=true
shift
fi
if [ "$1" = "-D" -o "$1" = "--dry-run" ]; then
export DRYRUN=1
shift
fi
if [ -z "$PACKAGES" ]; then
if [ "$#" -gt 0 ]; then
PACKAGES="$@"
else
if [ -z "$OAUTH_TOKEN" ]; then
echo "For updating all packages to work,"
echo " export OAUTH_TOKEN=\"token\""
echo "where \"token\" is a github authentication token"
echo "generated at https://github.com/settings/token"
exit 1
fi
OURDIR="$(dirname $0)"
# Packages that have known breakages in the current version and need
# to be updated if and only if there's a newer release fixing the
# issue blocking the update
BLACKLIST="sqlite"
# Packages that are known to break when auto-updated
# (e.g. perl doesn't like having Release: reset)
BLACKLIST="$BLACKLIST perl"
# Repositories that are archived for historic reasons
# but don't contain anything expected to be buildable
# ever again
BLACKLIST="$BLACKLIST consonance wxPythonGTK python2.4 python2.4-ldap python2.4-yaml python2.4-mysql python2.4-openid python2.4-wicked python2.4-imaging python2.4-libxml2 python2.4-feedparser python2.4-setuptools python2.4-virtualenv python2.4-elementtree"
# Repositories that need to be maintained manually
BLACKLIST="$BLACKLIST distro-release lsb-release"
# Repositories containing abandoned projects that we still distribute
# because they may be useful to some, but that don't have a working
# upstream website or repository to check for updates
BLACKLIST="$BLACKLIST clamz libifp"
# Repositories that contain active projects that should be updated at
# some point, but only after sorting out dependencies (e.g. Java/mvn
# packaging)
BLACKLIST="$BLACKLIST zookeeper"
# Repositories that should not be updated individually, but as
# part of a larger package set at the same time (e.g. KDE)
for i in qt qt6 kf kf6 plasma6 pd kapps kapps6; do
for j in $(cat "$OURDIR/$i.buildlist"); do
BLACKLIST="$BLACKLIST $(echo $j |sed -e 's,openmandriva/,,g')"
done
done
PACKAGES=""
PERPAGE=100
COUNT=0
START=""
org=OpenMandrivaAssociation
echo -n "Getting list of packages "
while true; do
echo -n .
QUERY="{\"query\": \"query {organization(login:\\\"$org\\\") { id name repositories(first:$PERPAGE $START) { edges { node { id name } cursor } pageInfo { endCursor hasNextPage } } } }\""
REPOS="$(curl -H "Authorization: token $OAUTH_TOKEN" -X POST -d "$QUERY" https://api.github.com/graphql 2>/dev/null)"
if [ -z "$REPOS" ]; then
echo "$QUERY failed" >&2
break
fi
for i in $(seq 0 $((PERPAGE-1))); do
R="$(echo $REPOS |json "['data']['organization']['repositories']['edges'][$i]['node']['name']").git"
if [ "$R" = ".git" ]; then
echo "No more repositories at $QUERY $i" >&2
break
fi
if [ "$R" = "abf-yml.git" -o "$R" = "secret-keys.git" -o "$R" = "OpenMandrivaAssociation.github.io.git" ]; then
# These repositories contain passwords and aren't public
# Since we aren't authenticated, can't mirror them
continue
fi
COUNT=$((COUNT+1))
PKG="$(echo $R |sed -e 's,\.git$,,')"
if ! echo " $BLACKLIST " |grep -q " $PKG "; then
PACKAGES="$PACKAGES $PKG"
fi
done
[ "$(echo $REPOS |json "['data']['organization']['repositories']['pageInfo']['hasNextPage']")" != "True" ] && break
START="after:\\\"$(echo $REPOS |json "['data']['organization']['repositories']['pageInfo']['endCursor']")\\\""
done
echo
fi
fi
PKGS=0
UPDATED=0
for i in $PACKAGES; do
OURVERSION=$(ourVersion $i)
NEWVERSION=$(upstreamVersion $i)
echo $NEWVERSION |grep -q '[()<>%-]' && NEWVERSION=ERROR
if [ "$OURVERSION" = "ERROR" -o "$NEWVERSION" = "ERROR" ]; then
mkdir -p ~/failed-builds
echo $i >>~/failed-builds/version-determination.err
echo "$i: ERROR trying to determine version"
elif [ "$OURVERSION" != "$NEWVERSION" -a "$(latest $OURVERSION $NEWVERSION)" = "$NEWVERSION" ]; then
if [ "$DRYRUN" = "1" ]; then
echo "*** Would update $i from $OURVERSION to $NEWVERSION ***"
else
echo "$i: trying to update from $OURVERSION to $NEWVERSION"
update $i $OURVERSION $NEWVERSION
fi
UPDATED=$((UPDATED+1))
elif [ "$OURVERSION" = "$NEWVERSION" ]; then
echo "$i: $OURVERSION is up to date"
elif $DOWNGRADE; then
if [ "$DRYRUN" = "1" ]; then
echo "*** Would downgrade $i from $OURVERSION to $NEWVERSION ***"
else
echo "$i: trying to downgrade from $OURVERSION to $NEWVERSION"
update $i $OURVERSION $NEWVERSION
fi
UPDATED=$((UPDATED+1))
else
echo "$i: our version $OURVERSION outnumbers upstream $NEWVERSION"
fi
PKGS=$((PKGS+1))
done
echo "Updated $UPDATED out of $PKGS packages"