Skip to content

Commit

Permalink
fix: archlinux prerelease (#578)
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Nov 17, 2022
1 parent b15966c commit 5f10dba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 8 additions & 2 deletions arch/arch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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,
)
}
}

Expand Down
5 changes: 3 additions & 2 deletions arch/arch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func exampleInfo() *nfpm.Info {
Priority: "extra",
Maintainer: "Carlos A Becker <pkg@carlosbecker.com>",
Version: "1.0.0",
Prerelease: "beta-1",
Section: "default",
Homepage: "http://carlosbecker.com",
Vendor: "nope",
Expand Down Expand Up @@ -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,
)
})
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 5f10dba

Please sign in to comment.