Open remi-espie opened 6 months ago
With the latest commit, the source .vhd
file is copied to a temporary directory randomly named with your tmp.Dir
function, and the job is done on this copy.
The copy takes place during the attach_isos
step of the common builder. I thought it made sense to put it here as it is where the file extension is also checked, and it made the modifications minimal.
As always, thanks for your review !
This PR adds support for
.vhd
files.Before this PR, when using a
.vhd
as theiso_url
(as stated possible in the documentation), VirtualBox returns the errorError attaching ISO: VBoxManage error: VBoxManage.exe: error: The medium '<path/to/vhd>' can't be used as the requested device type (DVD, detected HDD)
.This solves the issue by checking the extension of the file and, if it is
.vhd
, by changing the disk type fromdvddrive
tohdd
in the VirtualBox' VM creation command. If using ahdd
type disk, it will not be unmounted before export. It also removes the creation of a.vdi
disk if using a.vhd
.However, by using directly the
.vhd
file, it is modified and won't remain the same after running packer. An improvement would be to clone the.vhd
file to the temp directory, as (for example) the Hyper-V plugin do.This closes #123