Fix pacman-git builds (#2712)

* fix pacman-git ABI change

* add guard for ABI stability

* bump alpm for ABI fix

* normalize strings for comparison
This commit is contained in:
Jo
2025-11-28 21:20:27 +01:00
committed by GitHub
parent dc72277951
commit 99770dec04
6 changed files with 53 additions and 32 deletions

View File

@@ -42,6 +42,8 @@ type Package struct {
PArchitecture string
}
var _ alpm.IPackage = (*Package)(nil)
func (p *Package) Base() string {
return p.PBase
}
@@ -162,11 +164,6 @@ func (p *Package) SHA256Sum() string {
panic("not implemented")
}
// MD5Sum returns package MD5Sum.
func (p *Package) MD5Sum() string {
panic("not implemented")
}
// Packager returns package packager name.
func (p *Package) Packager() string {
panic("not implemented")

View File

@@ -205,7 +205,6 @@ func PKGBUILDRepos(ctx context.Context, dbExecutor DBSearcher, aurClient aur.Que
return cloned, errs.Return()
}
// TODO: replace with dep.ResolveTargets.
func getPackageUsableName(dbExecutor DBSearcher, aurClient aur.QueryClient,
logger *text.Logger, target string, mode parser.TargetMode,
) (dbname, pkgname string, isAUR, toSkip bool) {
@@ -219,13 +218,11 @@ func getPackageUsableName(dbExecutor DBSearcher, aurClient aur.QueryClient,
}
if pkg != nil {
name = getURLName(pkg)
dbName = pkg.DB().Name()
return dbName, name, false, false
return pkg.DB().Name(), getURLName(pkg), false, false
}
// If the package is not found in the database and it was expected to be
if pkg == nil && dbName != "" {
// Package not found in specified DB - skip it
if dbName != "" {
return dbName, name, true, true
}
}

View File

@@ -6,6 +6,7 @@ package runtime
import (
"path/filepath"
"runtime"
"strings"
"testing"
"github.com/Morganamilo/go-pacmanconf"
@@ -15,6 +16,33 @@ import (
"github.com/Jguer/yay/v12/pkg/settings/parser"
)
// normalizePath removes trailing slashes from paths (except for root "/").
func normalizePath(p string) string {
if p == "/" {
return p
}
return strings.TrimSuffix(p, "/")
}
// normalizePaths normalizes a slice of paths.
func normalizePaths(paths []string) []string {
result := make([]string, len(paths))
for i, p := range paths {
result[i] = normalizePath(p)
}
return result
}
// normalizePacmanConf normalizes directory paths in a pacmanconf.Config
// to handle differences between pacman versions (with/without trailing slashes).
func normalizePacmanConf(conf *pacmanconf.Config) {
conf.RootDir = normalizePath(conf.RootDir)
conf.DBPath = normalizePath(conf.DBPath)
conf.GPGDir = normalizePath(conf.GPGDir)
conf.CacheDir = normalizePaths(conf.CacheDir)
conf.HookDir = normalizePaths(conf.HookDir)
}
func TestPacmanConf(t *testing.T) {
t.Parallel()
path := "../../testdata/pacman.conf"
@@ -29,10 +57,10 @@ func TestPacmanConf(t *testing.T) {
}
expectedPacmanConf := &pacmanconf.Config{
RootDir: "/", DBPath: "/var/lib/pacman/",
CacheDir: []string{"/var/cache/pacman/pkg/"},
HookDir: []string{"/etc/pacman.d/hooks/"},
GPGDir: "/etc/pacman.d/gnupg/", LogFile: "/var/log/pacman.log",
RootDir: "/", DBPath: "/var/lib/pacman",
CacheDir: []string{"/var/cache/pacman/pkg"},
HookDir: []string{"/etc/pacman.d/hooks"},
GPGDir: "/etc/pacman.d/gnupg", LogFile: "/var/log/pacman.log",
HoldPkg: []string{"pacman", "glibc"}, IgnorePkg: []string{"xorm"},
IgnoreGroup: []string{"yorm"}, Architecture: expectedArch,
XferCommand: "/usr/bin/wget --passive-ftp -c -O %o %u",
@@ -62,5 +90,9 @@ func TestPacmanConf(t *testing.T) {
assert.Nil(t, err)
assert.NotNil(t, pacmanConf)
assert.Equal(t, color, false)
// Normalize paths to handle differences between pacman versions
// (some versions include trailing slashes, some don't)
normalizePacmanConf(pacmanConf)
assert.EqualValues(t, expectedPacmanConf, pacmanConf)
}