mirror of
https://github.com/mudler/luet.git
synced 2025-09-16 15:19:24 +00:00
Preserve cache data from deletion during uninstall
This commit is contained in:
@@ -82,11 +82,12 @@ var installCmd = &cobra.Command{
|
|||||||
Debug("Solver", LuetCfg.GetSolverOptions().CompactString())
|
Debug("Solver", LuetCfg.GetSolverOptions().CompactString())
|
||||||
|
|
||||||
inst := installer.NewLuetInstaller(installer.LuetInstallerOptions{
|
inst := installer.NewLuetInstaller(installer.LuetInstallerOptions{
|
||||||
Concurrency: LuetCfg.GetGeneral().Concurrency,
|
Concurrency: LuetCfg.GetGeneral().Concurrency,
|
||||||
SolverOptions: *LuetCfg.GetSolverOptions(),
|
SolverOptions: *LuetCfg.GetSolverOptions(),
|
||||||
NoDeps: nodeps,
|
NoDeps: nodeps,
|
||||||
Force: force,
|
Force: force,
|
||||||
OnlyDeps: onlydeps,
|
OnlyDeps: onlydeps,
|
||||||
|
PreserveSystemEssentialData: true,
|
||||||
})
|
})
|
||||||
inst.Repositories(repos)
|
inst.Repositories(repos)
|
||||||
|
|
||||||
|
@@ -21,6 +21,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/ghodss/yaml"
|
"github.com/ghodss/yaml"
|
||||||
@@ -36,11 +37,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type LuetInstallerOptions struct {
|
type LuetInstallerOptions struct {
|
||||||
SolverOptions config.LuetSolverOptions
|
SolverOptions config.LuetSolverOptions
|
||||||
Concurrency int
|
Concurrency int
|
||||||
NoDeps bool
|
NoDeps bool
|
||||||
OnlyDeps bool
|
OnlyDeps bool
|
||||||
Force bool
|
Force bool
|
||||||
|
PreserveSystemEssentialData bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type LuetInstaller struct {
|
type LuetInstaller struct {
|
||||||
@@ -375,7 +377,15 @@ func (l *LuetInstaller) uninstall(p pkg.Package, s *System) error {
|
|||||||
// Remove from target
|
// Remove from target
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
target := filepath.Join(s.Target, f)
|
target := filepath.Join(s.Target, f)
|
||||||
Info("Removing", target)
|
Debug("Removing", target)
|
||||||
|
|
||||||
|
if l.Options.PreserveSystemEssentialData &&
|
||||||
|
strings.HasPrefix(f, config.LuetCfg.GetSystem().GetSystemPkgsCacheDirPath()) ||
|
||||||
|
strings.HasPrefix(f, config.LuetCfg.GetSystem().GetSystemRepoDatabaseDirPath()) {
|
||||||
|
Warning("Preserve ", f, " which is required by luet ( you have to delete it manually if you really need to)")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
err := os.Remove(target)
|
err := os.Remove(target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Warning("Failed removing file (not present in the system target ?)", target)
|
Warning("Failed removing file (not present in the system target ?)", target)
|
||||||
|
Reference in New Issue
Block a user