From 200e26ea858f9bef99fba879a7a9e4d61600a751 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Fri, 26 Apr 2019 10:34:01 +0200 Subject: [PATCH 1/2] Step download: always copy local files instead of symlinking to fix #7534. The longer term fix for this would be to change the go-getter so that it can leave the source file where it is & tell us where it is. We will do this when the right time comes. --- common/step_download.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/common/step_download.go b/common/step_download.go index 4351e29c2..0012896bc 100644 --- a/common/step_download.go +++ b/common/step_download.go @@ -88,6 +88,19 @@ func (s *StepDownload) Run(ctx context.Context, state multistep.StateBag) multis return multistep.ActionHalt } +var ( + getters = getter.Getters +) + +func init() { + getters["file"] = &getter.FileGetter{ + // always copy local files instead of symlinking to fix GH-7534. The + // longer term fix for this would be to change the go-getter so that it + // can leave the source file where it is & tell us where it is. + Copy: true, + } +} + func (s *StepDownload) download(ctx context.Context, ui packer.Ui, source string) (string, error) { u, err := urlhelper.Parse(source) if err != nil { @@ -152,6 +165,7 @@ func (s *StepDownload) download(ctx context.Context, ui packer.Ui, source string ProgressListener: ui, Pwd: wd, Dir: false, + Getters: getters, } switch err := gc.Get(); err.(type) { From 65be2be38bd97be5290bc55b8837cebd70dc6cd4 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 29 Apr 2019 09:39:21 +0200 Subject: [PATCH 2/2] step_download: force copy of local files only on windows --- common/step_download.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/common/step_download.go b/common/step_download.go index 0012896bc..e562b619c 100644 --- a/common/step_download.go +++ b/common/step_download.go @@ -7,6 +7,7 @@ import ( "fmt" "log" "os" + "runtime" "strings" "github.com/gofrs/flock" @@ -93,11 +94,13 @@ var ( ) func init() { - getters["file"] = &getter.FileGetter{ - // always copy local files instead of symlinking to fix GH-7534. The - // longer term fix for this would be to change the go-getter so that it - // can leave the source file where it is & tell us where it is. - Copy: true, + if runtime.GOOS == "windows" { + getters["file"] = &getter.FileGetter{ + // always copy local files instead of symlinking to fix GH-7534. The + // longer term fix for this would be to change the go-getter so that it + // can leave the source file where it is & tell us where it is. + Copy: true, + } } }