]> ruderich.org/simon Gitweb - safcm/safcm.git/commitdiff
sync: never remove packages during installation on Debian
authorSimon Ruderich <simon@ruderich.org>
Tue, 26 Apr 2022 05:54:27 +0000 (07:54 +0200)
committerSimon Ruderich <simon@ruderich.org>
Tue, 26 Apr 2022 05:54:27 +0000 (07:54 +0200)
Guard against package conflicts to remove packages. The user must first
remove the conflicting package to prevent accidental removals.

remote/sync/packages_debian.go
remote/sync/packages_debian_test.go

index a18ab35d020e4f74baab07edeb7c07d4cbf327d6..8f6b83ac31a04b1b182779e80456b94ec026a213 100644 (file)
@@ -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
index 6ba31ab69d9b36a3e622d66da5902a0087ce9ebc..0afe0567daa4fa5075c82eab8ae97300d0220683 100644 (file)
@@ -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"`),
                },
 
                {