From b4dd921f3b98c09dc6eacb8c9a976143714fd230 Mon Sep 17 00:00:00 2001 From: Jguer Date: Tue, 15 Nov 2016 00:00:44 +0000 Subject: [PATCH 1/3] Fixed yogurt mode --- yay.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yay.go b/yay.go index 2005acd..12e9aea 100644 --- a/yay.go +++ b/yay.go @@ -68,7 +68,7 @@ func main() { var err error conf, err := readConfig(PacmanConf) - op, pkgs, options, err := parser() + op, options, pkgs, err := parser() if err != nil { fmt.Println(err) os.Exit(1) @@ -88,6 +88,7 @@ func main() { case "yogurt": for _, pkg := range pkgs { err = searchAndInstall(pkg, &conf, options) + break } case "--help", "-h": usage() From 97d094aae98086909e9323d772befe237ef2ed76 Mon Sep 17 00:00:00 2001 From: Jguer Date: Tue, 15 Nov 2016 01:46:11 +0000 Subject: [PATCH 2/3] Parallel update checking --- aur/aur.go | 65 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/aur/aur.go b/aur/aur.go index a441adf..90336ef 100644 --- a/aur/aur.go +++ b/aur/aur.go @@ -193,7 +193,6 @@ func UpdatePackages(baseDir string, conf *alpm.PacmanConfig, flags []string) err } var foreign []alpm.Package - var outdated []string // Find foreign packages in system for _, pkg := range localDb.PkgCache().Slice() { @@ -213,21 +212,46 @@ func UpdatePackages(baseDir string, conf *alpm.PacmanConfig, flags []string) err } // Find outdated packages + type Outdated struct { + res *Result + pkgVersion string + er error + } + + r := make(chan *Outdated) // Allocate a channel. for _, pkg := range foreign { - info, err := Info(pkg.Name()) - if err != nil { - return err - } + // fmt.Println("Checking number", i, pkg.Name()) + go func(pkg alpm.Package) { + info, err := Info(pkg.Name()) + if err != nil { + r <- nil + return + } - if info.Resultcount == 0 { - continue - } + if info.Resultcount == 0 { + r <- nil + return + } - // Leaving this here for now, warn about downgrades later - if int64(info.Results[0].LastModified) > pkg.InstallDate().Unix() { + // Leaving this here for now, warn about downgrades later + if int64(info.Results[0].LastModified) > pkg.InstallDate().Unix() { + r <- &Outdated{&info.Results[0], pkg.Version(), err} + } else { + r <- nil + } + }(pkg) + } + + var outdated []*Result + var checkedPkg *Outdated + for i := 0; i < len(foreign); i++ { + // fmt.Println("Wait Cycle", i) + checkedPkg = <-r + // fmt.Println(checkedPkg) + if checkedPkg != nil { fmt.Printf("\x1b[1m\x1b[32m==>\x1b[33;1m %s: \x1b[0m%s \x1b[33;1m-> \x1b[0m%s\n", - pkg.Name(), pkg.Version(), info.Results[0].Version) - outdated = append(outdated, pkg.Name()) + checkedPkg.res.Name, checkedPkg.pkgVersion, checkedPkg.res.Version) + outdated = append(outdated, checkedPkg.res) } } @@ -248,7 +272,7 @@ func UpdatePackages(baseDir string, conf *alpm.PacmanConfig, flags []string) err } for _, pkg := range outdated { - Install(pkg, baseDir, conf, flags) + pkg.Install(baseDir, conf, flags) } return nil @@ -296,11 +320,22 @@ func (a *Result) Install(baseDir string, conf *alpm.PacmanConfig, flags []string err = editcmd.Run() } } - _, err = a.Dependencies(conf) + depS, err := a.Dependencies(conf) if err != nil { return } + for _, dep := range depS { + q, errD := Info(dep) + if errD != nil { + return errD + } + + if len(q.Results) != 0 { + q.Results[0].Install(baseDir, conf, []string{"--asdeps"}) + } + } + err = os.Chdir(dir.String()) if err != nil { return @@ -348,14 +383,12 @@ func (a *Result) Dependencies(conf *alpm.PacmanConfig) (final []string, err erro deps := append(info.Results[0].MakeDepends, info.Results[0].Depends...) for _, dep := range deps { fields := strings.FieldsFunc(dep, f) - fmt.Println(fields[0]) // If package is installed let it go. _, err = localDb.PkgByName(fields[0]) if err == nil { continue } - fmt.Println(fields[0]) // If package is in repo let it be installed by makepkg. found := false for _, db := range dbList.Slice() { From c02e460979898faea70e63d2f09e5ca246c39007 Mon Sep 17 00:00:00 2001 From: Jguer Date: Tue, 15 Nov 2016 09:49:20 +0000 Subject: [PATCH 3/3] Let's avoid bins ending up here again --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index fd72f5c..20bcc50 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ _testmain.go # Output of the go coverage tool, specifically when used with LiteIDE *.out bin/yay +yay