1
0
forked from Plemya-x/ALR

Compare commits

...

6 Commits

7 changed files with 118 additions and 50 deletions

@ -20,7 +20,9 @@
package overrides
import (
"fmt"
"reflect"
"regexp"
"strings"
"golang.org/x/exp/slices"
@ -223,3 +225,19 @@ func parseLangs(langs []string, tags []language.Tag) ([]string, error) {
out = slices.Compact(out)
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,6 +24,7 @@ import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"golang.org/x/text/language"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/overrides"
@ -195,3 +196,43 @@ func TestResolveLangs(t *testing.T) {
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"
msgstr ""
#: pkg/build/build.go:104
#: pkg/build/build.go:105
msgid "Failed to prompt user to view build script"
msgstr ""
#: pkg/build/build.go:108
#: pkg/build/build.go:109
msgid "Building package"
msgstr ""
#: pkg/build/build.go:152
#: pkg/build/build.go:153
msgid "Downloading sources"
msgstr ""
#: pkg/build/build.go:164
#: pkg/build/build.go:165
msgid "Building package metadata"
msgstr ""
#: pkg/build/build.go:186
#: pkg/build/build.go:187
msgid "Compressing package"
msgstr ""
#: pkg/build/build.go:312
#: pkg/build/build.go:313
msgid ""
"Your system's CPU architecture doesn't match this package. Do you want to "
"build anyway?"
msgstr ""
#: pkg/build/build.go:323
#: pkg/build/build.go:324
msgid "This package is already installed"
msgstr ""
#: pkg/build/build.go:351
#: pkg/build/build.go:352
msgid "Installing build dependencies"
msgstr ""
#: pkg/build/build.go:393
#: pkg/build/build.go:394
msgid "Installing dependencies"
msgstr ""
#: pkg/build/build.go:439
#: pkg/build/build.go:440
msgid "Executing version()"
msgstr ""
#: pkg/build/build.go:459
#: pkg/build/build.go:460
msgid "Updating version"
msgstr ""
#: pkg/build/build.go:464
#: pkg/build/build.go:465
msgid "Executing prepare()"
msgstr ""
#: pkg/build/build.go:474
#: pkg/build/build.go:475
msgid "Executing build()"
msgstr ""
#: pkg/build/build.go:486
#: pkg/build/build.go:487
msgid "Executing package()"
msgstr ""
#: pkg/build/build.go:524
#: pkg/build/build.go:525
msgid "Executing files()"
msgstr ""
#: pkg/build/build.go:601
#: pkg/build/build.go:600
msgid "AutoProv is not implemented for this package format, so it's skipped"
msgstr ""
#: pkg/build/build.go:612
#: pkg/build/build.go:611
msgid "AutoReq is not implemented for this package format, so it's skipped"
msgstr ""
#: pkg/build/build.go:719
#: pkg/build/build.go:718
msgid "Would you like to remove the build dependencies?"
msgstr ""
#: pkg/build/build.go:825
#: pkg/build/build.go:824
msgid "The checksums array must be the same length as sources"
msgstr ""
@ -445,14 +445,14 @@ msgstr ""
msgid "Pull all repositories that have changed"
msgstr ""
#: upgrade.go:46
#: upgrade.go:47
msgid "Upgrade all installed packages"
msgstr ""
#: upgrade.go:82
#: upgrade.go:83
msgid "Error checking for updates"
msgstr ""
#: upgrade.go:93
#: upgrade.go:94
msgid "There is nothing to do."
msgstr ""

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

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

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

@ -33,6 +33,7 @@ import (
"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/overrides"
"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/distro"
@ -127,10 +128,12 @@ func checkForUpdates(ctx context.Context, mgr manager.Manager, info *distro.OSRe
pkg := pkgs[0]
repoVer := pkg.Version
releaseStr := overrides.ReleasePlatformSpecific(pkg.Release, info)
if pkg.Release != 0 && pkg.Epoch == 0 {
repoVer = fmt.Sprintf("%s-%d", pkg.Version, pkg.Release)
repoVer = fmt.Sprintf("%s-%s", pkg.Version, releaseStr)
} else if pkg.Release != 0 && pkg.Epoch != 0 {
repoVer = fmt.Sprintf("%d:%s-%d", pkg.Epoch, pkg.Version, pkg.Release)
repoVer = fmt.Sprintf("%d:%s-%s", pkg.Epoch, pkg.Version, releaseStr)
}
c := vercmp.Compare(repoVer, installed[pkgName])