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

@@ -170,12 +170,7 @@ func TestIntegrationCleanAUR(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
mockRunner := &exe.MockRunner{
CaptureFn: func(cmd *exec.Cmd) (stdout string, stderr string, err error) {
return "", "", nil
},
ShowFn: func(cmd *exec.Cmd) error { return nil },
}
mockRunner := &exe.MockRunner{}
cfg := &settings.Configuration{
BuildDir: buildDir,
@@ -194,9 +189,9 @@ func TestIntegrationCleanAUR(t *testing.T) {
cmdArgs.AddArg(tc.args...)
// Create the package directories to be cleaned
err := os.MkdirAll(yayGitDir, 0755)
err := os.MkdirAll(yayGitDir, 0o755)
require.NoError(t, err)
err = os.MkdirAll(zoomDir, 0755)
err = os.MkdirAll(zoomDir, 0o755)
require.NoError(t, err)
err = handleCmd(context.Background(),

6
go.mod
View File

@@ -2,7 +2,7 @@ module github.com/Jguer/yay/v12
require (
github.com/Jguer/aur v1.2.3
github.com/Jguer/go-alpm/v2 v2.2.2
github.com/Jguer/go-alpm/v2 v2.3.1
github.com/Jguer/votar v1.0.0
github.com/Morganamilo/go-pacmanconf v0.0.0-20210502114700-cff030e927a5
github.com/Morganamilo/go-srcinfo v1.0.0
@@ -23,9 +23,9 @@ require (
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/itchyny/gojq v0.12.17 // indirect
github.com/itchyny/timefmt-go v0.1.6 // indirect
github.com/itchyny/timefmt-go v0.1.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/ohler55/ojg v1.26.1 // indirect
github.com/ohler55/ojg v1.27.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

12
go.sum
View File

@@ -1,7 +1,7 @@
github.com/Jguer/aur v1.2.3 h1:D+OGgLxnAnZnw88DsRvnRQsn0Poxsy9ng7pBcsA0krM=
github.com/Jguer/aur v1.2.3/go.mod h1:Dahvb6L1yr0rR7svyYSDwaRJoQMeyvJblwJ3QH/7CUs=
github.com/Jguer/go-alpm/v2 v2.2.2 h1:sPwUoZp1X5Tw6K6Ba1lWvVJfcgVNEGVcxARLBttZnC0=
github.com/Jguer/go-alpm/v2 v2.2.2/go.mod h1:lfe8gSe83F/KERaQvEfrSqQ4n+8bES+ZIyKWR/gm3MI=
github.com/Jguer/go-alpm/v2 v2.3.1 h1:6xgyL28aI4E4gng/cH+kvCnpa95f4Qgmddmh8A7iTGk=
github.com/Jguer/go-alpm/v2 v2.3.1/go.mod h1:lfe8gSe83F/KERaQvEfrSqQ4n+8bES+ZIyKWR/gm3MI=
github.com/Jguer/votar v1.0.0 h1:drPYpV5Py5BeAQS8xezmT6uCEfLzotNjLf5yfmlHKTg=
github.com/Jguer/votar v1.0.0/go.mod h1:rc6vgVlTqNjI4nAnPbDTbdxw/N7kXkbB8BcUDjeFbYQ=
github.com/Morganamilo/go-pacmanconf v0.0.0-20210502114700-cff030e927a5 h1:TMscPjkb1ThXN32LuFY5bEYIcXZx3YlwzhS1GxNpn/c=
@@ -28,16 +28,16 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/itchyny/gojq v0.12.17 h1:8av8eGduDb5+rvEdaOO+zQUjA04MS0m3Ps8HiD+fceg=
github.com/itchyny/gojq v0.12.17/go.mod h1:WBrEMkgAfAGO1LUcGOckBl5O726KPp+OlkKug0I/FEY=
github.com/itchyny/timefmt-go v0.1.6 h1:ia3s54iciXDdzWzwaVKXZPbiXzxxnv1SPGFfM/myJ5Q=
github.com/itchyny/timefmt-go v0.1.6/go.mod h1:RRDZYC5s9ErkjQvTvvU7keJjxUYzIISJGxm9/mAERQg=
github.com/itchyny/timefmt-go v0.1.7 h1:xyftit9Tbw+Dc/huSSPJaEmX1TVL8lw5vxjJLK4GMMA=
github.com/itchyny/timefmt-go v0.1.7/go.mod h1:5E46Q+zj7vbTgWY8o5YkMeYb4I6GeWLFnetPy5oBrAI=
github.com/leonelquinteros/gotext v1.7.2 h1:bDPndU8nt+/kRo1m4l/1OXiiy2v7Z7dfPQ9+YP7G1Mc=
github.com/leonelquinteros/gotext v1.7.2/go.mod h1:9/haCkm5P7Jay1sxKDGJ5WIg4zkz8oZKw4ekNpALob8=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
github.com/ohler55/ojg v1.26.1 h1:J5TaLmVEuvnpVH7JMdT1QdbpJU545Yp6cKiCO4aQILc=
github.com/ohler55/ojg v1.26.1/go.mod h1:gQhDVpQLqrmnd2eqGAvJtn+NfKoYJbe/A4Sj3/Vro4o=
github.com/ohler55/ojg v1.27.0 h1:1JzdkMpDc/X9bzRaN1+8AFLnrSiFy96yDSaeACCGD5U=
github.com/ohler55/ojg v1.27.0/go.mod h1:/Y5dGWkekv9ocnUixuETqiL58f+5pAsUfg5P8e7Pa2o=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

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)
}