Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Add package validation guard and make pacman idempotent

Andras Bacsai089007919d22
diff --git a/app/Actions/Server/InstallDocker.php b/app/Actions/Server/InstallDocker.php
index 55a643e838..7e0ad81989 100644
--- a/app/Actions/Server/InstallDocker.php
+++ b/app/Actions/Server/InstallDocker.php
@@ -158,7 +158,8 @@ class InstallDocker
// Use -Syu to perform full system upgrade before installing Docker
// Partial upgrades (-Sy without -u) are discouraged on Arch Linux
// as they can lead to broken dependencies and system instability
- return 'pacman -Syu --noconfirm docker docker-compose && '.
+ // Use --needed to skip reinstalling packages that are already up-to-date (idempotent)
+ return 'pacman -Syu --noconfirm --needed docker docker-compose && '.
'systemctl enable docker.service && '.
'systemctl start docker.service';
}
diff --git a/app/Actions/Server/UpdatePackage.php b/app/Actions/Server/UpdatePackage.php
index 8b81377ee9..ab0ca94943 100644
--- a/app/Actions/Server/UpdatePackage.php
+++ b/app/Actions/Server/UpdatePackage.php
@@ -21,6 +21,13 @@ class UpdatePackage
];
}
+ // Validate that package name is provided when not updating all packages
+ if (! $all && ($package === null || $package === '')) {
+ return [
+ 'error' => "Package name required when 'all' is false.",
+ ];
+ }
+
// Sanitize package name to prevent command injection
// Only allow alphanumeric characters, hyphens, underscores, periods, plus signs, and colons
// These are valid characters in package names across most package managers