return err
}
- symBase, err := filepath.Rel(srcRoot, dstRoot)
+ srcRoot, err := filepath.Abs(srcRoot)
if err != nil {
- symBase, err = filepath.Abs(srcRoot)
- if err != nil {
- return err
- }
+ return err
}
return filepath.Walk(srcRoot, func(srcPath string, info os.FileInfo, err error) error {
// Always copy directories (don't symlink them).
// If we add a file in the overlay, we don't want to add it in the original.
if info.IsDir() {
- return os.Mkdir(dstPath, perm)
+ return os.MkdirAll(dstPath, perm|0200)
}
// If the OS supports symlinks, use them instead of copying bytes.
- if err := os.Symlink(filepath.Join(symBase, suffix), dstPath); err == nil {
+ if err := os.Symlink(srcPath, dstPath); err == nil {
return nil
}