feat(install): add --keepsrc to keep pkg/ and src/ directories (#2272)

* feat(install): add --nocleanbuild to keep pkg/ and src/ directories for
AUR packages

Providing this flag during installation of AUR packages allows for keeping
the src/ and pkg/ directories produced my makepkg. If the user wants to
delete the directories, they can either select to cleanBuild in the
cleanmenu or run the installation without the --nocleanbuild flag (yay
will only remove the directories if the package is rebuilt)

* fix(completion): simplify description for --nocleanbuild in fish

This makes the description consistent with the descriptions in the
man page, --help, and zsh completion.

* refactor(install): Rename --nocleanbuild to --keepsrc

This naming scheme is more familiar to users since it is the name of the
flag in Paru.

---------

Co-authored-by: jguer <me@jguer.space>
This commit is contained in:
Joey Holtzmanandjguer authored and GitHub committed 2023-09-18 09:21:42 +02:00
1 parent e60ccdf8b7
commit 04c76a404e
16 files changed
+248 -70

No files matched your search

+2
View File
@@ -53,6 +53,8 @@ func (c *Configuration) handleOption(option, value string) bool {
c.CleanAfter = true
case "noafterclean", "nocleanafter":
c.CleanAfter = false
case "keepsrc":
c.KeepSrc = true
case "debug":
c.Debug = true
return false
+2
View File
@@ -56,6 +56,7 @@ type Configuration struct {
TimeUpdate bool `json:"timeupdate"`
Devel bool `json:"devel"`
CleanAfter bool `json:"cleanAfter"`
KeepSrc bool `json:"keepSrc"`
Provides bool `json:"provides"`
PGPFetch bool `json:"pgpfetch"`
CleanMenu bool `json:"cleanmenu"`
@@ -193,6 +194,7 @@ func DefaultConfig(version string) *Configuration {
AURURL: "https://aur.archlinux.org",
BuildDir: os.ExpandEnv("$HOME/.cache/yay"),
CleanAfter: false,
KeepSrc: false,
Editor: "",
EditorFlags: "",
Devel: false,
+7
View File
@@ -39,6 +39,7 @@ type ICmdBuilder interface {
BuildMakepkgCmd(ctx context.Context, dir string, extraArgs ...string) *exec.Cmd
BuildPacmanCmd(ctx context.Context, args *parser.Arguments, mode parser.TargetMode, noConfirm bool) *exec.Cmd
AddMakepkgFlag(string)
GetKeepSrc() bool
SudoLoop()
}
@@ -56,6 +57,7 @@ type CmdBuilder struct {
PacmanBin string
PacmanConfigPath string
PacmanDBPath string
KeepSrc bool
Runner Runner
Log *text.Logger
}
@@ -75,6 +77,7 @@ func NewCmdBuilder(cfg *settings.Configuration, runner Runner, logger *text.Logg
PacmanBin: cfg.PacmanBin,
PacmanConfigPath: cfg.PacmanConf,
PacmanDBPath: dbPath,
KeepSrc: cfg.KeepSrc,
Runner: runner,
Log: logger,
}
@@ -296,3 +299,7 @@ func (c *CmdBuilder) Show(cmd *exec.Cmd) error {
func (c *CmdBuilder) Capture(cmd *exec.Cmd) (stdout, stderr string, err error) {
return c.Runner.Capture(cmd)
}
func (c *CmdBuilder) GetKeepSrc() bool {
return c.KeepSrc
}
+5
View File
@@ -25,6 +25,7 @@ type MockBuilder struct {
BuildMakepkgCmdCalls []Call
BuildMakepkgCmdFn func(ctx context.Context, dir string, extraArgs ...string) *exec.Cmd
BuildPacmanCmdFn func(ctx context.Context, args *parser.Arguments, mode parser.TargetMode, noConfirm bool) *exec.Cmd
GetKeepSrcFn func() bool
}
type MockRunner struct {
@@ -95,6 +96,10 @@ func (m *MockBuilder) Show(cmd *exec.Cmd) error {
return m.Runner.Show(cmd)
}
func (m *MockBuilder) GetKeepSrc() bool {
return false
}
func (m *MockRunner) Capture(cmd *exec.Cmd) (stdout, stderr string, err error) {
m.CaptureCallsMu.Lock()
m.CaptureCalls = append(m.CaptureCalls, Call{
+1
View File
@@ -378,6 +378,7 @@ func isArg(arg string) bool {
case "save":
case "afterclean", "cleanafter":
case "noafterclean", "nocleanafter":
case "keepsrc":
case "devel":
case "nodevel":
case "timeupdate":