Skip to content

Commit

Permalink
consolidate nfpms block
Browse files Browse the repository at this point in the history
  • Loading branch information
jackgopack4 committed Nov 20, 2024
1 parent ea4806f commit 4a15286
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 89 deletions.
16 changes: 5 additions & 11 deletions cmd/goreleaser/internal/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,14 @@ func Packages(dist string) (r []config.NFPM) {
return []config.NFPM{}
}
return []config.NFPM{
Package(dist, true),
Package(dist, false),
Package(dist),
}
}

// Package configures goreleaser to build a system package.
// https://goreleaser.com/customization/nfpm/
func Package(dist string, pie bool) config.NFPM {
id := dist
build := dist
if pie {
id = id + "-pie"
build = build + "-pie"
}
func Package(dist string) config.NFPM {
buildPie := dist + "-pie"
nfpmContents := config.NFPMContents{
{
Source: fmt.Sprintf("%s.service", dist),
Expand All @@ -242,8 +236,8 @@ func Package(dist string, pie bool) config.NFPM {
})
}
return config.NFPM{
ID: id,
Builds: []string{build},
ID: dist,
Builds: []string{dist, buildPie},
Formats: []string{"deb", "rpm"},

License: "Apache 2.0",
Expand Down
28 changes: 1 addition & 27 deletions distributions/otelcol-contrib/.goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,33 +119,6 @@ archives:
- otelcol-contrib
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
nfpms:
- package_name: otelcol-contrib
contents:
- src: otelcol-contrib.service
dst: /lib/systemd/system/otelcol-contrib.service
- src: otelcol-contrib.conf
dst: /etc/otelcol-contrib/otelcol-contrib.conf
type: config|noreplace
- src: config.yaml
dst: /etc/otelcol-contrib/config.yaml
type: config|noreplace
scripts:
preinstall: preinstall.sh
postinstall: postinstall.sh
preremove: preremove.sh
overrides:
rpm:
dependencies:
- /bin/sh
id: otelcol-contrib-pie
builds:
- otelcol-contrib-pie
formats:
- deb
- rpm
maintainer: The OpenTelemetry Collector maintainers <cncf-opentelemetry-maintainers@lists.cncf.io>
description: OpenTelemetry Collector - otelcol-contrib
license: Apache 2.0
- package_name: otelcol-contrib
contents:
- src: otelcol-contrib.service
Expand All @@ -167,6 +140,7 @@ nfpms:
id: otelcol-contrib
builds:
- otelcol-contrib
- otelcol-contrib-pie
formats:
- deb
- rpm
Expand Down
25 changes: 1 addition & 24 deletions distributions/otelcol-otlp/.goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,30 +118,6 @@ archives:
- otelcol-otlp
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
nfpms:
- package_name: otelcol-otlp
contents:
- src: otelcol-otlp.service
dst: /lib/systemd/system/otelcol-otlp.service
- src: otelcol-otlp.conf
dst: /etc/otelcol-otlp/otelcol-otlp.conf
type: config|noreplace
scripts:
preinstall: preinstall.sh
postinstall: postinstall.sh
preremove: preremove.sh
overrides:
rpm:
dependencies:
- /bin/sh
id: otelcol-otlp-pie
builds:
- otelcol-otlp-pie
formats:
- deb
- rpm
maintainer: The OpenTelemetry Collector maintainers <cncf-opentelemetry-maintainers@lists.cncf.io>
description: OpenTelemetry Collector - otelcol-otlp
license: Apache 2.0
- package_name: otelcol-otlp
contents:
- src: otelcol-otlp.service
Expand All @@ -160,6 +136,7 @@ nfpms:
id: otelcol-otlp
builds:
- otelcol-otlp
- otelcol-otlp-pie
formats:
- deb
- rpm
Expand Down
28 changes: 1 addition & 27 deletions distributions/otelcol/.goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,33 +119,6 @@ archives:
- otelcol
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
nfpms:
- package_name: otelcol
contents:
- src: otelcol.service
dst: /lib/systemd/system/otelcol.service
- src: otelcol.conf
dst: /etc/otelcol/otelcol.conf
type: config|noreplace
- src: config.yaml
dst: /etc/otelcol/config.yaml
type: config|noreplace
scripts:
preinstall: preinstall.sh
postinstall: postinstall.sh
preremove: preremove.sh
overrides:
rpm:
dependencies:
- /bin/sh
id: otelcol-pie
builds:
- otelcol-pie
formats:
- deb
- rpm
maintainer: The OpenTelemetry Collector maintainers <cncf-opentelemetry-maintainers@lists.cncf.io>
description: OpenTelemetry Collector - otelcol
license: Apache 2.0
- package_name: otelcol
contents:
- src: otelcol.service
Expand All @@ -167,6 +140,7 @@ nfpms:
id: otelcol
builds:
- otelcol
- otelcol-pie
formats:
- deb
- rpm
Expand Down

0 comments on commit 4a15286

Please sign in to comment.