mirror of
https://github.com/Jguer/yay
synced 2024-08-31 05:39:29 +00:00
chore(vcs): port VCS to download package
This commit is contained in:
parent
b8641256ab
commit
ab902e9cc6
|
@ -24,8 +24,6 @@ linters-settings:
|
||||||
min-complexity: 15
|
min-complexity: 15
|
||||||
goimports:
|
goimports:
|
||||||
local-prefixes: github.com/Jguer/yay/v10
|
local-prefixes: github.com/Jguer/yay/v10
|
||||||
golint:
|
|
||||||
min-confidence: 0
|
|
||||||
gomnd:
|
gomnd:
|
||||||
settings:
|
settings:
|
||||||
mnd:
|
mnd:
|
||||||
|
@ -84,7 +82,6 @@ linters:
|
||||||
#- dogsled
|
#- dogsled
|
||||||
# disabled for now
|
# disabled for now
|
||||||
#- godox
|
#- godox
|
||||||
#- interfacer
|
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
# Excluding configuration per-path, per-linter, per-text and per-source
|
# Excluding configuration per-path, per-linter, per-text and per-source
|
||||||
|
|
|
@ -82,7 +82,7 @@ func ABSPKGBUILD(httpClient *http.Client, dbName, pkgName string) ([]byte, error
|
||||||
return pkgBuild, nil
|
return pkgBuild, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ABSPKGBUILDRepo retrieves the PKGBUILD repository to a dest directory
|
// ABSPKGBUILDRepo retrieves the PKGBUILD repository to a dest directory.
|
||||||
func ABSPKGBUILDRepo(cmdRunner exe.Runner, cmdBuilder exe.GitCmdBuilder, dbName, pkgName, dest string, force bool) error {
|
func ABSPKGBUILDRepo(cmdRunner exe.Runner, cmdBuilder exe.GitCmdBuilder, dbName, pkgName, dest string, force bool) error {
|
||||||
pkgURL, err := getPackageRepoURL(dbName)
|
pkgURL, err := getPackageRepoURL(dbName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -5,8 +5,13 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/leonelquinteros/gotext"
|
||||||
|
|
||||||
|
"github.com/Jguer/yay/v10/pkg/multierror"
|
||||||
"github.com/Jguer/yay/v10/pkg/settings/exe"
|
"github.com/Jguer/yay/v10/pkg/settings/exe"
|
||||||
|
"github.com/Jguer/yay/v10/pkg/text"
|
||||||
)
|
)
|
||||||
|
|
||||||
var AURPackageURL = "https://aur.archlinux.org/cgit/aur.git"
|
var AURPackageURL = "https://aur.archlinux.org/cgit/aur.git"
|
||||||
|
@ -41,3 +46,49 @@ func AURPKGBUILDRepo(cmdRunner exe.Runner, cmdBuilder exe.GitCmdBuilder, aurURL,
|
||||||
|
|
||||||
return downloadGitRepo(cmdRunner, cmdBuilder, pkgURL, pkgName, dest, force)
|
return downloadGitRepo(cmdRunner, cmdBuilder, pkgURL, pkgName, dest, force)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AURPKGBUILDRepos(
|
||||||
|
cmdRunner exe.Runner,
|
||||||
|
cmdBuilder exe.GitCmdBuilder,
|
||||||
|
targets []string, aurURL, dest string, force bool) (map[string]bool, error) {
|
||||||
|
cloned := make(map[string]bool, len(targets))
|
||||||
|
|
||||||
|
var (
|
||||||
|
mux sync.Mutex
|
||||||
|
errs multierror.MultiError
|
||||||
|
wg sync.WaitGroup
|
||||||
|
)
|
||||||
|
|
||||||
|
sem := make(chan uint8, MaxConcurrentFetch)
|
||||||
|
|
||||||
|
for _, target := range targets {
|
||||||
|
sem <- 1
|
||||||
|
|
||||||
|
wg.Add(1)
|
||||||
|
|
||||||
|
go func(target string) {
|
||||||
|
err := AURPKGBUILDRepo(cmdRunner, cmdBuilder, aurURL, target, dest, force)
|
||||||
|
|
||||||
|
success := err == nil
|
||||||
|
if success {
|
||||||
|
mux.Lock()
|
||||||
|
cloned[target] = success
|
||||||
|
mux.Unlock()
|
||||||
|
} else {
|
||||||
|
errs.Add(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
text.OperationInfoln(
|
||||||
|
gotext.Get("(%d/%d) Downloaded PKGBUILD: %s",
|
||||||
|
len(cloned), len(targets), text.Cyan(target)))
|
||||||
|
|
||||||
|
<-sem
|
||||||
|
|
||||||
|
wg.Done()
|
||||||
|
}(target)
|
||||||
|
}
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
|
return cloned, errs.Return()
|
||||||
|
}
|
||||||
|
|
|
@ -199,7 +199,6 @@ func getPackageUsableName(dbExecutor DBSearcher, target string, mode settings.Ta
|
||||||
// if the user precised a db but the package is not in the db
|
// if the user precised a db but the package is not in the db
|
||||||
// then it is missing
|
// then it is missing
|
||||||
// Mode does not allow AUR packages
|
// Mode does not allow AUR packages
|
||||||
|
|
||||||
return dbName, name, aur, true
|
return dbName, name, aur, true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -216,5 +215,6 @@ func getPackageUsableName(dbExecutor DBSearcher, target string, mode settings.Ta
|
||||||
if aur && mode == settings.ModeRepo {
|
if aur && mode == settings.ModeRepo {
|
||||||
return dbName, name, aur, true
|
return dbName, name, aur, true
|
||||||
}
|
}
|
||||||
|
|
||||||
return dbName, name, aur, false
|
return dbName, name, aur, false
|
||||||
}
|
}
|
||||||
|
|
21
vcs.go
21
vcs.go
|
@ -1,12 +1,14 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/leonelquinteros/gotext"
|
"github.com/leonelquinteros/gotext"
|
||||||
|
|
||||||
"github.com/Jguer/yay/v10/pkg/db"
|
"github.com/Jguer/yay/v10/pkg/db"
|
||||||
"github.com/Jguer/yay/v10/pkg/dep"
|
"github.com/Jguer/yay/v10/pkg/dep"
|
||||||
|
"github.com/Jguer/yay/v10/pkg/download"
|
||||||
"github.com/Jguer/yay/v10/pkg/query"
|
"github.com/Jguer/yay/v10/pkg/query"
|
||||||
"github.com/Jguer/yay/v10/pkg/settings"
|
"github.com/Jguer/yay/v10/pkg/settings"
|
||||||
"github.com/Jguer/yay/v10/pkg/stringset"
|
"github.com/Jguer/yay/v10/pkg/stringset"
|
||||||
|
@ -30,8 +32,23 @@ func createDevelDB(config *settings.Configuration, dbExecutor db.Executor) error
|
||||||
|
|
||||||
bases := dep.GetBases(info)
|
bases := dep.GetBases(info)
|
||||||
toSkip := pkgbuildsToSkip(bases, stringset.FromSlice(remoteNames))
|
toSkip := pkgbuildsToSkip(bases, stringset.FromSlice(remoteNames))
|
||||||
_, err = downloadPkgbuilds(bases, toSkip, config.BuildDir)
|
|
||||||
if err != nil {
|
targets := make([]string, 0, len(bases))
|
||||||
|
for _, base := range bases {
|
||||||
|
if !toSkip.Get(base.Pkgbase()) {
|
||||||
|
targets = append(targets, base.Pkgbase())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toSkipSlice := toSkip.ToSlice()
|
||||||
|
if len(toSkipSlice) != 0 {
|
||||||
|
text.OperationInfoln(
|
||||||
|
gotext.Get("PKGBUILD up to date, Skipping (%d/%d): %s",
|
||||||
|
len(toSkipSlice), len(bases), text.Cyan(strings.Join(toSkipSlice, ", "))))
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, errA := download.AURPKGBUILDRepos(config.Runtime.CmdRunner,
|
||||||
|
config.Runtime.CmdBuilder, targets, config.AURURL, config.BuildDir, false); errA != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue