This commit basically grepped the code base for all uses of Dir.mktmpdir
and Tempfile.new/open and ensures the value is unique within the
code base and also prefixed with `vagrant-`.
Previously, most invocations of these commands simply used "vagrant",
thus making them indistinguishable when trying to identify leaks.
The only reason we were using Tempfile was to generate the path. This
commit switches to using `Dir::Tmpname.create`, which accomplishes the
same thing without the overhead of creating and removing a tempfile.
This commit separates the scratch and output directory creation from the
main package middleware into its own PackageSetupFolders middleware.
Additionally, the validation that ensures an output file does not exist
is moved into a validation function that can be shared across multiple
methods.
This refactor permits a pre-flight check to ensure box packaging would
be successful before actually stopping the VM.
Fixes GH-7351
This commit bumps the box resume delay time to 24h and makes it a
constant because I had a bugger of a time actually finding this in the
code :frowny:.
Fixes GH-7272
Without this change, the version string may be mutated when passed through
Gem::Version.new(version).to_s before being used to construct the box
directory. This is a problem when using prerelease version numbers because,
for example, it will look for "~/.vagrant.d/boxes/1.0.0.pre.alpha.1" when it
should be looking for "~/.vagrant.d/boxes/1.0.0-alpha.1".
This helps with some confusion caused in GH-2538, since the output says:
> Running cleanup tasks for 'shell' provisioner...
But that's actually not true. It is running the cleanup tasks iff the
provisioner defined a cleanup task. This commit changes the
provisioner_cleanup middleware to only run cleanup tasks if the subclass
defines a cleanup task.
The reason we can't just check if the provisioner `respond_to?` the
`cleanup` method is because the parent provisioner base class (which
all provisioners inherit from) defines a blank cleanup method. This is
important because it means we never risk calling an unimplemented
cleanup function, and it also helps define the public API for a
provisioner.