From: Simon Ruderich Date: Tue, 26 Apr 2022 05:54:27 +0000 (+0200) Subject: sync: never remove packages during installation on Debian X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=c666d9c0c4e61cb9e007bdcc5bd0be27d652612d;p=safcm%2Fsafcm.git sync: never remove packages during installation on Debian Guard against package conflicts to remove packages. The user must first remove the conflicting package to prevent accidental removals. --- diff --git a/remote/sync/packages_debian.go b/remote/sync/packages_debian.go index a18ab35..8f6b83a 100644 --- a/remote/sync/packages_debian.go +++ b/remote/sync/packages_debian.go @@ -59,6 +59,8 @@ func (s *Sync) syncPackagesDebian() error { // Don't require further acknowledgment; this won't perform // dangerous actions "--assume-yes", + // Never remove any packages + "--no-remove", // Don't perform upgrades "--no-upgrade", // Nobody needs those diff --git a/remote/sync/packages_debian_test.go b/remote/sync/packages_debian_test.go index 6ba31ab..0afe056 100644 --- a/remote/sync/packages_debian_test.go +++ b/remote/sync/packages_debian_test.go @@ -125,6 +125,7 @@ install ok installed package-two "/usr/bin/apt-get", "install", "--assume-yes", + "--no-remove", "--no-upgrade", "--no-install-recommends", "-o", "Dpkg::Options::=--force-confdef", @@ -148,7 +149,7 @@ install ok installed golang-1.16-src install ok installed package-two `, "3: packages: installing package-one package-three", - `4: packages: running "/usr/bin/apt-get" "install" "--assume-yes" "--no-upgrade" "--no-install-recommends" "-o" "Dpkg::Options::=--force-confdef" "-o" "Dpkg::Options::=--force-confold" "package-one" "package-three"`, + `4: packages: running "/usr/bin/apt-get" "install" "--assume-yes" "--no-remove" "--no-upgrade" "--no-install-recommends" "-o" "Dpkg::Options::=--force-confdef" "-o" "Dpkg::Options::=--force-confold" "package-one" "package-three"`, "5: packages: command output:\nfake stdout/stderr", }, safcm.MsgSyncResp{ @@ -201,6 +202,7 @@ install ok installed golang-1.16-src "/usr/bin/apt-get", "install", "--assume-yes", + "--no-remove", "--no-upgrade", "--no-install-recommends", "-o", "Dpkg::Options::=--force-confdef", @@ -223,7 +225,7 @@ install ok installed golang-1.16-go install ok installed golang-1.16-src `, "3: packages: installing package-one package-two", - `4: packages: running "/usr/bin/apt-get" "install" "--assume-yes" "--no-upgrade" "--no-install-recommends" "-o" "Dpkg::Options::=--force-confdef" "-o" "Dpkg::Options::=--force-confold" "package-one" "package-two"`, + `4: packages: running "/usr/bin/apt-get" "install" "--assume-yes" "--no-remove" "--no-upgrade" "--no-install-recommends" "-o" "Dpkg::Options::=--force-confdef" "-o" "Dpkg::Options::=--force-confold" "package-one" "package-two"`, "5: packages: command output:\nfake stdout/stderr", }, safcm.MsgSyncResp{ @@ -236,7 +238,7 @@ install ok installed golang-1.16-src }, }, }, - fmt.Errorf(`"/usr/bin/apt-get" "install" "--assume-yes" "--no-upgrade" "--no-install-recommends" "-o" "Dpkg::Options::=--force-confdef" "-o" "Dpkg::Options::=--force-confold" "package-one" "package-two" failed: fake error; output: "fake stdout/stderr"`), + fmt.Errorf(`"/usr/bin/apt-get" "install" "--assume-yes" "--no-remove" "--no-upgrade" "--no-install-recommends" "-o" "Dpkg::Options::=--force-confdef" "-o" "Dpkg::Options::=--force-confold" "package-one" "package-two" failed: fake error; output: "fake stdout/stderr"`), }, {