[Piuparts-commits] [piuparts] 07/07: p: new option --upgrade-before-distupgrade for two-stage upgrades

Holger Levsen holger at layer-acht.org
Mon Jun 12 11:55:09 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 af03869b9fa8bd1aa39c4c494e73f2aa1b10d7ad
Author: Andreas Beckmann <anbe at debian.org>
Date:   Mon Jun 12 12:58:31 2017 +0200

    p: new option --upgrade-before-distupgrade for two-stage upgrades
    
    note the spelling discrepancy between apt ("dist-upgrade") and
    piuparts ("distupgrade")
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>
    Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
 debian/changelog |  2 ++
 piuparts.1.txt   |  3 +++
 piuparts.py      | 14 +++++++++++---
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index c81a6e7..952539a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -19,6 +19,8 @@ piuparts (0.78) UNRELEASED; urgency=medium
     - Arguments to the --ignore/--ignore-regexp options (and internal
       ignored_files/ignored_patterns settings) that are prefixed with a ':'
       will verbosely log the ignored files if matched.
+    - New option --upgrade-before-distupgrade for 2-stage upgrades:
+      'apt-get upgrade && apt-get dist-upgrade'.
   * piuparts.conf: Use more aliases for mapping between releases and codenames
     to reduce the amount of changes needed on "moving targets" (like
     stable22sid) after a stable Debian release.
diff --git a/piuparts.1.txt b/piuparts.1.txt
index a68e151..a0c34f8 100644
--- a/piuparts.1.txt
+++ b/piuparts.1.txt
@@ -281,6 +281,9 @@ Note that file: addresses works if the directories are made accessible from with
 +
 Note: the temporary directory must *not* be mounted with the _nodev_ or _nosuid_ mount option.
 
+*--upgrade-before-distupgrade*::
+  Perform two-stage upgrades: 'apt-get upgrade && apt-get dist-upgrade'.
+
 *-v*, *--verbose*::
   This option no longer has any meaning, but it is still accepted for backwards compatibility.
 
diff --git a/piuparts.py b/piuparts.py
index f049b5e..4ce802f 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -195,6 +195,7 @@ class Settings:
         # tests and checks
         self.no_install_purge_test = False
         self.no_upgrade_test = False
+        self.upgrade_before_distupgrade = False
         self.distupgrade_to_testdebs = False
         self.install_remove_install = False
         self.install_purge_install = False
@@ -1098,7 +1099,7 @@ class Chroot:
         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):
+    def upgrade_to_distros(self, distros, packages, apt_get_upgrade=False):
         """Upgrade a chroot installation to each successive distro."""
         for distro in distros:
             logging.debug("Upgrading %s to %s" % (self.name, distro))
@@ -1107,6 +1108,8 @@ class Chroot:
             # Run custom scripts before upgrade
             self.run_scripts("pre_distupgrade")
             self.run(["apt-get", "update"])
+            if apt_get_upgrade:
+                self.run(["apt-get", "-y", "upgrade"])
             self.run(["apt-get", "-yf", "dist-upgrade"])
             self.remember_available_md5()
             os.environ["PIUPARTS_DISTRIBUTION_PREV"] = os.environ["PIUPARTS_DISTRIBUTION"]
@@ -2751,12 +2754,12 @@ def install_and_upgrade_between_distros(package_files, packages_qualified):
 
     os.environ["PIUPARTS_PHASE"] = "distupgrade"
 
-    chroot.upgrade_to_distros(settings.debian_distros[1:-1], distupgrade_packages)
+    chroot.upgrade_to_distros(settings.debian_distros[1:-1], distupgrade_packages, settings.upgrade_before_distupgrade)
 
     if settings.distupgrade_to_testdebs:
         chroot.enable_testdebs_repo(update=False)
 
-    chroot.upgrade_to_distros(settings.debian_distros[-1:], distupgrade_packages)
+    chroot.upgrade_to_distros(settings.debian_distros[-1:], distupgrade_packages, settings.upgrade_before_distupgrade)
 
     chroot.check_for_no_processes()
 
@@ -2996,6 +2999,10 @@ def parse_command_line():
                       default=False,
                       help="Don't check for broken symlinks.")
 
+    parser.add_option("--upgrade-before-distupgrade",
+                      action="store_true", default=False,
+                      help="Perform two-stage upgrades: 'apt-get upgrade && apt-get dist-upgrade'")
+
     parser.add_option("--no-upgrade-test",
                       action="store_true", default=False,
                       help="Skip testing the upgrade from an existing version " +
@@ -3185,6 +3192,7 @@ def parse_command_line():
     # tests and checks
     settings.no_install_purge_test = opts.no_install_purge_test
     settings.no_upgrade_test = opts.no_upgrade_test
+    settings.upgrade_before_distupgrade = opts.upgrade_before_distupgrade
     settings.distupgrade_to_testdebs = opts.distupgrade_to_testdebs
     settings.install_purge_install = opts.install_purge_install
     settings.install_remove_install = opts.install_remove_install

-- 
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