control: tag -1 +patch

This seems to work!

-- 
Sean Whitton
From f83804fe15c5aea48d3e1cea78123e1fe5939ff5 Mon Sep 17 00:00:00 2001
From: Sean Whitton <spwhit...@spwhitton.name>
Date: Thu, 2 Jun 2016 16:48:19 +0900
Subject: [PATCH] use apt-get install ./foo.deb

---
 debian/changelog |  6 ++++--
 piuparts.py      | 29 +++++++++++++++--------------
 2 files changed, 19 insertions(+), 16 deletions(-)
 mode change 100644 => 100755 piuparts.py

diff --git a/debian/changelog b/debian/changelog
index 01d853f..a802991 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,10 @@
 piuparts (0.72) UNRELEASED; urgency=medium
 
-  * continue developmentā€¦ 
+  * piuparts.py : use `apt-get -y install ./tmp/foo.deb' instead of `dpkg
+    -i ./tmp/foo.deb && apt-get install -yf' for more reliable dependency
+    resolution.  (Closes: #825487)
 
- -- Holger Levsen <hol...@debian.org>  Thu, 05 May 2016 14:04:29 +0200
+ -- Sean Whitton <spwhit...@spwhitton.name>  Thu, 02 Jun 2016 16:04:15 +0900
 
 piuparts (0.71) unstable; urgency=medium
 
diff --git a/piuparts.py b/piuparts.py
old mode 100644
new mode 100755
index 4be1130..2cdd7fc
--- a/piuparts.py
+++ b/piuparts.py
@@ -1161,12 +1161,19 @@ class Chroot:
         if package_files:
             self.copy_files(package_files, "tmp")
             tmp_files = [os.path.basename(a) for a in package_files]
-            tmp_files = [os.path.join("tmp", name) for name in tmp_files]
+            # to use apt-get install we need the './' or apt-get can't
+            # distinguish between a request to install a deb in a
+            # subdir from a request to install a package from a
+            # particular suite
+            tmp_files = [os.path.join("./tmp", name) for name in tmp_files]
 
             if with_scripts:
                 self.run_scripts("pre_install")
 
-            apt_get_install = ["apt-get", "-yf"]
+            # we need to pass --allow-downgrades because installing a
+            # deb with the same version as the version currently
+            # installed (i.e. reinstalling it) counts as a downgrade
+            apt_get_install = ["apt-get", "-y", "--allow-downgrades"]
             apt_get_install.extend(settings.distro_config.get_target_flags(
                 os.environ["PIUPARTS_DISTRIBUTION"]))
             apt_get_install.append("install")
@@ -1174,18 +1181,12 @@ class Chroot:
             if settings.list_installed_files:
                 pre_info = self.save_meta_data()
 
-            (ret, out) = self.run(["dpkg", "-i"] + tmp_files, ignore_errors=True)
-            if ret != 0:
-                if "dependency problems - leaving unconfigured" in out:
-                    pass
-                else:
-                    logging.error("Installation failed")
-                    panic()
-
-            if settings.list_installed_files:
-                self.list_installed_files(pre_info, self.save_meta_data())
-
-            self.run(apt_get_install)
+            # use `apt-get install foo.deb` rather than `dpkg -i
+            # foo.deb && apt-get install -yf` to avoid failures due to
+            # apt's dependency resolution deciding to remove the
+            # package we just installed.  See comments from apt
+            # maintainers in #825467
+            self.run(apt_get_install + tmp_files)
 
             if settings.list_installed_files:
                 self.list_installed_files(pre_info, self.save_meta_data())
-- 
2.8.1

Attachment: signature.asc
Description: PGP signature

Reply via email to