mirror of
https://github.com/goreleaser/nfpm
synced 2024-05-18 04:06:33 +02:00
Merge pull request #5 from goreleaser/recommends
feat: support recommending and suggesting packages
This commit is contained in:
commit
8bb63d15b7
|
@ -1,4 +1,3 @@
|
||||||
dist: trusty
|
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
|
@ -9,6 +8,8 @@ go: '1.10'
|
||||||
# - docker
|
# - docker
|
||||||
install:
|
install:
|
||||||
- make setup
|
- make setup
|
||||||
|
before_script:
|
||||||
|
- rpmbuild --version
|
||||||
script:
|
script:
|
||||||
- make ci
|
- make ci
|
||||||
after_success:
|
after_success:
|
||||||
|
|
|
@ -11,6 +11,8 @@ provides:
|
||||||
depends:
|
depends:
|
||||||
- foo
|
- foo
|
||||||
- bar
|
- bar
|
||||||
|
recommends:
|
||||||
|
- whatever
|
||||||
conflicts:
|
conflicts:
|
||||||
- not-foo
|
- not-foo
|
||||||
- not-bar
|
- not-bar
|
||||||
|
|
20
deb/deb.go
20
deb/deb.go
|
@ -152,6 +152,8 @@ Installed-Size: {{.InstalledSize}}
|
||||||
Replaces: {{join .Info.Replaces}}
|
Replaces: {{join .Info.Replaces}}
|
||||||
Provides: {{join .Info.Provides}}
|
Provides: {{join .Info.Provides}}
|
||||||
Depends: {{join .Info.Depends}}
|
Depends: {{join .Info.Depends}}
|
||||||
|
Recommends: {{join .Info.Recommends}}
|
||||||
|
Recommends: {{join .Info.Suggests}}
|
||||||
Conflicts: {{join .Info.Conflicts}}
|
Conflicts: {{join .Info.Conflicts}}
|
||||||
Homepage: {{.Info.Homepage}}
|
Homepage: {{.Info.Homepage}}
|
||||||
Description: {{.Info.Description}}
|
Description: {{.Info.Description}}
|
||||||
|
@ -172,13 +174,7 @@ func createControl(now time.Time, instSize int64, md5sums []byte, info nfpm.Info
|
||||||
defer compress.Close() // nolint: errcheck
|
defer compress.Close() // nolint: errcheck
|
||||||
|
|
||||||
var body bytes.Buffer
|
var body bytes.Buffer
|
||||||
var tmpl = template.New("control")
|
if err := writeControl(&body, controlData{
|
||||||
tmpl.Funcs(template.FuncMap{
|
|
||||||
"join": func(strs []string) string {
|
|
||||||
return strings.Trim(strings.Join(strs, ", "), " ")
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if err := template.Must(tmpl.Parse(controlTemplate)).Execute(&body, controlData{
|
|
||||||
Info: info,
|
Info: info,
|
||||||
InstalledSize: instSize / 1024,
|
InstalledSize: instSize / 1024,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
@ -204,6 +200,16 @@ func createControl(now time.Time, instSize int64, md5sums []byte, info nfpm.Info
|
||||||
return buf.Bytes(), nil
|
return buf.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func writeControl(w io.Writer, data controlData) error {
|
||||||
|
var tmpl = template.New("control")
|
||||||
|
tmpl.Funcs(template.FuncMap{
|
||||||
|
"join": func(strs []string) string {
|
||||||
|
return strings.Trim(strings.Join(strs, ", "), " ")
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return template.Must(tmpl.Parse(controlTemplate)).Execute(w, data)
|
||||||
|
}
|
||||||
|
|
||||||
func newFileInsideTarGz(out *tar.Writer, name string, content []byte, now time.Time) error {
|
func newFileInsideTarGz(out *tar.Writer, name string, content []byte, now time.Time) error {
|
||||||
var header = tar.Header{
|
var header = tar.Header{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package deb
|
package deb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"flag"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -8,33 +10,64 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var update = flag.Bool("update", false, "update .golden files")
|
||||||
|
|
||||||
|
var info = nfpm.WithDefaults(nfpm.Info{
|
||||||
|
Name: "foo",
|
||||||
|
Arch: "amd64",
|
||||||
|
Depends: []string{
|
||||||
|
"bash",
|
||||||
|
},
|
||||||
|
Recommends: []string{
|
||||||
|
"git",
|
||||||
|
},
|
||||||
|
Suggests: []string{
|
||||||
|
"bash",
|
||||||
|
},
|
||||||
|
Replaces: []string{
|
||||||
|
"svn",
|
||||||
|
},
|
||||||
|
Provides: []string{
|
||||||
|
"bzr",
|
||||||
|
},
|
||||||
|
Conflicts: []string{
|
||||||
|
"zsh",
|
||||||
|
},
|
||||||
|
Description: "Foo does things",
|
||||||
|
Priority: "extra",
|
||||||
|
Maintainer: "Carlos A Becker <pkg@carlosbecker.com>",
|
||||||
|
Version: "1.0.0",
|
||||||
|
Section: "default",
|
||||||
|
Homepage: "http://carlosbecker.com",
|
||||||
|
Vendor: "nope",
|
||||||
|
Files: map[string]string{
|
||||||
|
"../testdata/fake": "/usr/local/bin/fake",
|
||||||
|
},
|
||||||
|
ConfigFiles: map[string]string{
|
||||||
|
"../testdata/whatever.conf": "/etc/fake/fake.conf",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
func TestDeb(t *testing.T) {
|
func TestDeb(t *testing.T) {
|
||||||
var err = Default.Package(
|
var err = Default.Package(info, ioutil.Discard)
|
||||||
nfpm.WithDefaults(nfpm.Info{
|
|
||||||
Name: "foo",
|
|
||||||
Arch: "amd64",
|
|
||||||
Depends: []string{
|
|
||||||
"bash",
|
|
||||||
},
|
|
||||||
Description: "Foo does things",
|
|
||||||
Priority: "extra",
|
|
||||||
Maintainer: "Carlos A Becker <pkg@carlosbecker.com>",
|
|
||||||
Version: "1.0.0",
|
|
||||||
Section: "default",
|
|
||||||
Homepage: "http://carlosbecker.com",
|
|
||||||
Vendor: "nope",
|
|
||||||
Files: map[string]string{
|
|
||||||
"../testdata/fake": "/usr/local/bin/fake",
|
|
||||||
},
|
|
||||||
ConfigFiles: map[string]string{
|
|
||||||
"../testdata/whatever.conf": "/etc/fake/fake.conf",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
ioutil.Discard,
|
|
||||||
)
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestControl(t *testing.T) {
|
||||||
|
var w bytes.Buffer
|
||||||
|
assert.NoError(t, writeControl(&w, controlData{
|
||||||
|
Info: info,
|
||||||
|
InstalledSize: 10,
|
||||||
|
}))
|
||||||
|
var golden = "testdata/control.golden"
|
||||||
|
if *update {
|
||||||
|
ioutil.WriteFile(golden, w.Bytes(), 0655)
|
||||||
|
}
|
||||||
|
bts, err := ioutil.ReadFile(golden)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, string(bts), w.String())
|
||||||
|
}
|
||||||
|
|
||||||
func TestDebFileDoesNotExist(t *testing.T) {
|
func TestDebFileDoesNotExist(t *testing.T) {
|
||||||
var err = Default.Package(
|
var err = Default.Package(
|
||||||
nfpm.WithDefaults(nfpm.Info{
|
nfpm.WithDefaults(nfpm.Info{
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
Package: foo
|
||||||
|
Version: 1.0.0
|
||||||
|
Section: default
|
||||||
|
Priority: extra
|
||||||
|
Architecture: amd64
|
||||||
|
Maintainer: Carlos A Becker <pkg@carlosbecker.com>
|
||||||
|
Vendor: nope
|
||||||
|
Installed-Size: 10
|
||||||
|
Replaces: svn
|
||||||
|
Provides: bzr
|
||||||
|
Depends: bash
|
||||||
|
Recommends: git
|
||||||
|
Recommends: bash
|
||||||
|
Conflicts: zsh
|
||||||
|
Homepage: http://carlosbecker.com
|
||||||
|
Description: Foo does things
|
2
nfpm.go
2
nfpm.go
|
@ -45,6 +45,8 @@ type Info struct {
|
||||||
Replaces []string `yaml:"replaces,omitempty"`
|
Replaces []string `yaml:"replaces,omitempty"`
|
||||||
Provides []string `yaml:"provides,omitempty"`
|
Provides []string `yaml:"provides,omitempty"`
|
||||||
Depends []string `yaml:"depends,omitempty"`
|
Depends []string `yaml:"depends,omitempty"`
|
||||||
|
Recommends []string `yaml:"recommends,omitempty"`
|
||||||
|
Suggests []string `yaml:"suggests,omitempty"`
|
||||||
Conflicts []string `yaml:"conflicts,omitempty"`
|
Conflicts []string `yaml:"conflicts,omitempty"`
|
||||||
Maintainer string `yaml:"maintainer,omitempty"`
|
Maintainer string `yaml:"maintainer,omitempty"`
|
||||||
Description string `yaml:"description,omitempty"`
|
Description string `yaml:"description,omitempty"`
|
||||||
|
|
100
rpm/rpm.go
100
rpm/rpm.go
|
@ -10,6 +10,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
@ -32,6 +33,10 @@ func (*RPM) Package(info nfpm.Info, w io.Writer) error {
|
||||||
if info.Arch == "amd64" {
|
if info.Arch == "amd64" {
|
||||||
info.Arch = "x86_64"
|
info.Arch = "x86_64"
|
||||||
}
|
}
|
||||||
|
_, err := exec.LookPath("rpmbuild")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("rpmbuild not present in $PATH")
|
||||||
|
}
|
||||||
temps, err := setupTempFiles(info)
|
temps, err := setupTempFiles(info)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -70,21 +75,62 @@ func (*RPM) Package(info nfpm.Info, w io.Writer) error {
|
||||||
return errors.Wrap(err, "failed to copy rpm file to writer")
|
return errors.Wrap(err, "failed to copy rpm file to writer")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type rpmbuildVersion struct {
|
||||||
|
Major, Minor, Path int
|
||||||
|
}
|
||||||
|
|
||||||
|
func getRpmbuildVersion() (rpmbuildVersion, error) {
|
||||||
|
// #nosec
|
||||||
|
bts, err := exec.Command("rpmbuild", "--version").CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
return rpmbuildVersion{}, errors.Wrap(err, "failed to get rpmbuild version")
|
||||||
|
}
|
||||||
|
var v = make([]int, 3)
|
||||||
|
vs := strings.TrimSuffix(strings.TrimPrefix(string(bts), "RPM version "), "\n")
|
||||||
|
for i, part := range strings.Split(vs, ".")[:3] {
|
||||||
|
pi, err := strconv.Atoi(part)
|
||||||
|
if err != nil {
|
||||||
|
return rpmbuildVersion{}, errors.Wrapf(err, "could not parse version %s", vs)
|
||||||
|
}
|
||||||
|
v[i] = pi
|
||||||
|
}
|
||||||
|
return rpmbuildVersion{
|
||||||
|
Major: v[0],
|
||||||
|
Minor: v[1],
|
||||||
|
Path: v[2],
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func createSpec(info nfpm.Info, path string) error {
|
func createSpec(info nfpm.Info, path string) error {
|
||||||
var body bytes.Buffer
|
file, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0600)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "failed to create spec")
|
||||||
|
}
|
||||||
|
vs, err := getRpmbuildVersion()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return writeSpec(file, info, vs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeSpec(w io.Writer, info nfpm.Info, vs rpmbuildVersion) error {
|
||||||
var tmpl = template.New("spec")
|
var tmpl = template.New("spec")
|
||||||
tmpl.Funcs(template.FuncMap{
|
tmpl.Funcs(template.FuncMap{
|
||||||
"join": func(strs []string) string {
|
|
||||||
return strings.Trim(strings.Join(strs, ", "), " ")
|
|
||||||
},
|
|
||||||
"first_line": func(str string) string {
|
"first_line": func(str string) string {
|
||||||
return strings.Split(str, "\n")[0]
|
return strings.Split(str, "\n")[0]
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err := template.Must(tmpl.Parse(specTemplate)).Execute(&body, info); err != nil {
|
type data struct {
|
||||||
|
Info nfpm.Info
|
||||||
|
RPM413 bool
|
||||||
|
}
|
||||||
|
if err := template.Must(tmpl.Parse(specTemplate)).Execute(w, data{
|
||||||
|
Info: info,
|
||||||
|
RPM413: vs.Major >= 4 && vs.Minor >= 13,
|
||||||
|
}); err != nil {
|
||||||
return errors.Wrap(err, "failed to parse spec template")
|
return errors.Wrap(err, "failed to parse spec template")
|
||||||
}
|
}
|
||||||
return errors.Wrap(ioutil.WriteFile(path, body.Bytes(), 0644), "failed to write spec file")
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type tempFiles struct {
|
type tempFiles struct {
|
||||||
|
@ -196,37 +242,47 @@ const specTemplate = `
|
||||||
%define __spec_install_post %{nil}
|
%define __spec_install_post %{nil}
|
||||||
%define debug_package %{nil}
|
%define debug_package %{nil}
|
||||||
%define __os_install_post %{_dbpath}/brp-compress
|
%define __os_install_post %{_dbpath}/brp-compress
|
||||||
%define _arch {{.Arch}}
|
%define _arch {{ .Info.Arch }}
|
||||||
%define _bindir {{.Bindir}}
|
%define _bindir {{ .Info.Bindir }}
|
||||||
|
|
||||||
Name: {{ .Name }}
|
Name: {{ .Info.Name }}
|
||||||
Summary: {{ first_line .Description }}
|
Summary: {{ first_line .Info.Description }}
|
||||||
Version: {{ .Version }}
|
Version: {{ .Info.Version }}
|
||||||
Release: 1
|
Release: 1
|
||||||
License: {{ .License }}
|
License: {{ .Info.License }}
|
||||||
Group: Development/Tools
|
Group: Development/Tools
|
||||||
SOURCE0 : %{name}-%{version}.tar.gz
|
SOURCE0 : %{name}-%{version}.tar.gz
|
||||||
URL: {{ .Homepage }}
|
URL: {{ .Info.Homepage }}
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||||
|
|
||||||
{{ range $index, $element := .Replaces }}
|
{{ range $index, $element := .Info.Replaces }}
|
||||||
Obsolotes: {{ . }}
|
Obsoletes: {{ . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ range $index, $element := .Conflicts }}
|
{{ range $index, $element := .Info.Conflicts }}
|
||||||
Conflicts: {{ . }}
|
Conflicts: {{ . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ range $index, $element := .Provides }}
|
{{ range $index, $element := .Info.Provides }}
|
||||||
Provides: {{ . }}
|
Provides: {{ . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ range $index, $element := .Depends }}
|
{{ range $index, $element := .Info.Depends }}
|
||||||
Requires: {{ . }}
|
Requires: {{ . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if .RPM413 }}
|
||||||
|
{{ range $index, $element := .Info.Recommends }}
|
||||||
|
Recommends: {{ . }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ range $index, $element := .Info.Suggests }}
|
||||||
|
Suggests: {{ . }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
%description
|
%description
|
||||||
{{ .Description }}
|
{{ .Info.Description }}
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
|
@ -246,14 +302,14 @@ rm -rf %{buildroot}
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%defattr(-,root,root,-)
|
%defattr(-,root,root,-)
|
||||||
{{ range $index, $element := .Files }}
|
{{ range $index, $element := .Info.Files }}
|
||||||
{{ . }}
|
{{ . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
%{_bindir}/*
|
%{_bindir}/*
|
||||||
{{ range $index, $element := .ConfigFiles }}
|
{{ range $index, $element := .Info.ConfigFiles }}
|
||||||
{{ . }}
|
{{ . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ range $index, $element := .ConfigFiles }}
|
{{ range $index, $element := .Info.ConfigFiles }}
|
||||||
%config(noreplace) {{ . }}
|
%config(noreplace) {{ . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package rpm
|
package rpm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"flag"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -9,32 +11,67 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var update = flag.Bool("update", false, "update .golden files")
|
||||||
|
|
||||||
|
var info = nfpm.WithDefaults(nfpm.Info{
|
||||||
|
Name: "foo",
|
||||||
|
Arch: "amd64",
|
||||||
|
Depends: []string{
|
||||||
|
"bash",
|
||||||
|
},
|
||||||
|
Recommends: []string{
|
||||||
|
"git",
|
||||||
|
},
|
||||||
|
Suggests: []string{
|
||||||
|
"bash",
|
||||||
|
},
|
||||||
|
Replaces: []string{
|
||||||
|
"svn",
|
||||||
|
},
|
||||||
|
Provides: []string{
|
||||||
|
"bzr",
|
||||||
|
},
|
||||||
|
Conflicts: []string{
|
||||||
|
"zsh",
|
||||||
|
},
|
||||||
|
Description: "Foo does things",
|
||||||
|
Priority: "extra",
|
||||||
|
Maintainer: "Carlos A Becker <pkg@carlosbecker.com>",
|
||||||
|
Version: "1.0.0",
|
||||||
|
Section: "default",
|
||||||
|
Homepage: "http://carlosbecker.com",
|
||||||
|
Vendor: "nope",
|
||||||
|
License: "MIT",
|
||||||
|
Bindir: "/usr/local/bin",
|
||||||
|
Files: map[string]string{
|
||||||
|
"../testdata/fake": "/usr/local/bin/fake",
|
||||||
|
},
|
||||||
|
ConfigFiles: map[string]string{
|
||||||
|
"../testdata/whatever.conf": "/etc/fake/fake.conf",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
func TestSpec(t *testing.T) {
|
||||||
|
for golden, vs := range map[string]rpmbuildVersion{
|
||||||
|
"testdata/spec_4.14.x.golden": rpmbuildVersion{4, 14, 2},
|
||||||
|
"testdata/spec_4.13.x.golden": rpmbuildVersion{4, 13, 1},
|
||||||
|
"testdata/spec_4.12.x.golden": rpmbuildVersion{4, 12, 9},
|
||||||
|
} {
|
||||||
|
t.Run(golden, func(tt *testing.T) {
|
||||||
|
var w bytes.Buffer
|
||||||
|
assert.NoError(tt, writeSpec(&w, info, vs))
|
||||||
|
if *update {
|
||||||
|
ioutil.WriteFile(golden, w.Bytes(), 0655)
|
||||||
|
}
|
||||||
|
bts, err := ioutil.ReadFile(golden)
|
||||||
|
assert.NoError(tt, err)
|
||||||
|
assert.Equal(tt, string(bts), w.String())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestRPM(t *testing.T) {
|
func TestRPM(t *testing.T) {
|
||||||
var err = Default.Package(
|
var err = Default.Package(info, ioutil.Discard)
|
||||||
nfpm.WithDefaults(nfpm.Info{
|
|
||||||
Name: "foo",
|
|
||||||
Arch: "amd64",
|
|
||||||
Depends: []string{
|
|
||||||
"bash",
|
|
||||||
},
|
|
||||||
Description: "Foo does things",
|
|
||||||
Priority: "extra",
|
|
||||||
Maintainer: "Carlos A Becker <pkg@carlosbecker.com>",
|
|
||||||
Version: "1.0.0",
|
|
||||||
Section: "default",
|
|
||||||
Homepage: "http://carlosbecker.com",
|
|
||||||
Vendor: "nope",
|
|
||||||
License: "MIT",
|
|
||||||
Bindir: "/usr/local/bin",
|
|
||||||
Files: map[string]string{
|
|
||||||
"../testdata/fake": "/usr/local/bin/fake",
|
|
||||||
},
|
|
||||||
ConfigFiles: map[string]string{
|
|
||||||
"../testdata/whatever.conf": "/etc/fake/fake.conf",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
ioutil.Discard,
|
|
||||||
)
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,10 +99,20 @@ func TestNoFiles(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRPMBuildNotInPath(t *testing.T) {
|
func TestRPMBuildNotInPath(t *testing.T) {
|
||||||
|
path := os.Getenv("PATH")
|
||||||
|
defer os.Setenv("PATH", path)
|
||||||
assert.NoError(t, os.Setenv("PATH", ""))
|
assert.NoError(t, os.Setenv("PATH", ""))
|
||||||
var err = Default.Package(
|
var err = Default.Package(
|
||||||
nfpm.WithDefaults(nfpm.Info{}),
|
nfpm.WithDefaults(nfpm.Info{}),
|
||||||
ioutil.Discard,
|
ioutil.Discard,
|
||||||
)
|
)
|
||||||
assert.EqualError(t, err, `rpmbuild failed: exec: "rpmbuild": executable file not found in $PATH`)
|
assert.EqualError(t, err, `rpmbuild not present in $PATH`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRpmBuildVersion(t *testing.T) {
|
||||||
|
v, err := getRpmbuildVersion()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, 4, v.Major)
|
||||||
|
assert.True(t, v.Minor >= 11)
|
||||||
|
assert.True(t, v.Path >= 0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
|
||||||
|
%define __spec_install_post %{nil}
|
||||||
|
%define debug_package %{nil}
|
||||||
|
%define __os_install_post %{_dbpath}/brp-compress
|
||||||
|
%define _arch amd64
|
||||||
|
%define _bindir /usr/local/bin
|
||||||
|
|
||||||
|
Name: foo
|
||||||
|
Summary: Foo does things
|
||||||
|
Version: 1.0.0
|
||||||
|
Release: 1
|
||||||
|
License: MIT
|
||||||
|
Group: Development/Tools
|
||||||
|
SOURCE0 : %{name}-%{version}.tar.gz
|
||||||
|
URL: http://carlosbecker.com
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||||
|
|
||||||
|
|
||||||
|
Obsoletes: svn
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Conflicts: zsh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Provides: bzr
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requires: bash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%description
|
||||||
|
Foo does things
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q
|
||||||
|
|
||||||
|
%build
|
||||||
|
# Empty section.
|
||||||
|
|
||||||
|
%install
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
mkdir -p %{buildroot}
|
||||||
|
|
||||||
|
# in builddir
|
||||||
|
cp -a * %{buildroot}
|
||||||
|
|
||||||
|
%clean
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
|
||||||
|
%files
|
||||||
|
%defattr(-,root,root,-)
|
||||||
|
|
||||||
|
/usr/local/bin/fake
|
||||||
|
|
||||||
|
%{_bindir}/*
|
||||||
|
|
||||||
|
/etc/fake/fake.conf
|
||||||
|
|
||||||
|
|
||||||
|
%config(noreplace) /etc/fake/fake.conf
|
||||||
|
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
# noop
|
|
@ -0,0 +1,77 @@
|
||||||
|
|
||||||
|
%define __spec_install_post %{nil}
|
||||||
|
%define debug_package %{nil}
|
||||||
|
%define __os_install_post %{_dbpath}/brp-compress
|
||||||
|
%define _arch amd64
|
||||||
|
%define _bindir /usr/local/bin
|
||||||
|
|
||||||
|
Name: foo
|
||||||
|
Summary: Foo does things
|
||||||
|
Version: 1.0.0
|
||||||
|
Release: 1
|
||||||
|
License: MIT
|
||||||
|
Group: Development/Tools
|
||||||
|
SOURCE0 : %{name}-%{version}.tar.gz
|
||||||
|
URL: http://carlosbecker.com
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||||
|
|
||||||
|
|
||||||
|
Obsoletes: svn
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Conflicts: zsh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Provides: bzr
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requires: bash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Recommends: git
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Suggests: bash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%description
|
||||||
|
Foo does things
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q
|
||||||
|
|
||||||
|
%build
|
||||||
|
# Empty section.
|
||||||
|
|
||||||
|
%install
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
mkdir -p %{buildroot}
|
||||||
|
|
||||||
|
# in builddir
|
||||||
|
cp -a * %{buildroot}
|
||||||
|
|
||||||
|
%clean
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
|
||||||
|
%files
|
||||||
|
%defattr(-,root,root,-)
|
||||||
|
|
||||||
|
/usr/local/bin/fake
|
||||||
|
|
||||||
|
%{_bindir}/*
|
||||||
|
|
||||||
|
/etc/fake/fake.conf
|
||||||
|
|
||||||
|
|
||||||
|
%config(noreplace) /etc/fake/fake.conf
|
||||||
|
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
# noop
|
|
@ -0,0 +1,77 @@
|
||||||
|
|
||||||
|
%define __spec_install_post %{nil}
|
||||||
|
%define debug_package %{nil}
|
||||||
|
%define __os_install_post %{_dbpath}/brp-compress
|
||||||
|
%define _arch amd64
|
||||||
|
%define _bindir /usr/local/bin
|
||||||
|
|
||||||
|
Name: foo
|
||||||
|
Summary: Foo does things
|
||||||
|
Version: 1.0.0
|
||||||
|
Release: 1
|
||||||
|
License: MIT
|
||||||
|
Group: Development/Tools
|
||||||
|
SOURCE0 : %{name}-%{version}.tar.gz
|
||||||
|
URL: http://carlosbecker.com
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||||
|
|
||||||
|
|
||||||
|
Obsoletes: svn
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Conflicts: zsh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Provides: bzr
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requires: bash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Recommends: git
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Suggests: bash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%description
|
||||||
|
Foo does things
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q
|
||||||
|
|
||||||
|
%build
|
||||||
|
# Empty section.
|
||||||
|
|
||||||
|
%install
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
mkdir -p %{buildroot}
|
||||||
|
|
||||||
|
# in builddir
|
||||||
|
cp -a * %{buildroot}
|
||||||
|
|
||||||
|
%clean
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
|
||||||
|
%files
|
||||||
|
%defattr(-,root,root,-)
|
||||||
|
|
||||||
|
/usr/local/bin/fake
|
||||||
|
|
||||||
|
%{_bindir}/*
|
||||||
|
|
||||||
|
/etc/fake/fake.conf
|
||||||
|
|
||||||
|
|
||||||
|
%config(noreplace) /etc/fake/fake.conf
|
||||||
|
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
# noop
|
Loading…
Reference in New Issue