mirror of
https://github.com/Jguer/yay
synced 2024-08-31 05:39:29 +00:00
Move passToFoo() functions to their own file
This commit is contained in:
parent
473a2de225
commit
8427dc3804
70
cmd.go
70
cmd.go
|
@ -2,12 +2,10 @@ package main
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -578,71 +576,3 @@ func numberMenu(pkgS []string, flags []string) (err error) {
|
|||
|
||||
return err
|
||||
}
|
||||
|
||||
func show(cmd *exec.Cmd) error {
|
||||
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return fmt.Errorf("")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func capture(cmd *exec.Cmd) (string, string, error) {
|
||||
var outbuf, errbuf bytes.Buffer
|
||||
|
||||
cmd.Stdout = &outbuf
|
||||
cmd.Stderr = &errbuf
|
||||
err := cmd.Run()
|
||||
stdout := outbuf.String()
|
||||
stderr := errbuf.String()
|
||||
|
||||
return stdout, stderr, err
|
||||
}
|
||||
|
||||
// passToPacman outsources execution to pacman binary without modifications.
|
||||
func passToPacman(args *arguments) *exec.Cmd {
|
||||
argArr := make([]string, 0)
|
||||
|
||||
if args.needRoot() {
|
||||
argArr = append(argArr, "sudo")
|
||||
}
|
||||
|
||||
argArr = append(argArr, config.PacmanBin)
|
||||
argArr = append(argArr, cmdArgs.formatGlobals()...)
|
||||
argArr = append(argArr, args.formatArgs()...)
|
||||
if config.NoConfirm {
|
||||
argArr = append(argArr, "--noconfirm")
|
||||
}
|
||||
|
||||
argArr = append(argArr, "--")
|
||||
|
||||
argArr = append(argArr, args.targets...)
|
||||
|
||||
return exec.Command(argArr[0], argArr[1:]...)
|
||||
}
|
||||
|
||||
// passToMakepkg outsources execution to makepkg binary without modifications.
|
||||
func passToMakepkg(dir string, args ...string) *exec.Cmd {
|
||||
if config.NoConfirm {
|
||||
args = append(args)
|
||||
}
|
||||
|
||||
mflags := strings.Fields(config.MFlags)
|
||||
args = append(args, mflags...)
|
||||
|
||||
cmd := exec.Command(config.MakepkgBin, args...)
|
||||
cmd.Dir = dir
|
||||
return cmd
|
||||
}
|
||||
|
||||
func passToGit(dir string, _args ...string) *exec.Cmd {
|
||||
gitflags := strings.Fields(config.GitFlags)
|
||||
args := []string{"-C", dir}
|
||||
args = append(args, gitflags...)
|
||||
args = append(args, _args...)
|
||||
|
||||
cmd := exec.Command(config.GitBin, args...)
|
||||
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||
return cmd
|
||||
}
|
||||
|
|
75
exec.go
Normal file
75
exec.go
Normal file
|
@ -0,0 +1,75 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func show(cmd *exec.Cmd) error {
|
||||
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return fmt.Errorf("")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func capture(cmd *exec.Cmd) (string, string, error) {
|
||||
var outbuf, errbuf bytes.Buffer
|
||||
|
||||
cmd.Stdout = &outbuf
|
||||
cmd.Stderr = &errbuf
|
||||
err := cmd.Run()
|
||||
stdout := outbuf.String()
|
||||
stderr := errbuf.String()
|
||||
|
||||
return stdout, stderr, err
|
||||
}
|
||||
|
||||
func passToPacman(args *arguments) *exec.Cmd {
|
||||
argArr := make([]string, 0)
|
||||
|
||||
if args.needRoot() {
|
||||
argArr = append(argArr, "sudo")
|
||||
}
|
||||
|
||||
argArr = append(argArr, config.PacmanBin)
|
||||
argArr = append(argArr, cmdArgs.formatGlobals()...)
|
||||
argArr = append(argArr, args.formatArgs()...)
|
||||
if config.NoConfirm {
|
||||
argArr = append(argArr, "--noconfirm")
|
||||
}
|
||||
|
||||
argArr = append(argArr, "--")
|
||||
|
||||
argArr = append(argArr, args.targets...)
|
||||
|
||||
return exec.Command(argArr[0], argArr[1:]...)
|
||||
}
|
||||
|
||||
func passToMakepkg(dir string, args ...string) *exec.Cmd {
|
||||
if config.NoConfirm {
|
||||
args = append(args)
|
||||
}
|
||||
|
||||
mflags := strings.Fields(config.MFlags)
|
||||
args = append(args, mflags...)
|
||||
|
||||
cmd := exec.Command(config.MakepkgBin, args...)
|
||||
cmd.Dir = dir
|
||||
return cmd
|
||||
}
|
||||
|
||||
func passToGit(dir string, _args ...string) *exec.Cmd {
|
||||
gitflags := strings.Fields(config.GitFlags)
|
||||
args := []string{"-C", dir}
|
||||
args = append(args, gitflags...)
|
||||
args = append(args, _args...)
|
||||
|
||||
cmd := exec.Command(config.GitBin, args...)
|
||||
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||
return cmd
|
||||
}
|
|
@ -978,7 +978,6 @@ func buildInstallPkgBuilds(dp *depPool, do *depOrder, srcinfos map[string]*gosrc
|
|||
return err
|
||||
}
|
||||
|
||||
|
||||
for _, pkg := range do.Bases[pkg.PackageBase] {
|
||||
updateVCSData(pkg.Name, srcinfo.Source)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue