mirror of
https://git.launchpad.net/~ubuntu-qt-code/+git/calamares-settings-ubuntu
synced 2025-06-08 08:11:31 +00:00
[pkgselectprocess] Add dpkg diversions for dracut, update-initramfs, and locale-gen. These will be called later in the process.
This commit is contained in:
parent
fd47fdaf63
commit
9284c1f21b
@ -199,12 +199,74 @@ Calamares::JobResult PackageSelectProcess::runSnapCommand(const QStringList& sna
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit progress(endProgress);
|
emit progress(endProgress);
|
||||||
m_prettyStatus = tr("Snap packages installed successfully.");
|
m_prettyStatus = tr("Snap packages installed successfully!");
|
||||||
emit prettyStatusMessageChanged(m_prettyStatus);
|
emit prettyStatusMessageChanged(m_prettyStatus);
|
||||||
|
|
||||||
return Calamares::JobResult::ok();
|
return Calamares::JobResult::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PackageSelectProcess::divert(bool enable)
|
||||||
|
{
|
||||||
|
for (auto it = dpkgDiversions.constBegin(); it != dpkgDiversions.constEnd(); ++it) {
|
||||||
|
const QString& name = it.key();
|
||||||
|
const QString& path = it.value();
|
||||||
|
QString divertedPath = path + ".REAL";
|
||||||
|
QString command;
|
||||||
|
|
||||||
|
if (enable) {
|
||||||
|
qDebug() << tr("Adding diversion for %1...").arg(name);
|
||||||
|
command = QString("dpkg-divert --quiet --add --divert %1 --rename %2")
|
||||||
|
.arg(divertedPath, path);
|
||||||
|
} else {
|
||||||
|
qDebug() << tr("Removing diversion for %1...").arg(name);
|
||||||
|
QFile::remove(rootMountPoint + path);
|
||||||
|
command = QString("dpkg-divert --quiet --remove --rename %1").arg(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up the QProcess to run the command in chroot
|
||||||
|
QProcess process;
|
||||||
|
process.setProgram("/usr/sbin/chroot");
|
||||||
|
process.setArguments({ rootMountPoint, "/bin/bash", "-c", command });
|
||||||
|
process.setProcessChannelMode(QProcess::MergedChannels);
|
||||||
|
|
||||||
|
// Run the process
|
||||||
|
process.start();
|
||||||
|
if (!process.waitForFinished()) {
|
||||||
|
qWarning() << "Process error:" << process.errorString();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.exitStatus() != QProcess::NormalExit || process.exitCode() != 0) {
|
||||||
|
qWarning() << "Error handling diversion for" << name << ":" << process.readAll();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!enable) { continue; }
|
||||||
|
|
||||||
|
// Create the replacement script in chroot
|
||||||
|
QString scriptContent = QString(
|
||||||
|
"#!/bin/sh\n"
|
||||||
|
"echo \"%1: diverted (will be called later)\" >&1\n"
|
||||||
|
"exit 0\n"
|
||||||
|
).arg(name);
|
||||||
|
|
||||||
|
QString scriptPath = rootMountPoint + path;
|
||||||
|
QFile scriptFile(scriptPath);
|
||||||
|
|
||||||
|
if (!scriptFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
qWarning() << "Error creating script for" << name << ":" << scriptFile.errorString();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream out(&scriptFile);
|
||||||
|
out << scriptContent;
|
||||||
|
scriptFile.close();
|
||||||
|
|
||||||
|
// Make the script executable
|
||||||
|
QFile::setPermissions(scriptPath, QFile::permissions(scriptPath) | QFile::ExeOwner | QFile::ExeGroup | QFile::ExeOther);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Calamares::JobResult PackageSelectProcess::exec()
|
Calamares::JobResult PackageSelectProcess::exec()
|
||||||
{
|
{
|
||||||
auto gs = Calamares::JobQueue::instance()->globalStorage();
|
auto gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
@ -221,7 +283,7 @@ Calamares::JobResult PackageSelectProcess::exec()
|
|||||||
const QVariantList presentSnaps = installationData.value("present_snaps").toList();
|
const QVariantList presentSnaps = installationData.value("present_snaps").toList();
|
||||||
|
|
||||||
// Handle default value for rootMountPoint
|
// Handle default value for rootMountPoint
|
||||||
QString rootMountPoint = "/";
|
rootMountPoint = "/";
|
||||||
if (gs->contains("rootMountPoint")) {
|
if (gs->contains("rootMountPoint")) {
|
||||||
rootMountPoint = gs->value("rootMountPoint").toString();
|
rootMountPoint = gs->value("rootMountPoint").toString();
|
||||||
}
|
}
|
||||||
@ -260,6 +322,14 @@ Calamares::JobResult PackageSelectProcess::exec()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add diversions for dracut, update-initramfs, and locale-gen
|
||||||
|
dpkgDiversions = {
|
||||||
|
{"dracut", "/usr/bin/dracut"},
|
||||||
|
{"update-initramfs", "/usr/sbin/update-initramfs"},
|
||||||
|
{"locale-gen", "/usr/sbin/locale-gen"}
|
||||||
|
};
|
||||||
|
divert(true);
|
||||||
|
|
||||||
double installStart;
|
double installStart;
|
||||||
double installEnd;
|
double installEnd;
|
||||||
if (downloadUpdates) {
|
if (downloadUpdates) {
|
||||||
@ -337,6 +407,9 @@ Calamares::JobResult PackageSelectProcess::exec()
|
|||||||
autoremoveEnd,
|
autoremoveEnd,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
// Disable diversions
|
||||||
|
divert(false);
|
||||||
|
|
||||||
// Handle snap packages
|
// Handle snap packages
|
||||||
if (installationMode != "minimal") {
|
if (installationMode != "minimal") {
|
||||||
QStringList snapPackages;
|
QStringList snapPackages;
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#ifndef PACKAGESELECTPROCESS_H
|
#ifndef PACKAGESELECTPROCESS_H
|
||||||
#define PACKAGESELECTPROCESS_H
|
#define PACKAGESELECTPROCESS_H
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
#include "CppJob.h"
|
#include "CppJob.h"
|
||||||
#include "utils/PluginFactory.h"
|
#include "utils/PluginFactory.h"
|
||||||
@ -44,6 +46,11 @@ private:
|
|||||||
double startProgress,
|
double startProgress,
|
||||||
double endProgress);
|
double endProgress);
|
||||||
|
|
||||||
|
void divert(bool enable);
|
||||||
|
|
||||||
|
QMap<QString, QString> dpkgDiversions;
|
||||||
|
QString rootMountPoint;
|
||||||
|
|
||||||
QVariantMap m_configurationMap;
|
QVariantMap m_configurationMap;
|
||||||
QString m_prettyStatus;
|
QString m_prettyStatus;
|
||||||
};
|
};
|
||||||
|
7
debian/changelog
vendored
7
debian/changelog
vendored
@ -1,3 +1,10 @@
|
|||||||
|
calamares-settings-ubuntu (1:25.04.10) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
|
* [pkgselectprocess] Add dpkg diversions for dracut, update-initramfs, and
|
||||||
|
locale-gen. These will be called later in the process.
|
||||||
|
|
||||||
|
-- Simon Quigley <tsimonq2@ubuntu.com> Sun, 24 Nov 2024 20:22:55 -0600
|
||||||
|
|
||||||
calamares-settings-ubuntu (1:25.04.9) plucky; urgency=medium
|
calamares-settings-ubuntu (1:25.04.9) plucky; urgency=medium
|
||||||
|
|
||||||
* Add a Dracut config file for Lubuntu.
|
* Add a Dracut config file for Lubuntu.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user