Skip to content

Commit

Permalink
feat: add minimal support for Debian pre-dependencies (#696)
Browse files Browse the repository at this point in the history
* feat: add minimal support for Debian pre-dependencies

Basic support for adding 'Pre-Depends:' to Debian packages added.

* Make Predefined a debian-specific modification

Based on feedback from @caarlos0.

* Add some coverage of pre-depend Debian field in unit tests

* Update the configuration example to include Debian-specific predepends reference
  • Loading branch information
jeremy-gill authored Aug 15, 2023
1 parent 24a43c5 commit 3aded35
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions deb/deb.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,9 @@ Replaces: {{join .}}
{{- with nonEmpty .Info.Provides}}
Provides: {{join .}}
{{- end }}
{{- with .Info.Deb.Predepends}}
Pre-Depends: {{join .}}
{{- end }}
{{- with .Info.Depends}}
Depends: {{join .}}
{{- end }}
Expand Down
3 changes: 3 additions & 0 deletions deb/deb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ func exampleInfo() *nfpm.Info {
Type: files.TypeDir,
},
},
Deb: nfpm.Deb{
Predepends: []string{"less"},
},
},
})
}
Expand Down
1 change: 1 addition & 0 deletions deb/testdata/bad_provides.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Architecture: amd64
Maintainer: Carlos A Becker <[email protected]>
Installed-Size: 0
Replaces: svn
Pre-Depends: less
Depends: bash
Recommends: git
Suggests: bash
Expand Down
1 change: 1 addition & 0 deletions deb/testdata/control.golden
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Maintainer: Carlos A Becker <[email protected]>
Installed-Size: 10
Replaces: svn
Provides: bzr
Pre-Depends: less
Depends: bash
Recommends: git
Suggests: bash
Expand Down
2 changes: 2 additions & 0 deletions nfpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ func (c *Config) expandEnvVars() {
for k, v := range c.Info.Deb.Fields {
c.Info.Deb.Fields[k] = os.Expand(v, c.envMappingFunc)
}
c.Info.Deb.Predepends = c.expandEnvVarsStringSlice(c.Info.Deb.Predepends)
}

// Info contains information about a single package.
Expand Down Expand Up @@ -390,6 +391,7 @@ type Deb struct {
Signature DebSignature `yaml:"signature,omitempty" json:"signature,omitempty" jsonschema:"title=signature"`
Compression string `yaml:"compression,omitempty" json:"compression,omitempty" jsonschema:"title=compression algorithm to be used,enum=gzip,enum=xz,enum=none,default=gzip"`
Fields map[string]string `yaml:"fields,omitempty" json:"fields,omitempty" jsonschema:"title=fields"`
Predepends []string `yaml:"predepends,omitempty" json:"predepends,omitempty" jsonschema:"title=predepends directive,example=nfpm"`
}

type DebSignature struct {
Expand Down
6 changes: 6 additions & 0 deletions www/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,12 @@ deb:
fields:
Bugs: https://github.com/goreleaser/nfpm/issues

# The Debian-specific "predepends" field can be used to ensure the complete installation of a list of
# packages (including unpacking, pre- and post installation scripts) prior to the installation of the
# built package.
predepends:
- baz (>= 1.2.3-0)

apk:
# apk specific architecture name that overrides "arch" without performing any replacements.
apk_arch: armhf
Expand Down

0 comments on commit 3aded35

Please sign in to comment.