[Piuparts-commits] [piuparts] 03/07: p: keep history of 'apt-cache dumpavail | md5sum'

Holger Levsen holger at layer-acht.org
Fri Mar 17 15:43:21 UTC 2017


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch develop
in repository piuparts.

commit 4fe2352cedbda4c787d3fb1799fc57fafe5535a1
Author: Andreas Beckmann <anbe at debian.org>
Date:   Mon Mar 6 00:05:50 2017 +0100

    p: keep history of 'apt-cache dumpavail | md5sum'
    
    helps recognizing if the reference chroot metadata is outdated
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>
    Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
 debian/changelog |  3 +++
 piuparts.py      | 16 ++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index f93fbc4..1b61952 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,9 @@ piuparts (0.77) UNRELEASED; urgency=medium
       packages.
     - Only warn on broken symlinks found between installing the dependencies
       of the package to be tested and installing the package itself.
+    - Keep track of md5sums of the list of available packages in the chroot
+      to recognize mirror pushes during distupgrade tests and outdated
+      --end-meta meta-data.
   * piupartslib/packagesdb.py:
     - Add new state "outdated" to ignore packages if a dependency distro
       already has a newer version.  (Closes: #856846)
diff --git a/piuparts.py b/piuparts.py
index 76ec2a0..bd833c6 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -748,6 +748,7 @@ class Chroot:
         self.name = None
         self.bootstrapped = False
         self.mounts = []
+        self.avail_md5_history = []
 
     def create_temp_dir(self):
         """Create a temporary directory for the chroot."""
@@ -799,6 +800,7 @@ class Chroot:
         if settings.basetgz or settings.schroot or settings.existing_chroot:
             self.run(["apt-get", "-yf", "dist-upgrade"])
         self.minimize()
+        self.remember_available_md5()
 
         # Run custom scripts after creating the chroot.
         self.run_scripts("post_setup")
@@ -1086,6 +1088,13 @@ class Chroot:
             self.mount(bindmount, bindmount, opts="bind")
         self.run(["apt-get", "update"])
 
+    def remember_available_md5(self):
+        """Keep a history of 'apt-cache dumpavail | md5sum' after initial
+           setup and each dist-upgrade step to notice outdated reference
+           chroot metadata"""
+        errorcode, avail_md5 = self.run(["sh", "-c", "apt-cache dumpavail | md5sum"])
+        self.avail_md5_history.append(avail_md5.split()[0])
+
     def upgrade_to_distros(self, distros, packages):
         """Upgrade a chroot installation to each successive distro."""
         for distro in distros:
@@ -1096,6 +1105,7 @@ class Chroot:
             self.run_scripts("pre_distupgrade")
             self.run(["apt-get", "update"])
             self.run(["apt-get", "-yf", "dist-upgrade"])
+            self.remember_available_md5()
             os.environ["PIUPARTS_DISTRIBUTION_PREV"] = os.environ["PIUPARTS_DISTRIBUTION"]
             os.environ["PIUPARTS_DISTRIBUTION"] = settings.distro_config.get_distribution(distro)
             # Sometimes dist-upgrade won't upgrade the packages we want
@@ -1426,6 +1436,11 @@ class Chroot:
         """Restore package selections in a chroot to the state in
         'reference_chroot_state'."""
 
+        if reference_chroot_state["avail_md5"] != self.avail_md5_history:
+            logging.warn("History of available packages does not match - reference chroot may be outdated")
+            logging.debug(" reference: %s" % " ".join(reference_chroot_state["avail_md5"]))
+            logging.debug(" current  : %s" % " ".join(self.avail_md5_history))
+
         selections = reference_chroot_state["selections"]
         packages = unqualify(packages_qualified)
 
@@ -1548,6 +1563,7 @@ class Chroot:
 
     def get_state_meta_data(self):
         chroot_state = {}
+        chroot_state["avail_md5"] = self.avail_md5_history
         chroot_state["tree"] = self.get_tree_meta_data()
         chroot_state["selections"] = self.get_selections()
         chroot_state["diversions"] = self.get_diversions()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git



More information about the Piuparts-commits mailing list