f2f884a92f
The applyLayer implementation in pkg/chrootarchive has to set the TMPDIR environment variable so that archive.UnpackLayer() can successfully create the whiteout-file temp directory. Change UnpackLayer to create the temporary directory under the destination path so that environment variables do not need to be touched. Signed-off-by: Cory Snider <csnider@mirantis.com>
37 lines
958 B
Go
37 lines
958 B
Go
package chrootarchive // import "github.com/docker/docker/pkg/chrootarchive"
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"path/filepath"
|
|
|
|
"github.com/docker/docker/pkg/archive"
|
|
"github.com/docker/docker/pkg/longpath"
|
|
)
|
|
|
|
// applyLayerHandler parses a diff in the standard layer format from `layer`, and
|
|
// applies it to the directory `dest`. Returns the size in bytes of the
|
|
// contents of the layer.
|
|
func applyLayerHandler(dest string, layer io.Reader, options *archive.TarOptions, decompress bool) (size int64, err error) {
|
|
dest = filepath.Clean(dest)
|
|
|
|
// Ensure it is a Windows-style volume path
|
|
dest = longpath.AddPrefix(dest)
|
|
|
|
if decompress {
|
|
decompressed, err := archive.DecompressStream(layer)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
defer decompressed.Close()
|
|
|
|
layer = decompressed
|
|
}
|
|
|
|
s, err := archive.UnpackLayer(dest, layer, nil)
|
|
if err != nil {
|
|
return 0, fmt.Errorf("ApplyLayer %s failed UnpackLayer to %s: %s", layer, dest, err)
|
|
}
|
|
|
|
return s, nil
|
|
}
|