fix(build): cmake
This commit is contained in:
1 parent
1242753962
commit
4a773c63ce
17 files changed
+80
-75
No files matched your search
@@ -3,6 +3,6 @@ target_include_directories(apt_plugin PRIVATE ${CMAKE_SOURCE_DIR}/include)
|
||||
set_target_properties(apt_plugin PROPERTIES
|
||||
PREFIX ""
|
||||
OUTPUT_NAME "apt"
|
||||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/PackageMapper/plugins"
|
||||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/PacManager/plugins"
|
||||
)
|
||||
install(TARGETS apt_plugin DESTINATION lib/PackageMapper/plugins)
|
||||
install(TARGETS apt_plugin DESTINATION lib/PacManager/plugins)
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
std::function<void(const std::string&)> progressCallback) override {
|
||||
if (progressCallback) progressCallback("Installation de " + packageName + "...");
|
||||
|
||||
std::string output = exec(("sudo apt install -y " + packageName + " 2>&1").c_str());
|
||||
std::string output = exec(("pkexec apt install -y " + packageName + " 2>&1").c_str());
|
||||
|
||||
if (progressCallback) {
|
||||
std::istringstream iss(output);
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
std::function<void(const std::string&)> progressCallback) override {
|
||||
if (progressCallback) progressCallback("Suppression de " + packageName + "...");
|
||||
|
||||
std::string output = exec(("sudo apt remove -y " + packageName + " 2>&1").c_str());
|
||||
std::string output = exec(("pkexec apt remove -y " + packageName + " 2>&1").c_str());
|
||||
|
||||
if (progressCallback) {
|
||||
std::istringstream iss(output);
|
||||
@@ -97,12 +97,12 @@ public:
|
||||
std::function<void(const std::string&)> progressCallback = nullptr) override {
|
||||
if (packageName.empty()) {
|
||||
if (progressCallback) progressCallback("Mise à jour des paquets...");
|
||||
exec("sudo apt update 2>&1");
|
||||
exec("sudo apt upgrade -y 2>&1");
|
||||
exec("pkexec apt update 2>&1");
|
||||
exec("pkexec apt upgrade -y 2>&1");
|
||||
return true;
|
||||
} else {
|
||||
if (progressCallback) progressCallback("Mise à jour de " + packageName + "...");
|
||||
exec(("sudo apt install --only-upgrade -y " + packageName + " 2>&1").c_str());
|
||||
exec(("pkexec apt install --only-upgrade -y " + packageName + " 2>&1").c_str());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@ target_include_directories(pacman_plugin PRIVATE ${CMAKE_SOURCE_DIR}/include)
|
||||
set_target_properties(pacman_plugin PROPERTIES
|
||||
PREFIX ""
|
||||
OUTPUT_NAME "pacman"
|
||||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/PackageMapper/plugins"
|
||||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/PacManager/plugins"
|
||||
)
|
||||
install(TARGETS pacman_plugin DESTINATION lib/PackageMapper/plugins)
|
||||
install(TARGETS pacman_plugin DESTINATION lib/PacManager/plugins)
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
std::function<void(const std::string&)> progressCallback) override {
|
||||
if (progressCallback) progressCallback("Installation de " + packageName + "...");
|
||||
|
||||
std::string cmd = "sudo pacman -S --noconfirm " + packageName + " 2>&1";
|
||||
std::string cmd = "pkexec pacman -S --noconfirm " + packageName + " 2>&1";
|
||||
std::string output = exec(cmd.c_str());
|
||||
|
||||
if (progressCallback) {
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
std::function<void(const std::string&)> progressCallback) override {
|
||||
if (progressCallback) progressCallback("Suppression de " + packageName + "...");
|
||||
|
||||
std::string cmd = "sudo pacman -R --noconfirm " + packageName + " 2>&1";
|
||||
std::string cmd = "pkexec pacman -R --noconfirm " + packageName + " 2>&1";
|
||||
std::string output = exec(cmd.c_str());
|
||||
|
||||
if (progressCallback) {
|
||||
@@ -125,12 +125,12 @@ public:
|
||||
std::function<void(const std::string&)> progressCallback = nullptr) override {
|
||||
if (packageName.empty()) {
|
||||
if (progressCallback) progressCallback("Mise à jour de tous les paquets...");
|
||||
std::string cmd = "sudo pacman -Syu --noconfirm 2>&1";
|
||||
std::string cmd = "pkexec pacman -Syu --noconfirm 2>&1";
|
||||
exec(cmd.c_str());
|
||||
return true;
|
||||
} else {
|
||||
if (progressCallback) progressCallback("Mise à jour de " + packageName + "...");
|
||||
std::string cmd = "sudo pacman -S --noconfirm " + packageName + " 2>&1";
|
||||
std::string cmd = "pkexec pacman -S --noconfirm " + packageName + " 2>&1";
|
||||
exec(cmd.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@ target_include_directories(pkg_plugin PRIVATE ${CMAKE_SOURCE_DIR}/include)
|
||||
set_target_properties(pkg_plugin PROPERTIES
|
||||
PREFIX ""
|
||||
OUTPUT_NAME "pkg"
|
||||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/PackageMapper/plugins"
|
||||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/PacManager/plugins"
|
||||
)
|
||||
install(TARGETS pkg_plugin DESTINATION lib/PackageMapper/plugins)
|
||||
install(TARGETS pkg_plugin DESTINATION lib/PacManager/plugins)
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
std::function<void(const std::string&)> progressCallback) override {
|
||||
if (progressCallback) progressCallback("Installation de " + packageName + "...");
|
||||
|
||||
std::string output = exec(("sudo pkg install -y " + packageName + " 2>&1").c_str());
|
||||
std::string output = exec(("pkexec pkg install -y " + packageName + " 2>&1").c_str());
|
||||
|
||||
if (progressCallback) {
|
||||
std::istringstream iss(output);
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
std::function<void(const std::string&)> progressCallback) override {
|
||||
if (progressCallback) progressCallback("Suppression de " + packageName + "...");
|
||||
|
||||
std::string output = exec(("sudo pkg delete -y " + packageName + " 2>&1").c_str());
|
||||
std::string output = exec(("pkexec pkg delete -y " + packageName + " 2>&1").c_str());
|
||||
|
||||
if (progressCallback) {
|
||||
std::istringstream iss(output);
|
||||
@@ -100,11 +100,11 @@ public:
|
||||
std::function<void(const std::string&)> progressCallback = nullptr) override {
|
||||
if (packageName.empty()) {
|
||||
if (progressCallback) progressCallback("Mise à jour de tous les paquets...");
|
||||
exec("sudo pkg upgrade -y 2>&1");
|
||||
exec("pkexec pkg upgrade -y 2>&1");
|
||||
return true;
|
||||
} else {
|
||||
if (progressCallback) progressCallback("Mise à jour de " + packageName + "...");
|
||||
exec(("sudo pkg install -y " + packageName + " 2>&1").c_str());
|
||||
exec(("pkexec pkg install -y " + packageName + " 2>&1").c_str());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@ target_include_directories(universal_plugin PRIVATE ${CMAKE_SOURCE_DIR}/include)
|
||||
set_target_properties(universal_plugin PROPERTIES
|
||||
PREFIX ""
|
||||
OUTPUT_NAME "universal"
|
||||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/PackageMapper/plugins"
|
||||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/PacManager/plugins"
|
||||
)
|
||||
install(TARGETS universal_plugin DESTINATION lib/PackageMapper/plugins)
|
||||
install(TARGETS universal_plugin DESTINATION lib/PacManager/plugins)
|
||||
@@ -227,7 +227,7 @@ public:
|
||||
for (auto& mgr : m_managers) {
|
||||
if (!mgr.available) continue;
|
||||
if (progressCallback) progressCallback("🔄 Mise à jour via " + mgr.name + "...");
|
||||
std::string cmd = "sudo " + mgr.updateCmd + " 2>&1";
|
||||
std::string cmd = "pkexec sh -c \"" + mgr.updateCmd + "\" 2>&1";
|
||||
exec(cmd.c_str());
|
||||
}
|
||||
// Flatpak
|
||||
@@ -238,7 +238,7 @@ public:
|
||||
// Snap
|
||||
if (m_hasSnap) {
|
||||
if (progressCallback) progressCallback("🔄 Mise à jour Snap...");
|
||||
exec("sudo snap refresh 2>&1");
|
||||
exec("pkexec snap refresh 2>&1");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
if (!mgr.available) continue;
|
||||
if (isInstalledWithManager(mgr, packageName)) {
|
||||
if (progressCallback) progressCallback("🔄 Mise à jour via " + mgr.name + "...");
|
||||
std::string cmd = "sudo " + mgr.installCmd + " " + packageName + " 2>&1";
|
||||
std::string cmd = "pkexec sh -c \"" + mgr.installCmd + " " + packageName + "\" 2>&1";
|
||||
exec(cmd.c_str());
|
||||
return true;
|
||||
}
|
||||
@@ -410,7 +410,14 @@ private:
|
||||
// Parse common formats: "name version - description" or "name version description"
|
||||
size_t spacePos = line.find(' ');
|
||||
if (spacePos != std::string::npos) {
|
||||
pkg.name = line.substr(0, spacePos);
|
||||
// Strip repository prefix (e.g. "extra/vlc" -> "vlc")
|
||||
std::string firstToken = line.substr(0, spacePos);
|
||||
size_t slashPos = firstToken.find('/');
|
||||
if (slashPos != std::string::npos) {
|
||||
pkg.name = firstToken.substr(slashPos + 1);
|
||||
} else {
|
||||
pkg.name = firstToken;
|
||||
}
|
||||
size_t nextSpace = line.find(' ', spacePos + 1);
|
||||
if (nextSpace != std::string::npos) {
|
||||
pkg.version = line.substr(spacePos + 1, nextSpace - spacePos - 1);
|
||||
@@ -430,7 +437,7 @@ private:
|
||||
|
||||
bool installWithManager(const DetectedManager& mgr, const std::string& pkg,
|
||||
std::function<void(const std::string&)> progressCallback) {
|
||||
std::string cmd = "sudo " + mgr.installCmd + " " + pkg + " 2>&1";
|
||||
std::string cmd = "pkexec sh -c \"" + mgr.installCmd + " " + pkg + "\" 2>&1";
|
||||
std::string output = exec(cmd.c_str());
|
||||
if (progressCallback) {
|
||||
std::istringstream iss(output);
|
||||
@@ -444,7 +451,7 @@ private:
|
||||
|
||||
bool removeWithManager(const DetectedManager& mgr, const std::string& pkg,
|
||||
std::function<void(const std::string&)> progressCallback) {
|
||||
std::string cmd = "sudo " + mgr.removeCmd + " " + pkg + " 2>&1";
|
||||
std::string cmd = "pkexec sh -c \"" + mgr.removeCmd + " " + pkg + "\" 2>&1";
|
||||
exec(cmd.c_str());
|
||||
return !isInstalledWithManager(mgr, pkg);
|
||||
}
|
||||
@@ -497,13 +504,19 @@ private:
|
||||
PackageInfo pkg;
|
||||
size_t tabPos = line.find('\t');
|
||||
if (tabPos != std::string::npos) {
|
||||
pkg.name = line.substr(0, tabPos);
|
||||
size_t nextTab = line.find('\t', tabPos + 1);
|
||||
if (nextTab != std::string::npos) {
|
||||
pkg.description = line.substr(tabPos + 1, nextTab - tabPos - 1);
|
||||
// Columns: Name, Description, Application ID, Version, Branch, Remote
|
||||
size_t descTab = line.find('\t', tabPos + 1);
|
||||
size_t idTab = line.find('\t', descTab + 1);
|
||||
if (descTab != std::string::npos && idTab != std::string::npos) {
|
||||
pkg.description = line.substr(tabPos + 1, descTab - tabPos - 1);
|
||||
pkg.name = line.substr(descTab + 1, idTab - descTab - 1); // App ID
|
||||
} else {
|
||||
pkg.name = line.substr(0, tabPos);
|
||||
}
|
||||
pkg.installed = isFlatpakInstalled(pkg.name);
|
||||
results.push_back(pkg);
|
||||
if (!pkg.name.empty()) {
|
||||
results.push_back(pkg);
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
@@ -583,14 +596,14 @@ private:
|
||||
bool installSnap(const std::string& pkg,
|
||||
std::function<void(const std::string&)> progressCallback) {
|
||||
if (progressCallback) progressCallback("📦 Installation Snap: " + pkg + "...");
|
||||
exec(("sudo snap install " + pkg + " 2>&1").c_str());
|
||||
exec(("pkexec snap install " + pkg + " 2>&1").c_str());
|
||||
return isSnapInstalled(pkg);
|
||||
}
|
||||
|
||||
bool removeSnap(const std::string& pkg,
|
||||
std::function<void(const std::string&)> progressCallback) {
|
||||
if (progressCallback) progressCallback("🗑️ Suppression Snap: " + pkg + "...");
|
||||
exec(("sudo snap remove " + pkg + " 2>&1").c_str());
|
||||
exec(("pkexec snap remove " + pkg + " 2>&1").c_str());
|
||||
return !isSnapInstalled(pkg);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user