mirror of
https://github.com/mudler/luet.git
synced 2025-09-16 23:31:08 +00:00
Preserve cache data from deletion during uninstall
This commit is contained in:
@@ -87,6 +87,7 @@ var installCmd = &cobra.Command{
|
|||||||
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"
|
||||||
@@ -41,6 +42,7 @@ type LuetInstallerOptions struct {
|
|||||||
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