Compare commits
4 Commits
460e11d25f
...
cee2f2143b
Author | SHA1 | Date | |
---|---|---|---|
cee2f2143b | |||
03e0b5f538 | |||
ebaacb49c2 | |||
25111b9197 |
@ -1,7 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Exec=/usr/libexec/lubuntu-update-notifier/lubuntu-upg-notifier.sh
|
||||
NoDisplay=true
|
||||
Name=upgNotifier
|
||||
Icon=system-software-update
|
||||
Type=Application
|
||||
Version=0.1
|
12
debian/changelog
vendored
12
debian/changelog
vendored
@ -1,3 +1,15 @@
|
||||
lubuntu-update-notifier (0.6.1) UNRELEASED; urgency=medium
|
||||
|
||||
* Rough, initial migration to systemd units.
|
||||
|
||||
-- Simon Quigley <tsimonq2@ubuntu.com> Tue, 10 Oct 2023 14:14:56 -0500
|
||||
|
||||
lubuntu-update-notifier (0.6.0) mantic; urgency=medium
|
||||
|
||||
* Add support for release upgrading, when all updates are applied (LP: #2038958).
|
||||
|
||||
-- Simon Quigley <tsimonq2@ubuntu.com> Tue, 10 Oct 2023 14:06:19 -0500
|
||||
|
||||
lubuntu-update-notifier (0.5.4) lunar; urgency=medium
|
||||
|
||||
* Disconnect the status_changed() function from the status-changed signal in
|
||||
|
2
debian/control
vendored
2
debian/control
vendored
@ -19,8 +19,10 @@ Depends: aptdaemon,
|
||||
lxqt-sudo,
|
||||
python3,
|
||||
python3-aptdaemon (>= 0.6.20ubuntu16),
|
||||
python3-launchpadlib,
|
||||
python3-pyqt5,
|
||||
update-notifier-common,
|
||||
ubuntu-release-upgrader-qt,
|
||||
${misc:Depends},
|
||||
${python3:Depends},
|
||||
${shlibs:Depends}
|
||||
|
2
debian/lubuntu-update-notifier.install
vendored
2
debian/lubuntu-update-notifier.install
vendored
@ -1,2 +0,0 @@
|
||||
#data/upg-apply.desktop usr/share/applications
|
||||
data/upg-notifier-autostart.desktop etc/xdg/autostart
|
12
debian/lubuntu-update-notifier.postinst
vendored
Normal file
12
debian/lubuntu-update-notifier.postinst
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# This file can be removed following the release of Lubuntu 24.04 LTS
|
||||
# It's to ensure a smooth transition between the autostart file and the new
|
||||
# systemd user units provided
|
||||
|
||||
rm -f /etc/xdg/autostart/upg-notifier-autostart.desktop
|
||||
rm -f /home/*/.config/autostart/upg-notifier-autostart.desktop
|
||||
|
||||
#DEBHELPER#
|
7
debian/lubuntu-update-notifier.user.service
vendored
Normal file
7
debian/lubuntu-update-notifier.user.service
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=Lubuntu Update Notifier
|
||||
Wants=update-notifier-download.timer
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/libexec/lubuntu-update-notifier/lubuntu-upg-notifier.sh
|
10
debian/lubuntu-update-notifier.user.timer
vendored
Normal file
10
debian/lubuntu-update-notifier.user.timer
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Lubuntu Update Notifier
|
||||
Requires=lubuntu-update-notifier.service
|
||||
|
||||
[Timer]
|
||||
Unit=lubuntu-update-notifier.service
|
||||
OnCalendar=*-*-* *:00:00
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
@ -2,6 +2,7 @@
|
||||
# coding=utf-8
|
||||
|
||||
# Copyright (C) 2019 Hans P. Möller <hmollercl@lubuntu.me>
|
||||
# Copyright (C) 2023 Simon Quigley <tsimonq2@lubuntu.me>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -28,8 +29,10 @@ import gettext
|
||||
from PyQt5.QtWidgets import (QWidget, QApplication, QLabel, QDialogButtonBox,
|
||||
QHBoxLayout, QVBoxLayout, QTreeWidget,
|
||||
QTreeWidgetItem, QHeaderView)
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtCore import Qt, QThread, pyqtSignal
|
||||
from PyQt5.QtGui import QIcon
|
||||
from launchpadlib.launchpad import Launchpad
|
||||
|
||||
import importlib.util
|
||||
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
@ -37,16 +40,35 @@ spec = importlib.util.spec_from_file_location(
|
||||
apt_check = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(apt_check)
|
||||
|
||||
class RunUpgradeThread(QThread):
|
||||
finished = pyqtSignal()
|
||||
|
||||
def __init__(self, cmd):
|
||||
super().__init__()
|
||||
self.cmd = cmd
|
||||
|
||||
def run(self):
|
||||
process = subprocess.Popen(self.cmd)
|
||||
process.wait()
|
||||
self.finished.emit()
|
||||
|
||||
class Dialog(QWidget):
|
||||
''' UI '''
|
||||
|
||||
def __init__(self, upgrades, security_upgrades, reboot_required, upg_path):
|
||||
def __init__(self, upgrades, security_upgrades, release_upgrade, version, reboot_required, upg_path):
|
||||
QWidget.__init__(self)
|
||||
self.upgrades = upgrades
|
||||
self.security_upgrades = security_upgrades
|
||||
self.release_upgrade = release_upgrade
|
||||
self.version = version
|
||||
self.upg_path = upg_path
|
||||
self.reboot_required = reboot_required
|
||||
|
||||
try:
|
||||
self.launchpad = Launchpad.login_anonymously("lubuntu-update-notifier", "production", version="devel")
|
||||
except:
|
||||
self.launchpad = None
|
||||
|
||||
apt_pkg.init()
|
||||
try:
|
||||
self.cache = apt_pkg.Cache()
|
||||
@ -64,6 +86,8 @@ class Dialog(QWidget):
|
||||
''' UI initialization '''
|
||||
self.label = QLabel()
|
||||
self.label.setAlignment(Qt.AlignHCenter)
|
||||
self.label.setTextFormat(Qt.RichText)
|
||||
self.label.setOpenExternalLinks(True)
|
||||
|
||||
self.tw = QTreeWidget()
|
||||
if self.security_upgrades > 0:
|
||||
@ -93,7 +117,7 @@ class Dialog(QWidget):
|
||||
|
||||
self.tw.setVisible(False)
|
||||
|
||||
if self.upg_path is None:
|
||||
if self.upg_path is None and not self.release_upgrade:
|
||||
self.buttonBox.button(QDialogButtonBox.Apply).setVisible(False)
|
||||
|
||||
self.setLayout(vbox)
|
||||
@ -163,6 +187,10 @@ class Dialog(QWidget):
|
||||
td_child.addChild(short)
|
||||
toUpgrade.setIcon(0, QIcon.fromTheme("system-software-update"))
|
||||
self.tw.addTopLevelItem(toUpgrade)
|
||||
elif self.release_upgrade:
|
||||
self.setWindowTitle("Upgrade Lubuntu")
|
||||
text = self.new_version_text()
|
||||
self.buttonBox.clicked.connect(self.call_release_upgrader)
|
||||
|
||||
if self.reboot_required:
|
||||
if text == "":
|
||||
@ -192,43 +220,83 @@ class Dialog(QWidget):
|
||||
QDialogButtonBox.ApplyRole):
|
||||
''' starts upgrade process '''
|
||||
self.label.setText(_("Upgrading..."))
|
||||
# TODO maybe open another thread so notifier won't freeze
|
||||
cmd = ['lxqt-sudo', self.upg_path, '--full-upgrade']
|
||||
self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False)
|
||||
self.buttonBox.button(QDialogButtonBox.Apply).setVisible(False)
|
||||
self.tw.setVisible(False)
|
||||
process = subprocess.Popen(cmd)
|
||||
process.wait()
|
||||
|
||||
if self.upg_path == "terminal":
|
||||
text = _("Upgrade finished")
|
||||
cmd = ["lxqt-sudo", self.upg_path, "--full-upgrade"]
|
||||
self.thread = RunUpgradeThread(cmd)
|
||||
self.thread.finished.connect(self.on_upgrade_finished)
|
||||
self.thread.start()
|
||||
|
||||
reboot_required_path = Path("/var/run/reboot-required")
|
||||
if reboot_required_path.exists():
|
||||
text += "\n" + _("Reboot required")
|
||||
self.label.setText(text)
|
||||
self.closeBtn.setVisible(True)
|
||||
self.closeBtn.setEnabled(True)
|
||||
def on_upgrade_finished(self):
|
||||
if self.upg_path == "terminal":
|
||||
text = _("Upgrade finished")
|
||||
|
||||
else:
|
||||
app.quit()
|
||||
reboot_required_path = Path("/var/run/reboot-required")
|
||||
if reboot_required_path.exists():
|
||||
text += "\n" + _("Reboot required")
|
||||
self.label.setText(text)
|
||||
self.closeBtn.setVisible(True)
|
||||
self.closeBtn.setEnabled(True)
|
||||
elif self.release_upgrade:
|
||||
self.setWindowTitle("Upgrade Lubuntu")
|
||||
self.label.setText(self.new_version_text())
|
||||
self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(True)
|
||||
self.buttonBox.button(QDialogButtonBox.Apply).setVisible(True)
|
||||
self.buttonBox.clicked.disconnect(self.call_upgrade)
|
||||
self.buttonBox.clicked.connect(self.call_release_upgrader)
|
||||
else:
|
||||
app.quit()
|
||||
|
||||
def call_release_upgrader(self, btnClicked):
|
||||
if self.buttonBox.buttonRole(btnClicked) == QDialogButtonBox.ApplyRole:
|
||||
cmd = ["lxqt-sudo", "do-release-upgrade", "-m", "desktop", "-f", "DistUpgradeViewKDE"]
|
||||
self.thread2 = RunUpgradeThread(cmd)
|
||||
self.thread2.finished.connect(self.call_reject)
|
||||
self.thread2.start()
|
||||
elif self.buttonBox.buttonRole(btnClicked) == QDialogButtonBox.RejectRole:
|
||||
self.call_reject()
|
||||
|
||||
def new_version_text(self):
|
||||
try:
|
||||
main_version = '.'.join(self.version.split()[0].split('.')[:2])
|
||||
codename = self.launchpad.distributions["ubuntu"].getSeries(name_or_version=main_version).name
|
||||
except:
|
||||
codename = None
|
||||
|
||||
if codename:
|
||||
url_suffix = ""
|
||||
point_release = self.version.split(".")[2].split(" ")[0] if "." in self.version[4:] else "0"
|
||||
if point_release != "0":
|
||||
url_suffix = f"-{int(point_release)}"
|
||||
url_suffix += "-released"
|
||||
|
||||
text = f"<a href='https://lubuntu.me/{codename}{url_suffix}/'>"
|
||||
text += _("A new version of Lubuntu") + "</a> "
|
||||
text += _("is available. Would you like to install it?")
|
||||
else:
|
||||
text = _("A new version of Lubuntu is available. Would you like to install it?")
|
||||
|
||||
return text
|
||||
|
||||
|
||||
class App(QApplication):
|
||||
'''application'''
|
||||
|
||||
def __init__(self, upgrades, security_upgrades, reboot_required, upg_path,
|
||||
def __init__(self, upgrades, security_upgrades, release_upgrade, version, reboot_required, upg_path,
|
||||
*args):
|
||||
QApplication.__init__(self, *args)
|
||||
self.dialog = Dialog(upgrades, security_upgrades, reboot_required,
|
||||
self.dialog = Dialog(upgrades, security_upgrades, release_upgrade, version, reboot_required,
|
||||
upg_path)
|
||||
self.dialog.show()
|
||||
|
||||
|
||||
def main(args, upgrades, security_upgrades, reboot_required, upg_path):
|
||||
|
||||
def main(args, upgrades, security_upgrades, release_upgrade, version, reboot_required, upg_path):
|
||||
'''main'''
|
||||
global app
|
||||
app = App(upgrades, security_upgrades, reboot_required, upg_path, args)
|
||||
app = App(upgrades, security_upgrades, release_upgrade, version, reboot_required, upg_path, args)
|
||||
app.setWindowIcon(QIcon.fromTheme("system-software-update"))
|
||||
app.exec_()
|
||||
|
||||
@ -256,12 +324,29 @@ if __name__ == "__main__":
|
||||
dest="security_upgrades",
|
||||
help=_("How many security upgrades are available"),
|
||||
metavar="APP")
|
||||
parser.add_argument("-r",
|
||||
"--release-upgrade",
|
||||
dest="release_upgrade",
|
||||
help=_("Whether a release upgrade is required"),
|
||||
type=str,
|
||||
metavar="APP")
|
||||
parser.add_argument("-v",
|
||||
"--release-upgrade-version",
|
||||
dest="version",
|
||||
help=_("If a release upgrade is available, provide the version"),
|
||||
type=str,
|
||||
metavar="APP")
|
||||
|
||||
options = parser.parse_args()
|
||||
|
||||
reboot_required_path = Path("/var/run/reboot-required")
|
||||
reboot_required = reboot_required_path.exists()
|
||||
|
||||
if int(options.upgrades) > 0 or reboot_required:
|
||||
if int(options.release_upgrade) == 0:
|
||||
options.release_upgrade = True
|
||||
else:
|
||||
options.release_upgrade = False
|
||||
|
||||
if int(options.upgrades) > 0 or reboot_required or options.release_upgrade:
|
||||
main(sys.argv, int(options.upgrades), int(options.security_upgrades),
|
||||
reboot_required, options.upg_path)
|
||||
options.release_upgrade, options.version, reboot_required, options.upg_path)
|
||||
|
@ -16,22 +16,25 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
while true;
|
||||
do
|
||||
OUT=`/usr/lib/update-notifier/apt-check 2>&1`
|
||||
oldIFS=$IFS
|
||||
IFS=';'
|
||||
j=0
|
||||
for STRING in $OUT; do
|
||||
case $j in
|
||||
0)
|
||||
UPG=$STRING;;
|
||||
1)
|
||||
SEC=$STRING;;
|
||||
esac
|
||||
j=`expr $j + 1`
|
||||
done
|
||||
IFS=$oldIFS
|
||||
/usr/libexec/lubuntu-update-notifier/lubuntu-notifier.py -u $UPG -s $SEC -p /usr/bin/lubuntu-upgrader
|
||||
sleep 86400
|
||||
done;
|
||||
OUT=`/usr/lib/update-notifier/apt-check 2>&1`
|
||||
oldIFS=$IFS
|
||||
IFS=';'
|
||||
j=0
|
||||
for STRING in $OUT; do
|
||||
case $j in
|
||||
0)
|
||||
UPG=$STRING;;
|
||||
1)
|
||||
SEC=$STRING;;
|
||||
esac
|
||||
j=`expr $j + 1`
|
||||
done
|
||||
IFS=$oldIFS
|
||||
|
||||
NEWREL_CHECK=`/usr/bin/do-release-upgrade -c 2>&1`
|
||||
NEWREL=$?
|
||||
if [ "$NEWREL" -eq 0 ]; then
|
||||
VERSION=`echo $NEWREL_CHECK | awk -F\' '/available/{print $2}'`
|
||||
fi
|
||||
|
||||
/usr/libexec/lubuntu-update-notifier/lubuntu-notifier.py -u $UPG -s $SEC -r $NEWREL -v $VERSION -p /usr/bin/lubuntu-upgrader
|
||||
|
Loading…
x
Reference in New Issue
Block a user