diff options
Diffstat (limited to 'mga-advisor.py')
-rw-r--r-- | mga-advisor.py | 47 |
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"] |