1
0
forked from Plemya-x/ALR

Compare commits

..

No commits in common. "1c78adcca107de17abf38706485c0621ca3e7696" and "53e783df3101eaf71380617620992a12f0448cdf" have entirely different histories.

7 changed files with 50 additions and 118 deletions

@ -20,9 +20,7 @@
package overrides package overrides
import ( import (
"fmt"
"reflect" "reflect"
"regexp"
"strings" "strings"
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
@ -225,19 +223,3 @@ func parseLangs(langs []string, tags []language.Tag) ([]string, error) {
out = slices.Compact(out) out = slices.Compact(out)
return out, nil return out, nil
} }
func ReleasePlatformSpecific(release int, info *distro.OSRelease) string {
if info.ID == "altlinux" {
return fmt.Sprintf("alt%d", release)
}
if info.ID == "fedora" || slices.Contains(info.Like, "fedora") {
re := regexp.MustCompile(`platform:(\S+)`)
match := re.FindStringSubmatch(info.PlatformID)
if len(match) > 1 {
return fmt.Sprintf("%d.%s", release, match[1])
}
}
return fmt.Sprintf("%d", release)
}

@ -24,7 +24,6 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/stretchr/testify/assert"
"golang.org/x/text/language" "golang.org/x/text/language"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/overrides" "gitea.plemya-x.ru/Plemya-x/ALR/internal/overrides"
@ -196,43 +195,3 @@ func TestResolveLangs(t *testing.T) {
t.Errorf("expected %v, got %v", expected, names) t.Errorf("expected %v, got %v", expected, names)
} }
} }
func TestReleasePlatformSpecific(t *testing.T) {
type testCase struct {
info *distro.OSRelease
expected string
}
for _, tc := range []testCase{
{
info: &distro.OSRelease{
ID: "centos",
Like: []string{"rhel", "fedora"},
PlatformID: "platform:el8",
},
expected: "1.el8",
},
{
info: &distro.OSRelease{
ID: "fedora",
PlatformID: "platform:f42",
},
expected: "1.f42",
},
{
info: &distro.OSRelease{
ID: "altlinux",
},
expected: "alt1",
},
{
info: &distro.OSRelease{
ID: "ubuntu",
},
expected: "1",
},
} {
assert.Equal(t, tc.expected, overrides.ReleasePlatformSpecific(1, tc.info))
}
}

@ -285,81 +285,81 @@ msgstr ""
msgid "Error while running app" msgid "Error while running app"
msgstr "" msgstr ""
#: pkg/build/build.go:105 #: pkg/build/build.go:104
msgid "Failed to prompt user to view build script" msgid "Failed to prompt user to view build script"
msgstr "" msgstr ""
#: pkg/build/build.go:109 #: pkg/build/build.go:108
msgid "Building package" msgid "Building package"
msgstr "" msgstr ""
#: pkg/build/build.go:153 #: pkg/build/build.go:152
msgid "Downloading sources" msgid "Downloading sources"
msgstr "" msgstr ""
#: pkg/build/build.go:165 #: pkg/build/build.go:164
msgid "Building package metadata" msgid "Building package metadata"
msgstr "" msgstr ""
#: pkg/build/build.go:187 #: pkg/build/build.go:186
msgid "Compressing package" msgid "Compressing package"
msgstr "" msgstr ""
#: pkg/build/build.go:313 #: pkg/build/build.go:312
msgid "" msgid ""
"Your system's CPU architecture doesn't match this package. Do you want to " "Your system's CPU architecture doesn't match this package. Do you want to "
"build anyway?" "build anyway?"
msgstr "" msgstr ""
#: pkg/build/build.go:324 #: pkg/build/build.go:323
msgid "This package is already installed" msgid "This package is already installed"
msgstr "" msgstr ""
#: pkg/build/build.go:352 #: pkg/build/build.go:351
msgid "Installing build dependencies" msgid "Installing build dependencies"
msgstr "" msgstr ""
#: pkg/build/build.go:394 #: pkg/build/build.go:393
msgid "Installing dependencies" msgid "Installing dependencies"
msgstr "" msgstr ""
#: pkg/build/build.go:440 #: pkg/build/build.go:439
msgid "Executing version()" msgid "Executing version()"
msgstr "" msgstr ""
#: pkg/build/build.go:460 #: pkg/build/build.go:459
msgid "Updating version" msgid "Updating version"
msgstr "" msgstr ""
#: pkg/build/build.go:465 #: pkg/build/build.go:464
msgid "Executing prepare()" msgid "Executing prepare()"
msgstr "" msgstr ""
#: pkg/build/build.go:475 #: pkg/build/build.go:474
msgid "Executing build()" msgid "Executing build()"
msgstr "" msgstr ""
#: pkg/build/build.go:487 #: pkg/build/build.go:486
msgid "Executing package()" msgid "Executing package()"
msgstr "" msgstr ""
#: pkg/build/build.go:525 #: pkg/build/build.go:524
msgid "Executing files()" msgid "Executing files()"
msgstr "" msgstr ""
#: pkg/build/build.go:600 #: pkg/build/build.go:601
msgid "AutoProv is not implemented for this package format, so it's skipped" msgid "AutoProv is not implemented for this package format, so it's skipped"
msgstr "" msgstr ""
#: pkg/build/build.go:611 #: pkg/build/build.go:612
msgid "AutoReq is not implemented for this package format, so it's skipped" msgid "AutoReq is not implemented for this package format, so it's skipped"
msgstr "" msgstr ""
#: pkg/build/build.go:718 #: pkg/build/build.go:719
msgid "Would you like to remove the build dependencies?" msgid "Would you like to remove the build dependencies?"
msgstr "" msgstr ""
#: pkg/build/build.go:824 #: pkg/build/build.go:825
msgid "The checksums array must be the same length as sources" msgid "The checksums array must be the same length as sources"
msgstr "" msgstr ""
@ -445,14 +445,14 @@ msgstr ""
msgid "Pull all repositories that have changed" msgid "Pull all repositories that have changed"
msgstr "" msgstr ""
#: upgrade.go:47 #: upgrade.go:46
msgid "Upgrade all installed packages" msgid "Upgrade all installed packages"
msgstr "" msgstr ""
#: upgrade.go:83 #: upgrade.go:82
msgid "Error checking for updates" msgid "Error checking for updates"
msgstr "" msgstr ""
#: upgrade.go:94 #: upgrade.go:93
msgid "There is nothing to do." msgid "There is nothing to do."
msgstr "" msgstr ""

