autodist/repology-openmamba.py

48 lines
1.8 KiB
Python
Raw Normal View History

#!/usr/bin/python3
#
# repology-openmamba.py - find upstream packages updates from repology.org
# Copyright (c) 2021 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
import json, urllib.request, time
with open("/var/ftp/pub/openmamba/devel/legacy") as f:
legacy_packages = f.read().splitlines()
with open("/var/ftp/pub/openmamba/devel/ignore") as f:
data = json.loads(f.read())
ignored_packages = data["repology"]
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 and not p["srcname"] in ignored_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)