Repository: goreleaser/nfpm
Pull request #837 (2024-07-05 14:24:44)

test: centos8 mirrorlist has been down for a long time
tests for centos8 have been failing for a while because the mirror list seems to be down...

removing it, still testing on some fedora versions and centos9

cloudflare-pages[bot]: ## Deploying nfpm with &nbsp;<a href="https://pages.dev"><img alt="Cloudflare Pages" src="https://user-images.githubusercontent.com/23264/106598434-9e719e00-654f-11eb-9e59-6167043cfa01.png" width="16"></a> &nbsp;Cloudflare Pages

<table><tr><td><strong>Latest commit:</strong> </td><td>
<code>66d1a06</code>
</td></tr>
<tr><td><strong>Status:</strong></td><td>&nbsp;✅&nbsp; Deploy successful!</td></tr>
<tr><td><strong>Preview URL:</strong></td><td>
<a href='https://c1d56c36.nfpm.pages.dev'>https://c1d56c36.nfpm.pages.dev</a>
</td></tr>
<tr><td><strong>Branch Preview URL:</strong></td><td>
<a href='https://centos8-failing.nfpm.pages.dev'>https://centos8-failing.nfpm.pages.dev</a>
</td></tr>
</table>

[View logs](https://dash.cloudflare.com/?to=/:account/pages/view/nfpm/c1d56c36-327f-4604-810e-856eefde3050)


Patch:
diff --git a/rpm/rpm.go b/rpm/rpm.go
index 5ec04d1..3e98b70 100644
--- a/rpm/rpm.go
+++ b/rpm/rpm.go
@@ -271,7 +271,7 @@ func formatVersion(info *nfpm.Info) string {
 	version := info.Version
 
 	if info.Prerelease != "" {
-		version += "~" + info.Prerelease
+		version += "~" + strings.ReplaceAll(info.Prerelease, "-", "_")
 	}
 
 	if info.VersionMetadata != "" {


Test patch:
diff --git a/acceptance_test.go b/acceptance_test.go
index 7e934f5..3f1a2fc 100644
--- a/acceptance_test.go
+++ b/acceptance_test.go
@@ -297,7 +297,7 @@ func TestIPKSpecific(t *testing.T) {
 
 func TestRPMSign(t *testing.T) {
 	t.Parallel()
-	for _, os := range []string{"centos9", "centos8", "fedora34", "fedora36", "fedora38"} {
+	for _, os := range []string{"centos9", "fedora34", "fedora36", "fedora38"} {
 		os := os
 		t.Run(fmt.Sprintf("rpm/amd64/sign/%s", os), func(t *testing.T) {
 			t.Parallel()
diff --git a/rpm/rpm_test.go b/rpm/rpm_test.go
index 62ab016..7569871 100644
--- a/rpm/rpm_test.go
+++ b/rpm/rpm_test.go
@@ -420,6 +420,16 @@ func TestRPMVersionWithPrerelease(t *testing.T) {
 	require.Equal(t, "1", meta.Release)
 }
 
+func TestRPMVersionWithPrereleaseWithDashes(t *testing.T) {
+	info := exampleInfo()
+	info.Version = "1.0.0"
+	info.Prerelease = "rc1-alpha-omega" // nolint:goconst
+	meta, err := buildRPMMeta(info)
+	require.NoError(t, err)
+	require.Equal(t, "1.0.0~rc1_alpha_omega", meta.Version)
+	require.Equal(t, "1", meta.Release)
+}
+
 func TestRPMVersionWithReleaseAndPrerelease(t *testing.T) {
 	// https://fedoraproject.org/wiki/Package_Versioning_Examples#Complex_versioning_examples
 	info := exampleInfo()
diff --git a/testdata/acceptance/rpm_centos8.dockerfile b/testdata/acceptance/rpm_centos8.dockerfile
deleted file mode 100644
index 908f357..0000000
--- a/testdata/acceptance/rpm_centos8.dockerfile
+++ /dev/null
@@ -1,20 +0,0 @@
-FROM quay.io/centos/centos:stream8 AS test_base
-ARG package
-RUN yum install -y createrepo yum-utils
-RUN echo "${package}"
-COPY ${package} /tmp/foo.rpm
-
-FROM test_base AS signed
-COPY keys/pubkey.asc /tmp/pubkey.asc
-RUN rpm --import /tmp/pubkey.asc
-RUN rpm -q gpg-pubkey --qf '%{NAME}-%{VERSION}-%{RELEASE}\t%{SUMMARY}\n'
-RUN rpm -vK /tmp/foo.rpm
-RUN rpm -vK /tmp/foo.rpm | grep "RSA/SHA256 Signature, key ID 15bd80b3: OK"
-RUN rpm -K /tmp/foo.rpm
-RUN rpm -K /tmp/foo.rpm | grep -E "(?:pgp|digests signatures) OK"
-
-RUN rm -rf /etc/yum.repos.d/*.repo
-COPY keys/test.rpm.repo /etc/yum.repos.d/test.rpm.repo
-RUN createrepo /tmp
-RUN yum install -y foo
-