summaryrefslogtreecommitdiffstats
path: root/mga-advisor.py
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2024-12-16 09:33:03 +0100
committerPapoteur <papoteur@mageia.org>2024-12-16 09:33:03 +0100
commitb67336402d8aa082e73a0082478a67020f43d56d (patch)
tree7fb6e8a0293e4b416de2db0c6878c64c438a44df /mga-advisor.py
parent03408f8ba991626cecb0262f763e83ba7d584f98 (diff)
downloadmga-advisor-topic/dnf5.tar
mga-advisor-topic/dnf5.tar.gz
mga-advisor-topic/dnf5.tar.bz2
mga-advisor-topic/dnf5.tar.xz
mga-advisor-topic/dnf5.zip
Use libdnf5 for getting the sourcestopic/dnf5
This is based on: - getting the packages cited in Source RPM field, - extracting the name - searching the package in Testing reposotories having said name - adding the source package names removing .src at end. File dnfmadbbase comes from MADb config.py.in has to be copied in config.py and adapted to the location where dnf cache will be written and to the mirror to use.
Diffstat (limited to 'mga-advisor.py')
-rw-r--r--mga-advisor.py47
1 files changed, 26 insertions, 21 deletions
diff --git a/mga-advisor.py b/mga-advisor.py
index 8fbcf73..6743bbd 100644
--- a/mga-advisor.py
+++ b/mga-advisor.py
@@ -9,6 +9,9 @@ import requests
from textwrap import wrap
import time
+import config as config
+from dnf5madbbase import Dnf5MadbBase
+
from PySide6.QtWidgets import (
QApplication,
QWidget,
@@ -111,27 +114,12 @@ class Widget(QWidget):
r = requests.get(url, headers=headers)
if r.status_code == 200 and r.json()["faults"] == []:
desc =""
- for pkg in re.split(';|,| ', r.json()['bugs'][0]['cf_rpmpkg']):
- pkg = pkg.strip()
- if pkg == "":
- continue
- analyze = re.search(r"([\w\-\+_]+)-\d", pkg)
- if analyze is not None:
- pkg = analyze.group(1)
- sources = self.src_populate(pkg)
- for source in sources:
- suffix = ".mga" + source["mga_release"]
- if source["repo"] in ("tainted", "nonfree"):
- suffix += "." + source["repo"]
- self.ui.list_src.addItem(
- " ".join((source["mga_release"],
- source["repo"],
- source["package"] +
- "-" + source["version"] +
- "-" + source["release"] +
- suffix,
- )))
- desc += f" {pkg}"
+ sources = self._srpms(r.json()['bugs'][0]['cf_rpmpkg'])
+ for rel in sources.keys():
+ print(f"Adding {rel}")
+ for item in sources[rel]:
+ self.ui.list_src.addItem(item)
+ desc += f" {item}"
for cve in re.split(';|,| ', r.json()['bugs'][0]['cf_cve']):
cve = cve.strip()
if cve != "":
@@ -321,6 +309,23 @@ class Widget(QWidget):
self.ui.bug_le.setText(re.sub(r'\D', '', self.ui.bug_le.text()))
return True
+ def _srpms(self, field):
+ """
+ Return a set with the names of source packages in 2 latest releases
+ """
+ results = {}
+ for release in (config.TOP_RELEASE, config.TOP_RELEASE - 1):
+
+ distro = Dnf5MadbBase(str(release), "x86_64", config.DATA_PATH, refresh = True)
+ # extract list from bug report field, removing extra src.rpm
+ srpms = [srpm.strip().removesuffix(".rpm").removesuffix(".src") + "*" for srpm in re.split(';|,| ', field) if srpm.strip() != ""]
+ # get only the source package names
+ srpms_names = [x.get_name() for x in distro.search_nevra(srpms, repo=f"{release}-SRPMS-*")]
+ # We want the same source rpm, but from Testing repo
+ results[str(release)] = list(set([x.get_nevra().removesuffix(".src") for x in distro.search_name(srpms_names, repo=f"{release}-SRPMS-*testing*")]))
+ # print(f"For {release} {field} : {results[str(release)]}")
+ return results
+
def src_populate(self, package):
# retrieve information with repo, release from package name
cmd = ["mgarepo", "rpmlog"]