summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2023-10-29 00:49:49 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2023-10-29 01:45:48 -0500
commit10318dee4e944cbf7ac59d805c3397a7df456a29 (patch)
tree585cfc3807a73f7ea78022717616eb5c73c7b6dd
parent9cfc93630d065e38a0ab09faf29489da64c44d2d (diff)
downloadhorizon-10318dee4e944cbf7ac59d805c3397a7df456a29.tar.gz
horizon-10318dee4e944cbf7ac59d805c3397a7df456a29.tar.bz2
horizon-10318dee4e944cbf7ac59d805c3397a7df456a29.tar.xz
horizon-10318dee4e944cbf7ac59d805c3397a7df456a29.zip
Qt UI: Code quality improvements
* Implement some clang-tidy and clazy suggestions. * Use the default signingkey options based on the architecture instead of hard-coding it in the wizard *and* hscript/script_v.cc.
-rw-r--r--ui/qt5/horizonwizard.cc47
-rw-r--r--ui/qt5/horizonwizard.hh2
2 files changed, 18 insertions, 31 deletions
diff --git a/ui/qt5/horizonwizard.cc b/ui/qt5/horizonwizard.cc
index 623a491..e78d991 100644
--- a/ui/qt5/horizonwizard.cc
+++ b/ui/qt5/horizonwizard.cc
@@ -64,7 +64,7 @@ extern "C" {
#include "util/keymaps.hh"
-static std::map<int, std::string> help_id_map = {
+static const std::map<int, std::string> help_id_map = {
{HorizonWizard::Page_Intro, "intro"},
{HorizonWizard::Page_Input, "input"},
#ifdef NON_LIBRE_FIRMWARE
@@ -213,23 +213,19 @@ HorizonWizard::Subarch determinePowerPCPlatform() {
#endif
-HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent) {
+HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent), arch{UnknownCPU}, subarch{NoSubarch},
+ grub{true}, eudev{true}, binsh{Dash}, sbininit{S6} {
setWindowTitle(tr("Adélie Linux System Installation"));
setFixedSize(QSize(650, 512));
mirror_domain = "distfiles.adelielinux.org";
version = "stable";
- subarch = NoSubarch;
/* handwavy-future:
* Determine which platform kernel is being used, if any (-power8 etc)
* Determine hardware requirements (easy or mainline)
*/
- grub = true;
kernel = "easy-kernel";
- binsh = Dash;
- sbininit = S6;
- eudev = true;
ipv4.use = false;
ipv6.use = false;
@@ -272,7 +268,7 @@ HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent) {
setPage(Page_Commit, new CommitPage);
#endif /* !HAS_INSTALL_ENV */
- QObject::connect(this, &QWizard::helpRequested, [=]() {
+ QObject::connect(this, &QWizard::helpRequested, [this]() {
if(help_id_map.find(currentId()) == help_id_map.end()) {
qDebug() << "no help available for " << currentId();
QMessageBox nohelp(QMessageBox::Warning,
@@ -285,8 +281,8 @@ HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent) {
nohelp.exec();
return;
}
- std::string helppath = ":/wizard_help/resources/" +
- help_id_map.at(currentId()) + "-help.txt";
+ const std::string helppath = ":/wizard_help/resources/" +
+ help_id_map.at(currentId()) + "-help.txt";
QFile helpfile(helppath.c_str());
helpfile.open(QFile::ReadOnly);
HorizonHelpWindow help(&helpfile, this);
@@ -370,8 +366,6 @@ on an unknown architecture. Please add a definition to horizonwizard.hh, a \
setting in this preprocessor block, and a case statement for the automatic \
partitioner to continue. You may also wish to add an option to archpage.cc.
# endif
-#else /* !HAS_INSTALL_ENV */
- arch = UnknownCPU;
#endif /* HAS_INSTALL_ENV */
}
@@ -398,7 +392,7 @@ char *encrypt_pw(const char *the_pw) {
/*! Determine the node name of a given partition. */
QString nameForPartitionOnDisk(const std::string &dev, int part) {
const std::string maybe_p(::isdigit(dev[dev.size() - 1]) ? "p" : "");
- std::string raw_root = dev + maybe_p + std::to_string(part);
+ const auto raw_root = dev + maybe_p + std::to_string(part);
return QString::fromStdString(raw_root);
}
@@ -407,7 +401,7 @@ QString nameForPartitionOnDisk(const std::string &dev, int part) {
QStringList eraseDiskForArch(const std::string &raw_disk,
HorizonWizard::Arch arch,
HorizonWizard::Subarch subarch) {
- QString disk = QString::fromStdString(raw_disk);
+ const auto disk = QString::fromStdString(raw_disk);
switch(arch) {
case HorizonWizard::aarch64:/* 64-bit ARM mostly uses GPT */
@@ -437,7 +431,7 @@ QStringList eraseDiskForArch(const std::string &raw_disk,
/*! Determine the correct boot disk layout based on the target platform. */
QStringList bootForArch(const std::string &raw_disk, HorizonWizard::Arch arch,
HorizonWizard::Subarch subarch, int *start) {
- QString disk = QString::fromStdString(raw_disk);
+ const auto disk = QString::fromStdString(raw_disk);
switch(arch) {
case HorizonWizard::aarch64:/* 64-bit ARM: assume UEFI */
@@ -556,37 +550,24 @@ QString HorizonWizard::toHScript() {
switch(arch) {
case aarch64:
lines << "arch aarch64";
- lines << "signingkey https://distfiles.adelielinux.org/adelie/keys/aarch64/aarch64-1@packages.adelielinux.org.pub";
- lines << "signingkey https://distfiles.adelielinux.org/adelie/keys/aarch64/aarch64-2@packages.adelielinux.org.pub";
break;
case armv7:
lines << "arch armv7";
- lines << "signingkey https://distfiles.adelielinux.org/adelie/keys/armv7/armv7-1@packages.adelielinux.org.pub";
- lines << "signingkey https://distfiles.adelielinux.org/adelie/keys/armv7/armv7-2@packages.adelielinux.org.pub";
break;
case pmmx:
lines << "arch pmmx";
- lines << "signingkey https://distfiles.adelielinux.org/adelie/keys/pmmx/pmmx-1@packages.adelielinux.org.pub";
- lines << "signingkey https://distfiles.adelielinux.org/adelie/keys/pmmx/pmmx-2@packages.adelielinux.org.pub";
break;
case ppc:
lines << "arch ppc";
- lines << "signingkey https://distfiles.adelielinux.org/adelie/keys/ppc/ppc-1@packages.adelielinux.org.pub";
- lines << "signingkey https://distfiles.adelielinux.org/adelie/keys/ppc/ppc-2@packages.adelielinux.org.pub";
break;
case ppc64:
lines << "arch ppc64";
- lines << "signingkey https://distfiles.adelielinux.org/adelie/keys/ppc64/ppc64-1@packages.adelielinux.org.pub";
- lines << "signingkey https://distfiles.adelielinux.org/adelie/keys/ppc64/ppc64-2@packages.adelielinux.org.pub";
break;
case x86_64:
lines << "arch x86_64";
- lines << "signingkey https://distfiles.adelielinux.org/adelie/keys/x86_64/x86_64-1@packages.adelielinux.org.pub";
- lines << "signingkey https://distfiles.adelielinux.org/adelie/keys/x86_64/x86_64-2@packages.adelielinux.org.pub";
break;
case mips64:
lines << "arch mips64";
- /* XXX: MIPS signing keys are needed before we ship anything. */
break;
case mips:
lines << "arch mips";
@@ -602,6 +583,12 @@ QString HorizonWizard::toHScript() {
break;
}
+ if(!signing_keys.empty()) {
+ for(const auto &key : signing_keys) {
+ lines << QString{"signingkey %1"}.arg(key);
+ }
+ }
+
part_lines << (dynamic_cast<PartitionMountPage *>(page(Page_PartitionMount)))->mountLines();
if(chosen_disk.empty()) {
@@ -637,7 +624,7 @@ QString HorizonWizard::toHScript() {
/* Create the root partition */
lines << QString{"partition %1 %2 fill"}
.arg(QString::fromStdString(chosen_disk)).arg(start);
- QString root_part = nameForPartitionOnDisk(chosen_disk, start);
+ const auto root_part = nameForPartitionOnDisk(chosen_disk, start);
lines << QString{"fs %1 ext4"}.arg(root_part);
lines << QString{"mount %1 /"}.arg(root_part);
}
@@ -727,8 +714,6 @@ QString HorizonWizard::toHScript() {
#ifdef NON_LIBRE_FIRMWARE
if(this->firmware) {
lines << "firmware true";
- lines << "signingkey https://distfiles.adelielinux.org/adelie/keys/packages@pleroma.apkfission.net-5ac0b300.rsa.pub";
- lines << "signingkey https://distfiles.adelielinux.org/adelie/keys/packages@pleroma.apkfission.net-5ac04808.rsa.pub";
} else {
lines << "firmware false";
}
diff --git a/ui/qt5/horizonwizard.hh b/ui/qt5/horizonwizard.hh
index b39287c..d4a5dfd 100644
--- a/ui/qt5/horizonwizard.hh
+++ b/ui/qt5/horizonwizard.hh
@@ -153,6 +153,8 @@ public:
std::string mirror_domain;
/*! The version of Adélie to install. Typically "1.0". */
std::string version;
+ /*! The signing keys to use. If empty, use defaults. */
+ QStringList signing_keys;
/*! The architecture being installed. */
Arch arch;
/*! If relevant, the subtype of the architecture being installed. */