1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-03 13:11:48 +02:00

feat: lintian overrides (#2892)

* 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>
This commit is contained in:
Carlos Alexandro Becker 2022-02-09 11:40:51 -03:00 committed by GitHub
parent a3f9b69e11
commit 02a94ce23e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 7 deletions

View File

@ -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 }}'

View File

@ -1,2 +0,0 @@
goreleaser: statically-linked-binary
goreleaser: changelog-file-missing-in-native-package

View File

@ -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

View File

@ -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) {

View File

@ -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 {

View File

@ -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.