fix: use platform specific release in compare

This commit is contained in:
2025-01-25 11:16:33 +03:00
parent 6410f7547b
commit 981f49587b
6 changed files with 73 additions and 49 deletions

View File

@ -20,7 +20,9 @@
package overrides
import (
"fmt"
"reflect"
"regexp"
"strings"
"golang.org/x/exp/slices"
@ -223,3 +225,21 @@ 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)
}
for _, v := range info.Like {
if v == "fedora" {
re := regexp.MustCompile(`platform:(\S+)`)
match := re.FindStringSubmatch(info.PlatformID)
if len(match) > 1 {
return fmt.Sprintf("%d.%s", release, match[0])
}
}
}
return fmt.Sprintf("%d", release)
}