Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: lintian overrides #2892

Merged
merged 2 commits into from Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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