From f66349696e80f88dd8e0828fbcba6d5d5bef1b08 Mon Sep 17 00:00:00 2001 From: morganamilo Date: Tue, 6 Mar 2018 03:42:26 +0000 Subject: [PATCH 1/3] Add support to skip pkgbuild downloads. If a pkgbuild is already in cache and matches the version on the aur skip the download. The version we check comes from the .SRCINFO file on disk which is never updated. (updates through pkgver() edit the pkgbuild but do not effect the .SRCINFO). Therefore if the the version of the .SRCINFO matches the AUR's version there must not be an update. In the case of the on disk version being newer than the AUR version we can assume user interaction and they probably do not want it overwitten so in that case also skip the download. --- cmd.go | 20 ++++---------------- config.go | 2 ++ install.go | 27 +++++++++++++++++++++------ 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/cmd.go b/cmd.go index 15e9dfac..02bb2f8d 100644 --- a/cmd.go +++ b/cmd.go @@ -341,16 +341,6 @@ func handleConfig(option string) bool { config.CleanAfter = true case "noafterclean": config.CleanAfter = false - // case "gendb": - // err = createDevelDB() - // if err != nil { - // fmt.Println(err) - // } - // err = saveVCSInfo() - // if err != nil { - // fmt.Println(err) - // } - // os.Exit(0) case "devel": config.Devel = true case "nodevel": @@ -363,14 +353,12 @@ func handleConfig(option string) bool { config.SortMode = TopDown case "bottomup": config.SortMode = BottomUp - // case "help": - // usage() - // os.Exit(0) - // case "version": - // fmt.Printf("yay v%s\n", version) - // os.Exit(0) case "noconfirm": config.NoConfirm = true + case "redownload": + config.ReDownload = true + case "noredownload": + config.ReDownload = false default: return false } diff --git a/config.go b/config.go index b5101890..d394f3e9 100644 --- a/config.go +++ b/config.go @@ -39,6 +39,7 @@ type Configuration struct { NoConfirm bool `json:"-"` Devel bool `json:"devel"` CleanAfter bool `json:"cleanAfter"` + ReDownload bool `json:"redownload"` } var version = "3.373" @@ -112,6 +113,7 @@ func defaultSettings(config *Configuration) { config.TarBin = "/usr/bin/bsdtar" config.TimeUpdate = false config.RequestSplitN = 150 + config.ReDownload = false } // Editor returns the preferred system editor. diff --git a/install.go b/install.go index 775ed773..e0499df4 100644 --- a/install.go +++ b/install.go @@ -399,20 +399,35 @@ func parsesrcinfosGenerate(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD, return nil } -func dowloadPkgBuilds(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg) (err error) { +func dowloadPkgBuilds(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg) error { for k, pkg := range pkgs { - //todo make pretty - str := bold(cyan("::") + " Downloading (%d/%d): %s\n") + if !config.ReDownload { + dir := config.BuildDir + pkg.PackageBase + "/.SRCINFO" + pkgbuild, err := gopkg.ParseSRCINFO(dir) + + if err == nil { + version, err := gopkg.NewCompleteVersion(pkg.Version) + if err == nil { + if !version.Newer(pkgbuild.Version()) { + str := bold(cyan("::") + " PKGBUILD up to date, Skipping (%d/%d): %s\n") + fmt.Printf(str, k+1, len(pkgs), formatPkgbase(pkg, bases)) + continue + } + } + } + } + + str := bold(cyan("::") + " Downloading PKGBUILD (%d/%d): %s\n") fmt.Printf(str, k+1, len(pkgs), formatPkgbase(pkg, bases)) - err = downloadAndUnpack(baseURL+pkg.URLPath, config.BuildDir, false) + err := downloadAndUnpack(baseURL+pkg.URLPath, config.BuildDir, false) if err != nil { - return + return err } } - return + return nil } func downloadPkgBuildsSources(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg) (err error) { From d5fc1e0de5bebc2e9324cbd068cdcd201e93f795 Mon Sep 17 00:00:00 2001 From: morganamilo Date: Tue, 6 Mar 2018 15:17:55 +0000 Subject: [PATCH 2/3] Update docs for --redownload and --noredownload --- cmd.go | 2 ++ yay.8 | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/cmd.go b/cmd.go index 02bb2f8d..049fa45f 100644 --- a/cmd.go +++ b/cmd.go @@ -46,6 +46,8 @@ Permanent configuration options: --noafterclean Do not remove package sources after successful build --timeupdate Check package's AUR page for changes during sysupgrade --notimeupdate Do not checking of AUR page changes + --redownload Always download pkgbuilds + --noredownload Skip pkgbuild download if in cache and up to date Print specific options: -c --complete Used for completions diff --git a/yay.8 b/yay.8 index d13eb9f5..b070edd5 100644 --- a/yay.8 +++ b/yay.8 @@ -151,6 +151,17 @@ the last modification time of each package's AUR page\&. .RS 4 Do not consider build times during sysupgrade\&. .RE +.PP +\fB\-\-redownload\fR +.RS 4 +When downloading pkgbuilds if the pkgbuild is found in cache and is equal or +newer than the AUR's version use that instead of downloading a new one\&. +.RE +.PP +\fB\-\-noredownload\fR +.RS 4 +Always download pkgbuilds even when a copy is avaliable in cache\&. +.RE .SH "EXAMPLES" .PP yay \fIfoo\fR From a6cab60888be89f0c5bd36e3248299ecb8396e85 Mon Sep 17 00:00:00 2001 From: morganamilo Date: Wed, 7 Mar 2018 21:32:55 +0000 Subject: [PATCH 3/3] Add --redownloadall option and fix manpage descs --- cmd.go | 10 +++++++--- config.go | 4 ++-- install.go | 6 +++--- yay.8 | 12 +++++++++--- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/cmd.go b/cmd.go index 049fa45f..8ce6fdea 100644 --- a/cmd.go +++ b/cmd.go @@ -46,7 +46,8 @@ Permanent configuration options: --noafterclean Do not remove package sources after successful build --timeupdate Check package's AUR page for changes during sysupgrade --notimeupdate Do not checking of AUR page changes - --redownload Always download pkgbuilds + --redownload Always download pkgbuilds of targets + --redownloadall Always download pkgbuilds of all AUR packages --noredownload Skip pkgbuild download if in cache and up to date Print specific options: @@ -358,9 +359,11 @@ func handleConfig(option string) bool { case "noconfirm": config.NoConfirm = true case "redownload": - config.ReDownload = true + config.ReDownload = "yes" + case "redownloadall": + config.ReDownload = "all" case "noredownload": - config.ReDownload = false + config.ReDownload = "no" default: return false } @@ -370,6 +373,7 @@ func handleConfig(option string) bool { } func handleVersion() { + fmt.Print(config.ReDownload) fmt.Printf("yay v%s\n", version) } diff --git a/config.go b/config.go index d394f3e9..e95130ff 100644 --- a/config.go +++ b/config.go @@ -31,6 +31,7 @@ type Configuration struct { PacmanBin string `json:"pacmanbin"` PacmanConf string `json:"pacmanconf"` TarBin string `json:"tarbin"` + ReDownload string `json:"redownload"` RequestSplitN int `json:"requestsplitn"` SearchMode int `json:"-"` SortMode int `json:"sortmode"` @@ -39,7 +40,6 @@ type Configuration struct { NoConfirm bool `json:"-"` Devel bool `json:"devel"` CleanAfter bool `json:"cleanAfter"` - ReDownload bool `json:"redownload"` } var version = "3.373" @@ -113,7 +113,7 @@ func defaultSettings(config *Configuration) { config.TarBin = "/usr/bin/bsdtar" config.TimeUpdate = false config.RequestSplitN = 150 - config.ReDownload = false + config.ReDownload = "no" } // Editor returns the preferred system editor. diff --git a/install.go b/install.go index e0499df4..fb33c03d 100644 --- a/install.go +++ b/install.go @@ -164,7 +164,7 @@ func install(parser *arguments) error { return fmt.Errorf("Aborting due to user") } - err = dowloadPkgBuilds(dc.Aur, dc.Bases) + err = downloadPkgBuilds(dc.Aur, parser.targets, dc.Bases) if err != nil { return err } @@ -399,9 +399,9 @@ func parsesrcinfosGenerate(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD, return nil } -func dowloadPkgBuilds(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg) error { +func downloadPkgBuilds(pkgs []*rpc.Pkg, targets stringSet, bases map[string][]*rpc.Pkg) error { for k, pkg := range pkgs { - if !config.ReDownload { + if config.ReDownload == "no" || (config.ReDownload == "yes" && !targets.get(pkg.Name)) { dir := config.BuildDir + pkg.PackageBase + "/.SRCINFO" pkgbuild, err := gopkg.ParseSRCINFO(dir) diff --git a/yay.8 b/yay.8 index b070edd5..38fd30b6 100644 --- a/yay.8 +++ b/yay.8 @@ -154,13 +154,19 @@ Do not consider build times during sysupgrade\&. .PP \fB\-\-redownload\fR .RS 4 -When downloading pkgbuilds if the pkgbuild is found in cache and is equal or -newer than the AUR's version use that instead of downloading a new one\&. +Always download pkgbuilds of targets even when a copy is avaliable in cache\&. +.RE +.PP +\fB\-\-redownloadall\fR +.RS 4 +Always download pkgbuilds of all AUR packages even when a copy is avaliable +in cache\&. .RE .PP \fB\-\-noredownload\fR .RS 4 -Always download pkgbuilds even when a copy is avaliable in cache\&. +When downloading pkgbuilds if the pkgbuild is found in cache and is equal or +newer than the AUR's version use that instead of downloading a new one\&. .RE .SH "EXAMPLES" .PP