Skip to content

Commit acc639a

Browse files
committed
fixed chaotic-setup button
1 parent 948a2c9 commit acc639a

File tree

1 file changed

+45
-15
lines changed

1 file changed

+45
-15
lines changed

src/gui/settings_widget.cpp

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -945,27 +945,49 @@ void SettingsWidget::onSetupChaoticClicked() {
945945
msgBox.setWindowTitle("Setup Chaotic-AUR");
946946
msgBox.setText("Install Chaotic-AUR repository?");
947947
msgBox.setInformativeText(
948-
"This will install:\n"
949-
"chaotic-keyring\n"
950-
"• chaotic-mirrorlist\n\n"
951-
"These packages are required to use the Chaotic-AUR repository.\n"
952-
"You may need to manually add the repository to /etc/pacman.conf if not already configured.");
948+
"This will:\n"
949+
"1. Download chaotic-keyring and chaotic-mirrorlist packages\n"
950+
"2. Install them using pacman\n"
951+
"3. Add the repository to /etc/pacman.conf\n\n"
952+
"This requires internet connection and administrator privileges.");
953953
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
954954
msgBox.setDefaultButton(QMessageBox::Yes);
955955

956956
if (msgBox.exec() != QMessageBox::Yes) {
957957
return;
958958
}
959959

960-
m_statusLabel->setText("Installing Chaotic-AUR packages...");
960+
m_statusLabel->setText("Setting up Chaotic-AUR repository...");
961961
m_statusLabel->setStyleSheet("QLabel { color: #0066cc; padding: 10px; }");
962962
m_statusLabel->show();
963963
m_setupChaoticButton->setEnabled(false);
964964

965-
// Install chaotic-keyring and chaotic-mirrorlist
965+
// Use a shell script to download and install chaotic-aur packages
966+
// This follows the official installation guide from aur.chaotic.cx
967+
QString script =
968+
"cd /tmp && "
969+
"rm -f chaotic-keyring.pkg.tar.zst chaotic-mirrorlist.pkg.tar.zst && "
970+
"curl -L -O https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst && "
971+
"curl -L -O https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst && "
972+
"pacman -U --noconfirm chaotic-keyring.pkg.tar.zst chaotic-mirrorlist.pkg.tar.zst";
973+
966974
QProcess* process = new QProcess(this);
975+
976+
// Capture both stdout and stderr for debugging
977+
process->setProcessChannelMode(QProcess::MergedChannels);
978+
967979
connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
968980
this, [this, process](int exitCode, QProcess::ExitStatus exitStatus) {
981+
QString output = process->readAll();
982+
983+
Logger::info(QString("Chaotic-AUR setup exit code: %1, status: %2")
984+
.arg(exitCode)
985+
.arg(exitStatus == QProcess::NormalExit ? "Normal" : "Crashed"));
986+
987+
if (!output.isEmpty()) {
988+
Logger::debug(QString("Chaotic-AUR setup output:\n%1").arg(output));
989+
}
990+
969991
process->deleteLater();
970992
m_setupChaoticButton->setEnabled(true);
971993

@@ -980,23 +1002,31 @@ void SettingsWidget::onSetupChaoticClicked() {
9801002

9811003
QMessageBox::information(this, "Success",
9821004
"Chaotic-AUR packages installed successfully!\n\n"
983-
"If the repository is not yet configured, you may need to add it to /etc/pacman.conf:\n\n"
984-
"[chaotic-aur]\n"
985-
"Include = /etc/pacman.d/chaotic-mirrorlist");
1005+
"You can now enable the Chaotic-AUR repository using the checkbox above.\n"
1006+
"After enabling, remember to sync the package databases.");
9861007
} else {
9871008
m_statusLabel->setText("Failed to install Chaotic-AUR packages.");
9881009
m_statusLabel->setStyleSheet("QLabel { color: #aa0000; padding: 10px; }");
9891010
m_statusLabel->show();
990-
Logger::error("Failed to install Chaotic-AUR packages");
1011+
Logger::error(QString("Failed to install Chaotic-AUR packages. Exit code: %1").arg(exitCode));
1012+
1013+
// Show output in error message if available
1014+
QString errorDetails = "Possible reasons:\n"
1015+
"• No internet connection\n"
1016+
"• Download failed\n"
1017+
"• Installation cancelled\n"
1018+
"• User denied authentication\n\n";
1019+
1020+
if (!output.isEmpty() && output.length() < 500) {
1021+
errorDetails += "Error output:\n" + output;
1022+
}
9911023

9921024
QMessageBox::critical(this, "Error",
993-
"Failed to install Chaotic-AUR packages.\n"
994-
"Please check the logs for details.");
1025+
"Failed to install Chaotic-AUR packages.\n\n" + errorDetails);
9951026
}
9961027
});
9971028

998-
process->start("pkexec", QStringList() << "pacman" << "-S" << "--noconfirm"
999-
<< "chaotic-keyring" << "chaotic-mirrorlist");
1029+
process->start("pkexec", QStringList() << "bash" << "-c" << script);
10001030
}
10011031

10021032
void SettingsWidget::onRemoveChaoticClicked() {

0 commit comments

Comments
 (0)