From f9ab92d002c5457b991e8de189f63798e9bc9fb4 Mon Sep 17 00:00:00 2001 From: Remi Rampin Date: Thu, 9 Mar 2017 12:19:04 -0500 Subject: [PATCH] Add vagrant --[dont-]install-packages option Currently whether to install packages is controlled by --use-chroot, meaning packages are always preferred over packed files if --dont-use-chroot is used. This adds new options to change that, though the default behavior is unchanged. --- .../reprounzip/unpackers/vagrant/__init__.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/reprounzip-vagrant/reprounzip/unpackers/vagrant/__init__.py b/reprounzip-vagrant/reprounzip/unpackers/vagrant/__init__.py index 601ea221b..420a30727 100644 --- a/reprounzip-vagrant/reprounzip/unpackers/vagrant/__init__.py +++ b/reprounzip-vagrant/reprounzip/unpackers/vagrant/__init__.py @@ -251,18 +251,21 @@ def vagrant_setup_create(args): logging.info("Using box %s", box) logging.debug("Distribution: %s", target_distribution or "unknown") - # If using chroot, we might still need to install packages to get missing - # (not packed) files - if use_chroot: + install_packages = args.install_packages + if install_packages is None: + install_packages = not use_chroot + + # We might still need to install packages to get missing (not packed) files + if not install_packages: packages = [pkg for pkg in packages if not pkg.packfiles] if packages: - record_usage(vagrant_install_pkgs=True) logging.info("Some packages were not packed, so we'll install and " "copy their files\n" "Packages that are missing:\n%s", ' '.join(pkg.name for pkg in packages)) if packages: + record_usage(vagrant_install_pkgs=True) try: installer = select_installer(pack, runs, target_distribution) except CantFindInstaller as e: @@ -823,6 +826,13 @@ def add_opt_setup(opts): opts.add_argument('--distribution', nargs=1, help="Distribution used in the Vagrant box (for " "package installer selection)") + opts.add_argument('--install-packages', action='store_true', + default=None, dest='install_packages', + help="Install packages rather than using packed " + "files") + opts.add_argument('--dont-install-packages', action='store_false', + default=None, dest='install_packages', + help="Don't install packages, use packed files") opts.add_argument('--memory', nargs=1, help="Amount of RAM to allocate to VM (megabytes, " "default: box default)")