diff --git a/cmd.go b/cmd.go index 1ed66920..e2fe6d2d 100644 --- a/cmd.go +++ b/cmd.go @@ -345,6 +345,10 @@ func handleConfig(option, value string) bool { config.UseAsk = true case "nouseask": config.UseAsk = false + case "combinedupgrade": + config.CombinedUpgrade = true + case "nocombinedupgrade": + config.CombinedUpgrade = false case "a", "aur": mode = ModeAUR case "repo": diff --git a/config.go b/config.go index 18f47161..daff6461 100644 --- a/config.go +++ b/config.go @@ -35,41 +35,42 @@ const ( // Configuration stores yay's config. type Configuration struct { - BuildDir string `json:"buildDir"` - Editor string `json:"editor"` - EditorFlags string `json:"editorflags"` - MakepkgBin string `json:"makepkgbin"` - PacmanBin string `json:"pacmanbin"` - PacmanConf string `json:"pacmanconf"` - TarBin string `json:"tarbin"` - ReDownload string `json:"redownload"` - ReBuild string `json:"rebuild"` - AnswerClean string `json:"answerclean"` - AnswerDiff string `json:"answerdiff"` - AnswerEdit string `json:"answeredit"` - AnswerUpgrade string `json:"answerupgrade"` - GitBin string `json:"gitbin"` - GpgBin string `json:"gpgbin"` - GpgFlags string `json:"gpgflags"` - MFlags string `json:"mflags"` - SortBy string `json:"sortby"` - GitFlags string `json:"gitflags"` - RequestSplitN int `json:"requestsplitn"` - SearchMode int `json:"-"` - SortMode int `json:"sortmode"` - SudoLoop bool `json:"sudoloop"` - TimeUpdate bool `json:"timeupdate"` - NoConfirm bool `json:"-"` - Devel bool `json:"devel"` - CleanAfter bool `json:"cleanAfter"` - GitClone bool `json:"gitclone"` - Provides bool `json:"provides"` - PGPFetch bool `json:"pgpfetch"` - UpgradeMenu bool `json:"upgrademenu"` - CleanMenu bool `json:"cleanmenu"` - DiffMenu bool `json:"diffmenu"` - EditMenu bool `json:"editmenu"` - UseAsk bool `json:"useask"` + BuildDir string `json:"buildDir"` + Editor string `json:"editor"` + EditorFlags string `json:"editorflags"` + MakepkgBin string `json:"makepkgbin"` + PacmanBin string `json:"pacmanbin"` + PacmanConf string `json:"pacmanconf"` + TarBin string `json:"tarbin"` + ReDownload string `json:"redownload"` + ReBuild string `json:"rebuild"` + AnswerClean string `json:"answerclean"` + AnswerDiff string `json:"answerdiff"` + AnswerEdit string `json:"answeredit"` + AnswerUpgrade string `json:"answerupgrade"` + GitBin string `json:"gitbin"` + GpgBin string `json:"gpgbin"` + GpgFlags string `json:"gpgflags"` + MFlags string `json:"mflags"` + SortBy string `json:"sortby"` + GitFlags string `json:"gitflags"` + RequestSplitN int `json:"requestsplitn"` + SearchMode int `json:"-"` + SortMode int `json:"sortmode"` + SudoLoop bool `json:"sudoloop"` + TimeUpdate bool `json:"timeupdate"` + NoConfirm bool `json:"-"` + Devel bool `json:"devel"` + CleanAfter bool `json:"cleanAfter"` + GitClone bool `json:"gitclone"` + Provides bool `json:"provides"` + PGPFetch bool `json:"pgpfetch"` + UpgradeMenu bool `json:"upgrademenu"` + CleanMenu bool `json:"cleanmenu"` + DiffMenu bool `json:"diffmenu"` + EditMenu bool `json:"editmenu"` + CombinedUpgrade bool `json:"combinedupgrade"` + UseAsk bool `json:"useask"` } var version = "7.885" @@ -179,6 +180,7 @@ func defaultSettings(config *Configuration) { config.DiffMenu = true config.EditMenu = false config.UseAsk = false + config.CombinedUpgrade = false } // Editor returns the preferred system editor. diff --git a/install.go b/install.go index 52464eda..492c4282 100644 --- a/install.go +++ b/install.go @@ -22,7 +22,6 @@ func install(parser *arguments) error { var aurUp upSlice var repoUp upSlice - requestTargets := parser.copy().targets warnings := &aurWarnings{} removeMake := false @@ -39,9 +38,64 @@ func install(parser *arguments) error { remoteNamesCache := sliceToStringSet(remoteNames) localNamesCache := sliceToStringSet(localNames) + if mode == ModeAny || mode == ModeRepo { + if config.CombinedUpgrade { + if parser.existsArg("y", "refresh") { + arguments := parser.copy() + parser.delArg("y", "refresh") + arguments.delArg("u", "sysupgrade") + arguments.delArg("s", "search") + arguments.delArg("i", "info") + arguments.delArg("l", "list") + arguments.clearTargets() + err = passToPacman(arguments) + if err != nil { + return fmt.Errorf("Error installing repo packages") + } + } + } else if parser.existsArg("y", "refresh") || parser.existsArg("u", "sysupgrade") || len(parser.targets) > 0 { + arguments := parser.copy() + targets := parser.targets + parser.clearTargets() + arguments.clearTargets() + + //seperate aur and repo targets + for _, target := range targets { + if localNamesCache.get(target) { + arguments.addTarget(target) + } else { + parser.addTarget(target) + } + } + + if parser.existsArg("y", "refresh") || parser.existsArg("u", "sysupgrade") || len(arguments.targets) > 0 { + err = passToPacman(arguments) + if err != nil { + return fmt.Errorf("Error installing repo packages") + } + } + + //we may have done -Sy, our handle now has an old + //database. + err = initAlpmHandle() + if err != nil { + return err + } + + _, _, localNames, remoteNames, err = filterPackages() + if err != nil { + return err + } + + remoteNamesCache = sliceToStringSet(remoteNames) + localNamesCache = sliceToStringSet(localNames) + } + } + + requestTargets := parser.copy().targets + //create the arguments to pass for the repo install arguments := parser.copy() - arguments.delArg("y", "refresh") arguments.delArg("asdeps", "asdep") arguments.delArg("asexplicit", "asexp") arguments.op = "S" diff --git a/main.go b/main.go index 17d6f819..3966d38e 100644 --- a/main.go +++ b/main.go @@ -159,9 +159,8 @@ func initAlpm() (err error) { alpmConf.GPGDir = value } - alpmHandle, err = alpmConf.CreateHandle() + err = initAlpmHandle() if err != nil { - err = fmt.Errorf("Unable to CreateHandle: %s", err) return } @@ -174,8 +173,24 @@ func initAlpm() (err error) { useColor = alpmConf.Options&alpm.ConfColor > 0 } - alpmHandle.SetQuestionCallback(questionCallback) + return +} +func initAlpmHandle() (err error) { + if alpmHandle != nil { + err = alpmHandle.Release() + if err != nil { + return err + } + } + + alpmHandle, err = alpmConf.CreateHandle() + if err != nil { + err = fmt.Errorf("Unable to CreateHandle: %s", err) + return + } + + alpmHandle.SetQuestionCallback(questionCallback) return }