Merge pull request #516 from Morganamilo/combine

Separate Pacman upgrade and AUR Upgrade by default
This commit is contained in:
Anna 2018-07-01 00:23:45 +01:00 committed by GitHub
commit 38b4e2bec7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 115 additions and 40 deletions

4
cmd.go
View File

@ -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":

View File

@ -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.

View File

@ -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"

21
main.go
View File

@ -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
}