From 8d8b880ac48bbe77c9f249c3c339406d40cb9d7f Mon Sep 17 00:00:00 2001 From: pauloj95 <37109548+pauloj95@users.noreply.github.com> Date: Tue, 5 Feb 2019 17:47:00 +0000 Subject: [PATCH 1/4] add force to powershell move command this will allow powershell move in provisioners and replace file if existing found... issue example: https://github.com/hashicorp/packer/issues/7280 --- provisioner/guest_commands.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provisioner/guest_commands.go b/provisioner/guest_commands.go index 3a361a208..ca2b238a4 100644 --- a/provisioner/guest_commands.go +++ b/provisioner/guest_commands.go @@ -30,7 +30,7 @@ var guestOSTypeCommands = map[string]guestOSTypeCommand{ mkdir: "powershell.exe -Command \"New-Item -ItemType directory -Force -ErrorAction SilentlyContinue -Path %s\"", removeDir: "powershell.exe -Command \"rm %s -recurse -force\"", statPath: "powershell.exe -Command { if (test-path %s) { exit 0 } else { exit 1 } }", - mv: "powershell.exe -Command \"mv %s %s\"", + mv: "powershell.exe -Command \"mv %s %s -force\"", }, } From d7b93aa34378c4bc4ff5771269badd12724c2c16 Mon Sep 17 00:00:00 2001 From: pauloj95 <37109548+pauloj95@users.noreply.github.com> Date: Wed, 6 Feb 2019 10:27:45 +0000 Subject: [PATCH 2/4] add force to guestcommands test too --- provisioner/guest_commands_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provisioner/guest_commands_test.go b/provisioner/guest_commands_test.go index 08baca058..27499740d 100644 --- a/provisioner/guest_commands_test.go +++ b/provisioner/guest_commands_test.go @@ -183,7 +183,7 @@ func TestMovePath(t *testing.T) { t.Fatalf("Failed to create new GuestCommands for OS: %s", WindowsOSType) } cmd = guestCmd.MovePath("C:\\Temp\\SomeDir", "C:\\Temp\\NewDir") - if cmd != "powershell.exe -Command \"mv C:\\Temp\\SomeDir C:\\Temp\\NewDir\"" { + if cmd != "powershell.exe -Command \"mv C:\\Temp\\SomeDir C:\\Temp\\NewDir\ -force"" { t.Fatalf("Unexpected Windows remove dir cmd: %s", cmd) } From b4d1c77cc05b9d49c264857d60957cc895b81ffe Mon Sep 17 00:00:00 2001 From: pauloj95 <37109548+pauloj95@users.noreply.github.com> Date: Wed, 6 Feb 2019 10:30:37 +0000 Subject: [PATCH 3/4] Update guest_commands_test.go --- provisioner/guest_commands_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provisioner/guest_commands_test.go b/provisioner/guest_commands_test.go index 27499740d..bdea019cc 100644 --- a/provisioner/guest_commands_test.go +++ b/provisioner/guest_commands_test.go @@ -183,7 +183,7 @@ func TestMovePath(t *testing.T) { t.Fatalf("Failed to create new GuestCommands for OS: %s", WindowsOSType) } cmd = guestCmd.MovePath("C:\\Temp\\SomeDir", "C:\\Temp\\NewDir") - if cmd != "powershell.exe -Command \"mv C:\\Temp\\SomeDir C:\\Temp\\NewDir\ -force"" { + if cmd != "powershell.exe -Command \"mv C:\\Temp\\SomeDir C:\\Temp\\NewDir -force\"" { t.Fatalf("Unexpected Windows remove dir cmd: %s", cmd) } From b1fffee614d6fc60bbe232dd9a425387996f3f81 Mon Sep 17 00:00:00 2001 From: pauloj95 <37109548+pauloj95@users.noreply.github.com> Date: Wed, 6 Feb 2019 10:50:29 +0000 Subject: [PATCH 4/4] Update guest_commands_test.go --- provisioner/guest_commands_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provisioner/guest_commands_test.go b/provisioner/guest_commands_test.go index bdea019cc..ffbad4bbd 100644 --- a/provisioner/guest_commands_test.go +++ b/provisioner/guest_commands_test.go @@ -189,7 +189,7 @@ func TestMovePath(t *testing.T) { // Windows OS w/ space in path cmd = guestCmd.MovePath("C:\\Temp\\Some Dir", "C:\\Temp\\New Dir") - if cmd != "powershell.exe -Command \"mv C:\\Temp\\Some` Dir C:\\Temp\\New` Dir\"" { + if cmd != "powershell.exe -Command \"mv C:\\Temp\\Some` Dir C:\\Temp\\New` Dir -force\"" { t.Fatalf("Unexpected Windows remove dir cmd: %s", cmd) } }