Skip to content

Commit ea5a94e

Browse files
committed
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.
1 parent da466ba commit ea5a94e

File tree

4 files changed

+38
-13
lines changed

4 files changed

+38
-13
lines changed

cmd.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ func handleConfig(option, value string) bool {
341341
config.EditMenu = true
342342
case "noeditmenu":
343343
config.EditMenu = false
344+
case "useask":
345+
config.UseAsk = true
346+
case "nouseask":
347+
config.UseAsk = false
344348
case "a", "aur":
345349
mode = ModeAUR
346350
case "repo":

config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ type Configuration struct {
6969
CleanMenu bool `json:"cleanmenu"`
7070
DiffMenu bool `json:"diffmenu"`
7171
EditMenu bool `json:"editmenu"`
72+
UseAsk bool `json:"useask"`
7273
}
7374

7475
var version = "7.885"
@@ -177,6 +178,7 @@ func defaultSettings(config *Configuration) {
177178
config.CleanMenu = true
178179
config.DiffMenu = true
179180
config.EditMenu = false
181+
config.UseAsk = false
180182
}
181183

182184
// Editor returns the preferred system editor.

depCheck.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (dp *depPool) checkReverseConflicts(conflicts mapStringSet) {
124124
})
125125
}
126126

127-
func (dp *depPool) CheckConflicts() error {
127+
func (dp *depPool) CheckConflicts() (mapStringSet, error) {
128128
var wg sync.WaitGroup
129129
innerConflicts := make(mapStringSet)
130130
conflicts := make(mapStringSet)
@@ -159,12 +159,17 @@ func (dp *depPool) CheckConflicts() error {
159159
fmt.Println(str)
160160
}
161161

162-
return fmt.Errorf("Unresolvable package conflicts, aborting")
162+
return nil, fmt.Errorf("Unresolvable package conflicts, aborting")
163163
}
164164

165165
if len(conflicts) != 0 {
166166
fmt.Println()
167167
fmt.Println(bold(red(arrow)), bold("Package conflicts found:"))
168+
169+
if !config.UseAsk {
170+
fmt.Println(bold(red(arrow)), bold("You will have to confirm these when installing"))
171+
}
172+
168173
for name, pkgs := range conflicts {
169174
str := red(bold(smallArrow)) + " Installing " + cyan(name) + " will remove:"
170175
for pkg := range pkgs {
@@ -178,7 +183,7 @@ func (dp *depPool) CheckConflicts() error {
178183
fmt.Println()
179184
}
180185

181-
return nil
186+
return conflicts, nil
182187
}
183188

184189
type missing struct {

install.go

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func install(parser *arguments) error {
116116
return fmt.Errorf(bold(red(arrow)) + " Refusing to install AUR Packages as root, Aborting.")
117117
}
118118

119-
err = dp.CheckConflicts()
119+
conflicts, err := dp.CheckConflicts()
120120
if err != nil {
121121
return err
122122
}
@@ -279,17 +279,12 @@ func install(parser *arguments) error {
279279
}
280280
}
281281

282-
//conflicts have been checked so answer y for them
283-
ask, _ := strconv.Atoi(cmdArgs.globals["ask"])
284-
uask := alpm.QuestionType(ask) | alpm.QuestionTypeConflictPkg
285-
cmdArgs.globals["ask"] = fmt.Sprint(uask)
286-
287282
err = downloadPkgBuildsSources(do.Aur, do.Bases, incompatible)
288283
if err != nil {
289284
return err
290285
}
291286

292-
err = buildInstallPkgBuilds(dp, do, srcinfosStale, parser, incompatible)
287+
err = buildInstallPkgBuilds(dp, do, srcinfosStale, parser, incompatible, conflicts)
293288
if err != nil {
294289
return err
295290
}
@@ -745,7 +740,7 @@ func downloadPkgBuildsSources(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, inco
745740
return
746741
}
747742

748-
func buildInstallPkgBuilds(dp *depPool, do *depOrder, srcinfos map[string]*gopkg.PKGBUILD, parser *arguments, incompatible stringSet) error {
743+
func buildInstallPkgBuilds(dp *depPool, do *depOrder, srcinfos map[string]*gopkg.PKGBUILD, parser *arguments, incompatible stringSet, conflicts mapStringSet) error {
749744
for _, pkg := range do.Aur {
750745
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
751746
built := true
@@ -807,13 +802,34 @@ func buildInstallPkgBuilds(dp *depPool, do *depOrder, srcinfos map[string]*gopkg
807802
arguments.clearTargets()
808803
arguments.op = "U"
809804
arguments.delArg("confirm")
805+
arguments.delArg("noconfirm")
810806
arguments.delArg("c", "clean")
811807
arguments.delArg("q", "quiet")
812808
arguments.delArg("q", "quiet")
813809
arguments.delArg("y", "refresh")
814810
arguments.delArg("u", "sysupgrade")
815811
arguments.delArg("w", "downloadonly")
816812

813+
oldConfirm := config.NoConfirm
814+
815+
//conflicts have been checked so answer y for them
816+
if config.UseAsk {
817+
ask, _ := strconv.Atoi(cmdArgs.globals["ask"])
818+
uask := alpm.QuestionType(ask) | alpm.QuestionTypeConflictPkg
819+
cmdArgs.globals["ask"] = fmt.Sprint(uask)
820+
} else {
821+
conflict := false
822+
for _, split := range do.Bases[pkg.PackageBase] {
823+
if _, ok := conflicts[split.Name]; ok {
824+
conflict = true
825+
}
826+
}
827+
828+
if !conflict {
829+
config.NoConfirm = true
830+
}
831+
}
832+
817833
depArguments := makeArguments()
818834
depArguments.addArg("D", "asdeps")
819835
expArguments := makeArguments()
@@ -850,8 +866,6 @@ func buildInstallPkgBuilds(dp *depPool, do *depOrder, srcinfos map[string]*gopkg
850866
}
851867
}
852868

853-
oldConfirm := config.NoConfirm
854-
config.NoConfirm = true
855869
err = passToPacman(arguments)
856870
if err != nil {
857871
return err

0 commit comments

Comments
 (0)