By default yay uses Package Version for updates. Use --timeupdates to set updates based on modification time. Closes #9

This commit is contained in:
Jguer 2017-05-25 00:28:35 +01:00
parent 22f8dcf150
commit 3905dd86a4
3 changed files with 17 additions and 2 deletions

View file

@ -167,7 +167,8 @@ func Upgrade(flags []string) error {
if _, ok := foreign[res.Name]; ok {
// Leaving this here for now, warn about downgrades later
if int64(res.LastModified) > foreign[res.Name].BuildDate().Unix() {
if (!config.YayConf.TimeUpdate && (int64(res.LastModified) > foreign[res.Name].BuildDate().Unix())) ||
alpm.VerCmp(foreign[res.Name].Version(), res.Version) < 0 {
buffer.WriteString(fmt.Sprintf("\x1b[1m\x1b[32m==>\x1b[33;1m %s: \x1b[0m%s \x1b[33;1m-> \x1b[0m%s\n",
res.Name, foreign[res.Name].Version(), res.Version))
outdated = append(outdated, res)
@ -187,8 +188,18 @@ func Upgrade(flags []string) error {
return nil
}
var finalmdeps []string
for _, pkgi := range outdated {
PkgInstall(&pkgi, flags)
mdeps, err := PkgInstall(&pkgi, flags)
finalmdeps = append(finalmdeps, mdeps...)
if err != nil {
fmt.Println(err)
}
}
err = pacman.CleanRemove(finalmdeps)
if err != nil {
fmt.Println(err)
}
return nil

View file

@ -38,6 +38,7 @@ type Configuration struct {
SearchMode int `json:"-"`
SortMode int `json:"sortmode"`
TarBin string `json:"tarbin"`
TimeUpdate bool `json:"versionupdate"`
}
// YayConf holds the current config values for yay.
@ -123,6 +124,7 @@ func defaultSettings(config *Configuration) {
config.PacmanConf = "/etc/pacman.conf"
config.SortMode = BottomUp
config.TarBin = "/usr/bin/bsdtar"
config.TimeUpdate = false
}
// Editor returns the preferred system editor.

2
yay.go
View file

@ -68,6 +68,8 @@ func parser() (op string, options []string, packages []string, changedConfig boo
config.YayConf.Devel = true
case "--nodevel":
config.YayConf.Devel = false
case "--timeupdates":
config.YayConf.TimeUpdate = true
case "--topdown":
config.YayConf.SortMode = config.TopDown
case "--complete":