diff --git a/.goreleaser.yaml b/.goreleaser.yaml index b1d69e5acbb..4a3060fbb42 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -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 @@ -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 }}' diff --git a/.lintian-overrides b/.lintian-overrides deleted file mode 100644 index e5fecda4122..00000000000 --- a/.lintian-overrides +++ /dev/null @@ -1,2 +0,0 @@ -goreleaser: statically-linked-binary -goreleaser: changelog-file-missing-in-native-package diff --git a/internal/pipe/nfpm/nfpm.go b/internal/pipe/nfpm/nfpm.go index 586465c112c..ce4aeda6db9 100644 --- a/internal/pipe/nfpm/nfpm.go +++ b/internal/pipe/nfpm/nfpm.go @@ -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 diff --git a/internal/pipe/nfpm/nfpm_test.go b/internal/pipe/nfpm/nfpm_test.go index 6e1078a48aa..1eb33f331a7 100644 --- a/internal/pipe/nfpm/nfpm_test.go +++ b/internal/pipe/nfpm/nfpm_test.go @@ -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", + }, }, }, }, @@ -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) { diff --git a/pkg/config/config.go b/pkg/config/config.go index 8c8e762c1cd..8aef1b8b883 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -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 { diff --git a/www/docs/customization/nfpm.md b/www/docs/customization/nfpm.md index 8be0f3c0717..6c0c2e5b85d 100644 --- a/www/docs/customization/nfpm.md +++ b/www/docs/customization/nfpm.md @@ -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.