pkg/chrootarchive: provide TMPDIR for ApplyLayer

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
This commit is contained in:
unclejack 2014-11-18 23:33:13 +02:00
parent a80a838e6f
commit 78bd3c0356

View file

@ -3,6 +3,7 @@ package chrootarchive
import ( import (
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"runtime" "runtime"
"syscall" "syscall"
@ -21,9 +22,16 @@ func applyLayer() {
if err := syscall.Chdir("/"); err != nil { if err := syscall.Chdir("/"); err != nil {
fatal(err) fatal(err)
} }
if err := archive.ApplyLayer("/", os.Stdin); err != nil { tmpDir, err := ioutil.TempDir("/", "temp-docker-extract")
if err != nil {
fatal(err) fatal(err)
} }
os.Setenv("TMPDIR", tmpDir)
if err := archive.ApplyLayer("/", os.Stdin); err != nil {
os.RemoveAll(tmpDir)
fatal(err)
}
os.RemoveAll(tmpDir)
os.Exit(0) os.Exit(0)
} }