From 37f3309917d2dfdf1e2ed6a701dcac90aee86f4a Mon Sep 17 00:00:00 2001 From: Jordan Day Date: Tue, 11 Jun 2019 08:54:24 -0500 Subject: [PATCH] Defer clean and remove make --- go.sum | 3 +-- install.go | 54 +++++++++++++++++++++++++----------------------------- 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/go.sum b/go.sum index f9665ff4..59b0f396 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,8 @@ github.com/Jguer/go-alpm v0.0.0-20190302211415-9c82d5170ce0 h1:jkaSC1289bzjkoc1qRMDrl4Oad2uoERHHqpptYsGIJY= github.com/Jguer/go-alpm v0.0.0-20190302211415-9c82d5170ce0/go.mod h1:FyxWWXMCnKWSU8prNG5ryzjilFJVj6PUr6yMR36rALA= +github.com/Morganamilo/go-pacmanconf v0.0.0-20180910220353-9c5265e1b14f h1:ptFKynTV1p8JCzqk81NcMj0DV0Xle+PdKxfHjPbdIOU= github.com/Morganamilo/go-pacmanconf v0.0.0-20180910220353-9c5265e1b14f/go.mod h1:Hk55m330jNiwxRodIlMCvw5iEyoRUCIY64W1p9D+tHc= github.com/Morganamilo/go-srcinfo v1.0.0 h1:Wh4nEF+HJWo+29hnxM18Q2hi+DUf0GejS13+Wg+dzmI= github.com/Morganamilo/go-srcinfo v1.0.0/go.mod h1:MP6VGY1NNpVUmYIEgoM9acix95KQqIRyqQ0hCLsyYUY= -github.com/jguer/go-alpm v0.0.0-20190302211415-9c82d5170ce0 h1:wZzXS9/D7IIySAdxND1YkS2Gn4UVG5xEwHYehJ4ltNs= -github.com/jguer/go-alpm v0.0.0-20190302211415-9c82d5170ce0/go.mod h1:1F60/e8oQFVJrZRH0TBqwtiB5ajJ5avOc4MoGRY9CFU= github.com/mikkeloscar/aur v0.0.0-20181111113612-b71516da3ae9 h1:g4TBYa1sjv/TZfU9t82oYlRneu8cCVr3dnazE7os5vw= github.com/mikkeloscar/aur v0.0.0-20181111113612-b71516da3ae9/go.mod h1:n1NKHoldRNhIEufSx1PiDYcd2W+wpbz5/5K+p2eNDVk= diff --git a/install.go b/install.go index 61fc83da..45f42830 100644 --- a/install.go +++ b/install.go @@ -9,13 +9,12 @@ import ( "strings" "sync" - gosrc "github.com/Morganamilo/go-srcinfo" alpm "github.com/Jguer/go-alpm" + gosrc "github.com/Morganamilo/go-srcinfo" ) // Install handles package installs -func install(parser *arguments) error { - var err error +func install(parser *arguments) (err error) { var incompatible stringSet var do *depOrder @@ -25,7 +24,6 @@ func install(parser *arguments) error { var srcinfos map[string]*gosrc.Srcinfo warnings := &aurWarnings{} - removeMake := false if mode == modeAny || mode == modeRepo { if config.CombinedUpgrade { @@ -164,14 +162,20 @@ func install(parser *arguments) error { do.Print() fmt.Println() + if config.CleanAfter { + defer cleanAfter(do.Aur) + } + if do.HasMake() { switch config.RemoveMake { case "yes": - removeMake = true + defer removeMake(do, &err) case "no": - removeMake = false + break default: - removeMake = continueTask("Remove make dependencies after install?", false) + if continueTask("Remove make dependencies after install?", false) { + defer removeMake(do, &err) + } } } @@ -323,31 +327,23 @@ func install(parser *arguments) error { return err } - if removeMake { - removeArguments := makeArguments() - removeArguments.addArg("R", "u") - - for _, pkg := range do.getMake() { - removeArguments.addTarget(pkg) - } - - oldValue := config.NoConfirm - config.NoConfirm = true - err = show(passToPacman(removeArguments)) - config.NoConfirm = oldValue - - if err != nil { - return err - } - } - - if config.CleanAfter { - cleanAfter(do.Aur) - } - return nil } +func removeMake(do *depOrder, err *error) { + removeArguments := makeArguments() + removeArguments.addArg("R", "u") + + for _, pkg := range do.getMake() { + removeArguments.addTarget(pkg) + } + + oldValue := config.NoConfirm + config.NoConfirm = true + *err = show(passToPacman(removeArguments)) + config.NoConfirm = oldValue +} + func inRepos(syncDB alpm.DBList, pkg string) bool { target := toTarget(pkg)