[Piuparts-devel] Bug#589498: [PATCH 1/5] add PIUPARTS_TEST and PIUPARTS_PHASE to the environment
Andreas Beckmann
debian at abeckmann.de
Fri Nov 11 11:22:36 UTC 2011
add the PIUPARTS_TEST and PIUPARTS_PHASE variables with values
'install', 'upgrade', or 'distupgrade' to the environment so that
the pre/post_install_* hook scripts know where they are being run
Signed-off-by: Andreas Beckmann <debian at abeckmann.de>
---
README.txt | 23 ++++++++++++++++++++---
piuparts.py | 15 +++++++++++++++
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/README.txt b/README.txt
index dab3161..ff83ae7 100644
--- a/README.txt
+++ b/README.txt
@@ -151,15 +151,32 @@ being tested (seperated by spaces, if applicable) or the .changes
file(s) being used. So when running in master-slave mode, it
will be set to the (one) package being tested at a time.
+Depending on the current test, the variable PIUPARTS_TEST is set
+to
+. 'install' (installation and purging test),
+. 'upgrade' (installation, upgrade and purging tests) or
+. 'distupgrade'.
+
+During the 'upgrade' and 'distupgrade' tests, the variable
+PIUPARTS_PHASE is set to one of the following values:
+. 'install' while initially installing the packages from the repository,
+. 'upgrade' when upgrading to the .debs,
+. 'distupgrade' while reinstalling the packages after 'apt-get dist-upgrade' to ensure they were not removed accidently
+During the 'install' test, the PIUPARTS_PHASE variable is set to
+'install'.
+
The following prefixes for scripts are recognized:
'post_setup_' - after the *setup* of the chroot is finished.
-'pre_install_' - before *installing* your package.
+'pre_install_' - before *installing* your package. Depending on
+the test, this may be run multiple times. The PIUPARTS_TEST and
+PIUPARTS_PHASE variables can be used to distinguish the cases.
'post_install_' - after *installing* your package and its
-dependencies. In the case of the upgrade test, it is after
-install and upgrade.
+dependencies. Depending on the test, this may be run multiple
+times. The PIUPARTS_TEST and PIUPARTS_PHASE variables can be used
+to distinguish the cases.
'pre_remove_' - before *removing* your package.
diff --git a/piuparts.py b/piuparts.py
index 1fb4744..8209e41 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -1679,7 +1679,10 @@ def install_purge_test(chroot, root_info, selections, package_list, packages):
Assume 'root' is a directory already populated with a working
chroot, with packages in states given by 'selections'."""
+ os.environ["PIUPARTS_TEST"] = "install"
+
# Install packages into the chroot.
+ os.environ["PIUPARTS_PHASE"] = "install"
if settings.warn_on_others:
# Create a metapackage with dependencies from the given packages
@@ -1750,7 +1753,10 @@ def install_upgrade_test(chroot, root_info, selections, package_list, package_na
"""Install package via apt-get, then upgrade from package files.
Return True if successful, False if not."""
+ os.environ["PIUPARTS_TEST"] = "upgrade"
+
# First install via apt-get.
+ os.environ["PIUPARTS_PHASE"] = "install"
chroot.install_packages_by_name(package_names)
chroot.run_scripts("pre_upgrade")
@@ -1758,6 +1764,7 @@ def install_upgrade_test(chroot, root_info, selections, package_list, package_na
chroot.check_for_broken_symlinks()
# Then from the package files.
+ os.environ["PIUPARTS_PHASE"] = "upgrade"
chroot.install_package_files(package_list)
file_owners = chroot.get_files_owned_by_packages()
@@ -1816,6 +1823,8 @@ def install_and_upgrade_between_distros(filenames, packages):
# a reasonable default behaviour for distro upgrade tests, which are not
# done by default anyway.
+ os.environ["PIUPARTS_TEST"] = "distupgrade"
+
chroot = get_chroot()
chroot.create()
cid = do_on_panic(chroot.remove)
@@ -1852,6 +1861,8 @@ def install_and_upgrade_between_distros(filenames, packages):
chroot.check_for_no_processes()
+ os.environ["PIUPARTS_PHASE"] = "install"
+
chroot.run(["apt-get", "update"])
chroot.install_packages_by_name(packages)
@@ -1859,10 +1870,14 @@ def install_and_upgrade_between_distros(filenames, packages):
chroot.check_for_no_processes()
+ os.environ["PIUPARTS_PHASE"] = "distupgrade"
+
chroot.upgrade_to_distros(settings.debian_distros[1:], packages)
chroot.check_for_no_processes()
+ os.environ["PIUPARTS_PHASE"] = "upgrade"
+
chroot.install_package_files(filenames)
chroot.run(["apt-get", "clean"])
--
1.7.7.1
More information about the Piuparts-devel
mailing list