Do not use leading slashes for paths in layer tarballs to be more compatible with docker
This commit is contained in:
		
							parent
							
								
									56eeaf41e6
								
							
						
					
					
						commit
						c75749b840
					
				|  | @ -25,6 +25,7 @@ import ( | ||||||
| 	"io/ioutil" | 	"io/ioutil" | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
|  | 	"strings" | ||||||
| 	"syscall" | 	"syscall" | ||||||
| 
 | 
 | ||||||
| 	"github.com/docker/docker/pkg/archive" | 	"github.com/docker/docker/pkg/archive" | ||||||
|  | @ -74,7 +75,14 @@ func (t *Tar) AddFileToTar(p string) error { | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 	hdr.Name = p | 
 | ||||||
|  | 	if p != "/" { | ||||||
|  | 		// Docker uses no leading / in the tarball
 | ||||||
|  | 		hdr.Name = strings.TrimLeft(p, "/") | ||||||
|  | 	} else { | ||||||
|  | 		// allow entry for / to preserve permission changes etc. (currently ignored anyway by Docker runtime)
 | ||||||
|  | 		hdr.Name = p | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	hardlink, linkDst := t.checkHardlink(p, i) | 	hardlink, linkDst := t.checkHardlink(p, i) | ||||||
| 	if hardlink { | 	if hardlink { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue