Repository: goreleaser/nfpm
Pull request #99 (2019-11-05 02:45:05)

fix(rpm): desc, summary and group
refs https://github.com/google/rpmpack/pull/33
refs https://github.com/goreleaser/goreleaser/issues/1229

codecov-io: # [Codecov](https://codecov.io/gh/goreleaser/nfpm/pull/99?src=pr&el=h1) Report
> Merging [#99](https://codecov.io/gh/goreleaser/nfpm/pull/99?src=pr&el=desc) into [master](https://codecov.io/gh/goreleaser/nfpm/commit/9fe80bd9bdab77144c0072df0a20d3136410f785?src=pr&el=desc) will **increase** coverage by `0.05%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/goreleaser/nfpm/pull/99/graphs/tree.svg?width=650&token=9QKGIxn7wg&height=150&src=pr)](https://codecov.io/gh/goreleaser/nfpm/pull/99?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master      #99      +/-   ##
==========================================
+ Coverage   71.87%   71.93%   +0.05%     
==========================================
  Files           5        5              
  Lines         480      481       +1     
==========================================
+ Hits          345      346       +1     
  Misses         84       84              
  Partials       51       51
```


| [Impacted Files](https://codecov.io/gh/goreleaser/nfpm/pull/99?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [rpm/rpm.go](https://codecov.io/gh/goreleaser/nfpm/pull/99/diff?src=pr&el=tree#diff-cnBtL3JwbS5nbw==) | `72.97% <100%> (+0.18%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/nfpm/pull/99?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/goreleaser/nfpm/pull/99?src=pr&el=footer). Last update [9fe80bd...5093be0](https://codecov.io/gh/goreleaser/nfpm/pull/99?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/go.mod b/go.mod
index e9cf7b4..32bae38 100644
--- a/go.mod
+++ b/go.mod
@@ -22,3 +22,6 @@ require (
 	gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
 	gopkg.in/yaml.v2 v2.2.4
 )
+
+// TODO: remove this when https://github.com/google/rpmpack/pull/33 gets merged in.
+replace github.com/google/rpmpack => github.com/caarlos0/rpmpack v0.0.0-20191105023656-ae56d4a24f9a
diff --git a/go.sum b/go.sum
index f4597a3..0746eaf 100644
--- a/go.sum
+++ b/go.sum
@@ -8,6 +8,8 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2c
 github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
 github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb h1:m935MPodAbYS46DG4pJSv7WO+VECIWUQ7OJYSoTrMh4=
 github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb/go.mod h1:PkYb9DJNAwrSvRx5DYA+gUcOIgTGVMNkfSCbZM8cWpI=
+github.com/caarlos0/rpmpack v0.0.0-20191105023656-ae56d4a24f9a h1:5dtf2X2ew+yN4Y0r2UjkjbGMyfMKC6XYu1H4gYsCb4g=
+github.com/caarlos0/rpmpack v0.0.0-20191105023656-ae56d4a24f9a/go.mod h1:RaTPr0KUf2K7fnZYLNDrr8rxAamWs3iNywJLtQ2AzBg=
 github.com/cavaliercoder/go-cpio v0.0.0-20180626203310-925f9528c45e h1:hHg27A0RSSp2Om9lubZpiMgVbvn39bsUmW9U5h0twqc=
 github.com/cavaliercoder/go-cpio v0.0.0-20180626203310-925f9528c45e/go.mod h1:oDpT4efm8tSYHXV5tHSdRvBet/b/QzxZ+XyyPehvm3A=
 github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
@@ -16,8 +18,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
 github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
-github.com/google/rpmpack v0.0.0-20191101142923-13d81472ccfe h1:P1WflKHEgTAYe39btxYzeds84DhxQSLj4hfoNn0tCyQ=
-github.com/google/rpmpack v0.0.0-20191101142923-13d81472ccfe/go.mod h1:RaTPr0KUf2K7fnZYLNDrr8rxAamWs3iNywJLtQ2AzBg=
 github.com/imdario/mergo v0.3.8 h1:CGgOkSJeqMRmt0D9XLWExdT4m4F1vd3FV3VPt+0VxkQ=
 github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
 github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
diff --git a/rpm/rpm.go b/rpm/rpm.go
index b8ff15e..f5558dd 100644
--- a/rpm/rpm.go
+++ b/rpm/rpm.go
@@ -6,6 +6,7 @@ import (
 	"io"
 	"io/ioutil"
 	"os"
+	"strings"
 	"time"
 
 	"github.com/google/rpmpack"
@@ -104,6 +105,7 @@ func buildRPMMeta(info *nfpm.Info) (*rpmpack.RPMMetaData, error) {
 
 	return &rpmpack.RPMMetaData{
 		Name:        info.Name,
+		Summary:     strings.Split(info.Description, "\n")[0],
 		Description: info.Description,
 		Version:     info.Version,
 		Release:     defaultTo(info.Release, "1"),
@@ -113,7 +115,7 @@ func buildRPMMeta(info *nfpm.Info) (*rpmpack.RPMMetaData, error) {
 		URL:         info.Homepage,
 		Vendor:      info.Vendor,
 		Packager:    info.Maintainer,
-		Group:       info.RPM.Group,
+		Group:       defaultTo(info.RPM.Group, "Development/Tools"),
 		Provides:    provides,
 		Requires:    depends,
 		Obsoletes:   replaces,


Test patch:
diff --git a/rpm/rpm_test.go b/rpm/rpm_test.go
index 0843938..ac8ea73 100644
--- a/rpm/rpm_test.go
+++ b/rpm/rpm_test.go
@@ -13,12 +13,14 @@ import (
 )
 
 const (
-	tagRelease = 0x03ea // 1002
-	tagGroup   = 0x03f8 // 1016
-	tagPrein   = 0x03ff // 1023
-	tagPostin  = 0x0400 // 1024
-	tagPreun   = 0x0401 // 1025
-	tagPostun  = 0x0402 // 1026
+	tagRelease     = 0x03ea // 1002
+	tagSummary     = 0x03ec // 1004
+	tagDescription = 0x03ed // 1005
+	tagGroup       = 0x03f8 // 1016
+	tagPrein       = 0x03ff // 1023
+	tagPostin      = 0x0400 // 1024
+	tagPreun       = 0x0401 // 1025
+	tagPostun      = 0x0402 // 1026
 )
 
 func exampleInfo() *nfpm.Info {
@@ -87,9 +89,22 @@ func TestRPM(t *testing.T) {
 	assert.NoError(t, err)
 	rpm, err := rpmutils.ReadRpm(file)
 	assert.NoError(t, err)
+
 	release, err := rpm.Header.GetString(tagRelease)
 	assert.NoError(t, err)
 	assert.Equal(t, "1", release)
+
+	group, err := rpm.Header.GetString(tagGroup)
+	assert.NoError(t, err)
+	assert.Equal(t, "Development/Tools", group)
+
+	summary, err := rpm.Header.GetString(tagSummary)
+	assert.NoError(t, err)
+	assert.Equal(t, "Foo does things", summary)
+
+	description, err := rpm.Header.GetString(tagDescription)
+	assert.NoError(t, err)
+	assert.Equal(t, "Foo does things", description)
 }
 
 func TestWithRPMTags(t *testing.T) {
@@ -105,6 +120,7 @@ func TestWithRPMTags(t *testing.T) {
 	info.RPM = nfpm.RPM{
 		Group: "default",
 	}
+	info.Description = "first line\nsecond line\nthird line"
 	assert.NoError(t, Default.Package(info, f))
 
 	file, err := os.OpenFile(f.Name(), os.O_RDONLY, 0600) //nolint:gosec
@@ -120,6 +136,14 @@ func TestWithRPMTags(t *testing.T) {
 	group, err := rpm.Header.GetString(tagGroup)
 	assert.NoError(t, err)
 	assert.Equal(t, "default", group)
+
+	summary, err := rpm.Header.GetString(tagSummary)
+	assert.NoError(t, err)
+	assert.Equal(t, "first line", summary)
+
+	description, err := rpm.Header.GetString(tagDescription)
+	assert.NoError(t, err)
+	assert.Equal(t, info.Description, description)
 }
 
 func TestRPMVersionWithDash(t *testing.T) {