Skip to content

Commit ca4db5a

Browse files
committed
New build
1 parent a245ba7 commit ca4db5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+5797
-3321
lines changed

debian/changelog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
mx-boot-options (24.9) mx; urgency=medium
2+
3+
* When running Live prompt to change live boot options or chroot to an installed system
4+
* Change syslinux.cfg and isolinux.cfg when running Live
5+
6+
-- Adrian <[email protected]> Mon, 02 Sep 2024 21:10:05 -0400
7+
18
mx-boot-options (24.6) mx; urgency=medium
29

310
* Fix: setting GRUB background photo

debs/mx-boot-options_24.6.dsc

Lines changed: 0 additions & 31 deletions
This file was deleted.

debs/mx-boot-options_24.6.tar.xz

-181 KB
Binary file not shown.

debs/mx-boot-options_24.9.dsc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-----BEGIN PGP SIGNED MESSAGE-----
2+
Hash: SHA512
3+
4+
Format: 3.0 (native)
5+
Source: mx-boot-options
6+
Binary: mx-boot-options
7+
Architecture: any
8+
Version: 24.9
9+
Maintainer: Adrian <[email protected]>
10+
Standards-Version: 3.9.8
11+
Build-Depends: debhelper (>= 10), qtbase5-dev, qttools5-dev-tools
12+
Package-List:
13+
mx-boot-options deb admin optional arch=any
14+
Checksums-Sha1:
15+
8c09601ab3346b0d1651ee39366abfcf653ec0c8 188556 mx-boot-options_24.9.tar.xz
16+
Checksums-Sha256:
17+
43a5477c7da9f8e831fa18023a4f7afec2b8ce2a6a441b223c7085365fc33d00 188556 mx-boot-options_24.9.tar.xz
18+
Files:
19+
decfa580a087f9a561749eda38b920e0 188556 mx-boot-options_24.9.tar.xz
20+
21+
-----BEGIN PGP SIGNATURE-----
22+
23+
iQFHBAEBCgAxFiEE8ndToY6S45N+YzXncJOMeAZ57pgFAmbWYokTHGFkcmlhbkBt
24+
eGxpbnV4Lm9yZwAKCRBwk4x4BnnumIk7B/9/+/LjxHLhCyLv9AWdUOEnCNIJ/wil
25+
vZUZKf5C8GWlD5EY07dnEuMiRb/qTAeO1aYVJIQz3vasQv9LmbxOGj9cRjbfn1n4
26+
9zEufUoivc8bOWWiga+mxMQGP8s2InkuXD5ZGh9E1aFthOLGnvudq4ERG3tQH508
27+
Ux8Wxsrjbsj7TYn+ifnmsTcPRymKDhOFCePWHZo4J+K1qahZbglSR1Qw2H8+Don6
28+
JIGssMDGq1xTwjS3zkivEq29kiFJ/FHK3/CPT5oLvo82vOu3NAy0yq+/Emnf/nmU
29+
qvP3xCBEnkkICLxCHlTt+m63O8MBIMArh/LxTtYnX+ukR1JADrdnrqIP
30+
=2iAy
31+
-----END PGP SIGNATURE-----

debs/mx-boot-options_24.9.tar.xz

184 KB
Binary file not shown.

mainwindow.cpp

Lines changed: 92 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,23 @@ void MainWindow::setup()
120120
ui->pushThemeFile->setVisible(grubThemesExist);
121121
ui->pushThemeFile->setDisabled(true);
122122

123-
// If running live, read Linux partitions and set chroot on the selected one
123+
// If running live, prompt user to choose between changing options for the live system or the installed system
124124
if (live) {
125-
QString part = selectPartiton(getLinuxPartitions());
126-
if (!part.isEmpty()) {
127-
createChrootEnv(part);
125+
QMessageBox msgBox(this);
126+
msgBox.setWindowTitle(tr("Live System Detected"));
127+
msgBox.setText(tr("You are currently running a live system. Would you like to modify the boot options for the live system "
128+
"or for an installed system?"));
129+
QPushButton *liveButton = msgBox.addButton(tr("Live System"), QMessageBox::ActionRole);
130+
QPushButton *installedButton = msgBox.addButton(tr("Installed System"), QMessageBox::ActionRole);
131+
msgBox.exec();
132+
133+
if (msgBox.clickedButton() == installedButton) {
134+
QString partition = selectPartiton(getLinuxPartitions());
135+
if (!partition.isEmpty()) {
136+
createChrootEnv(partition);
137+
}
138+
} else if (msgBox.clickedButton() == liveButton) {
139+
boot_location = QFileInfo::exists("/live/config/did-toram") ? "/live/to-ram" : "/live/boot-dev";
128140
}
129141
}
130142

@@ -665,6 +677,68 @@ bool MainWindow::replaceGrubArg(const QString &key, const QString &item)
665677
return replaced; // Return whether a replacement occurred
666678
}
667679

