mirror of
https://github.com/Jguer/yay
synced 2024-08-31 05:39:29 +00:00
Fixed pacman pass prepend
This commit is contained in:
parent
5b60bb6781
commit
1a77f42276
23
actions.go
23
actions.go
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/Jguer/go-alpm"
|
"github.com/Jguer/go-alpm"
|
||||||
|
@ -14,6 +15,7 @@ import (
|
||||||
func searchAndInstall(pkgName string, conf *alpm.PacmanConfig, flags string) (err error) {
|
func searchAndInstall(pkgName string, conf *alpm.PacmanConfig, flags string) (err error) {
|
||||||
var num int
|
var num int
|
||||||
var numberString string
|
var numberString string
|
||||||
|
var pacBuffer bytes.Buffer
|
||||||
|
|
||||||
a, err := aur.Search(pkgName, true)
|
a, err := aur.Search(pkgName, true)
|
||||||
r, err := SearchPackages(pkgName, conf)
|
r, err := SearchPackages(pkgName, conf)
|
||||||
|
@ -35,7 +37,7 @@ func searchAndInstall(pkgName string, conf *alpm.PacmanConfig, flags string) (er
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var index int
|
var aurInstall []aur.Result
|
||||||
result := strings.Fields(numberString)
|
result := strings.Fields(numberString)
|
||||||
for _, numS := range result {
|
for _, numS := range result {
|
||||||
num, err = strconv.Atoi(numS)
|
num, err = strconv.Atoi(numS)
|
||||||
|
@ -46,17 +48,22 @@ func searchAndInstall(pkgName string, conf *alpm.PacmanConfig, flags string) (er
|
||||||
|
|
||||||
// Install package
|
// Install package
|
||||||
if num > len(r.Results)-1 {
|
if num > len(r.Results)-1 {
|
||||||
index = num - len(r.Results)
|
aurInstall = append(aurInstall, a.Results[num-len(r.Results)])
|
||||||
err = a.Results[index].Install(BuildDir, conf, flags)
|
|
||||||
if err != nil {
|
|
||||||
// Do not abandon program, we might still be able to install the rest
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
InstallPackage(r.Results[num].Name, conf, flags)
|
pacBuffer.WriteString(r.Results[num].Name)
|
||||||
|
pacBuffer.WriteString(" ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InstallPackage(strings.TrimSpace(pacBuffer.String()), conf, flags)
|
||||||
|
|
||||||
|
for _, aurpkg := range aurInstall {
|
||||||
|
err = aurpkg.Install(BuildDir, conf, flags)
|
||||||
|
if err != nil {
|
||||||
|
// Do not abandon program, we might still be able to install the rest
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ func passToPacman(op string, pkg string, flags string) error {
|
||||||
if strings.Contains(op, "Q") {
|
if strings.Contains(op, "Q") {
|
||||||
cmd = exec.Command("pacman", args...)
|
cmd = exec.Command("pacman", args...)
|
||||||
} else {
|
} else {
|
||||||
args = append(args, "pacman")
|
args = append([]string{"pacman"}, args...)
|
||||||
cmd = exec.Command("sudo", args...)
|
cmd = exec.Command("sudo", args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
yay.go
3
yay.go
|
@ -7,9 +7,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PacmanBin describes the default installation point of pacman
|
|
||||||
const PacmanBin string = "/usr/bin/pacman"
|
|
||||||
|
|
||||||
// PacmanConf describes the default pacman config file
|
// PacmanConf describes the default pacman config file
|
||||||
const PacmanConf string = "/etc/pacman.conf"
|
const PacmanConf string = "/etc/pacman.conf"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue