mirror of
https://github.com/Jguer/yay.git
synced 2025-11-29 00:05:47 -05:00
fix(install): use global arguments when removing make dependencies (#1940)
fix(install): use global arguments when removing make dependencies One example where this would fail before is when the `--root` argument was passed in by the user. Yay would install the make dependencies to the new root directory, but would try to remove them from / causing the installation to fail if the make dependencies were not found in the default installation path (/).
This commit is contained in:
parent
fa2e726ca6
commit
0387dfdb59
@ -224,7 +224,7 @@ func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Execu
|
|||||||
switch config.RemoveMake {
|
switch config.RemoveMake {
|
||||||
case "yes":
|
case "yes":
|
||||||
defer func() {
|
defer func() {
|
||||||
err = removeMake(ctx, config.Runtime.CmdBuilder, do.GetMake())
|
err = removeMake(ctx, config.Runtime.CmdBuilder, do.GetMake(), cmdArgs)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
case "no":
|
case "no":
|
||||||
@ -232,7 +232,7 @@ func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Execu
|
|||||||
default:
|
default:
|
||||||
if text.ContinueTask(os.Stdin, gotext.Get("Remove make dependencies after install?"), false, settings.NoConfirm) {
|
if text.ContinueTask(os.Stdin, gotext.Get("Remove make dependencies after install?"), false, settings.NoConfirm) {
|
||||||
defer func() {
|
defer func() {
|
||||||
err = removeMake(ctx, config.Runtime.CmdBuilder, do.GetMake())
|
err = removeMake(ctx, config.Runtime.CmdBuilder, do.GetMake(), cmdArgs)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,8 +383,8 @@ func addUpgradeTargetsToArgs(ctx context.Context, dbExecutor db.Executor,
|
|||||||
return requestTargets, nil
|
return requestTargets, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeMake(ctx context.Context, cmdBuilder exe.ICmdBuilder, makeDeps []string) error {
|
func removeMake(ctx context.Context, cmdBuilder exe.ICmdBuilder, makeDeps []string, cmdArgs *parser.Arguments) error {
|
||||||
removeArguments := parser.MakeArguments()
|
removeArguments := cmdArgs.CopyGlobal()
|
||||||
|
|
||||||
err := removeArguments.AddArg("R", "u")
|
err := removeArguments.AddArg("R", "u")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/Jguer/yay/v11/pkg/menus"
|
"github.com/Jguer/yay/v11/pkg/menus"
|
||||||
"github.com/Jguer/yay/v11/pkg/settings"
|
"github.com/Jguer/yay/v11/pkg/settings"
|
||||||
"github.com/Jguer/yay/v11/pkg/settings/exe"
|
"github.com/Jguer/yay/v11/pkg/settings/exe"
|
||||||
|
"github.com/Jguer/yay/v11/pkg/settings/parser"
|
||||||
"github.com/Jguer/yay/v11/pkg/text"
|
"github.com/Jguer/yay/v11/pkg/text"
|
||||||
|
|
||||||
gosrc "github.com/Morganamilo/go-srcinfo"
|
gosrc "github.com/Morganamilo/go-srcinfo"
|
||||||
@ -70,7 +71,7 @@ func (preper *Preparer) ShouldCleanAURDirs(pkgBuildDirs map[string]string) PostI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (preper *Preparer) ShouldCleanMakeDeps() PostInstallHookFunc {
|
func (preper *Preparer) ShouldCleanMakeDeps(cmdArgs *parser.Arguments) PostInstallHookFunc {
|
||||||
if len(preper.makeDeps) == 0 {
|
if len(preper.makeDeps) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -89,7 +90,7 @@ func (preper *Preparer) ShouldCleanMakeDeps() PostInstallHookFunc {
|
|||||||
text.Debugln("added post install hook to clean up AUR makedeps", preper.makeDeps)
|
text.Debugln("added post install hook to clean up AUR makedeps", preper.makeDeps)
|
||||||
|
|
||||||
return func(ctx context.Context) error {
|
return func(ctx context.Context) error {
|
||||||
return removeMake(ctx, preper.cfg.Runtime.CmdBuilder, preper.makeDeps)
|
return removeMake(ctx, preper.cfg.Runtime.CmdBuilder, preper.makeDeps, cmdArgs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
sync.go
2
sync.go
@ -112,7 +112,7 @@ func (o *OperationService) Run(ctx context.Context,
|
|||||||
return errInstall
|
return errInstall
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanFunc := preparer.ShouldCleanMakeDeps()
|
cleanFunc := preparer.ShouldCleanMakeDeps(cmdArgs)
|
||||||
if cleanFunc != nil {
|
if cleanFunc != nil {
|
||||||
installer.AddPostInstallHook(cleanFunc)
|
installer.AddPostInstallHook(cleanFunc)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user