From da74c198e239cd5417072d73fe1c2f22511eefed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20P=2E=20M=C3=B6ller?= Date: Sat, 26 Sep 2020 18:16:42 -0300 Subject: [PATCH] added security package mark --- debian/changelog | 1 + helper | 1 + lubuntu-notifier.py | 54 ++++++++++++++++++++++++++++++++++++--------- resources | 1 + 4 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 helper create mode 100644 resources diff --git a/debian/changelog b/debian/changelog index 0865a00..90bf081 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ lubuntu-update-notifier (0.4dev) UNRELEASED; urgency=medium * Added internationalization support. * Added packages version info. + * Added security package mark. -- Hans P Möller Sat, 12 Sep 2020 13:59:25 -0300 diff --git a/helper b/helper new file mode 100644 index 0000000..3b996c4 --- /dev/null +++ b/helper @@ -0,0 +1 @@ +./lubuntu-notifier.py -u 0 -s 0 -p ./lubuntu-upgrader diff --git a/lubuntu-notifier.py b/lubuntu-notifier.py index 5bf0ff0..869dbdb 100755 --- a/lubuntu-notifier.py +++ b/lubuntu-notifier.py @@ -27,10 +27,28 @@ import gettext from PyQt5.QtWidgets import (QWidget, QApplication, QLabel, QDialogButtonBox, QHBoxLayout, QVBoxLayout, QTreeWidget, - QTreeWidgetItem) + QTreeWidgetItem, QHeaderView) from PyQt5.QtCore import Qt from PyQt5.QtGui import QIcon +DISTRO = subprocess.check_output( + ["lsb_release", "-c", "-s"], + universal_newlines=True).strip() + + +def isSecurityUpgrade(ver): + " check if the given version is a security update (or masks one) " + security_pockets = [("Ubuntu", "%s-security" % DISTRO), + ("UbuntuESM", "%s-infra-security" % DISTRO), + ("UbuntuESMApps", "%s-apps-security" % DISTRO), + ("gNewSense", "%s-security" % DISTRO), + ("Debian", "%s-updates" % DISTRO)] + for (file, index) in ver.file_list: + for origin, archive in security_pockets: + if (file.archive == archive and file.origin == origin): + return True + return False + class Dialog(QWidget): ''' UI ''' @@ -60,9 +78,16 @@ class Dialog(QWidget): self.label.setAlignment(Qt.AlignHCenter) self.tw = QTreeWidget() - self.tw.setColumnCount(1) - self.tw.setHeaderLabels([_('Affected Packages')]) - self.tw.setHeaderHidden(True) + if self.security_upgrades > 0: + self.tw.setColumnCount(2) + self.tw.setHeaderLabels([_('Affected Packages'), + _('Security')]) + self.tw.header().setSectionResizeMode(0, QHeaderView.Stretch) + self.tw.header().setStretchLastSection(False) + else: + self.tw.setColumnCount(1) + self.tw.setHeaderLabels([_('Affected Packages')]) + self.tw.setHeaderHidden(True) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Cancel | QDialogButtonBox.Apply) @@ -117,19 +142,26 @@ class Dialog(QWidget): if len(pkg_install) > 0: toInstall = QTreeWidgetItem([_('Install')]) for p in pkg_install: - td_child = QTreeWidgetItem([p[0].name]) + td_child = QTreeWidgetItem([p[0].name + " / " + + p[1].ver_str]) + if isSecurityUpgrade(p[1]): + td_child.setIcon(1, QIcon.fromTheme("security-high")) + toInstall.setIcon(1, QIcon.fromTheme("security-high")) toInstall.addChild(td_child) - td_child.addChild(QTreeWidgetItem([p[1].ver_str])) - toInstall.setIcon(0, - QIcon.fromTheme("system-software-install")) + # td_child.addChild(QTreeWidgetItem([p[1].ver_str])) + toInstall.setIcon(0, QIcon.fromTheme( + "system-software-install")) self.tw.addTopLevelItem(toInstall) if len(pkg_upgrade) > 0: toUpgrade = QTreeWidgetItem([_('Upgrade')]) for p in pkg_upgrade: - td_child = QTreeWidgetItem([p[0].name]) + td_child = QTreeWidgetItem( + [p[0].name + " / " + p[0].current_ver.ver_str + + " -> " + p[1].ver_str]) + if isSecurityUpgrade(p[1]) or p[0].name == 'vlc-bin': + td_child.setIcon(1, QIcon.fromTheme("security-high")) + toUpgrade.setIcon(1, QIcon.fromTheme("security-high")) toUpgrade.addChild(td_child) - td_child.addChild(QTreeWidgetItem( - [p[0].current_ver.ver_str + " -> " + p[1].ver_str])) toUpgrade.setIcon(0, QIcon.fromTheme("system-software-update")) self.tw.addTopLevelItem(toUpgrade) diff --git a/resources b/resources new file mode 100644 index 0000000..62a414d --- /dev/null +++ b/resources @@ -0,0 +1 @@ +https://apt-team.pages.debian.net/python-apt/library/apt_pkg.html