mirror of
https://github.com/mudler/luet.git
synced 2025-08-26 10:58:55 +00:00
🔧 Consider removals when appending packages to be uninstalled
This commit is contained in:
parent
0a90129e34
commit
fbe9b038dd
@ -357,7 +357,7 @@ func (l *LuetInstaller) installerOpWorker(i int, wg *sync.WaitGroup, systemLock
|
|||||||
l.Options.Context.Debug("Replacing package inplace")
|
l.Options.Context.Debug("Replacing package inplace")
|
||||||
toUninstall, uninstall, err := l.generateUninstallFn(pp.Option, s, pp.Package)
|
toUninstall, uninstall, err := l.generateUninstallFn(pp.Option, s, pp.Package)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Options.Context.Error("Failed to generate Uninstall function for" + err.Error())
|
l.Options.Context.Debug("Skipping uninstall, fail to generate uninstall function, error: " + err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
systemLock.Lock()
|
systemLock.Lock()
|
||||||
@ -399,7 +399,7 @@ func (l *LuetInstaller) getOpsWithOptions(
|
|||||||
toUninstall pkg.Packages, installMatch map[string]ArtifactMatch, installOpt, uninstallOpt Option,
|
toUninstall pkg.Packages, installMatch map[string]ArtifactMatch, installOpt, uninstallOpt Option,
|
||||||
syncedRepos Repositories, toInstall pkg.Packages, solution solver.PackagesAssertions, allRepos pkg.PackageDatabase, s *System) ([]installerOp, error) {
|
syncedRepos Repositories, toInstall pkg.Packages, solution solver.PackagesAssertions, allRepos pkg.PackageDatabase, s *System) ([]installerOp, error) {
|
||||||
|
|
||||||
l.Options.Context.Info("Computing installation order")
|
l.Options.Context.Debug("Computing installation order")
|
||||||
resOps := []installerOp{}
|
resOps := []installerOp{}
|
||||||
|
|
||||||
insertPackage := func(install pkg.Package, uninstall ...pkg.Package) {
|
insertPackage := func(install pkg.Package, uninstall ...pkg.Package) {
|
||||||
@ -456,13 +456,14 @@ func (l *LuetInstaller) getOpsWithOptions(
|
|||||||
for _, p := range foundPackages {
|
for _, p := range foundPackages {
|
||||||
if _, ok := removals[p.GetPackageName()]; !ok {
|
if _, ok := removals[p.GetPackageName()]; !ok {
|
||||||
toRemove = append(toRemove, p)
|
toRemove = append(toRemove, p)
|
||||||
}
|
|
||||||
removals[p.GetPackageName()] = nil
|
removals[p.GetPackageName()] = nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
insertPackage(match.Package, toRemove...)
|
insertPackage(match.Package, toRemove...)
|
||||||
} else if pack, err := toUninstall.Find(match.Package.GetPackageName()); err == nil {
|
} else if pack, err := toUninstall.Find(match.Package.GetPackageName()); err == nil {
|
||||||
if _, ok := removals[pack.GetPackageName()]; !ok {
|
if _, ok := removals[pack.GetPackageName()]; !ok {
|
||||||
insertPackage(match.Package, pack)
|
insertPackage(match.Package, pack)
|
||||||
|
removals[pack.GetPackageName()] = nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
insertPackage(match.Package)
|
insertPackage(match.Package)
|
||||||
@ -478,9 +479,12 @@ func (l *LuetInstaller) getOpsWithOptions(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
|
if _, ok := removals[p.GetPackageName()]; !ok {
|
||||||
resOps = append(resOps, installerOp{
|
resOps = append(resOps, installerOp{
|
||||||
Uninstall: []operation{{Package: p, Option: uninstallOpt}},
|
Uninstall: []operation{{Package: p, Option: uninstallOpt}},
|
||||||
})
|
})
|
||||||
|
removals[p.GetPackageName()] = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resOps, nil
|
return resOps, nil
|
||||||
@ -540,10 +544,17 @@ func (l *LuetInstaller) checkAndUpgrade(r Repositories, s *System) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if l.Options.AutoOSCheck {
|
if l.Options.AutoOSCheck {
|
||||||
|
l.Options.Context.Info("Performing automatic oscheck")
|
||||||
packs := s.OSCheck()
|
packs := s.OSCheck()
|
||||||
if len(packs) > 0 {
|
if len(packs) > 0 {
|
||||||
|
p := ""
|
||||||
|
for _, r := range packs {
|
||||||
|
p += " " + r.HumanReadableString()
|
||||||
|
}
|
||||||
|
l.Options.Context.Info("Following packages requires reinstallation: " + p)
|
||||||
return l.swap(o, r, packs, packs, s)
|
return l.swap(o, r, packs, packs, s)
|
||||||
}
|
}
|
||||||
|
l.Options.Context.Info("OSCheck done")
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
@ -31,9 +31,11 @@ func (s *System) OSCheck() (notFound pkg.Packages) {
|
|||||||
defer s.Unlock()
|
defer s.Unlock()
|
||||||
for f, p := range s.fileIndex {
|
for f, p := range s.fileIndex {
|
||||||
if _, err := os.Lstat(filepath.Join(s.Target, f)); err != nil {
|
if _, err := os.Lstat(filepath.Join(s.Target, f)); err != nil {
|
||||||
|
if _, err := s.Database.FindPackage(p); err == nil {
|
||||||
notFound = append(notFound, p)
|
notFound = append(notFound, p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
notFound = notFound.Unique()
|
notFound = notFound.Unique()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user