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