Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
| ... | ... |
@@ -5,6 +5,8 @@ import ( |
| 5 | 5 |
"io" |
| 6 | 6 |
"os" |
| 7 | 7 |
"path/filepath" |
| 8 |
+ "runtime" |
|
| 9 |
+ "strings" |
|
| 8 | 10 |
|
| 9 | 11 |
"github.com/docker/docker/builder" |
| 10 | 12 |
"github.com/docker/docker/pkg/pools" |
| ... | ... |
@@ -56,7 +58,7 @@ func (c *lazyContext) Stat(path string) (string, builder.FileInfo, error) {
|
| 56 | 56 |
return "", nil, errors.WithStack(convertPathError(err, cleanPath)) |
| 57 | 57 |
} |
| 58 | 58 |
|
| 59 |
- relPath, err := filepath.Rel(c.root, fullPath) |
|
| 59 |
+ relPath, err := rel(c.root, fullPath) |
|
| 60 | 60 |
if err != nil {
|
| 61 | 61 |
return "", nil, errors.WithStack(convertPathError(err, cleanPath)) |
| 62 | 62 |
} |
| ... | ... |
@@ -82,7 +84,7 @@ func (c *lazyContext) Walk(root string, walkFn builder.WalkFunc) error {
|
| 82 | 82 |
return err |
| 83 | 83 |
} |
| 84 | 84 |
return filepath.Walk(fullPath, func(fullPath string, fi os.FileInfo, err error) error {
|
| 85 |
- relPath, err := filepath.Rel(c.root, fullPath) |
|
| 85 |
+ relPath, err := rel(c.root, fullPath) |
|
| 86 | 86 |
if err != nil {
|
| 87 | 87 |
return errors.WithStack(err) |
| 88 | 88 |
} |
| ... | ... |
@@ -147,3 +149,18 @@ func convertPathError(err error, cleanpath string) error {
|
| 147 | 147 |
} |
| 148 | 148 |
return err |
| 149 | 149 |
} |
| 150 |
+ |
|
| 151 |
+func rel(basepath, targpath string) (string, error) {
|
|
| 152 |
+ // filepath.Rel can't handle UUID paths in windows |
|
| 153 |
+ if runtime.GOOS == "windows" {
|
|
| 154 |
+ pfx := basepath + `\` |
|
| 155 |
+ if strings.HasPrefix(targpath, pfx) {
|
|
| 156 |
+ p := strings.TrimPrefix(targpath, pfx) |
|
| 157 |
+ if p == "" {
|
|
| 158 |
+ p = "." |
|
| 159 |
+ } |
|
| 160 |
+ return p, nil |
|
| 161 |
+ } |
|
| 162 |
+ } |
|
| 163 |
+ return filepath.Rel(basepath, targpath) |
|
| 164 |
+} |