autodist-upstream-updates: add support to fetch updates from repology API (repology.org)

This commit is contained in:
Silvan Calarco 2021-03-14 11:55:11 +01:00
parent 9d003905df
commit b6d3b83d1e
3 changed files with 49 additions and 8 deletions

View File

@ -84,6 +84,7 @@ install-programs:
@$(INSTALL_SCRIPT) webbuild/webbuild-functions $(DESTDIR)$(pck_datadir)/webbuild-functions @$(INSTALL_SCRIPT) webbuild/webbuild-functions $(DESTDIR)$(pck_datadir)/webbuild-functions
@$(INSTALL_SCRIPT) webbuild/webbuild-functions-private $(DESTDIR)$(pck_datadir)/webbuild-functions-private @$(INSTALL_SCRIPT) webbuild/webbuild-functions-private $(DESTDIR)$(pck_datadir)/webbuild-functions-private
@$(INSTALL_SCRIPT) telegram/openmamba_bot.py $(DESTDIR)$(pck_datadir)/openmamba_bot.py @$(INSTALL_SCRIPT) telegram/openmamba_bot.py $(DESTDIR)$(pck_datadir)/openmamba_bot.py
@$(INSTALL_SCRIPT) repology-openmamba.py $(DESTDIR)$(pck_datadir)/repology-openmamba.py
@cp -a webbuild/html/* $(DESTDIR)$(htmldir) @cp -a webbuild/html/* $(DESTDIR)$(htmldir)
install-data: install-data:

View File

@ -76,7 +76,7 @@ function version_compare()
return 2 return 2
fi fi
else else
if [[ "$A" > "$B" ]]; then if [[ ${1} =~ ^[0-9]+$ || "$A" > "$B" ]]; then
return 1 return 1
elif [[ "$A" < "$B" ]]; then elif [[ "$A" < "$B" ]]; then
return 2 return 2
@ -276,17 +276,18 @@ parse_distromatic() {
} }
if [ ! "$skip_parsing" ]; then if [ ! "$skip_parsing" ]; then
tmpfile=`mktemp -q -t autodist-upstream-updates.XXXXXXXX` #tmpfile=`mktemp -q -t autodist-upstream-updates.XXXXXXXX`
buildstmp=`mktemp -q -t autodist-upstream-updates.XXXXXXXX` buildstmp=`mktemp -q -t autodist-upstream-updates.XXXXXXXX`
tail -n+2 $BUILDS_FILE > $buildstmp tail -n+2 $BUILDS_FILE > $buildstmp
parse_arch_linux #parse_arch_linux
parse_xorg #parse_xorg
parse_gnome #parse_gnome
parse_distromatic #parse_distromatic
/usr/share/autodist/repology-openmamba.py > $UPDATES_DB.tmp
cat $tmpfile | sort -uf > $UPDATES_DB.tmp #cat $tmpfile | sort -uf > $UPDATES_DB.tmp
rm -f $tmpfile #rm -f $tmpfile
> $UPDATES_DB > $UPDATES_DB
unset lastpkg unset lastpkg

39
repology-openmamba.py Executable file
View File

@ -0,0 +1,39 @@
#!/usr/bin/python3
import json, urllib.request, time
with open("/var/ftp/pub/openmamba/devel/legacy") as f:
legacy_packages = f.read().splitlines()
from_package = ""
while True:
#print("fetching https://repology.org/api/v1/projects/" + from_package + "?inrepo=openmamba&outdated=1")
url = urllib.request.urlopen("https://repology.org/api/v1/projects/" + from_package + "?inrepo=openmamba&outdated=1")
data = json.loads(url.read().decode())
if from_package != "" and len(data.keys()) <= 1:
break
for k in data.keys():
package = k
if package == from_package:
continue
openmamba_srcname = None
openmamba_version = None
newest_version = None
newest_repos = []
for p in data[k]:
if p["repo"] == "openmamba" and openmamba_srcname is None:
if not p["srcname"] in legacy_packages:
openmamba_version = p["version"]
openmamba_srcname = p["srcname"]
elif p["status"] == "newest":
# kaos_build provides unreleased kde package versions
if p["repo"] != "kaos_build":
newest_version = p["version"]
newest_repos.append(p["repo"])
newest_repos = list(dict.fromkeys(newest_repos))
if openmamba_srcname and newest_version is not None and len(newest_repos) > 0:
print(openmamba_srcname + " " + newest_version + " " + ",".join(newest_repos))
from_package = package + "/"
time.sleep(1)