From 54868329e69e2a437ca80c125e420484ba14eb58 Mon Sep 17 00:00:00 2001 From: Mathieu Champlon Date: Mon, 10 Sep 2018 21:53:09 +0200 Subject: [PATCH] Fix path separator on Windows On Windows os.PathSeparator is \ but here it's all unix file paths being manipulated. Signed-off-by: Mathieu Champlon --- src/cmd/linuxkit/moby/build.go | 2 +- src/cmd/linuxkit/moby/image.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cmd/linuxkit/moby/build.go b/src/cmd/linuxkit/moby/build.go index ffd99c403..284a36db3 100644 --- a/src/cmd/linuxkit/moby/build.go +++ b/src/cmd/linuxkit/moby/build.go @@ -454,7 +454,7 @@ func filesystem(m Moby, tw *tar.Writer, idMap map[string]uint32) error { return errors.New("Did not specify path for file") } // tar archives should not have absolute paths - if f.Path[0] == os.PathSeparator { + if f.Path[0] == '/' { f.Path = f.Path[1:] } mode := int64(0600) diff --git a/src/cmd/linuxkit/moby/image.go b/src/cmd/linuxkit/moby/image.go index 93420cfd5..ef16416a1 100644 --- a/src/cmd/linuxkit/moby/image.go +++ b/src/cmd/linuxkit/moby/image.go @@ -58,11 +58,11 @@ func tarPrefix(path string, tw tarWriter) error { if path == "" { return nil } - if path[len(path)-1] != byte('/') { + if path[len(path)-1] != '/' { return fmt.Errorf("path does not end with /: %s", path) } path = path[:len(path)-1] - if path[0] == byte('/') { + if path[0] == '/' { return fmt.Errorf("path should be relative: %s", path) } mkdir := "" @@ -85,7 +85,7 @@ func tarPrefix(path string, tw tarWriter) error { // ImageTar takes a Docker image and outputs it to a tar stream func ImageTar(ref *reference.Spec, prefix string, tw tarWriter, trust bool, pull bool, resolv string) (e error) { log.Debugf("image tar: %s %s", ref, prefix) - if prefix != "" && prefix[len(prefix)-1] != byte('/') { + if prefix != "" && prefix[len(prefix)-1] != '/' { return fmt.Errorf("prefix does not end with /: %s", prefix) }