mirror of
https://github.com/Jguer/yay.git
synced 2024-11-07 01:27:21 +01:00
Merge pull request #1101 from Morganamilo/#942
Add SudoBin and SudoFlags
This commit is contained in:
commit
9420a9724f
2
cmd.go
2
cmd.go
@ -111,6 +111,8 @@ Permanent configuration options:
|
|||||||
--batchinstall Build multiple AUR packages then install them together
|
--batchinstall Build multiple AUR packages then install them together
|
||||||
--nobatchinstall Build and install each AUR package one by one
|
--nobatchinstall Build and install each AUR package one by one
|
||||||
|
|
||||||
|
--sudo <file> sudo command to use
|
||||||
|
--sudoflags <flags> Pass arguments to sudo
|
||||||
--sudoloop Loop sudo calls in the background to avoid timeout
|
--sudoloop Loop sudo calls in the background to avoid timeout
|
||||||
--nosudoloop Do not loop sudo calls in the background
|
--nosudoloop Do not loop sudo calls in the background
|
||||||
|
|
||||||
|
@ -61,6 +61,8 @@ type Configuration struct {
|
|||||||
SearchBy string `json:"searchby"`
|
SearchBy string `json:"searchby"`
|
||||||
GitFlags string `json:"gitflags"`
|
GitFlags string `json:"gitflags"`
|
||||||
RemoveMake string `json:"removemake"`
|
RemoveMake string `json:"removemake"`
|
||||||
|
SudoBin string `json:"sudobin"`
|
||||||
|
SudoFlags string `json:"sudoflags"`
|
||||||
RequestSplitN int `json:"requestsplitn"`
|
RequestSplitN int `json:"requestsplitn"`
|
||||||
SearchMode int `json:"-"`
|
SearchMode int `json:"-"`
|
||||||
SortMode int `json:"sortmode"`
|
SortMode int `json:"sortmode"`
|
||||||
@ -166,6 +168,8 @@ func defaultSettings() *Configuration {
|
|||||||
TarBin: "bsdtar",
|
TarBin: "bsdtar",
|
||||||
GitBin: "git",
|
GitBin: "git",
|
||||||
GpgBin: "gpg",
|
GpgBin: "gpg",
|
||||||
|
SudoBin: "sudo",
|
||||||
|
SudoFlags: "",
|
||||||
TimeUpdate: false,
|
TimeUpdate: false,
|
||||||
RequestSplitN: 150,
|
RequestSplitN: 150,
|
||||||
ReDownload: "no",
|
ReDownload: "no",
|
||||||
@ -211,6 +215,8 @@ func (config *Configuration) expandEnv() {
|
|||||||
config.TarBin = os.ExpandEnv(config.TarBin)
|
config.TarBin = os.ExpandEnv(config.TarBin)
|
||||||
config.GitBin = os.ExpandEnv(config.GitBin)
|
config.GitBin = os.ExpandEnv(config.GitBin)
|
||||||
config.GpgBin = os.ExpandEnv(config.GpgBin)
|
config.GpgBin = os.ExpandEnv(config.GpgBin)
|
||||||
|
config.SudoBin = os.ExpandEnv(config.SudoBin)
|
||||||
|
config.SudoFlags = os.ExpandEnv(config.SudoFlags)
|
||||||
config.ReDownload = os.ExpandEnv(config.ReDownload)
|
config.ReDownload = os.ExpandEnv(config.ReDownload)
|
||||||
config.ReBuild = os.ExpandEnv(config.ReBuild)
|
config.ReBuild = os.ExpandEnv(config.ReBuild)
|
||||||
config.AnswerClean = os.ExpandEnv(config.AnswerClean)
|
config.AnswerClean = os.ExpandEnv(config.AnswerClean)
|
||||||
|
13
doc/yay.8
13
doc/yay.8
@ -502,6 +502,19 @@ gpg is called by Yay. Arguments are split on whitespace before being
|
|||||||
passed to gpg. Multiple arguments may be passed by supplying a space
|
passed to gpg. Multiple arguments may be passed by supplying a space
|
||||||
separated list that is quoted by the shell.
|
separated list that is quoted by the shell.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B \-\-sudo <command>
|
||||||
|
The command to use for \fBsudo\fR calls. This can be a command in
|
||||||
|
\fBPATH\fR or an absolute path to the file.
|
||||||
|
The sudoloop is not guarantee to work with a custom \fBsudo\fR command.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B \-\-sudoflags <flags>
|
||||||
|
Passes arguments to sudo. These flags get passed to every instance where
|
||||||
|
sudo is called by Yay. Arguments are split on whitespace before being
|
||||||
|
passed to sudo. Multiple arguments may be passed by supplying a space
|
||||||
|
separated list that is quoted by the shell.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-\-sudoloop
|
.B \-\-sudoloop
|
||||||
Loop sudo calls in the background to prevent sudo from timing out during long
|
Loop sudo calls in the background to prevent sudo from timing out during long
|
||||||
|
9
exec.go
9
exec.go
@ -45,7 +45,9 @@ func sudoLoop() {
|
|||||||
|
|
||||||
func updateSudo() {
|
func updateSudo() {
|
||||||
for {
|
for {
|
||||||
err := show(exec.Command("sudo", "-v"))
|
mSudoFlags := strings.Fields(config.SudoFlags)
|
||||||
|
mSudoFlags = append([]string{"-v"}, mSudoFlags...)
|
||||||
|
err := show(exec.Command(config.SudoBin, mSudoFlags...))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
} else {
|
} else {
|
||||||
@ -76,8 +78,11 @@ func waitLock() {
|
|||||||
func passToPacman(args *arguments) *exec.Cmd {
|
func passToPacman(args *arguments) *exec.Cmd {
|
||||||
argArr := make([]string, 0)
|
argArr := make([]string, 0)
|
||||||
|
|
||||||
|
mSudoFlags := strings.Fields(config.SudoFlags)
|
||||||
|
|
||||||
if args.needRoot() {
|
if args.needRoot() {
|
||||||
argArr = append(argArr, "sudo")
|
argArr = append(argArr, config.SudoBin)
|
||||||
|
argArr = append(argArr, mSudoFlags...)
|
||||||
}
|
}
|
||||||
|
|
||||||
argArr = append(argArr, config.PacmanBin)
|
argArr = append(argArr, config.PacmanBin)
|
||||||
|
@ -421,6 +421,8 @@ func isArg(arg string) bool {
|
|||||||
case "tar":
|
case "tar":
|
||||||
case "git":
|
case "git":
|
||||||
case "gpg":
|
case "gpg":
|
||||||
|
case "sudo":
|
||||||
|
case "sudoflags":
|
||||||
case "requestsplitn":
|
case "requestsplitn":
|
||||||
case "sudoloop":
|
case "sudoloop":
|
||||||
case "nosudoloop":
|
case "nosudoloop":
|
||||||
@ -558,6 +560,10 @@ func handleConfig(option, value string) bool {
|
|||||||
config.GitBin = value
|
config.GitBin = value
|
||||||
case "gpg":
|
case "gpg":
|
||||||
config.GpgBin = value
|
config.GpgBin = value
|
||||||
|
case "sudo":
|
||||||
|
config.SudoBin = value
|
||||||
|
case "sudoflags":
|
||||||
|
config.SudoFlags = value
|
||||||
case "requestsplitn":
|
case "requestsplitn":
|
||||||
n, err := strconv.Atoi(value)
|
n, err := strconv.Atoi(value)
|
||||||
if err == nil && n > 0 {
|
if err == nil && n > 0 {
|
||||||
@ -692,6 +698,8 @@ func hasParam(arg string) bool {
|
|||||||
case "tar":
|
case "tar":
|
||||||
case "git":
|
case "git":
|
||||||
case "gpg":
|
case "gpg":
|
||||||
|
case "sudo":
|
||||||
|
case "sudoflags":
|
||||||
case "requestsplitn":
|
case "requestsplitn":
|
||||||
case "answerclean":
|
case "answerclean":
|
||||||
case "answerdiff":
|
case "answerdiff":
|
||||||
|
Loading…
Reference in New Issue
Block a user