mirror of
https://github.com/Jguer/yay.git
synced 2024-11-07 17:47:21 +01:00
01666aef37
* give a more complete message on vcs error * bump timeouts for vcs checking
98 lines
2.4 KiB
Go
98 lines
2.4 KiB
Go
package upgrade
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/leonelquinteros/gotext"
|
|
|
|
"github.com/Jguer/yay/v12/pkg/db"
|
|
"github.com/Jguer/yay/v12/pkg/query"
|
|
"github.com/Jguer/yay/v12/pkg/text"
|
|
"github.com/Jguer/yay/v12/pkg/vcs"
|
|
)
|
|
|
|
func UpDevel(
|
|
ctx context.Context,
|
|
log *text.Logger,
|
|
remote map[string]db.IPackage,
|
|
aurdata map[string]*query.Pkg,
|
|
localCache vcs.Store,
|
|
) UpSlice {
|
|
toRemove := make([]string, 0)
|
|
toUpgrade := UpSlice{Up: make([]Upgrade, 0), Repos: []string{"devel"}}
|
|
|
|
ctxTimeout, cancel := context.WithTimeout(ctx, 20*time.Second)
|
|
defer cancel()
|
|
for pkgName, pkg := range remote {
|
|
if localCache.ToUpgrade(ctxTimeout, pkgName) {
|
|
if _, ok := aurdata[pkgName]; !ok {
|
|
text.Warnln(gotext.Get("ignoring package devel upgrade (no AUR info found):"), pkgName)
|
|
continue
|
|
}
|
|
|
|
if pkg.ShouldIgnore() {
|
|
printIgnoringPackage(log, pkg, "latest-commit")
|
|
continue
|
|
}
|
|
|
|
toUpgrade.Up = append(toUpgrade.Up,
|
|
Upgrade{
|
|
Name: pkg.Name(),
|
|
Base: pkg.Base(),
|
|
Repository: "devel",
|
|
LocalVersion: pkg.Version(),
|
|
RemoteVersion: "latest-commit",
|
|
Reason: pkg.Reason(),
|
|
})
|
|
}
|
|
}
|
|
|
|
localCache.RemovePackages(toRemove)
|
|
|
|
return toUpgrade
|
|
}
|
|
|
|
func printIgnoringPackage(logger *text.Logger, pkg db.IPackage, newPkgVersion string) {
|
|
left, right := GetVersionDiff(pkg.Version(), newPkgVersion)
|
|
|
|
logger.Warnln(gotext.Get("%s: ignoring package upgrade (%s => %s)",
|
|
text.Cyan(pkg.Name()),
|
|
left, right,
|
|
))
|
|
}
|
|
|
|
// UpAUR gathers foreign packages and checks if they have new versions.
|
|
// Output: Upgrade type package list.
|
|
func UpAUR(log *text.Logger, remote map[string]db.IPackage, aurdata map[string]*query.Pkg,
|
|
timeUpdate, enableDowngrade bool,
|
|
) UpSlice {
|
|
toUpgrade := UpSlice{Up: make([]Upgrade, 0), Repos: []string{"aur"}}
|
|
|
|
for name, pkg := range remote {
|
|
aurPkg, ok := aurdata[name]
|
|
if !ok {
|
|
continue
|
|
}
|
|
|
|
if (timeUpdate && (int64(aurPkg.LastModified) > pkg.BuildDate().Unix())) ||
|
|
(db.VerCmp(pkg.Version(), aurPkg.Version) < 0) || enableDowngrade {
|
|
if pkg.ShouldIgnore() {
|
|
printIgnoringPackage(log, pkg, aurPkg.Version)
|
|
} else {
|
|
toUpgrade.Up = append(toUpgrade.Up,
|
|
Upgrade{
|
|
Name: aurPkg.Name,
|
|
Base: aurPkg.PackageBase,
|
|
Repository: "aur",
|
|
LocalVersion: pkg.Version(),
|
|
RemoteVersion: aurPkg.Version,
|
|
Reason: pkg.Reason(),
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
return toUpgrade
|
|
}
|