@ -299,27 +299,27 @@ msgstr ""
msgid "Error while running app" msgid "Error while running app"
msgstr "Ошибка при запуске приложения" msgstr "Ошибка при запуске приложения"
#: pkg/build/build.go:105 #: pkg/build/build.go:104
msgid "Failed to prompt user to view build script" msgid "Failed to prompt user to view build script"
msgstr "Не удалось предложить пользователю просмотреть скрипт сборки" msgstr "Не удалось предложить пользователю просмотреть скрипт сборки"
#: pkg/build/build.go:109 #: pkg/build/build.go:108
msgid "Building package" msgid "Building package"
msgstr "Сборка пакета" msgstr "Сборка пакета"
#: pkg/build/build.go:153 #: pkg/build/build.go:152
msgid "Downloading sources" msgid "Downloading sources"
msgstr "Скачивание источников" msgstr "Скачивание источников"
#: pkg/build/build.go:165 #: pkg/build/build.go:164
msgid "Building package metadata" msgid "Building package metadata"
msgstr "Сборка метаданных пакета" msgstr "Сборка метаданных пакета"
#: pkg/build/build.go:187 #: pkg/build/build.go:186
msgid "Compressing package" msgid "Compressing package"
msgstr "Сжатие пакета" msgstr "Сжатие пакета"
#: pkg/build/build.go:313 #: pkg/build/build.go:312
msgid "" msgid ""
"Your system's CPU architecture doesn't match this package. Do you want to " "Your system's CPU architecture doesn't match this package. Do you want to "
"build anyway?" "build anyway?"
@ -327,57 +327,57 @@ msgstr ""
"Архитектура процессора вашей системы не соответствует этому пакету. Вы все " "Архитектура процессора вашей системы не соответствует этому пакету. Вы все "
"равно хотите выполнить сборку?" "равно хотите выполнить сборку?"
#: pkg/build/build.go:324 #: pkg/build/build.go:323
msgid "This package is already installed" msgid "This package is already installed"
msgstr "Этот пакет уже установлен" msgstr "Этот пакет уже установлен"
#: pkg/build/build.go:352 #: pkg/build/build.go:351
msgid "Installing build dependencies" msgid "Installing build dependencies"
msgstr "Установка зависимостей сборки" msgstr "Установка зависимостей сборки"
#: pkg/build/build.go:394 #: pkg/build/build.go:393
msgid "Installing dependencies" msgid "Installing dependencies"
msgstr "Установка зависимостей" msgstr "Установка зависимостей"
#: pkg/build/build.go:440 #: pkg/build/build.go:439
msgid "Executing version()" msgid "Executing version()"
msgstr "Исполнение версия()" msgstr "Исполнение версия()"
#: pkg/build/build.go:460 #: pkg/build/build.go:459
msgid "Updating version" msgid "Updating version"
msgstr "Обновление версии" msgstr "Обновление версии"
#: pkg/build/build.go:465 #: pkg/build/build.go:464
msgid "Executing prepare()" msgid "Executing prepare()"
msgstr "Исполнение prepare()" msgstr "Исполнение prepare()"
#: pkg/build/build.go:475 #: pkg/build/build.go:474
msgid "Executing build()" msgid "Executing build()"
msgstr "Исполнение build()" msgstr "Исполнение build()"
#: pkg/build/build.go:487 #: pkg/build/build.go:486
msgid "Executing package()" msgid "Executing package()"
msgstr "Исполнение package()" msgstr "Исполнение package()"
#: pkg/build/build.go:525 #: pkg/build/build.go:524
msgid "Executing files()" msgid "Executing files()"
msgstr "Исполнение package()" msgstr "Исполнение package()"
#: pkg/build/build.go:600 #: pkg/build/build.go:601
msgid "AutoProv is not implemented for this package format, so it's skipped" msgid "AutoProv is not implemented for this package format, so it's skipped"
msgstr "" msgstr ""
"AutoProv не реализовано для этого формата пакета, поэтому будет пропущено" "AutoProv не реализовано для этого формата пакета, поэтому будет пропущено"
#: pkg/build/build.go:611 #: pkg/build/build.go:612
msgid "AutoReq is not implemented for this package format, so it's skipped" msgid "AutoReq is not implemented for this package format, so it's skipped"
msgstr "" msgstr ""
"AutoReq не реализовано для этого формата пакета, поэтому будет пропущено" "AutoReq не реализовано для этого формата пакета, поэтому будет пропущено"
#: pkg/build/build.go:718 #: pkg/build/build.go:719
msgid "Would you like to remove the build dependencies?" msgid "Would you like to remove the build dependencies?"
msgstr "Хотели бы вы удалить зависимости сборки?" msgstr "Хотели бы вы удалить зависимости сборки?"
#: pkg/build/build.go:824 #: pkg/build/build.go:825
msgid "The checksums array must be the same length as sources" msgid "The checksums array must be the same length as sources"
msgstr "Массив контрольных сумм должен быть той же длины, что и источники" msgstr "Массив контрольных сумм должен быть той же длины, что и источники"
@ -465,14 +465,14 @@ msgstr "Ошибка при удалении пакетов из базы дан
msgid "Pull all repositories that have changed" msgid "Pull all repositories that have changed"
msgstr "Скачать все изменённые репозитории" msgstr "Скачать все изменённые репозитории"
#: upgrade.go:47 #: upgrade.go:46
msgid "Upgrade all installed packages" msgid "Upgrade all installed packages"
msgstr "Обновить все установленные пакеты" msgstr "Обновить все установленные пакеты"
#: upgrade.go:83 #: upgrade.go:82
msgid "Error checking for updates" msgid "Error checking for updates"
msgstr "Ошибка при проверке обновлений" msgstr "Ошибка при проверке обновлений"
#: upgrade.go:94 #: upgrade.go:93
msgid "There is nothing to do." msgid "There is nothing to do."
msgstr "Здесь нечего делать." msgstr "Здесь нечего делать."

@ -35,7 +35,6 @@ import (
"time" "time"
// Импортируем пакеты для поддержки различных форматов пакетов (APK, DEB, RPM и ARCH). // Импортируем пакеты для поддержки различных форматов пакетов (APK, DEB, RPM и ARCH).
_ "github.com/goreleaser/nfpm/v2/apk" _ "github.com/goreleaser/nfpm/v2/apk"
_ "github.com/goreleaser/nfpm/v2/arch" _ "github.com/goreleaser/nfpm/v2/arch"
_ "github.com/goreleaser/nfpm/v2/deb" _ "github.com/goreleaser/nfpm/v2/deb"
@ -43,7 +42,6 @@ import (
"github.com/leonelquinteros/gotext" "github.com/leonelquinteros/gotext"
"mvdan.cc/sh/v3/expand" "mvdan.cc/sh/v3/expand"
"mvdan.cc/sh/v3/interp" "mvdan.cc/sh/v3/interp"
"mvdan.cc/sh/v3/shell"
"mvdan.cc/sh/v3/syntax" "mvdan.cc/sh/v3/syntax"
"github.com/goreleaser/nfpm/v2" "github.com/goreleaser/nfpm/v2"
@ -54,7 +52,6 @@ import (
"gitea.plemya-x.ru/Plemya-x/ALR/internal/cpu" "gitea.plemya-x.ru/Plemya-x/ALR/internal/cpu"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/db" "gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/dl" "gitea.plemya-x.ru/Plemya-x/ALR/internal/dl"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/overrides"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/shutils/decoder" "gitea.plemya-x.ru/Plemya-x/ALR/internal/shutils/decoder"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/shutils/handlers" "gitea.plemya-x.ru/Plemya-x/ALR/internal/shutils/handlers"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/shutils/helpers" "gitea.plemya-x.ru/Plemya-x/ALR/internal/shutils/helpers"
@ -537,10 +534,7 @@ func executeFunctions(ctx context.Context, dec *decoder.Decoder, dirs types.Dire
return nil, err return nil, err
} }
contents, err := shell.Fields(buf.String(), func(s string) string { return "" }) contents := strings.Fields(strings.TrimSpace(buf.String()))
if err != nil {
return nil, err
}
output.Contents = &contents output.Contents = &contents
} }
@ -577,7 +571,9 @@ func buildPkgMetadata(
}) })
} }
pkgInfo.Release = overrides.ReleasePlatformSpecific(vars.Release, info) if pkgFormat == "rpm" && info.ID == "altlinux" {
pkgInfo.Release = "alt" + pkgInfo.Release
}
if vars.Epoch != 0 { if vars.Epoch != 0 {
pkgInfo.Epoch = strconv.FormatUint(uint64(vars.Epoch), 10) pkgInfo.Epoch = strconv.FormatUint(uint64(vars.Epoch), 10)

@ -44,7 +44,6 @@ type OSRelease struct {
SupportURL string SupportURL string
BugReportURL string BugReportURL string
Logo string Logo string
PlatformID string
} }
var parsed *OSRelease var parsed *OSRelease
@ -103,7 +102,6 @@ func ParseOSRelease(ctx context.Context) (*OSRelease, error) {
SupportURL: runner.Vars["SUPPORT_URL"].Str, SupportURL: runner.Vars["SUPPORT_URL"].Str,
BugReportURL: runner.Vars["BUG_REPORT_URL"].Str, BugReportURL: runner.Vars["BUG_REPORT_URL"].Str,
Logo: runner.Vars["LOGO"].Str, Logo: runner.Vars["LOGO"].Str,
PlatformID: runner.Vars["PLATFORM_ID"].Str,
} }
distroUpdated := false distroUpdated := false

@ -33,7 +33,6 @@ import (
"gitea.plemya-x.ru/Plemya-x/ALR/internal/config" "gitea.plemya-x.ru/Plemya-x/ALR/internal/config"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/db" "gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/overrides"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/types" "gitea.plemya-x.ru/Plemya-x/ALR/internal/types"
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/build" "gitea.plemya-x.ru/Plemya-x/ALR/pkg/build"
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/distro" "gitea.plemya-x.ru/Plemya-x/ALR/pkg/distro"
@ -128,12 +127,10 @@ func checkForUpdates(ctx context.Context, mgr manager.Manager, info *distro.OSRe
pkg := pkgs[0] pkg := pkgs[0]
repoVer := pkg.Version repoVer := pkg.Version
releaseStr := overrides.ReleasePlatformSpecific(pkg.Release, info)
if pkg.Release != 0 && pkg.Epoch == 0 { if pkg.Release != 0 && pkg.Epoch == 0 {
repoVer = fmt.Sprintf("%s-%s", pkg.Version, releaseStr) repoVer = fmt.Sprintf("%s-%d", pkg.Version, pkg.Release)
} else if pkg.Release != 0 && pkg.Epoch != 0 { } else if pkg.Release != 0 && pkg.Epoch != 0 {
repoVer = fmt.Sprintf("%d:%s-%s", pkg.Epoch, pkg.Version, releaseStr) repoVer = fmt.Sprintf("%d:%s-%d", pkg.Epoch, pkg.Version, pkg.Release)
} }
c := vercmp.Compare(repoVer, installed[pkgName]) c := vercmp.Compare(repoVer, installed[pkgName])