From 5f10dba792c4ec4d6a60147d4990a732e63570f3 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 17 Nov 2022 09:50:38 -0300 Subject: [PATCH] fix: archlinux prerelease (#578) Signed-off-by: Carlos A Becker Signed-off-by: Carlos A Becker --- arch/arch.go | 10 ++++++++-- arch/arch_test.go | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/arch.go b/arch/arch.go index cd561329..c24eae3d 100644 --- a/arch/arch.go +++ b/arch/arch.go @@ -72,7 +72,7 @@ func (ArchLinux) ConventionalFileName(info *nfpm.Info) string { name := fmt.Sprintf( "%s-%s-%d-%s.pkg.tar.zst", info.Name, - info.Version, + info.Version+strings.ReplaceAll(info.Prerelease, "-", "_"), pkgrel, info.Arch, ) @@ -411,7 +411,13 @@ func createPkginfo(info *nfpm.Info, tw *tar.Writer, totalSize int64) (*MtreeEntr if info.Epoch != "" { epoch, err := strconv.ParseUint(info.Epoch, 10, 64) if err == nil { - pkgver = fmt.Sprintf("%d:%s-%d", epoch, info.Version, pkgrel) + pkgver = fmt.Sprintf( + "%d:%s%s-%d", + epoch, + info.Version, + strings.ReplaceAll(info.Prerelease, "-", "_"), + pkgrel, + ) } } diff --git a/arch/arch_test.go b/arch/arch_test.go index c54e87c9..aebaa988 100644 --- a/arch/arch_test.go +++ b/arch/arch_test.go @@ -21,6 +21,7 @@ func exampleInfo() *nfpm.Info { Priority: "extra", Maintainer: "Carlos A Becker ", Version: "1.0.0", + Prerelease: "beta-1", Section: "default", Homepage: "http://carlosbecker.com", Vendor: "nope", @@ -120,7 +121,7 @@ func TestArchConventionalFileName(t *testing.T) { info.Arch = arch name := Default.ConventionalFileName(info) require.Equal(t, - "foo-test-1.0.0-1-"+archToArchLinux[arch]+".pkg.tar.zst", + "foo-test-1.0.0beta_1-1-"+archToArchLinux[arch]+".pkg.tar.zst", name, ) }) @@ -180,7 +181,7 @@ func TestArchVersionWithEpoch(t *testing.T) { pkginfoData, err := makeTestPkginfo(t, info) require.NoError(t, err) fields := extractPkginfoFields(pkginfoData) - require.Equal(t, "2:0.0.1-1", fields["pkgver"]) + require.Equal(t, "2:0.0.1beta_1-1", fields["pkgver"]) } func TestArchOverrideArchitecture(t *testing.T) {