Always pass PacmanConf to pacman

Normaly we only pass --config to pacman if the user specifies it on the
command line. Otherwise we let pacman use it's default config location.

If the user has changed pacmanconf in Yay's config file then this could
cause a miss match between the config we use to init alpm and the config
pacman is using.
This commit is contained in:
morganamilo 2018-07-28 19:51:19 +01:00
parent 6892ea153f
commit 5ce740068e
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E
4 changed files with 22 additions and 21 deletions

14
cmd.go
View file

@ -119,18 +119,6 @@ If no operation is provided -Y will be assumed`)
}
func handleCmd() (err error) {
for option, value := range cmdArgs.options {
if handleConfig(option, value) {
cmdArgs.delArg(option)
}
}
for option, value := range cmdArgs.globals {
if handleConfig(option, value) {
cmdArgs.delArg(option)
}
}
if shouldSaveConfig {
config.saveConfig()
}
@ -232,6 +220,8 @@ func handleConfig(option, value string) bool {
config.SortBy = value
case "noconfirm":
config.NoConfirm = true
case "config":
config.PacmanConf = value
case "redownload":
config.ReDownload = "yes"
case "redownloadall":

View file

@ -85,8 +85,8 @@ func passToPacman(args *arguments) *exec.Cmd {
argArr = append(argArr, "--noconfirm")
}
argArr = append(argArr, "--config", config.PacmanConf)
argArr = append(argArr, "--")
argArr = append(argArr, args.targets...)
if args.needRoot() {

View file

@ -109,11 +109,6 @@ func initAlpm() (err error) {
var exists bool
//var double bool
value, _, exists = cmdArgs.getArg("config")
if exists {
config.PacmanConf = value
}
alpmConf, err = readAlpmConfig(config.PacmanConf)
if err != nil {
err = fmt.Errorf("Unable to read Pacman conf: %s", err)
@ -223,6 +218,8 @@ func main() {
goto cleanup
}
cmdArgs.extractYayOptions()
err = initVCS()
if err != nil {
fmt.Println(err)

View file

@ -593,10 +593,10 @@ func (parser *arguments) parseCommandLine() (err error) {
parser.op = "Y"
}
if cmdArgs.existsArg("-") {
if parser.existsArg("-") {
var file *os.File
err = cmdArgs.parseStdin()
cmdArgs.delArg("-")
err = parser.parseStdin()
parser.delArg("-")
if err != nil {
return
@ -614,6 +614,20 @@ func (parser *arguments) parseCommandLine() (err error) {
return
}
func (parser *arguments) extractYayOptions() {
for option, value := range parser.options {
if handleConfig(option, value) {
parser.delArg(option)
}
}
for option, value := range parser.globals {
if handleConfig(option, value) {
parser.delArg(option)
}
}
}
//parses input for number menus splitted by spaces or commas
//supports individual selection: 1 2 3 4
//supports range selections: 1-4 10-20