Repository: goreleaser/nfpm
Pull request #261 (2020-12-06 21:56:29)

test: Intergate and test rpmpack ghost file fix
Bump github.com/google/rpmpack to integrate the ghost file handling
fix [google/rpmpack 52].

Updated the TestRPMGhostFiles fix to test the updated
functionality. Now, we expect that the files are listed in the RPM
header, but without any cpio content.

This is an extension of PR #246.

[google/rpmpack 52]: https://github.com/google/rpmpack/pull/52

vercel[bot]: This pull request is being automatically deployed with Vercel ([learn more](https://vercel.link/github-learn-more)).  
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: [https://vercel.com/goreleaser/nfpm/lhe8hltpi](https://vercel.com/goreleaser/nfpm/lhe8hltpi)  
✅ Preview: *In Progress*


codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/nfpm/pull/261?src=pr&el=h1) Report
> Merging [#261](https://codecov.io/gh/goreleaser/nfpm/pull/261?src=pr&el=desc) (5ebf6de) into [master](https://codecov.io/gh/goreleaser/nfpm/commit/8dc2e90ae194707460e2abce6dc87860eb179cfa?el=desc) (8dc2e90) will **not change** coverage.
> The diff coverage is `n/a`.

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

```diff
@@           Coverage Diff           @@
##           master     #261   +/-   ##
=======================================
  Coverage   68.76%   68.76%           
=======================================
  Files           9        9           
  Lines        1031     1031           
=======================================
  Hits          709      709           
  Misses        190      190           
  Partials      132      132           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/nfpm/pull/261?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/261?src=pr&el=footer). Last update [8dc2e90...5ebf6de](https://codecov.io/gh/goreleaser/nfpm/pull/261?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 59c22a5..1127857 100644
--- a/go.mod
+++ b/go.mod
@@ -9,7 +9,7 @@ require (
 	github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
 	github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
 	github.com/golangci/golangci-lint v1.33.0
-	github.com/google/rpmpack v0.0.0-20200919095143-1c1eea455332
+	github.com/google/rpmpack v0.0.0-20201206194719-59e495f2b7e1
 	github.com/goreleaser/chglog v0.1.2
 	github.com/goreleaser/fileglob v0.3.0
 	github.com/imdario/mergo v0.3.11
diff --git a/go.sum b/go.sum
index 9c06bf5..b68b9e8 100644
--- a/go.sum
+++ b/go.sum
@@ -197,6 +197,8 @@ github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OI
 github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
 github.com/google/rpmpack v0.0.0-20200919095143-1c1eea455332 h1:/7+8vH2OZt7aaatqFUE9STn3NHVt15l21vI+jJog5gw=
 github.com/google/rpmpack v0.0.0-20200919095143-1c1eea455332/go.mod h1:+y9lKiqDhR4zkLl+V9h4q0rdyrYVsWWm6LLCQP33DIk=
+github.com/google/rpmpack v0.0.0-20201206194719-59e495f2b7e1 h1:BRIy5qQZKSC/nthA5ueW547F73BV5hMoIoxhPfhxa3k=
+github.com/google/rpmpack v0.0.0-20201206194719-59e495f2b7e1/go.mod h1:+y9lKiqDhR4zkLl+V9h4q0rdyrYVsWWm6LLCQP33DIk=
 github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
 github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=


Test patch:
diff --git a/rpm/rpm_test.go b/rpm/rpm_test.go
index 6295f5e..69148ea 100644
--- a/rpm/rpm_test.go
+++ b/rpm/rpm_test.go
@@ -632,15 +632,28 @@ func TestRPMGhostFiles(t *testing.T) {
 	err := Default.Package(info, &rpmFileBuffer)
 	require.NoError(t, err)
 
-	packagedFileHeader, err := extractFileHeaderFromRpm(rpmFileBuffer.Bytes(), filename)
+	headerFiles, err := extraFileInfoSliceFromRpm(rpmFileBuffer.Bytes())
 	require.NoError(t, err)
 
-	packagedFile, err := extractFileFromRpm(rpmFileBuffer.Bytes(), filename)
-	require.NoError(t, err)
+	type headerFileInfo struct {
+		Name string
+		Size int64
+		Mode int
+	}
+	expected := []headerFileInfo{
+		{filename, 0, cpio.S_ISREG | 0644},
+	}
+	actual := make([]headerFileInfo, 0)
+	for _, fileInfo := range headerFiles {
+		actual = append(actual, headerFileInfo{fileInfo.Name(), fileInfo.Size(), fileInfo.Mode()})
+	}
+	assert.Equal(t, expected, actual)
 
-	assert.Equal(t, filename, packagedFileHeader.Filename())
-	assert.Equal(t, cpio.S_ISREG|0644, packagedFileHeader.Mode())
-	assert.Equal(t, "", string(packagedFile))
+	_, err = extractFileHeaderFromRpm(rpmFileBuffer.Bytes(), filename)
+	require.Error(t, err)
+
+	_, err = extractFileFromRpm(rpmFileBuffer.Bytes(), filename)
+	require.Error(t, err)
 }
 
 func TestDisableGlobbing(t *testing.T) {
@@ -698,6 +711,14 @@ func extractFileFromRpm(rpm []byte, filename string) ([]byte, error) {
 	return nil, os.ErrNotExist
 }
 
+func extraFileInfoSliceFromRpm(rpm []byte) ([]rpmutils.FileInfo, error) {
+	rpmFile, err := rpmutils.ReadRpm(bytes.NewReader(rpm))
+	if err != nil {
+		return nil, err
+	}
+	return rpmFile.Header.GetFiles()
+}
+
 func extractFileHeaderFromRpm(rpm []byte, filename string) (*cpio.Cpio_newc_header, error) {
 	rpmFile, err := rpmutils.ReadRpm(bytes.NewReader(rpm))
 	if err != nil {