joefitzgerald / packer-windows

Windows Packer Templates
MIT License
1.63k stars 1.12k forks source link

Fix issue #220: sdelete 2.0 is too slow #233

Closed jpmat296 closed 6 years ago

jpmat296 commented 7 years ago

Back to SDelete 1.61 thanks to archive.org URL

I don't know if some people would prefer to stay with sdelete 2 since it seems sdelete 2 works well for them.

petemounce commented 7 years ago

I've used this diff/fix and can confirm that it works.

discentem commented 6 years ago

Even with this change, my build still crashes :(

Any ideas?


    virtualbox-iso:
    virtualbox-iso: C: defrag:   100.00% complete, 7 passes needed, fragmented/total = 8/104943
    virtualbox-iso:
    virtualbox-iso: C:\Users\vagrant>cmd /c C:\Windows\System32\reg.exe ADD HKCU\Software\Sysinternals\SDelete /v EulaAccepted /t REG_DWORD /d 1 /f
    virtualbox-iso: The operation completed successfully.
    virtualbox-iso:
    virtualbox-iso: C:\Users\vagrant>cmd /c C:\Windows\Temp\SDelete.exe -q -z C:
    virtualbox-iso: 'C:\Windows\Temp\SDelete.exe' is not recognized as an internal or external command,
    virtualbox-iso: operable program or batch file.
==> virtualbox-iso: Unregistering and deleting virtual machine...
==> virtualbox-iso: Deleting output directory...
Build 'virtualbox-iso' errored: Script exited with non-zero exit status: 1

==> Some builds didn't complete successfully and had errors:
--> parallels-iso: Failed creating Parallels driver: exec: "prlctl": executable file not found in $PATH
--> vmware-iso: Couldn't find VMware tools for 'windows'! VMware often downloads these
tools on-demand. However, to do this, you need to create a fake VM
of the proper type then click the 'install tools' option in the
VMware GUI.
--> virtualbox-iso: Script exited with non-zero exit status: 1

==> Builds finished but no artifacts were created.
petemounce commented 6 years ago

@discentem please post more of your log. It indicates that sdelete.exe was not present in c:\Windows\temp, but without earlier messages one cannot see why.

discentem commented 6 years ago

@petemounce of course I can't get it fail in the same way again. failed in the above fashion 3 times this morning but not now.

discentem commented 6 years ago

@petemounce It failed again due to sdelete. Here's the full log:

https://gist.github.com/discentem/7dbd01aeebefb0b3b3c7dd7d19fd0502

petemounce commented 6 years ago

The line that fetches the sdelete zip file

if not exist "C:\Windows\Temp\SDelete.zip" (powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://web.archive.org/web/20140902022253/http://download.sysinternals.com/files/SDelete.zip', 'C:\Windows\Temp\SDelete.zip')"  0<NUL )

is now fetching some HTML rather than the zip file. Using the web archive is inherently quite a brittle way of fetching a dependency, since the behaviour of the URL may change, like it has here.

If you change the line so it downloads http://web.archive.org/web/20140803110527if_/http://download.sysinternals.com/files/SDelete.zip that should work - until the next time it doesn't.

StefanScherer commented 6 years ago

Closing this, we should use another tool instead of depending of no longer available downloads. A PowerShell native solution mentioned in https://github.com/joefitzgerald/packer-windows/issues/220#issuecomment-341979050 would be better.