mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 17:17:22 +01: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
|
||||
goimports:
|
||||
local-prefixes: github.com/Jguer/yay/v10
|
||||
golint:
|
||||
min-confidence: 0
|
||||
gomnd:
|
||||
settings:
|
||||
mnd:
|
||||
@ -84,7 +82,6 @@ linters:
|
||||
#- dogsled
|
||||
# disabled for now
|
||||
#- godox
|
||||
#- interfacer
|
||||
|
||||
issues:
|
||||
# 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
|
||||
}
|
||||
|
||||
// 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 {
|
||||
pkgURL, err := getPackageRepoURL(dbName)
|
||||
if err != nil {
|
||||
|
@ -5,8 +5,13 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"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/text"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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
|
||||
// then it is missing
|
||||
// Mode does not allow AUR packages
|
||||
|
||||
return dbName, name, aur, true
|
||||
}
|
||||
} else {
|
||||
@ -216,5 +215,6 @@ func getPackageUsableName(dbExecutor DBSearcher, target string, mode settings.Ta
|
||||
if aur && mode == settings.ModeRepo {
|
||||
return dbName, name, aur, true
|
||||
}
|
||||
|
||||
return dbName, name, aur, false
|
||||
}
|
||||
|
21
vcs.go
21
vcs.go
@ -1,12 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/leonelquinteros/gotext"
|
||||
|
||||
"github.com/Jguer/yay/v10/pkg/db"
|
||||
"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/settings"
|
||||
"github.com/Jguer/yay/v10/pkg/stringset"
|
||||
@ -30,8 +32,23 @@ func createDevelDB(config *settings.Configuration, dbExecutor db.Executor) error
|
||||
|
||||
bases := dep.GetBases(info)
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user