Defer clean and remove make

This commit is contained in:
Jordan Day 2019-06-11 08:54:24 -05:00
parent 86b73689a3
commit 37f3309917
2 changed files with 26 additions and 31 deletions

3
go.sum
View File

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

View File

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