1
0

feat: initial daemon implementation

This commit is contained in:
2024-02-20 13:25:31 +00:00
parent 820208d079
commit 0314b5ca93
45 changed files with 2989 additions and 1041 deletions

View File

@ -6,7 +6,7 @@ import (
"github.com/rs/zerolog/log"
"code.dumpstack.io/tools/out-of-tree/config"
"code.dumpstack.io/tools/out-of-tree/config/dotfiles"
"code.dumpstack.io/tools/out-of-tree/container"
"code.dumpstack.io/tools/out-of-tree/distro"
)
@ -47,14 +47,12 @@ func (centos CentOS) Packages() (pkgs []string, err error) {
"| grep -v src " +
"| cut -d ' ' -f 1"
output, err := c.Run(config.Dir("tmp"), []string{cmd})
output, err := c.Run(dotfiles.Dir("tmp"), []string{cmd})
if err != nil {
return
}
for _, pkg := range strings.Fields(output) {
pkgs = append(pkgs, pkg)
}
pkgs = append(pkgs, strings.Fields(output)...)
return
}

View File

@ -10,7 +10,7 @@ import (
"github.com/rs/zerolog/log"
"code.dumpstack.io/tools/out-of-tree/cache"
"code.dumpstack.io/tools/out-of-tree/config"
"code.dumpstack.io/tools/out-of-tree/config/dotfiles"
"code.dumpstack.io/tools/out-of-tree/container"
"code.dumpstack.io/tools/out-of-tree/distro"
"code.dumpstack.io/tools/out-of-tree/distro/debian/snapshot"
@ -329,8 +329,8 @@ func (d Debian) Kernels() (kernels []distro.KernelInfo, err error) {
return
}
cpath := config.Dir("volumes", c.Name())
rootfs := config.File("images", c.Name()+".img")
cpath := dotfiles.Dir("volumes", c.Name())
rootfs := dotfiles.File("images", c.Name()+".img")
files, err := os.ReadDir(cpath)
if err != nil {
@ -413,17 +413,17 @@ func (d Debian) volumes(pkgname string) (volumes []container.Volume) {
pkgdir := filepath.Join("volumes", c.Name(), pkgname)
volumes = append(volumes, container.Volume{
Src: config.Dir(pkgdir, "/lib/modules"),
Src: dotfiles.Dir(pkgdir, "/lib/modules"),
Dest: "/lib/modules",
})
volumes = append(volumes, container.Volume{
Src: config.Dir(pkgdir, "/usr/src"),
Src: dotfiles.Dir(pkgdir, "/usr/src"),
Dest: "/usr/src",
})
volumes = append(volumes, container.Volume{
Src: config.Dir(pkgdir, "/boot"),
Src: dotfiles.Dir(pkgdir, "/boot"),
Dest: "/boot",
})
@ -518,7 +518,7 @@ func (d Debian) cleanup(pkgname string) {
return
}
pkgdir := config.Dir(filepath.Join("volumes", c.Name(), pkgname))
pkgdir := dotfiles.Dir(filepath.Join("volumes", c.Name(), pkgname))
log.Debug().Msgf("cleanup %s", pkgdir)

View File

@ -11,7 +11,7 @@ import (
"github.com/rs/zerolog/log"
"code.dumpstack.io/tools/out-of-tree/cache"
"code.dumpstack.io/tools/out-of-tree/config"
"code.dumpstack.io/tools/out-of-tree/config/dotfiles"
"code.dumpstack.io/tools/out-of-tree/distro/debian/snapshot"
"code.dumpstack.io/tools/out-of-tree/distro/debian/snapshot/metasnap"
"code.dumpstack.io/tools/out-of-tree/fs"
@ -406,7 +406,7 @@ func GetKernelsWithLimit(limit int, mode GetKernelsMode) (kernels []DebianKernel
err error) {
if CachePath == "" {
CachePath = config.File("debian.cache")
CachePath = dotfiles.File("debian.cache")
log.Debug().Msgf("Use default kernels cache path: %s", CachePath)
if !fs.PathExists(CachePath) {

View File

@ -12,8 +12,6 @@ import (
"code.dumpstack.io/tools/out-of-tree/distro/debian/snapshot/mr"
)
const timeLayout = "20060102T150405Z"
const URL = "https://snapshot.debian.org"
func SourcePackageVersions(name string) (versions []string, err error) {

View File

@ -99,3 +99,8 @@ func (d Distro) RootFS() string {
return ""
}
type Command struct {
Distro Distro
Command string
}

View File

@ -83,10 +83,7 @@ func (suse OpenSUSE) Packages() (pkgs []string, err error) {
return
}
for _, pkg := range strings.Fields(output) {
pkgs = append(pkgs, pkg)
}
pkgs = append(pkgs, strings.Fields(output)...)
return
}

View File

@ -7,7 +7,7 @@ import (
"github.com/rs/zerolog/log"
"code.dumpstack.io/tools/out-of-tree/config"
"code.dumpstack.io/tools/out-of-tree/config/dotfiles"
"code.dumpstack.io/tools/out-of-tree/container"
"code.dumpstack.io/tools/out-of-tree/distro"
)
@ -57,15 +57,12 @@ func (ol OracleLinux) Packages() (pkgs []string, err error) {
"| grep -v src " +
"| cut -d ' ' -f 1"
output, err := c.Run(config.Dir("tmp"), []string{cmd})
output, err := c.Run(dotfiles.Dir("tmp"), []string{cmd})
if err != nil {
return
}
for _, pkg := range strings.Fields(output) {
pkgs = append(pkgs, pkg)
}
pkgs = append(pkgs, strings.Fields(output)...)
return
}

View File

@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"code.dumpstack.io/tools/out-of-tree/config"
"code.dumpstack.io/tools/out-of-tree/config/dotfiles"
"code.dumpstack.io/tools/out-of-tree/container"
"code.dumpstack.io/tools/out-of-tree/distro"
)
@ -51,15 +51,12 @@ func (u Ubuntu) Packages() (pkgs []string, err error) {
"--names-only '^linux-image-[0-9\\.\\-]*-generic$' " +
"| awk '{ print $1 }'"
output, err := c.Run(config.Dir("tmp"), []string{cmd})
output, err := c.Run(dotfiles.Dir("tmp"), []string{cmd})
if err != nil {
return
}
for _, pkg := range strings.Fields(output) {
pkgs = append(pkgs, pkg)
}
pkgs = append(pkgs, strings.Fields(output)...)
return
}