Rebased patch against develop On Tue, 10 Apr 2018 16:57:02 -0300 Agustin Henze <t...@aayy.com.ar> wrote: > Hi holger, > > On 03/27/18 12:42, Holger Levsen wrote: > [...] > > So we first now need to do the above code changes and then deprecate > > --keep-env after the buster release. > > > > Filing a bug so we don't forget. > > > > Please find the patch attached
Cheers, -- TiN
>From e78f80435ebe933c3cb6cdc5f56ab48f51619046 Mon Sep 17 00:00:00 2001 From: Agustin Henze <t...@aayy.com.ar> Date: Tue, 10 Apr 2018 15:22:28 -0300 Subject: [PATCH] Deprecate --keep-tmpdir in favor of --keep-env (Closes: #894232) When the user pass --keep-tmpdir as parameter, the following message is printed out: WARNING `--keep-tmpdir` is deprecated, use `--keep-env` instead Signed-off-by: Agustin Henze <t...@aayy.com.ar> --- piuparts.1.txt | 2 +- piuparts.py | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/piuparts.1.txt b/piuparts.1.txt index 7d7c91de..603eaf12 100644 --- a/piuparts.1.txt +++ b/piuparts.1.txt @@ -143,7 +143,7 @@ The tarball can be created with the '-s' option, or you can use one that *pbuild *--install-remove-install*:: Remove package after installation and reinstall. For testing installation in config-files-remaining state. -*-k*, *--keep-tmpdir*:: +*-k*, *--keep-env*:: Depending on which option is passed, keep the environment used for testing after the program ends:: * By default it doesn't remove the temporary directory for the chroot, * or if --schroot is used, the schroot session is not terminated, diff --git a/piuparts.py b/piuparts.py index 90a2851b..5a4da223 100644 --- a/piuparts.py +++ b/piuparts.py @@ -153,7 +153,7 @@ class Settings: def __init__(self): self.defaults = None self.tmpdir = None - self.keep_tmpdir = False + self.keep_env = False self.shell_on_error = False self.max_command_output_size = 8 * 1024 * 1024 # 8 MB (google-android-ndk-installer on install) (daptup on dist-upgrade) self.max_command_runtime = 60 * 60 # 60 minutes (texlive-full and blends metapackages on dist-upgrade) @@ -826,7 +826,7 @@ class Chroot: def remove(self): """Remove a chroot and all its contents.""" - if not settings.keep_tmpdir and os.path.exists(self.name): + if not settings.keep_env and os.path.exists(self.name): self.terminate_running_processes() self.unmount_all() if settings.lvm_volume: @@ -844,7 +844,7 @@ class Chroot: if os.path.exists(self.name): create_file(os.path.join(self.name, ".piuparts.tmpdir"), "removal failed") logging.debug("Removed directory tree at %s" % self.name) - elif settings.keep_tmpdir: + elif settings.keep_env: if settings.schroot: logging.debug("Keeping schroot session %s at %s" % (self.schroot_session, self.name)) elif settings.docker_image: @@ -2738,8 +2738,14 @@ def parse_command_line(): action="store_true", default=False, help="Enable the installation of Suggests.") - parser.add_option("-k", "--keep-tmpdir", - action="store_true", default=False, + def keep_env_parser(option, opt_str, value, parser): + setattr(parser.values, option.dest, True) + if "--keep-tmpdir" == opt_str: + print('WARNING `--keep-tmpdir` is deprecated, use `--keep-env` ' + 'instead') + + parser.add_option("-k", "--keep-env", "--keep-tmpdir", action="callback", + callback=keep_env_parser, default=False, dest='keep_env', help="Keep the environment used for testing after the " "program ends.") @@ -2952,7 +2958,7 @@ def parse_command_line(): defaults = DefaultsFactory().new_defaults() settings.tmpdir = opts.tmpdir - settings.keep_tmpdir = opts.keep_tmpdir + settings.keep_env = opts.keep_env settings.shell_on_error = opts.shell_on_error settings.single_changes_list = opts.single_changes_list settings.single_packages = opts.single_packages -- 2.17.0