Skip to content

Commit

Permalink
Remove default usage of --ask
Browse files Browse the repository at this point in the history
--ask is no longer used when installing AUR packages, instead pass no
confirm when we know there are no conflicts and wait for manual
confirmation when there are.

This means that when there are no conflicts there should be no change in
behaviour and the user will not need to intervene at all.

The old behaviour can still be used with --useask.
  • Loading branch information
Morganamilo committed Jun 22, 2018
1 parent da466ba commit ea5a94e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 13 deletions.
4 changes: 4 additions & 0 deletions cmd.go
Expand Up @@ -341,6 +341,10 @@ func handleConfig(option, value string) bool {
config.EditMenu = true
case "noeditmenu":
config.EditMenu = false
case "useask":
config.UseAsk = true
case "nouseask":
config.UseAsk = false
case "a", "aur":
mode = ModeAUR
case "repo":
Expand Down
2 changes: 2 additions & 0 deletions config.go
Expand Up @@ -69,6 +69,7 @@ type Configuration struct {
CleanMenu bool `json:"cleanmenu"`
DiffMenu bool `json:"diffmenu"`
EditMenu bool `json:"editmenu"`
UseAsk bool `json:"useask"`
}

var version = "7.885"
Expand Down Expand Up @@ -177,6 +178,7 @@ func defaultSettings(config *Configuration) {
config.CleanMenu = true
config.DiffMenu = true
config.EditMenu = false
config.UseAsk = false
}

// Editor returns the preferred system editor.
Expand Down
11 changes: 8 additions & 3 deletions depCheck.go
Expand Up @@ -124,7 +124,7 @@ func (dp *depPool) checkReverseConflicts(conflicts mapStringSet) {
})
}

func (dp *depPool) CheckConflicts() error {
func (dp *depPool) CheckConflicts() (mapStringSet, error) {
var wg sync.WaitGroup
innerConflicts := make(mapStringSet)
conflicts := make(mapStringSet)
Expand Down Expand Up @@ -159,12 +159,17 @@ func (dp *depPool) CheckConflicts() error {
fmt.Println(str)
}

return fmt.Errorf("Unresolvable package conflicts, aborting")
return nil, fmt.Errorf("Unresolvable package conflicts, aborting")
}

if len(conflicts) != 0 {
fmt.Println()
fmt.Println(bold(red(arrow)), bold("Package conflicts found:"))

if !config.UseAsk {
fmt.Println(bold(red(arrow)), bold("You will have to confirm these when installing"))
}

for name, pkgs := range conflicts {
str := red(bold(smallArrow)) + " Installing " + cyan(name) + " will remove:"
for pkg := range pkgs {
Expand All @@ -178,7 +183,7 @@ func (dp *depPool) CheckConflicts() error {
fmt.Println()
}

return nil
return conflicts, nil
}

type missing struct {
Expand Down
34 changes: 24 additions & 10 deletions install.go
Expand Up @@ -116,7 +116,7 @@ func install(parser *arguments) error {
return fmt.Errorf(bold(red(arrow)) + " Refusing to install AUR Packages as root, Aborting.")
}

err = dp.CheckConflicts()
conflicts, err := dp.CheckConflicts()
if err != nil {
return err
}
Expand Down Expand Up @@ -279,17 +279,12 @@ func install(parser *arguments) error {
}
}

//conflicts have been checked so answer y for them
ask, _ := strconv.Atoi(cmdArgs.globals["ask"])
uask := alpm.QuestionType(ask) | alpm.QuestionTypeConflictPkg
cmdArgs.globals["ask"] = fmt.Sprint(uask)

err = downloadPkgBuildsSources(do.Aur, do.Bases, incompatible)
if err != nil {
return err
}

err = buildInstallPkgBuilds(dp, do, srcinfosStale, parser, incompatible)
err = buildInstallPkgBuilds(dp, do, srcinfosStale, parser, incompatible, conflicts)
if err != nil {
return err
}
Expand Down Expand Up @@ -745,7 +740,7 @@ func downloadPkgBuildsSources(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, inco
return
}

func buildInstallPkgBuilds(dp *depPool, do *depOrder, srcinfos map[string]*gopkg.PKGBUILD, parser *arguments, incompatible stringSet) error {
func buildInstallPkgBuilds(dp *depPool, do *depOrder, srcinfos map[string]*gopkg.PKGBUILD, parser *arguments, incompatible stringSet, conflicts mapStringSet) error {
for _, pkg := range do.Aur {
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
built := true
Expand Down Expand Up @@ -807,13 +802,34 @@ func buildInstallPkgBuilds(dp *depPool, do *depOrder, srcinfos map[string]*gopkg
arguments.clearTargets()
arguments.op = "U"
arguments.delArg("confirm")
arguments.delArg("noconfirm")
arguments.delArg("c", "clean")
arguments.delArg("q", "quiet")
arguments.delArg("q", "quiet")
arguments.delArg("y", "refresh")
arguments.delArg("u", "sysupgrade")
arguments.delArg("w", "downloadonly")

oldConfirm := config.NoConfirm

//conflicts have been checked so answer y for them
if config.UseAsk {
ask, _ := strconv.Atoi(cmdArgs.globals["ask"])
uask := alpm.QuestionType(ask) | alpm.QuestionTypeConflictPkg
cmdArgs.globals["ask"] = fmt.Sprint(uask)
} else {
conflict := false
for _, split := range do.Bases[pkg.PackageBase] {
if _, ok := conflicts[split.Name]; ok {
conflict = true
}
}

if !conflict {
config.NoConfirm = true
}
}

depArguments := makeArguments()
depArguments.addArg("D", "asdeps")
expArguments := makeArguments()
Expand Down Expand Up @@ -850,8 +866,6 @@ func buildInstallPkgBuilds(dp *depPool, do *depOrder, srcinfos map[string]*gopkg
}
}

oldConfirm := config.NoConfirm
config.NoConfirm = true
err = passToPacman(arguments)
if err != nil {
return err
Expand Down

0 comments on commit ea5a94e

Please sign in to comment.