Browse Source

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

Jguer 8 năm trước cách đây
mục cha
commit
3905dd86a4
3 tập tin đã thay đổi với 17 bổ sung2 xóa
  1. 13 2
      aur/aur.go
  2. 2 0
      config/config.go
  3. 2 0
      yay.go

+ 13 - 2
aur/aur.go

@@ -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

+ 2 - 0
config/config.go

@@ -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 - 0
yay.go

@@ -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":