mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 09:07:21 +01:00
Dont bump pkgver() while downloading sources
Previously we ran pkgver() right after dowloading sources. This is a problem because prepare() should be called and all dependencies should be installed before pkgver(). Instead bump the pkgver while building then get the new pkgver used for install. Previously we parsed `makepkg --printsrcinfo` to get the new version. Insead use `makepkg --packagelist` as it is much faster.
This commit is contained in:
parent
aa649d9b41
commit
24f596959d
27
cmd.go
27
cmd.go
@ -561,3 +561,30 @@ func passToMakepkg(dir string, args ...string) (err error) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func passToMakepkgCapture(dir string, args ...string) (string, string, error) {
|
||||
var outbuf, errbuf bytes.Buffer
|
||||
|
||||
if config.NoConfirm {
|
||||
args = append(args)
|
||||
}
|
||||
|
||||
mflags := strings.Fields(config.MFlags)
|
||||
args = append(args, mflags...)
|
||||
|
||||
cmd := exec.Command(config.MakepkgBin, args...)
|
||||
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||
cmd.Dir = dir
|
||||
cmd.Stdout = &outbuf
|
||||
cmd.Stderr = &errbuf
|
||||
|
||||
err := cmd.Run()
|
||||
stdout := outbuf.String()
|
||||
stderr := errbuf.String()
|
||||
|
||||
if err == nil {
|
||||
_ = saveVCSInfo()
|
||||
}
|
||||
|
||||
return stdout, stderr, err
|
||||
}
|
||||
|
53
install.go
53
install.go
@ -28,7 +28,6 @@ func install(parser *arguments) error {
|
||||
|
||||
removeMake := false
|
||||
srcinfosStale := make(map[string]*gopkg.PKGBUILD)
|
||||
srcinfos := make(map[string]*gopkg.PKGBUILD)
|
||||
|
||||
//remotenames: names of all non repo packages on the system
|
||||
_, _, localNames, remoteNames, err := filterPackages()
|
||||
@ -246,12 +245,7 @@ func install(parser *arguments) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = parseSRCINFOGenerate(dc.Aur, srcinfos, dc.Bases)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = buildInstallPkgBuilds(dc.Aur, srcinfos, parser.targets, parser, dc.Bases, incompatible)
|
||||
err = buildInstallPkgBuilds(dc.Aur, srcinfosStale, parser.targets, parser, dc.Bases, incompatible)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -323,6 +317,24 @@ nextpkg:
|
||||
return incompatible, nil
|
||||
}
|
||||
|
||||
func getVersionFromPkgbuild(dir string) (string, error) {
|
||||
stdout, stderr, err := passToMakepkgCapture(dir, "--packagelist")
|
||||
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("%s%s", stderr, err)
|
||||
}
|
||||
|
||||
line := strings.Split(stdout, "\n")[0]
|
||||
split := strings.Split(line, "-")
|
||||
|
||||
if len(split) < 4 {
|
||||
return "", fmt.Errorf("Can not parse version from: %s", split)
|
||||
}
|
||||
//pkg-name-pkgver-pkgrel-arch: extract pkgver-pkgrel
|
||||
ver := split[len(split)-3] + "-" + split[len(split)-2]
|
||||
return ver, nil
|
||||
}
|
||||
|
||||
func cleanEditNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed stringSet) ([]*rpc.Pkg, []*rpc.Pkg, error) {
|
||||
toPrint := ""
|
||||
askClean := false
|
||||
@ -349,7 +361,6 @@ func cleanEditNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed
|
||||
|
||||
fmt.Print(toPrint)
|
||||
|
||||
|
||||
if askClean {
|
||||
fmt.Println(bold(green(arrow + " Packages to cleanBuild?")))
|
||||
fmt.Println(bold(green(arrow) + cyan(" [N]one ") + "[A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)"))
|
||||
@ -579,7 +590,7 @@ func downloadPkgBuilds(pkgs []*rpc.Pkg, targets stringSet, bases map[string][]*r
|
||||
func downloadPkgBuildsSources(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, incompatable stringSet) (err error) {
|
||||
for _, pkg := range pkgs {
|
||||
dir := config.BuildDir + pkg.PackageBase + "/"
|
||||
args := []string{"--nobuild", "--nocheck", "--noprepare", "--nodeps"}
|
||||
args := []string{"--verifysource", "-Ccf"}
|
||||
|
||||
if incompatable.get(pkg.PackageBase) {
|
||||
args = append(args, "--ignorearch")
|
||||
@ -605,17 +616,27 @@ func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD,
|
||||
built := true
|
||||
|
||||
srcinfo := srcinfos[pkg.PackageBase]
|
||||
version := srcinfo.CompleteVersion()
|
||||
|
||||
//pkgver bump
|
||||
err := passToMakepkg(dir, "--nobuild", "-fCc")
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error making: %s", pkg.Name)
|
||||
}
|
||||
|
||||
version, err := getVersionFromPkgbuild(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if config.ReBuild == "no" || (config.ReBuild == "yes" && !targets.get(pkg.Name)) {
|
||||
for _, split := range bases[pkg.PackageBase] {
|
||||
file, err := completeFileName(dir, split.Name+"-"+version.String()+"-"+arch+".pkg")
|
||||
file, err := completeFileName(dir, split.Name+"-"+version+"-"+arch+".pkg")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if file == "" {
|
||||
file, err = completeFileName(dir, split.Name+"-"+version.String()+"-"+"any"+".pkg")
|
||||
file, err = completeFileName(dir, split.Name+"-"+version+"-"+"any"+".pkg")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -631,7 +652,7 @@ func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD,
|
||||
|
||||
if built {
|
||||
fmt.Println(bold(yellow(arrow)),
|
||||
cyan(pkg.Name+"-"+pkg.Version) + bold(" Already made -- skipping build"))
|
||||
cyan(pkg.Name+"-"+version)+bold(" Already made -- skipping build"))
|
||||
} else {
|
||||
args := []string{"-Ccf", "--noconfirm"}
|
||||
|
||||
@ -671,20 +692,20 @@ func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD,
|
||||
localNamesCache := sliceToStringSet(localNames)
|
||||
|
||||
for _, split := range bases[pkg.PackageBase] {
|
||||
file, err := completeFileName(dir, split.Name+"-"+version.String()+"-"+arch+".pkg")
|
||||
file, err := completeFileName(dir, split.Name+"-"+version+"-"+arch+".pkg")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if file == "" {
|
||||
file, err = completeFileName(dir, split.Name+"-"+version.String()+"-"+"any"+".pkg")
|
||||
file, err = completeFileName(dir, split.Name+"-"+version+"-"+"any"+".pkg")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if file == "" {
|
||||
return fmt.Errorf("Could not find built package " + split.Name + "-" + version.String() + "-" + arch + ".pkg")
|
||||
return fmt.Errorf("Could not find built package " + split.Name + "-" + version + "-" + arch + ".pkg")
|
||||
}
|
||||
|
||||
arguments.addTarget(file)
|
||||
|
Loading…
Reference in New Issue
Block a user