Compare commits
5 Commits
ubuntu/1.0
...
ubuntu/plu
Author | SHA1 | Date | |
---|---|---|---|
|
217d71ba43 | ||
|
fed35d17a8 | ||
|
d418d68a29 | ||
978e9bfa5f | |||
953908831e |
@ -9,8 +9,7 @@ set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Widgets DBus LinguistTools)
|
||||
|
||||
set(TS_FILES
|
||||
src/translations/lubuntu-update_en_US.ts
|
||||
@ -36,22 +35,22 @@ set(PROJECT_SOURCES
|
||||
src/conffilehandlerdialog.h
|
||||
src/conffilehandlerdialog.cpp
|
||||
src/conffilehandlerdialog.ui
|
||||
src/ipcfilewatcher.h
|
||||
src/ipcfilewatcher.cpp
|
||||
src/releaseupgradewindow.h
|
||||
src/releaseupgradewindow.cpp
|
||||
src/releaseupgradewindow.ui
|
||||
src/upgradedelaywindow.h
|
||||
src/upgradedelaywindow.cpp
|
||||
src/upgradedelaywindow.ui
|
||||
src/windowshowwatcher.h
|
||||
src/windowshowwatcher.cpp
|
||||
${TS_FILES}
|
||||
)
|
||||
|
||||
set(TRANSLATION_RESOURCES "src/translations.qrc")
|
||||
|
||||
configure_file(${TRANSLATION_RESOURCES} translations.qrc COPYONLY)
|
||||
qt5_add_translation(QM_FILES ${TS_FILES})
|
||||
qt5_add_resources(QM_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
|
||||
qt6_add_translation(QM_FILES ${TS_FILES})
|
||||
qt6_add_resources(QM_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
|
||||
|
||||
add_custom_target(translations ALL DEPENDS ${QM_FILES})
|
||||
|
||||
@ -63,7 +62,9 @@ add_executable(lubuntu-update
|
||||
|
||||
add_dependencies(lubuntu-update translations)
|
||||
|
||||
target_link_libraries(lubuntu-update PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
target_link_libraries(lubuntu-update PRIVATE
|
||||
Qt6::Widgets
|
||||
Qt6::DBus)
|
||||
|
||||
install(TARGETS lubuntu-update
|
||||
BUNDLE DESTINATION .
|
||||
|
28
debian/changelog
vendored
28
debian/changelog
vendored
@ -1,3 +1,31 @@
|
||||
lubuntu-update-notifier (1.1.1) plucky; urgency=medium
|
||||
|
||||
* Switch debconf frontend to noninteractive. (LP: #2091704)
|
||||
|
||||
-- Aaron Rainbolt <arraybolt3@ubuntu.com> Tue, 24 Dec 2024 13:51:28 -0600
|
||||
|
||||
lubuntu-update-notifier (1.1.0) oracular; urgency=medium
|
||||
|
||||
* Port to Qt6.
|
||||
|
||||
-- Aaron Rainbolt <arraybolt3@ubuntu.com> Thu, 15 Aug 2024 16:58:41 -0500
|
||||
|
||||
lubuntu-update-notifier (1.0.0) noble; urgency=medium
|
||||
|
||||
* Change from beta to final release.
|
||||
* Use D-Bus as a window show trigger rather than clunky drop files, this
|
||||
will prevent issues if multiple users are logged in at once.
|
||||
|
||||
-- Aaron Rainbolt <arraybolt3@ubuntu.com> Mon, 25 Mar 2024 16:15:49 -0500
|
||||
|
||||
lubuntu-update-notifier (1.0.0~beta1) noble; urgency=medium
|
||||
|
||||
* Change from alpha to beta testing phase, this has been tested for a while
|
||||
and looks pretty stable so far.
|
||||
* Wait to start until lxqt-notificationd is present. (LP: #2056379)
|
||||
|
||||
-- Aaron Rainbolt <arraybolt3@ubuntu.com> Thu, 07 Mar 2024 04:06:13 +0000
|
||||
|
||||
lubuntu-update-notifier (1.0.0~alpha4) noble; urgency=medium
|
||||
|
||||
* Fix infinite loop when no eligible new release is available.
|
||||
|
4
debian/control
vendored
4
debian/control
vendored
@ -5,8 +5,8 @@ Maintainer: Lubuntu Developers <lubuntu-devel@lists.ubuntu.com>
|
||||
Build-Depends: cmake,
|
||||
debhelper-compat (= 13),
|
||||
lxqt-sudo (>= 1.4.0-0ubuntu2),
|
||||
qtbase5-dev,
|
||||
qttools5-dev
|
||||
qt6-base-dev,
|
||||
qt6-tools-dev
|
||||
Standards-Version: 4.6.2
|
||||
Rules-Requires-Root: no
|
||||
|
||||
|
1
debian/files
vendored
Normal file
1
debian/files
vendored
Normal file
@ -0,0 +1 @@
|
||||
lubuntu-update-notifier_1.1.0~ppa1_source.buildinfo admin optional
|
@ -88,10 +88,10 @@ void AptManager::handleUpdateProcessBuffer()
|
||||
// yes, this gave me a headache also
|
||||
if (dlLineMatch.hasMatch()) { // Increments the progress counter for each package downloaded
|
||||
internalUpdateProgress++;
|
||||
} else if (line.count() >= 25 && line.left(24) == "Preparing to unpack .../" && numPackagesToPrep != 0) {
|
||||
} else if (line.length() >= 25 && line.left(24) == "Preparing to unpack .../" && numPackagesToPrep != 0) {
|
||||
internalUpdateProgress++; // Increments the progress counter for each package that is "prepared to unpack"
|
||||
numPackagesToPrep--;
|
||||
} else if (line.count() >= 10 && line.left(9) == "Unpacking") {
|
||||
} else if (line.length() >= 10 && line.left(9) == "Unpacking") {
|
||||
/*
|
||||
* Increments the progress counter for each package that is unpacked
|
||||
* The package name may be suffixed with ":amd64" or some other
|
||||
@ -109,7 +109,7 @@ void AptManager::handleUpdateProcessBuffer()
|
||||
internalUpdateProgress++;
|
||||
}
|
||||
}
|
||||
} else if (line.count() >= 11 && line.left(10) == "Setting up") {
|
||||
} else if (line.length() >= 11 && line.left(10) == "Setting up") {
|
||||
QStringList parts = line.split(' ');
|
||||
QString packageName;
|
||||
if (parts.count() >= 3) {
|
||||
@ -118,7 +118,7 @@ void AptManager::handleUpdateProcessBuffer()
|
||||
internalUpdateProgress++;
|
||||
}
|
||||
}
|
||||
} else if (line.count() >= 9 && line.left(8) == "Removing") {
|
||||
} else if (line.length() >= 9 && line.left(8) == "Removing") {
|
||||
QStringList parts = line.split(' ');
|
||||
QString packageName;
|
||||
if (parts.count() >= 2) {
|
||||
@ -136,7 +136,7 @@ void AptManager::handleUpdateProcessBuffer()
|
||||
}
|
||||
aptProcess->readLine(lineBuf, 2048);
|
||||
QString confLine = QString(lineBuf);
|
||||
confLine = confLine.left(confLine.count() - 2);
|
||||
confLine = confLine.left(confLine.length() - 2);
|
||||
if (confLine == "Lubuntu Update !!! CONFIGURATION FILE LIST END") {
|
||||
emit conffileListReady(conffileList); // this triggers the main window to show the conffile handler window
|
||||
break;
|
||||
@ -151,7 +151,7 @@ void AptManager::handleUpdateProcessBuffer()
|
||||
}
|
||||
aptProcess->readLine(lineBuf, 2048);
|
||||
QString releaseCode = QString(lineBuf);
|
||||
releaseCode = releaseCode.left(releaseCode.count() - 2);
|
||||
releaseCode = releaseCode.left(releaseCode.length() - 2);
|
||||
emit newRelease(releaseCode);
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ QList<QStringList> AptManager::getUpdateInfo()
|
||||
* spaces, we know we're no longer reading a package list.
|
||||
*/
|
||||
|
||||
if (stdoutLine.count() < 3 || stdoutLine.left(2) != " ") {
|
||||
if (stdoutLine.length() < 3 || stdoutLine.left(2) != " ") {
|
||||
gettingInstallPackages = false;
|
||||
gettingUpgradePackages = false;
|
||||
gettingUninstallPackages = false;
|
||||
@ -317,7 +317,7 @@ QStringList AptManager::getSecurityUpdateList()
|
||||
QString distroLine;
|
||||
while (distroFinder.readLineInto(&distroLine)) {
|
||||
// The line has to be at least 18 characters long - 16 for the string "DISTRIB_CODENAME", one for the = sign, and one for a codename with a length of at least one.
|
||||
if (distroLine.count() >= 18 && distroLine.left(16) == "DISTRIB_CODENAME") {
|
||||
if (distroLine.length() >= 18 && distroLine.left(16) == "DISTRIB_CODENAME") {
|
||||
QStringList distroParts = distroLine.split('=');
|
||||
if (distroParts.count() >= 2) {
|
||||
distroName = distroParts[1];
|
||||
|
@ -1,38 +0,0 @@
|
||||
#include "ipcfilewatcher.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileSystemWatcher>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
IPCFileWatcher::IPCFileWatcher(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
QDir targetDir("/dev/shm/lubuntu-update");
|
||||
bool couldRemove = targetDir.removeRecursively();
|
||||
if (!couldRemove) {
|
||||
qCritical() << "Could not clear IPC directory. Ensure that /dev/shm and /dev/shm/lubuntu-update are world-readable and world-writable.";
|
||||
initFailed = true;
|
||||
return;
|
||||
}
|
||||
targetDir.mkdir("/dev/shm/lubuntu-update");
|
||||
QFileSystemWatcher *watcher = new QFileSystemWatcher(QStringList() << "/dev/shm/lubuntu-update");
|
||||
connect(watcher, &QFileSystemWatcher::directoryChanged, this, &IPCFileWatcher::checkForShowWindowFile);
|
||||
initFailed = false;
|
||||
}
|
||||
|
||||
bool IPCFileWatcher::didInitFail()
|
||||
{
|
||||
return initFailed;
|
||||
}
|
||||
|
||||
void IPCFileWatcher::checkForShowWindowFile()
|
||||
{
|
||||
QFile flagFile("/dev/shm/lubuntu-update/lubuntu-update-show-win");
|
||||
if (flagFile.exists()) {
|
||||
flagFile.remove();
|
||||
emit showWindowFlagDetected();
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
#ifndef IPCFILEWATCHER_H
|
||||
#define IPCFILEWATCHER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class IPCFileWatcher : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IPCFileWatcher(QObject *parent = nullptr);
|
||||
bool didInitFail();
|
||||
|
||||
signals:
|
||||
void showWindowFlagDetected();
|
||||
|
||||
private:
|
||||
bool initFailed;
|
||||
|
||||
void checkForShowWindowFile();
|
||||
};
|
||||
|
||||
#endif // IPCFILEWATCHER_H
|
@ -66,7 +66,7 @@ elif [ "$1" = 'doupdate' ]; then
|
||||
dpkg --configure -a
|
||||
|
||||
# Run the real update
|
||||
DEBIAN_FRONTEND='kde' apt-get -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' -o Apt::Color='0' -o Dpkg::Use-Pty='0' -y dist-upgrade |& tee /run/lubuntu-update-apt-log
|
||||
DEBIAN_FRONTEND='noninteractive' apt-get -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' -o Apt::Color='0' -o Dpkg::Use-Pty='0' -y dist-upgrade |& tee /run/lubuntu-update-apt-log
|
||||
|
||||
# Find all the conffiles
|
||||
doConffiles='y';
|
||||
|
90
src/main.cpp
90
src/main.cpp
@ -1,14 +1,38 @@
|
||||
#include "ipcfilewatcher.h"
|
||||
#include "windowshowwatcher.h"
|
||||
#include "orchestrator.h"
|
||||
#include "mainwindow.h"
|
||||
#include "conffilehandlerdialog.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusError>
|
||||
#include <QDBusInterface>
|
||||
#include <QDebug>
|
||||
#include <QDialog>
|
||||
#include <QLocale>
|
||||
#include <QProcess>
|
||||
#include <QThread>
|
||||
#include <QTranslator>
|
||||
|
||||
/*
|
||||
* Detects if at least `count` processes that match `procName` are running.
|
||||
*/
|
||||
bool detectProc(QString procName, int count)
|
||||
{
|
||||
QProcess procDetector;
|
||||
procDetector.setProgram("/usr/bin/bash");
|
||||
procDetector.setArguments(QStringList() << "-c" << "ps axo comm | grep " + procName);
|
||||
procDetector.start();
|
||||
procDetector.waitForFinished();
|
||||
QString procDetectResult = procDetector.readAllStandardOutput();
|
||||
procDetectResult = procDetectResult.trimmed();
|
||||
QStringList procDetectResultList = procDetectResult.split('\n');
|
||||
if (procDetectResultList.count() >= count) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
@ -23,40 +47,53 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If Lubuntu Update is already running, create
|
||||
* /dev/shm/lubuntu-update/lubuntu-update-show-win and exit. This will
|
||||
* trigger the existing process to pop up a window.
|
||||
*/
|
||||
// Connect to D-Bus.
|
||||
auto dbusConnection = QDBusConnection::sessionBus();
|
||||
|
||||
QProcess procDetector;
|
||||
procDetector.setProgram("/usr/bin/bash");
|
||||
procDetector.setArguments(QStringList() << "-c" << "ps axo comm | grep lubuntu-update");
|
||||
procDetector.start();
|
||||
procDetector.waitForFinished();
|
||||
QString procDetectResult = procDetector.readAllStandardOutput();
|
||||
procDetectResult = procDetectResult.trimmed();
|
||||
QStringList procDetectResultList = procDetectResult.split('\n');
|
||||
if (procDetectResultList.count() > 1) {
|
||||
QFile flagFile("/dev/shm/lubuntu-update/lubuntu-update-show-win");
|
||||
flagFile.open(QFile::WriteOnly);
|
||||
flagFile.close();
|
||||
/*
|
||||
* If Lubuntu Update is already running, instruct the running instance to
|
||||
* display its window via the D-Bus connection.
|
||||
*/
|
||||
if (detectProc("lubuntu-update", 2)) {
|
||||
auto iface = new QDBusInterface("me.lubuntu.LubuntuUpdate.window", "/", "me.lubuntu.LubuntuUpdate.window", dbusConnection);
|
||||
if (!iface->isValid()) {
|
||||
qWarning().noquote() << dbusConnection.lastError().message();
|
||||
return 1;
|
||||
}
|
||||
iface->call("showWindow");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait to run until lxqt-notificationd is running. This avoids a bug that
|
||||
* causes notifications to show up in the entirely wrong spot. If it takes
|
||||
* longer than about 30 seconds to show up, we continue on without it for
|
||||
* the sake of getting security updates.
|
||||
*/
|
||||
for (int i = 0;i < 30;i++) {
|
||||
// "lxqt-notificati" is intentionally truncated here since that's how it shows up in the output of `ps axo comm`.
|
||||
if (detectProc("lxqt-notificati", 1)) {
|
||||
// Wait for it to initialize fully - 3 seconds should be way more than enough
|
||||
QThread::sleep(3);
|
||||
break;
|
||||
} else {
|
||||
QThread::sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Don't want the updater to stop just because the user closed it :P
|
||||
a.setQuitOnLastWindowClosed(false);
|
||||
|
||||
/*
|
||||
* IPCFileWatcher just watches the /dev/shm/lubuntu-update folder for the
|
||||
* creation of a lubuntu-update-show-win file. If it detects it, it
|
||||
* immediately deletes it and emits a signal. This is then used later to
|
||||
* cause the updater window to pop up.
|
||||
* WindowShowWatcher is a very simple D-Bus service that allow triggering
|
||||
* the Lubuntu Update window to be shown. If anything calls "showWindow"
|
||||
* on this service, Lubuntu Update's window will pop up.
|
||||
*/
|
||||
QObject obj;
|
||||
auto *wsw = new WindowShowWatcher(&obj);
|
||||
dbusConnection.registerObject("/", &obj);
|
||||
|
||||
IPCFileWatcher *p = new IPCFileWatcher();
|
||||
|
||||
if (p->didInitFail()) {
|
||||
if (!dbusConnection.registerService("me.lubuntu.LubuntuUpdate.window")) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -71,10 +108,9 @@ int main(int argc, char *argv[])
|
||||
* there's no need to do anything with this except create it and then
|
||||
* start the event loop.
|
||||
*/
|
||||
|
||||
Orchestrator *o = new Orchestrator();
|
||||
|
||||
QObject::connect(p, &IPCFileWatcher::showWindowFlagDetected, o, &Orchestrator::displayUpdater);
|
||||
QObject::connect(wsw, &WindowShowWatcher::showWindowTriggered, o, &Orchestrator::displayUpdater);
|
||||
|
||||
/*
|
||||
* This is an artifact from testing the conffile handler window. You can
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>462</width>
|
||||
<width>473</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -37,6 +37,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QProgressBar" name="progressBar">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
6
src/windowshowwatcher.cpp
Normal file
6
src/windowshowwatcher.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "windowshowwatcher.h"
|
||||
|
||||
void WindowShowWatcher::showWindow()
|
||||
{
|
||||
emit showWindowTriggered();
|
||||
}
|
23
src/windowshowwatcher.h
Normal file
23
src/windowshowwatcher.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef WINDOWSHOWWATCHER_H
|
||||
#define WINDOWSHOWWATCHER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDBusAbstractAdaptor>
|
||||
#include <QDBusVariant>
|
||||
|
||||
class WindowShowWatcher : public QDBusAbstractAdaptor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "me.lubuntu.LubuntuUpdate.window")
|
||||
|
||||
public:
|
||||
explicit WindowShowWatcher(QObject *obj) : QDBusAbstractAdaptor(obj) {}
|
||||
|
||||
public slots:
|
||||
void showWindow();
|
||||
|
||||
signals:
|
||||
void showWindowTriggered();
|
||||
};
|
||||
|
||||
#endif // WINDOWSHOWWATCHER_H
|
Loading…
x
Reference in New Issue
Block a user