From 6bee268ea98971269ba19ce74bf3daaba2cdbfc5 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Wed, 26 Mar 2025 10:11:24 +0300 Subject: [PATCH] fix installing multiple packages --- e2e-tests/common_test.go | 11 +++-- e2e-tests/images/Dockerfile.ubuntu-24.04 | 6 ++- e2e-tests/issue_50_install_multiple_test.go | 55 +++++++++++++++++++++ internal/translations/default.pot | 18 +++---- internal/translations/po/ru/default.po | 18 +++---- pkg/build/build.go | 12 +++-- 6 files changed, 91 insertions(+), 29 deletions(-) create mode 100644 e2e-tests/issue_50_install_multiple_test.go diff --git a/e2e-tests/common_test.go b/e2e-tests/common_test.go index 5a5ce3c..51466a1 100644 --- a/e2e-tests/common_test.go +++ b/e2e-tests/common_test.go @@ -100,11 +100,11 @@ func e2eSpawn(runnable e2e.Runnable, command e2e.Command, timeout time.Duration, var ALL_SYSTEMS []string = []string{ "ubuntu-24.04", - "alt-sisyphus", - "archlinux", - //"alpine", - "opensuse-leap", - "redos-8", + // "alt-sisyphus", + // "archlinux", + // "alpine", + // "opensuse-leap", + // "redos-8", } var COMMON_SYSTEMS []string = []string{ @@ -155,6 +155,7 @@ func dockerMultipleRun(t *testing.T, name string, ids []string, f func(t *testin Volumes: []string{ "./alr:/usr/bin/alr", }, + Privileged: true, }, ) assert.NoError(t, e2e.StartAndWaitReady(runnable)) diff --git a/e2e-tests/images/Dockerfile.ubuntu-24.04 b/e2e-tests/images/Dockerfile.ubuntu-24.04 index 29be950..821a1f2 100644 --- a/e2e-tests/images/Dockerfile.ubuntu-24.04 +++ b/e2e-tests/images/Dockerfile.ubuntu-24.04 @@ -1,5 +1,7 @@ FROM ubuntu:24.10 -RUN apt update && apt install -y ca-certificates -RUN useradd -m -s /bin/bash alr-user +RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates sudo +RUN useradd -m -s /bin/bash alr-user && \ + echo "alr-user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/alr-user && \ + chmod 0440 /etc/sudoers.d/alr-user USER alr-user ENTRYPOINT ["tail", "-f", "/dev/null"] \ No newline at end of file diff --git a/e2e-tests/issue_50_install_multiple_test.go b/e2e-tests/issue_50_install_multiple_test.go new file mode 100644 index 0000000..1aee227 --- /dev/null +++ b/e2e-tests/issue_50_install_multiple_test.go @@ -0,0 +1,55 @@ +// ALR - Any Linux Repository +// Copyright (C) 2025 Евгений Храмов +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//go:build e2e + +package e2etests_test + +import ( + "testing" + + "github.com/alecthomas/assert/v2" + "github.com/efficientgo/e2e" +) + +func TestE2EIssue50InstallMultiple(t *testing.T) { + dockerMultipleRun( + t, + "issue-50-install-multiple", + COMMON_SYSTEMS, + func(t *testing.T, r e2e.Runnable) { + err := r.Exec(e2e.NewCommand( + "alr", + "addrepo", + "--name", + "alr-repo", + "--url", + "https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git", + )) + assert.NoError(t, err) + + err = r.Exec(e2e.NewCommand( + "alr", "in", "foo-pkg", "bar-pkg", + )) + assert.NoError(t, err) + + err = r.Exec(e2e.NewCommand("cat", "/opt/foo")) + assert.NoError(t, err) + err = r.Exec(e2e.NewCommand("cat", "/opt/bar")) + assert.NoError(t, err) + }, + ) +} diff --git a/internal/translations/default.pot b/internal/translations/default.pot index def4219..07bf9c5 100644 --- a/internal/translations/default.pot +++ b/internal/translations/default.pot @@ -375,39 +375,39 @@ msgstr "" msgid "Installing build dependencies" msgstr "" -#: pkg/build/build.go:517 +#: pkg/build/build.go:521 msgid "Installing dependencies" msgstr "" -#: pkg/build/build.go:598 +#: pkg/build/build.go:602 msgid "Would you like to remove the build dependencies?" msgstr "" -#: pkg/build/build.go:661 +#: pkg/build/build.go:665 msgid "Executing prepare()" msgstr "" -#: pkg/build/build.go:671 +#: pkg/build/build.go:675 msgid "Executing build()" msgstr "" -#: pkg/build/build.go:701 pkg/build/build.go:721 +#: pkg/build/build.go:705 pkg/build/build.go:725 msgid "Executing %s()" msgstr "" -#: pkg/build/build.go:780 +#: pkg/build/build.go:784 msgid "Error installing native packages" msgstr "" -#: pkg/build/build.go:804 +#: pkg/build/build.go:808 msgid "Error installing package" msgstr "" -#: pkg/build/build.go:863 +#: pkg/build/build.go:867 msgid "AutoProv is not implemented for this package format, so it's skipped" msgstr "" -#: pkg/build/build.go:874 +#: pkg/build/build.go:878 msgid "AutoReq is not implemented for this package format, so it's skipped" msgstr "" diff --git a/internal/translations/po/ru/default.po b/internal/translations/po/ru/default.po index 8060f94..3aa0dc8 100644 --- a/internal/translations/po/ru/default.po +++ b/internal/translations/po/ru/default.po @@ -389,40 +389,40 @@ msgstr "Этот пакет уже установлен" msgid "Installing build dependencies" msgstr "Установка зависимостей сборки" -#: pkg/build/build.go:517 +#: pkg/build/build.go:521 msgid "Installing dependencies" msgstr "Установка зависимостей" -#: pkg/build/build.go:598 +#: pkg/build/build.go:602 msgid "Would you like to remove the build dependencies?" msgstr "Хотели бы вы удалить зависимости сборки?" -#: pkg/build/build.go:661 +#: pkg/build/build.go:665 msgid "Executing prepare()" msgstr "Исполнение prepare()" -#: pkg/build/build.go:671 +#: pkg/build/build.go:675 msgid "Executing build()" msgstr "Исполнение build()" -#: pkg/build/build.go:701 pkg/build/build.go:721 +#: pkg/build/build.go:705 pkg/build/build.go:725 msgid "Executing %s()" msgstr "Исполнение %s()" -#: pkg/build/build.go:780 +#: pkg/build/build.go:784 msgid "Error installing native packages" msgstr "Ошибка при установке нативных пакетов" -#: pkg/build/build.go:804 +#: pkg/build/build.go:808 msgid "Error installing package" msgstr "Ошибка при установке пакета" -#: pkg/build/build.go:863 +#: pkg/build/build.go:867 msgid "AutoProv is not implemented for this package format, so it's skipped" msgstr "" "AutoProv не реализовано для этого формата пакета, поэтому будет пропущено" -#: pkg/build/build.go:874 +#: pkg/build/build.go:878 msgid "AutoReq is not implemented for this package format, so it's skipped" msgstr "" "AutoReq не реализовано для этого формата пакета, поэтому будет пропущено" diff --git a/pkg/build/build.go b/pkg/build/build.go index 34df3b2..27fd2a1 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -489,13 +489,17 @@ func (b *Builder) getBuildersForPackages(pkgs []db.Package) []*Builder { } pkgsMap := make(map[string]*item) for _, pkg := range pkgs { - if pkgsMap[pkg.BasePkgName] == nil { - pkgsMap[pkg.BasePkgName] = &item{ + name := pkg.BasePkgName + if name == "" { + name = pkg.Name + } + if pkgsMap[name] == nil { + pkgsMap[name] = &item{ pkg: &pkg, } } - pkgsMap[pkg.BasePkgName].packages = append( - pkgsMap[pkg.BasePkgName].packages, + pkgsMap[name].packages = append( + pkgsMap[name].packages, pkg.Name, ) }