[Piuparts-commits] [SCM] piuparts git repository branch, master, updated. eda668423fa87898c59d1075118693714aa5a053
Andreas Beckmann
debian at abeckmann.de
Fri Dec 23 10:27:14 UTC 2011
The following commit has been merged in the master branch:
commit 1956848e70026f75c248408cbf80b892620ba554
Author: Andreas Beckmann <debian at abeckmann.de>
Date: Fri Nov 11 12:11:02 2011 +0100
add PIUPARTS_TEST and PIUPARTS_PHASE to the environment
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>
diff --git a/README.txt b/README.txt
index 3fd4e8a..e81d4c2 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 5e1047f..33a9997 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -1865,7 +1865,10 @@ def install_purge_test(chroot, root_info, selections, package_files, 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
@@ -1935,7 +1938,10 @@ def install_upgrade_test(chroot, root_info, selections, package_files, packages)
"""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(packages)
chroot.run_scripts("pre_upgrade")
@@ -1944,6 +1950,7 @@ def install_upgrade_test(chroot, root_info, selections, package_files, packages)
chroot.check_for_broken_symlinks()
# Then from the package files.
+ os.environ["PIUPARTS_PHASE"] = "upgrade"
chroot.install_package_files(package_files)
chroot.check_for_no_processes()
@@ -2003,6 +2010,8 @@ def install_and_upgrade_between_distros(package_files, 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)
@@ -2043,16 +2052,22 @@ def install_and_upgrade_between_distros(package_files, packages):
chroot.check_for_no_processes()
+ os.environ["PIUPARTS_PHASE"] = "install"
+
chroot.install_packages_by_name(packages)
chroot.run_scripts("pre_upgrade")
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(package_files)
chroot.check_for_no_processes()
--
piuparts git repository
More information about the Piuparts-commits
mailing list