680+
void MainWindow::replaceSyslinuxArg(const QString &args)
681+
{
682+
const QStringList configFiles
683+
= {boot_location + "/boot/syslinux/syslinux.cfg", boot_location + "/boot/isolinux/isolinux.cfg"};
684+
685+
for (const QString &configFile : configFiles) {
686+
QFile file(configFile);
687+
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
688+
qWarning() << "Failed to open" << configFile << "for reading.";
689+
continue;
690+
}
691+
692+
QStringList new_list;
693+
bool replaced = false;
694+
695+
while (!file.atEnd()) {
696+
QString line = file.readLine().trimmed();
697+
if (!kernel_options.isEmpty() && line.contains(kernel_options)) {
698+
line.replace(kernel_options, args);
699+
replaced = true;
700+
} else if (kernel_options.isEmpty() && line.startsWith("APPEND") && !replaced) {
701+
QStringList parts = line.split(' ', Qt::SkipEmptyParts);
702+
if (parts.size() > 1) {
703+
parts[1] = args;
704+
} else {
705+
parts.append(args);
706+
}
707+
line = parts.join(' ');
708+
replaced = true;
709+
}
710+
new_list << line;
711+
}
712+
713+
file.close();
714+
715+
if (!replaced) {
716+
qWarning() << "No" << (kernel_options.isEmpty() ? "APPEND line" : kernel_options) << "found to replace in"
717+
<< configFile << ".";
718+
continue;
719+
}
720+
721+
// Write to a temporary file using QTemporaryFile
722+
QTemporaryFile tempFile(QDir::tempPath() + "/XXXXXX.tmp");
723+
if (!tempFile.open()) {
724+
qWarning() << "Failed to open temporary file for writing.";
725+
continue;
726+
}
727+
728+
QTextStream stream(&tempFile);
729+
stream.setCodec("UTF-8");
730+
stream << new_list.join("\n") << "\n";
731+
tempFile.flush();
732+
tempFile.close();
733+
734+
// Move the temporary file to the original file
735+
QString tempFilePath = tempFile.fileName();
736+
if (!cmd.runAsRoot("mv " + tempFilePath + " " + configFile)) {
737+
qWarning() << "Failed to move" << tempFilePath << "to" << configFile << ".";
738+
}
739+
}
740+
}
741+
668742
void MainWindow::readGrubCfg()
669743
{
670744
QStringList content;
@@ -759,7 +833,7 @@ void MainWindow::readDefaultGrub()
759833
ui->pushBgFile->setDisabled(themeExists);
760834
} else if (line.startsWith("GRUB_CMDLINE_LINUX_DEFAULT=")) {
761835
QString cmdline = line.remove("GRUB_CMDLINE_LINUX_DEFAULT=").remove("\"").remove("'");
762-
ui->textKernel->setText(cmdline);
836+
ui->textKernel->setText(live ? kernel_options : cmdline);
763837
ui->radioLimitedMsg->setChecked(cmdline.contains("hush"));
764838
ui->radioDetailedMsg->setChecked(cmdline.contains("quiet"));
765839
ui->radioVeryDetailedMsg->setChecked(!cmdline.contains("hush") && !cmdline.contains("quiet"));
@@ -775,14 +849,14 @@ void MainWindow::readDefaultGrub()
775849
}
776850

777851
// Read kernel line and options from /proc/cmdline
778-
void MainWindow::readKernelOpts()
852+
QString MainWindow::readKernelOpts()
779853
{
780854
QFile file("/proc/cmdline");
781855
if (!file.open(QIODevice::ReadOnly)) {
782856
qWarning() << "Failed to open file:" << file.fileName() << "- Error:" << file.errorString();
783-
return;
857+
return {};
784858
}
785-
kernel_options = file.readAll().trimmed();
859+
return file.readAll().trimmed();
786860
}
787861

788862
void MainWindow::cmdStart()
@@ -836,6 +910,9 @@ void MainWindow::pushApply_clicked()
836910

837911
if (kernel_options_changed) {
838912
replaceGrubArg("GRUB_CMDLINE_LINUX_DEFAULT", "\"" + ui->textKernel->text() + "\"");
913+
if (live) {
914+
replaceSyslinuxArg(ui->textKernel->text());
915+
}
839916
}
840917

841918
if (options_changed) {
@@ -907,9 +984,15 @@ void MainWindow::pushApply_clicked()
907984
writeDefaultGrub();
908985
progress->setLabelText(tr("Updating grub..."));
909986
cmd.runAsRoot(chroot + "update-grub");
987+
if (live) {
988+
cmd.runAsRoot("cp /boot/grub/grub.cfg " + boot_location + "/boot/grub/grub.cfg");
989+
}
910990
}
911991
progress->close();
912-
QMessageBox::information(this, tr("Done"), tr("Changes have been successfully applied."));
992+
QString message = live && boot_location == "/live/to-ram"
993+
? tr("You are currently running in live mode with the 'toram' option. Please remember to save the persistence file or remaster, otherwise any changes made will be lost.")
994+
: tr("Your changes have been successfully applied.");
995+
QMessageBox::information(this, tr("Operation Complete"), message);
913996
}
914997

915998
// Reset change flags

mainwindow.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,15 @@ private slots:
8989
bool splash_changed {};
9090
bool live = isLive();
9191

92+
const QString kernel_options {readKernelOpts()};
93+
QString boot_location;
9294
QString chroot;
93-
QString kernel_options;
9495
QString user;
9596
QStringList default_grub;
9697
QStringList grub_cfg;
9798
QTemporaryDir tmpdir;
9899

100+
QString readKernelOpts();
99101
QString selectPartiton(const QStringList &list);
100102
QStringList getLinuxPartitions();
101103
bool inVirtualMachine();
@@ -121,7 +123,7 @@ private slots:
121123
QStringList *bootorder);
122124
void readDefaultGrub();
123125
void readGrubCfg();
124-
void readKernelOpts();
126+
void replaceSyslinuxArg(const QString &args);
125127
void saveBootOrder(const QListWidget *list);
126128
void setGeneralConnections();
127129
void setup();

0 commit comments

Comments
 (0)