Skip to content

Commit

Permalink
feat: lintian overrides (#2892)
Browse files Browse the repository at this point in the history
* feat: lintian overrides

allow to more easily set lintian overrides

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* fix: lintian

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
  • Loading branch information
caarlos0 committed Feb 9, 2022
1 parent a3f9b69 commit 02a94ce
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 7 deletions.
9 changes: 4 additions & 5 deletions .goreleaser.yaml
Expand Up @@ -240,11 +240,6 @@ nfpms:
dst: /usr/share/doc/goreleaser/copyright
file_info:
mode: 0644
- src: .lintian-overrides
dst: ./usr/share/lintian/overrides/goreleaser
packager: deb
file_info:
mode: 0644
formats:
- apk
- deb
Expand All @@ -253,6 +248,10 @@ nfpms:
- git
recommends:
- golang
deb:
lintian_overrides:
- statically-linked-binary
- changelog-file-missing-in-native-package

snapcrafts:
- name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
Expand Down
2 changes: 0 additions & 2 deletions .lintian-overrides

This file was deleted.

24 changes: 24 additions & 0 deletions internal/pipe/nfpm/nfpm.go
Expand Up @@ -186,6 +186,30 @@ func create(ctx *context.Context, fpm config.NFPM, format string, binaries []*ar
})
}

if len(fpm.Deb.Lintian) > 0 {
lines := make([]string, 0, len(fpm.Deb.Lintian))
for _, ov := range fpm.Deb.Lintian {
lines = append(lines, fmt.Sprintf("%s: %s", fpm.PackageName, ov))
}
lintianPath := filepath.Join(ctx.Config.Dist, "deb", fpm.PackageName, ".lintian")
if err := os.MkdirAll(filepath.Dir(lintianPath), 0o755); err != nil {
return fmt.Errorf("failed to write lintian file: %w", err)
}
if err := os.WriteFile(lintianPath, []byte(strings.Join(lines, "\n")), 0o644); err != nil {
return fmt.Errorf("failed to write lintian file: %w", err)
}

log.Infof("creating %q", lintianPath)
contents = append(contents, &files.Content{
Source: lintianPath,
Destination: filepath.Join("./usr/share/lintian/overrides", fpm.PackageName),
Packager: "deb",
FileInfo: &files.ContentFileInfo{
Mode: 0o644,
},
})
}

log := log.WithField("package", fpm.PackageName).WithField("format", format).WithField("arch", arch)

// FPM meta package should not contain binaries at all
Expand Down
8 changes: 8 additions & 0 deletions internal/pipe/nfpm/nfpm_test.go
Expand Up @@ -598,6 +598,10 @@ func TestDebSpecificConfig(t *testing.T) {
Signature: config.NFPMDebSignature{
KeyFile: "./testdata/privkey.gpg",
},
Lintian: []string{
"statically-linked-binary",
"changelog-file-missing-in-native-package",
},
},
},
},
Expand Down Expand Up @@ -633,6 +637,10 @@ func TestDebSpecificConfig(t *testing.T) {
"NFPM_SOMEID_PASSPHRASE": "hunter2",
}
require.NoError(t, Pipe{}.Run(ctx))

bts, err := os.ReadFile(filepath.Join(dist, "deb/foo/.lintian"))
require.NoError(t, err)
require.Equal(t, "foo: statically-linked-binary\nfoo: changelog-file-missing-in-native-package", string(bts))
})

t.Run("packager specific passphrase set", func(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Expand Up @@ -615,6 +615,7 @@ type NFPMDeb struct {
Triggers NFPMDebTriggers `yaml:"triggers,omitempty"`
Breaks []string `yaml:"breaks,omitempty"`
Signature NFPMDebSignature `yaml:"signature,omitempty"`
Lintian []string `yaml:"lintian_overrides,omitempty"`
}

type NFPMAPKScripts struct {
Expand Down
5 changes: 5 additions & 0 deletions www/docs/customization/nfpm.md
Expand Up @@ -287,6 +287,11 @@ nfpms:

# Custom configuration applied only to the Deb packager.
deb:
# Lintian overrides
lintian_overrides:
- statically-linked-binary
- changelog-file-missing-in-native-package

# Custom deb special files.
scripts:
# Deb rules script.
Expand Down

0 comments on commit 02a94ce

Please sign in to comment.