Skip to content
Permalink
Browse files

Remove default usage of --ask

--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 ea5a94e0f8bb5f76879099e6d319c0c0102231c2
Showing with 38 additions and 13 deletions.
  1. +4 −0 cmd.go
  2. +2 −0 config.go
  3. +8 −3 depCheck.go
  4. +24 −10 install.go
4 cmd.go
@@ -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":
@@ -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"
@@ -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.
@@ -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)
@@ -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 {
@@ -178,7 +183,7 @@ func (dp *depPool) CheckConflicts() error {
fmt.Println()
}

return nil
return conflicts, nil
}

type missing struct {
@@ -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
}
@@ -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
}
@@ -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
@@ -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()
@@ -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

0 comments on commit ea5a94e

Please sign in to comment.
You can’t perform that action at this time.