mirror of
https://github.com/Jguer/yay
synced 2024-08-31 21:58:39 +00:00
chore(install): reduce cognitive load
This commit is contained in:
parent
7a280e0199
commit
5da8161328
29
install.go
29
install.go
|
@ -66,18 +66,20 @@ func install(cmdArgs *settings.Arguments, dbExecutor db.Executor, ignoreProvider
|
||||||
var do *dep.Order
|
var do *dep.Order
|
||||||
|
|
||||||
var srcinfos map[string]*gosrc.Srcinfo
|
var srcinfos map[string]*gosrc.Srcinfo
|
||||||
|
noDeps := cmdArgs.ExistsDouble("d", "nodeps")
|
||||||
|
sysupgradeArg := cmdArgs.ExistsArg("u", "sysupgrade")
|
||||||
|
refreshArg := cmdArgs.ExistsArg("y", "refresh")
|
||||||
warnings := query.NewWarnings()
|
warnings := query.NewWarnings()
|
||||||
|
|
||||||
if config.Runtime.Mode == settings.ModeAny || config.Runtime.Mode == settings.ModeRepo {
|
if config.Runtime.Mode == settings.ModeAny || config.Runtime.Mode == settings.ModeRepo {
|
||||||
if config.CombinedUpgrade {
|
if config.CombinedUpgrade {
|
||||||
if cmdArgs.ExistsArg("y", "refresh") {
|
if refreshArg {
|
||||||
err = earlyRefresh(cmdArgs)
|
err = earlyRefresh(cmdArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf(gotext.Get("error refreshing databases"))
|
return fmt.Errorf(gotext.Get("error refreshing databases"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if cmdArgs.ExistsArg("y", "refresh") || cmdArgs.ExistsArg("u", "sysupgrade") || len(cmdArgs.Targets) > 0 {
|
} else if refreshArg || sysupgradeArg || len(cmdArgs.Targets) > 0 {
|
||||||
err = earlyPacmanCall(cmdArgs, dbExecutor)
|
err = earlyPacmanCall(cmdArgs, dbExecutor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -114,7 +116,7 @@ func install(cmdArgs *settings.Arguments, dbExecutor db.Executor, ignoreProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we are doing -u also request all packages needing update
|
// if we are doing -u also request all packages needing update
|
||||||
if cmdArgs.ExistsArg("u", "sysupgrade") {
|
if sysupgradeArg {
|
||||||
ignore, targets, errUp := sysupgradeTargets(dbExecutor, cmdArgs.ExistsDouble("u", "sysupgrade"))
|
ignore, targets, errUp := sysupgradeTargets(dbExecutor, cmdArgs.ExistsDouble("u", "sysupgrade"))
|
||||||
if errUp != nil {
|
if errUp != nil {
|
||||||
return errUp
|
return errUp
|
||||||
|
@ -139,16 +141,14 @@ func install(cmdArgs *settings.Arguments, dbExecutor db.Executor, ignoreProvider
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cmdArgs.ExistsDouble("d", "nodeps") {
|
err = dp.CheckMissing(noDeps)
|
||||||
err = dp.CheckMissing()
|
if err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(dp.Aur) == 0 {
|
if len(dp.Aur) == 0 {
|
||||||
if !config.CombinedUpgrade {
|
if !config.CombinedUpgrade {
|
||||||
if cmdArgs.ExistsArg("u", "sysupgrade") {
|
if sysupgradeArg {
|
||||||
fmt.Println(gotext.Get(" there is nothing to do"))
|
fmt.Println(gotext.Get(" there is nothing to do"))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -166,12 +166,9 @@ func install(cmdArgs *settings.Arguments, dbExecutor db.Executor, ignoreProvider
|
||||||
return fmt.Errorf(gotext.Get("refusing to install AUR packages as root, aborting"))
|
return fmt.Errorf(gotext.Get("refusing to install AUR packages as root, aborting"))
|
||||||
}
|
}
|
||||||
|
|
||||||
var conflicts stringset.MapStringSet
|
conflicts, err := dp.CheckConflicts(config.UseAsk, settings.NoConfirm, noDeps)
|
||||||
if !cmdArgs.ExistsDouble("d", "nodeps") {
|
if err != nil {
|
||||||
conflicts, err = dp.CheckConflicts(config.UseAsk, settings.NoConfirm)
|
return err
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do = dep.GetOrder(dp)
|
do = dep.GetOrder(dp)
|
||||||
|
|
|
@ -119,10 +119,14 @@ func (dp *Pool) checkReverseConflicts(conflicts stringset.MapStringSet) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dp *Pool) CheckConflicts(useAsk, noConfirm bool) (stringset.MapStringSet, error) {
|
func (dp *Pool) CheckConflicts(useAsk, noConfirm, noDeps bool) (stringset.MapStringSet, error) {
|
||||||
|
conflicts := make(stringset.MapStringSet)
|
||||||
|
if noDeps {
|
||||||
|
return conflicts, nil
|
||||||
|
}
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
innerConflicts := make(stringset.MapStringSet)
|
innerConflicts := make(stringset.MapStringSet)
|
||||||
conflicts := make(stringset.MapStringSet)
|
|
||||||
wg.Add(2)
|
wg.Add(2)
|
||||||
|
|
||||||
text.OperationInfoln(gotext.Get("Checking for conflicts..."))
|
text.OperationInfoln(gotext.Get("Checking for conflicts..."))
|
||||||
|
@ -268,7 +272,11 @@ func stringSliceEqual(a, b []string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dp *Pool) CheckMissing() error {
|
func (dp *Pool) CheckMissing(noDeps bool) error {
|
||||||
|
if noDeps {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
missing := &missing{
|
missing := &missing{
|
||||||
make(stringset.StringSet),
|
make(stringset.StringSet),
|
||||||
make(map[string][][]string),
|
make(map[string][][]string),
|
||||||
|
|
Loading…
Reference in a new issue