Use single temp directory base
This commit is contained in:
parent
32b692f752
commit
056e38698e
2
debug.go
2
debug.go
@ -144,7 +144,7 @@ func (cmd *DebugCmd) Run(g *Globals) (err error) {
|
||||
}
|
||||
defer q.Stop()
|
||||
|
||||
tmp, err := ioutil.TempDir("/tmp/", "out-of-tree_")
|
||||
tmp, err := ioutil.TempDir(tempDirBase, "out-of-tree_")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ func unpackTar(archive, destination string) (err error) {
|
||||
}
|
||||
|
||||
func downloadImage(path, file string) (err error) {
|
||||
tmp, err := ioutil.TempDir("/tmp/", "out-of-tree_")
|
||||
tmp, err := ioutil.TempDir(tempDirBase, "out-of-tree_")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
16
kernel.go
16
kernel.go
@ -172,7 +172,7 @@ func matchDebImagePkg(container, mask string) (pkgs []string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
output, err := c.Run("/tmp", cmd)
|
||||
output, err := c.Run(tempDirBase, cmd)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -203,7 +203,7 @@ func matchCentOSDevelPkg(container, mask string, generic bool) (
|
||||
return
|
||||
}
|
||||
|
||||
output, err := c.Run("/tmp", cmd)
|
||||
output, err := c.Run(tempDirBase, cmd)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -389,7 +389,7 @@ func generateBaseDockerImage(registry string, commands []config.DockerCommand,
|
||||
}
|
||||
|
||||
func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (err error) {
|
||||
tmpdir, err := os.MkdirTemp("", "out-of-tree-"+pkgname+"-")
|
||||
tmpdir, err := os.MkdirTemp(tempDirBase, "out-of-tree-"+pkgname+"-")
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("make tmp directory")
|
||||
}
|
||||
@ -445,7 +445,7 @@ func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (e
|
||||
|
||||
cmd := fmt.Sprintf("apt-get install -y %s %s", pkgname, headerspkg)
|
||||
|
||||
_, err = c.Run("/tmp", cmd)
|
||||
_, err = c.Run(tempDirBase, cmd)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -459,14 +459,14 @@ func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (e
|
||||
}
|
||||
cmd := fmt.Sprintf("yum -y install %s %s\n", imagepkg,
|
||||
pkgname)
|
||||
_, err = c.Run("/tmp", cmd)
|
||||
_, err = c.Run(tempDirBase, cmd)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
cmd = fmt.Sprintf("dracut --add-drivers 'e1000 ext4' -f "+
|
||||
"/boot/initramfs-%s.img %s\n", version, version)
|
||||
_, err = c.Run("/tmp", cmd)
|
||||
_, err = c.Run(tempDirBase, cmd)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -505,7 +505,7 @@ func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (e
|
||||
cmd += " && cp -r /usr/src/* /target/usr/src/"
|
||||
}
|
||||
|
||||
_, err = c.Run("/tmp", cmd)
|
||||
_, err = c.Run(tempDirBase, cmd)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -676,7 +676,7 @@ func listContainersKernels(dii containerImageInfo, newkcfg *config.KernelConfig,
|
||||
for _, cmd := range []string{
|
||||
"find /boot -type f -exec chmod a+r {} \\;",
|
||||
} {
|
||||
_, err = c.Run("/tmp", cmd)
|
||||
_, err = c.Run(tempDirBase, cmd)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
7
main.go
7
main.go
@ -89,6 +89,8 @@ func (lw *LevelWriter) WriteLevel(l zerolog.Level, p []byte) (n int, err error)
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
var tempDirBase string
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
@ -101,7 +103,7 @@ func main() {
|
||||
Compact: true,
|
||||
}),
|
||||
kong.Vars{
|
||||
"version": "2.0.5",
|
||||
"version": "2.0.6",
|
||||
},
|
||||
)
|
||||
|
||||
@ -124,6 +126,9 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
tempDirBase = usr.HomeDir + "/.out-of-tree/tmp/"
|
||||
os.MkdirAll(tempDirBase, os.ModePerm)
|
||||
|
||||
log.Logger = log.Output(zerolog.MultiLevelWriter(
|
||||
&LevelWriter{Writer: zerolog.NewConsoleWriter(
|
||||
func(w *zerolog.ConsoleWriter) {
|
||||
|
10
pew.go
10
pew.go
@ -14,7 +14,6 @@ import (
|
||||
"math/rand"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -599,14 +598,7 @@ func (cmd PewCmd) testArtifact(swg *sizedwaitgroup.SizedWaitGroup,
|
||||
}
|
||||
}()
|
||||
|
||||
usr, err := user.Current()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
tmpdir := usr.HomeDir + "/.out-of-tree/tmp"
|
||||
os.MkdirAll(tmpdir, os.ModePerm)
|
||||
|
||||
tmp, err := ioutil.TempDir(tmpdir, "out-of-tree_")
|
||||
tmp, err := ioutil.TempDir(tempDirBase, "out-of-tree_")
|
||||
if err != nil {
|
||||
slog.Error().Err(err).Msg("making tmp directory")
|
||||
return
|
||||
|
@ -61,7 +61,7 @@ func preload(q *qemu.System, ki config.KernelInfo, pm config.PreloadModule,
|
||||
func buildAndInsmod(workPath string, q *qemu.System, ki config.KernelInfo,
|
||||
dockerTimeout time.Duration, cache string) (err error) {
|
||||
|
||||
tmp, err := ioutil.TempDir("", "out-of-tree_")
|
||||
tmp, err := ioutil.TempDir(tempDirBase, "out-of-tree_")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user