Add new release detection code (not very user-visible yet)

ubuntu/noble
Aaron Rainbolt 11 months ago
parent c9bd42fea3
commit 2a7548e4ce

@ -144,6 +144,22 @@ void AptManager::handleUpdateProcessBuffer()
conffileList.append(confLine);
}
}
} else if (line == "Lubuntu Update !!! NEW LTS RELEASE") {
// Same busy-wait technique, but here we're just getting one extra line, the model code.
while (!aptProcess->canReadLine()) {
QThread::msleep(20);
}
aptProcess->readLine(lineBuf, 2048);
QString ltsReleaseCode = QString(lineBuf);
emit newLtsRelease(ltsReleaseCode);
} else if (line == "Lubuntu Update !!! NEW STABLE RELEASE") {
// Ditto
while (!aptProcess->canReadLine()) {
QThread::msleep(20);
}
aptProcess->readLine(lineBuf, 2048);
QString stableReleaseCode = QString(lineBuf);
emit newStableRelease(stableReleaseCode);
}
double percentageDone = (static_cast<double>(internalUpdateProgress) / (((internalUpdateInfo[0].count() + internalUpdateInfo[1].count()) * 4) + internalUpdateInfo[2].count())) * 100;

@ -28,6 +28,8 @@ signals:
void progressUpdated(int progress);
void logLineReady(QString logLine);
void conffileListReady(QStringList conffileList);
void newLtsRelease(QString code);
void newStableRelease(QString code);
private slots:
void handleUpdateProcessBuffer();

@ -4,6 +4,43 @@
set -e
export LC_ALL='C'
# Returns 0 if the release is supported, 1 if unsupported, 2 if if didn't exist at all, and 3 if something went wrong.
isReleaseSupported () {
releaseYear="${1:-}";
releaseMonth="${2:-}";
metaReleaseStr="${3:-}";
if [ -z "$releaseYear" ]; then
echo '! ! ! releaseYear is blank';
return 3;
elif [ -z "$releaseMonth" ]; then
echo '! ! ! releaseMonth is blank';
return 3;
elif [ -z "$metaReleaseStr" ]; then
echo '! ! ! metaReleaseStr is blank';
return 3;
fi
releaseCode="$releaseYear.$releaseMonth";
scanForSupported='n';
while IFS= read -r line || [[ -n $line ]]; do
if [[ "$line" =~ $releaseCode ]]; then
scanForSupported='y';
fi
if [ "$scanForSupported" = 'y' ]; then
if [[ "$line" =~ Supported ]]; then
if [ "$(echo "$line" | cut -d':' -f2 | tail -c+2)" = '0' ]; then
return 1;
else
return 0;
fi
fi
fi
done < <(printf '%s' "$metaReleaseStr")
return 2;
}
if [ "$1" = 'pkgver' ]; then
shift
while [ "$1" != '' ]; do
@ -90,5 +127,42 @@ elif [ "$1" = 'doupdate' ]; then
fi
done
echo 'Checking release status...'
releaseCode="$(cat /etc/lsb-release | grep "DISTRIB_RELEASE" | cut -d'=' -f2)";
releaseYear="$(cut -d'.' -f1 <<< "$releaseCode")";
releaseMonth="$(cut -d'.' -f2 <<< "$releaseCode")";
metaReleaseData="$(curl https://changelogs.ubuntu.com/meta-release)";
nextReleaseMonth='';
nextReleaseYear='';
nextLTSReleaseMonth='';
nextLTSReleaseYear='';
if ((releaseMonth == 4)); then
nextReleaseMonth=((releaseMonth + 6));
nextReleaseYear="$releaseYear";
if (((releaseYear % 2) == 0)); then
nextLTSReleaseMonth='04';
nextLTSReleaseYear=((releaseYear + 2));
fi
else
nextReleaseMonth="$releaseMonth";
nextReleaseYear=((releaseYear + 1));
fi
if [ -n "$nextLTSReleaseYear" ]; then
if isReleaseSupported "$nextLTSReleaseYear" "$nextLTSReleaseMonth" "$metaReleaseData"; then
echo 'Lubuntu Update !!! NEW LTS RELEASE';
echo "$nextLTSReleaseYear.$nextLTSReleaseMonth";
fi
fi
if ! (((nextReleaseYear == nextLTSReleaseYear) && (nextReleaseMonth == nextLTSReleaseMonth))); then
if isReleaseSupported "$nextReleaseYear" "$nextReleaseMonth" "$metaReleaseData"; then
echo 'Lubuntu Update !!! NEW STABLE RELEASE';
echo "$nextReleaseYear.$nextReleaseMonth";
fi
fi
echo 'Update installation complete.'
fi

@ -25,6 +25,8 @@ MainWindow::MainWindow(QWidget *parent)
connect(aptManager, &AptManager::progressUpdated, this, &MainWindow::onProgressUpdate);
connect(aptManager, &AptManager::logLineReady, this, &MainWindow::onLogLineReady);
connect(aptManager, &AptManager::conffileListReady, this, &MainWindow::onConffileListReady);
connect(aptManager, &AptManager::newLtsRelease, this, &MainWindow::onNewLtsRelease);
connect(aptManager, &AptManager::newStableRelease, this, &MainWindow::onNewStableRelease);
}
MainWindow::~MainWindow()
@ -143,6 +145,7 @@ void MainWindow::onUpdateCompleted()
ui->progressBar->setVisible(false);
ui->statLabel->setText(tr("Update installation complete."));
emit updatesInstalled(); // this tells the orchestrator to hide the tray icon
handleNewReleases();
}
void MainWindow::onCheckUpdatesCompleted()
@ -175,3 +178,20 @@ void MainWindow::onConffileListReady(QStringList conffileList)
}
aptManager->doneWithConffiles();
}
void MainWindow::onNewLtsRelease(QString code)
{
newLtsReleaseAvailable = true;
}
void MainWindow::onNewStableRelease(QString code)
{
newStableReleaseAvailable = true;
}
void MainWindow::handleNewReleases()
{
// TODO: Write code that informs the user when a new release is available here
newLtsReleaseAvailable = false;
newStableReleaseAvailable = false;
}

@ -39,9 +39,15 @@ private slots:
void onProgressUpdate(int progress);
void onLogLineReady(QString logLine);
void onConffileListReady(QStringList conffileList);
void onNewLtsRelease(QString code);
void onNewStableRelease(QString code);
private:
Ui::MainWindow *ui;
AptManager *aptManager;
bool newLtsReleaseAvailable = false;
bool newStableReleaseAvailable = false;
void handleNewReleases();
};
#endif // MAINWINDOW_H

Loading…
Cancel
Save