mirror of
https://github.com/Jguer/yay
synced 2024-10-31 13:42:27 +00: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
2 changed files with 64 additions and 16 deletions
27
cmd.go
27
cmd.go
|
@ -561,3 +561,30 @@ func passToMakepkg(dir string, args ...string) (err error) {
|
||||||
}
|
}
|
||||||
return
|
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
|
removeMake := false
|
||||||
srcinfosStale := make(map[string]*gopkg.PKGBUILD)
|
srcinfosStale := make(map[string]*gopkg.PKGBUILD)
|
||||||
srcinfos := make(map[string]*gopkg.PKGBUILD)
|
|
||||||
|
|
||||||
//remotenames: names of all non repo packages on the system
|
//remotenames: names of all non repo packages on the system
|
||||||
_, _, localNames, remoteNames, err := filterPackages()
|
_, _, localNames, remoteNames, err := filterPackages()
|
||||||
|
@ -246,12 +245,7 @@ func install(parser *arguments) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = parseSRCINFOGenerate(dc.Aur, srcinfos, dc.Bases)
|
err = buildInstallPkgBuilds(dc.Aur, srcinfosStale, parser.targets, parser, dc.Bases, incompatible)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = buildInstallPkgBuilds(dc.Aur, srcinfos, parser.targets, parser, dc.Bases, incompatible)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -323,6 +317,24 @@ nextpkg:
|
||||||
return incompatible, nil
|
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) {
|
func cleanEditNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed stringSet) ([]*rpc.Pkg, []*rpc.Pkg, error) {
|
||||||
toPrint := ""
|
toPrint := ""
|
||||||
askClean := false
|
askClean := false
|
||||||
|
@ -349,7 +361,6 @@ func cleanEditNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed
|
||||||
|
|
||||||
fmt.Print(toPrint)
|
fmt.Print(toPrint)
|
||||||
|
|
||||||
|
|
||||||
if askClean {
|
if askClean {
|
||||||
fmt.Println(bold(green(arrow + " Packages to cleanBuild?")))
|
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)"))
|
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) {
|
func downloadPkgBuildsSources(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, incompatable stringSet) (err error) {
|
||||||
for _, pkg := range pkgs {
|
for _, pkg := range pkgs {
|
||||||
dir := config.BuildDir + pkg.PackageBase + "/"
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
||||||
args := []string{"--nobuild", "--nocheck", "--noprepare", "--nodeps"}
|
args := []string{"--verifysource", "-Ccf"}
|
||||||
|
|
||||||
if incompatable.get(pkg.PackageBase) {
|
if incompatable.get(pkg.PackageBase) {
|
||||||
args = append(args, "--ignorearch")
|
args = append(args, "--ignorearch")
|
||||||
|
@ -605,17 +616,27 @@ func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD,
|
||||||
built := true
|
built := true
|
||||||
|
|
||||||
srcinfo := srcinfos[pkg.PackageBase]
|
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)) {
|
if config.ReBuild == "no" || (config.ReBuild == "yes" && !targets.get(pkg.Name)) {
|
||||||
for _, split := range bases[pkg.PackageBase] {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if file == "" {
|
if file == "" {
|
||||||
file, err = completeFileName(dir, split.Name+"-"+version.String()+"-"+"any"+".pkg")
|
file, err = completeFileName(dir, split.Name+"-"+version+"-"+"any"+".pkg")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -631,7 +652,7 @@ func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD,
|
||||||
|
|
||||||
if built {
|
if built {
|
||||||
fmt.Println(bold(yellow(arrow)),
|
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 {
|
} else {
|
||||||
args := []string{"-Ccf", "--noconfirm"}
|
args := []string{"-Ccf", "--noconfirm"}
|
||||||
|
|
||||||
|
@ -671,20 +692,20 @@ func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD,
|
||||||
localNamesCache := sliceToStringSet(localNames)
|
localNamesCache := sliceToStringSet(localNames)
|
||||||
|
|
||||||
for _, split := range bases[pkg.PackageBase] {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if file == "" {
|
if file == "" {
|
||||||
file, err = completeFileName(dir, split.Name+"-"+version.String()+"-"+"any"+".pkg")
|
file, err = completeFileName(dir, split.Name+"-"+version+"-"+"any"+".pkg")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if file == "" {
|
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)
|
arguments.addTarget(file)
|
||||||
|
|
Loading…
Reference in a new issue