feat: add ability to remove build_deps
All checks were successful
Pre-commit / pre-commit (pull_request) Successful in 5m36s
Update alr-git / changelog (push) Successful in 26s

This commit is contained in:
2025-06-28 20:19:07 +03:00
parent a83561b6a5
commit 6355f25089
6 changed files with 73 additions and 19 deletions

View File

@ -11,7 +11,7 @@
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
<text x="33.5" y="15" fill="#010101" fill-opacity=".3">coverage</text>
<text x="33.5" y="14">coverage</text>
<text x="86" y="15" fill="#010101" fill-opacity=".3">19.9%</text>
<text x="86" y="14">19.9%</text>
<text x="86" y="15" fill="#010101" fill-opacity=".3">19.8%</text>
<text x="86" y="14">19.8%</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 926 B

After

Width:  |  Height:  |  Size: 926 B

View File

@ -214,6 +214,8 @@ type CheckerExecutor interface {
type InstallerExecutor interface {
InstallLocal(paths []string, opts *manager.Opts) error
Install(pkgs []string, opts *manager.Opts) error
Remove(pkgs []string, opts *manager.Opts) error
RemoveAlreadyInstalled(pkgs []string) ([]string, error)
}
@ -408,7 +410,7 @@ func (b *Builder) BuildPackage(
sources, checksums = removeDuplicatesSources(sources, checksums)
slog.Debug("installBuildDeps")
alrBuildDeps, err := b.installBuildDeps(ctx, input, buildDepends)
alrBuildDeps, installedBuildDeps, err := b.installBuildDeps(ctx, input, buildDepends)
if err != nil {
return nil, err
}
@ -477,9 +479,39 @@ func (b *Builder) BuildPackage(
builtDeps = removeDuplicates(append(builtDeps, res...))
err = b.removeBuildDeps(ctx, input, installedBuildDeps)
if err != nil {
return nil, err
}
return builtDeps, nil
}
func (b *Builder) removeBuildDeps(ctx context.Context, input interface {
BuildOptsProvider
}, deps []string,
) error {
if len(deps) > 0 {
remove, err := cliutils.YesNoPrompt(ctx, gotext.Get("Would you like to remove the build dependencies?"), input.BuildOpts().Interactive, false)
if err != nil {
return err
}
if remove {
err = b.installerExecutor.Remove(
deps,
&manager.Opts{
NoConfirm: !input.BuildOpts().Interactive,
},
)
if err != nil {
return err
}
}
}
return nil
}
type InstallPkgsArgs struct {
BuildArgs
AlrPkgs []alrsh.Package
@ -608,20 +640,22 @@ func (i *Builder) installBuildDeps(
PkgFormatProvider
},
pkgs []string,
) ([]*BuiltDep, error) {
) ([]*BuiltDep, []string, error) {
var builtDeps []*BuiltDep
var deps []string
var err error
if len(pkgs) > 0 {
deps, err := i.installerExecutor.RemoveAlreadyInstalled(pkgs)
deps, err = i.installerExecutor.RemoveAlreadyInstalled(pkgs)
if err != nil {
return nil, err
return nil, nil, err
}
builtDeps, err = i.InstallPkgs(ctx, input, deps) // Устанавливаем выбранные пакеты
if err != nil {
return nil, err
return nil, nil, err
}
}
return builtDeps, nil
return builtDeps, deps, nil
}
func (i *Builder) installOptDeps(

View File

@ -36,6 +36,10 @@ func (i *Installer) Install(pkgs []string, opts *manager.Opts) error {
return i.mgr.Install(opts, pkgs...)
}
func (i *Installer) Remove(pkgs []string, opts *manager.Opts) error {
return i.mgr.Remove(opts, pkgs...)
}
func (i *Installer) RemoveAlreadyInstalled(pkgs []string) ([]string, error) {
filteredPackages := []string{}

View File

@ -70,6 +70,17 @@ func (s *InstallerRPCServer) Install(args *InstallArgs, reply *struct{}) error {
return s.Impl.Install(args.PackagesOrPaths, args.Opts)
}
func (r *InstallerRPC) Remove(pkgs []string, opts *manager.Opts) error {
return r.client.Call("Plugin.Remove", &InstallArgs{
PackagesOrPaths: pkgs,
Opts: opts,
}, nil)
}
func (s *InstallerRPCServer) Remove(args *InstallArgs, reply *struct{}) error {
return s.Impl.Remove(args.PackagesOrPaths, args.Opts)
}
func (r *InstallerRPC) RemoveAlreadyInstalled(paths []string) ([]string, error) {
var val []string
err := r.client.Call("Plugin.RemoveAlreadyInstalled", paths, &val)

View File

@ -174,19 +174,23 @@ msgstr ""
msgid "Error removing packages"
msgstr ""
#: internal/build/build.go:376
#: internal/build/build.go:378
msgid "Building package"
msgstr ""
#: internal/build/build.go:405
#: internal/build/build.go:407
msgid "The checksums array must be the same length as sources"
msgstr ""
#: internal/build/build.go:447
#: internal/build/build.go:449
msgid "Downloading sources"
msgstr ""
#: internal/build/build.go:539
#: internal/build/build.go:495
msgid "Would you like to remove the build dependencies?"
msgstr ""
#: internal/build/build.go:571
msgid "Installing dependencies"
msgstr ""

View File

@ -181,19 +181,23 @@ msgstr "Для команды remove ожидался хотя бы 1 аргум
msgid "Error removing packages"
msgstr "Ошибка при удалении пакетов"
#: internal/build/build.go:376
#: internal/build/build.go:378
msgid "Building package"
msgstr "Сборка пакета"
#: internal/build/build.go:405
#: internal/build/build.go:407
msgid "The checksums array must be the same length as sources"
msgstr "Массив контрольных сумм должен быть той же длины, что и источники"
#: internal/build/build.go:447
#: internal/build/build.go:449
msgid "Downloading sources"
msgstr "Скачивание источников"
#: internal/build/build.go:539
#: internal/build/build.go:495
msgid "Would you like to remove the build dependencies?"
msgstr "Хотели бы вы удалить зависимости сборки?"
#: internal/build/build.go:571
msgid "Installing dependencies"
msgstr "Установка зависимостей"
@ -663,9 +667,6 @@ msgstr "Здесь нечего делать."
#~ msgid "Installing build dependencies"
#~ msgstr "Установка зависимостей сборки"
#~ msgid "Would you like to remove the build dependencies?"
#~ msgstr "Хотели бы вы удалить зависимости сборки?"
#~ msgid "Error installing native packages"
#~ msgstr "Ошибка при установке нативных пакетов"