Use alpm_sync_sysupgrade for uprepo

This allows us to support the Upgrade Usage option as well as relying on
alpm's logic instead of coming up with out own.

It is possible that this could lead to showing replaces in the upgrade
menu.
This commit is contained in:
morganamilo 2018-07-25 02:04:17 +01:00
parent 3180c66f39
commit f4aa7f7933
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E

View file

@ -297,23 +297,38 @@ func printLocalNewerThanAUR(
// upRepo gathers local packages and checks if they have new versions.
// Output: Upgrade type package list.
func upRepo(local []alpm.Package) (upSlice, error) {
dbList, err := alpmHandle.SyncDbs()
if err != nil {
return nil, err
}
slice := upSlice{}
for _, pkg := range local {
newPkg := pkg.NewVersion(dbList)
if newPkg != nil {
if pkg.ShouldIgnore() {
printIgnoringPackage(pkg, newPkg.Version())
} else {
slice = append(slice, upgrade{pkg.Name(), newPkg.DB().Name(), pkg.Version(), newPkg.Version()})
localDB, err := alpmHandle.LocalDb()
if err != nil {
return slice, err
}
err = alpmHandle.TransInit(alpm.TransFlagNoLock)
if err != nil {
return slice, err
}
defer alpmHandle.TransRelease()
alpmHandle.SyncSysupgrade(cmdArgs.existsDouble("u", "sysupgrade"))
alpmHandle.TransGetAdd().ForEach(func(pkg alpm.Package) error {
localPkg, err := localDB.PkgByName(pkg.Name())
localVer := "-"
if err == nil {
localVer = localPkg.Version()
}
slice = append(slice, upgrade{
pkg.Name(),
pkg.DB().Name(),
localVer,
pkg.Version(),
})
return nil
})
return slice, nil
}