2021-03-14 11:55:11 +01:00
|
|
|
#!/usr/bin/python3
|
2021-05-15 13:41:26 +02:00
|
|
|
#
|
|
|
|
# repology-openmamba.py - find upstream packages updates from repology.org
|
2024-02-08 17:08:30 +01:00
|
|
|
# Copyright (c) 2021-2024 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
2021-05-15 13:41:26 +02:00
|
|
|
#
|
2021-03-14 11:55:11 +01:00
|
|
|
|
2024-02-08 17:08:30 +01:00
|
|
|
import json
|
|
|
|
import rpm
|
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
import urllib.request
|
2021-03-14 11:55:11 +01:00
|
|
|
|
|
|
|
|
2024-02-08 17:08:30 +01:00
|
|
|
with open("/var/ftp/pub/openmamba/base/legacy") as f:
|
2021-03-14 11:55:11 +01:00
|
|
|
legacy_packages = f.read().splitlines()
|
|
|
|
|
2024-02-08 17:08:30 +01:00
|
|
|
with open("/var/ftp/pub/openmamba/base/updates-conf.json") as f:
|
2021-05-15 13:41:26 +02:00
|
|
|
data = json.loads(f.read())
|
2024-02-08 17:08:30 +01:00
|
|
|
ignored_packages = data["repology"]["ignore"]
|
2021-05-15 13:41:26 +02:00
|
|
|
|
2021-03-14 11:55:11 +01:00
|
|
|
from_package = ""
|
2022-10-02 12:43:26 +02:00
|
|
|
last_from_package = "NONE"
|
|
|
|
results = []
|
|
|
|
|
2021-03-14 11:55:11 +01:00
|
|
|
while True:
|
2022-10-02 12:43:26 +02:00
|
|
|
if from_package == last_from_package:
|
|
|
|
break
|
|
|
|
requrl = "https://repology.org/api/v1/projects/"
|
|
|
|
if from_package != "":
|
|
|
|
requrl += from_package +"/"
|
|
|
|
requrl += "?inrepo=openmamba&outdated=1"
|
|
|
|
sys.stderr.write("Requesting: " + requrl + "\n")
|
2024-09-14 15:00:16 +02:00
|
|
|
req = urllib.request.Request(
|
|
|
|
requrl,
|
|
|
|
data=None,
|
|
|
|
headers={'User-Agent': 'autodist/1.5.3 (Linux; openmamba; reports@openmamba.org)'}
|
|
|
|
)
|
|
|
|
url = urllib.request.urlopen(req)
|
2022-10-02 12:43:26 +02:00
|
|
|
#print(requrl)
|
2021-03-14 11:55:11 +01:00
|
|
|
data = json.loads(url.read().decode())
|
|
|
|
|
|
|
|
if from_package != "" and len(data.keys()) <= 1:
|
|
|
|
break
|
|
|
|
for k in data.keys():
|
2022-10-02 12:43:26 +02:00
|
|
|
if k == from_package:
|
2021-03-14 11:55:11 +01:00
|
|
|
continue
|
2022-10-02 12:43:26 +02:00
|
|
|
package = k
|
2021-03-14 11:55:11 +01:00
|
|
|
openmamba_srcname = None
|
|
|
|
openmamba_version = None
|
2022-10-02 12:43:26 +02:00
|
|
|
openmamba_altnames = []
|
2021-03-14 11:55:11 +01:00
|
|
|
newest_version = None
|
|
|
|
newest_repos = []
|
|
|
|
for p in data[k]:
|
2022-10-02 12:43:26 +02:00
|
|
|
if p["repo"] == "openmamba":
|
|
|
|
if not p["srcname"] in ignored_packages and \
|
|
|
|
not p["srcname"] in legacy_packages:
|
|
|
|
if openmamba_srcname is None:
|
|
|
|
openmamba_version = p["version"]
|
|
|
|
openmamba_srcname = p["srcname"]
|
|
|
|
else:
|
|
|
|
openmamba_altnames.append(p["srcname"])
|
2021-03-14 11:55:11 +01:00
|
|
|
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:
|
2022-10-02 12:43:26 +02:00
|
|
|
results.append(openmamba_srcname + " " + newest_version)
|
|
|
|
for altname in openmamba_altnames:
|
|
|
|
results.append(altname + " " + newest_version)
|
|
|
|
last_from_package = from_package
|
|
|
|
from_package = package
|
2021-03-14 11:55:11 +01:00
|
|
|
time.sleep(1)
|
2022-10-02 12:43:26 +02:00
|
|
|
|
|
|
|
results_sorted = sorted(set(results), key=str.casefold)
|
|
|
|
#results_unique = set(results_sorted)
|
|
|
|
for result in results_sorted:
|
|
|
|
print(result)
|