mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-24 04:16:27 +02:00
Merge pull request #337 from goreleaser/rpm
building rpm packages as well
This commit is contained in:
commit
429d42bf0b
@ -39,6 +39,7 @@ fpm:
|
||||
vendor: GoReleaser
|
||||
formats:
|
||||
- deb
|
||||
- rpm
|
||||
dependencies:
|
||||
- git
|
||||
snapcraft:
|
||||
|
@ -6,7 +6,7 @@ install:
|
||||
- make setup
|
||||
- gem install fpm
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install --yes snapd
|
||||
- sudo apt-get install --yes snapd rpm
|
||||
- export PATH=/snap/bin:$PATH
|
||||
- sudo snap install snapcraft --candidate --classic
|
||||
script:
|
||||
|
@ -13,6 +13,7 @@ Prerequisites are:
|
||||
* `make`
|
||||
* [Go 1.8+](http://golang.org/doc/install)
|
||||
* [fpm](https://fpm.readthedocs.io/en/latest/installing.html)
|
||||
* rpm / rpmbuild
|
||||
* [snapcraft](http://snapcraft.io/)
|
||||
|
||||
Clone `goreleaser` from source into `$GOPATH`:
|
||||
|
@ -64,6 +64,7 @@ func archFor(key string) string {
|
||||
func create(ctx *context.Context, format, folder, arch string, binaries []context.Binary) error {
|
||||
var path = filepath.Join(ctx.Config.Dist, folder)
|
||||
var file = path + "." + format
|
||||
var log = log.WithField("format", format).WithField("arch", arch)
|
||||
log.WithField("file", file).Info("creating fpm archive")
|
||||
|
||||
var options = []string{
|
||||
@ -72,7 +73,6 @@ func create(ctx *context.Context, format, folder, arch string, binaries []contex
|
||||
"--name", ctx.Config.ProjectName,
|
||||
"--version", ctx.Version,
|
||||
"--architecture", arch,
|
||||
// "--chdir", path,
|
||||
"--package", file,
|
||||
"--force",
|
||||
}
|
||||
@ -109,7 +109,7 @@ func create(ctx *context.Context, format, folder, arch string, binaries []contex
|
||||
// binary=/usr/local/bin/binary
|
||||
log.WithField("path", binary.Path).
|
||||
WithField("name", binary.Name).
|
||||
Info("passed binary to fpm")
|
||||
Debug("added binary to fpm package")
|
||||
options = append(options, fmt.Sprintf(
|
||||
"%s=%s",
|
||||
binary.Path,
|
||||
@ -120,7 +120,7 @@ func create(ctx *context.Context, format, folder, arch string, binaries []contex
|
||||
for src, dest := range ctx.Config.FPM.Files {
|
||||
log.WithField("src", src).
|
||||
WithField("dest", dest).
|
||||
Info("passed extra file to fpm")
|
||||
Debug("added an extra file to the fpm package")
|
||||
options = append(options, fmt.Sprintf(
|
||||
"%s=%s",
|
||||
src,
|
||||
@ -128,6 +128,7 @@ func create(ctx *context.Context, format, folder, arch string, binaries []contex
|
||||
))
|
||||
}
|
||||
|
||||
log.WithField("args", options).Debug("creating fpm package")
|
||||
if out, err := exec.Command("fpm", options...).CombinedOutput(); err != nil {
|
||||
return errors.New(string(out))
|
||||
}
|
||||
|
@ -18,22 +18,8 @@ func TestDescription(t *testing.T) {
|
||||
func TestRunPipeNoFormats(t *testing.T) {
|
||||
var assert = assert.New(t)
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{},
|
||||
}
|
||||
assert.NoError(Pipe{}.Run(ctx))
|
||||
}
|
||||
|
||||
func TestRunPipeFormatBinary(t *testing.T) {
|
||||
var assert = assert.New(t)
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{
|
||||
FPM: config.FPM{
|
||||
Formats: []string{"deb"},
|
||||
},
|
||||
Archive: config.Archive{
|
||||
Format: "binary",
|
||||
},
|
||||
},
|
||||
Version: "1.0.0",
|
||||
Config: config.Project{},
|
||||
}
|
||||
assert.NoError(Pipe{}.Run(ctx))
|
||||
}
|
||||
@ -49,11 +35,12 @@ func TestRunPipe(t *testing.T) {
|
||||
_, err = os.Create(binPath)
|
||||
assert.NoError(err)
|
||||
var ctx = &context.Context{
|
||||
Version: "1.0.0",
|
||||
Config: config.Project{
|
||||
ProjectName: "mybin",
|
||||
Dist: dist,
|
||||
FPM: config.FPM{
|
||||
Formats: []string{"deb"},
|
||||
Formats: []string{"deb", "rpm"},
|
||||
Dependencies: []string{"make"},
|
||||
Conflicts: []string{"git"},
|
||||
Description: "Some description",
|
||||
@ -78,9 +65,10 @@ func TestNoFPMInPath(t *testing.T) {
|
||||
}()
|
||||
assert.NoError(os.Setenv("PATH", ""))
|
||||
var ctx = &context.Context{
|
||||
Version: "1.0.0",
|
||||
Config: config.Project{
|
||||
FPM: config.FPM{
|
||||
Formats: []string{"deb"},
|
||||
Formats: []string{"deb", "rpm"},
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -95,10 +83,11 @@ func TestCreateFileDoesntExist(t *testing.T) {
|
||||
assert.NoError(os.Mkdir(dist, 0755))
|
||||
assert.NoError(os.Mkdir(filepath.Join(dist, "mybin"), 0755))
|
||||
var ctx = &context.Context{
|
||||
Version: "1.0.0",
|
||||
Config: config.Project{
|
||||
Dist: dist,
|
||||
FPM: config.FPM{
|
||||
Formats: []string{"deb"},
|
||||
Formats: []string{"deb", "rpm"},
|
||||
Files: map[string]string{
|
||||
"testdata/testfile.txt": "/var/lib/test/testfile.txt",
|
||||
},
|
||||
@ -112,9 +101,10 @@ func TestCreateFileDoesntExist(t *testing.T) {
|
||||
func TestRunPipeWithExtraFiles(t *testing.T) {
|
||||
var assert = assert.New(t)
|
||||
var ctx = &context.Context{
|
||||
Version: "1.0.0",
|
||||
Config: config.Project{
|
||||
FPM: config.FPM{
|
||||
Formats: []string{"deb"},
|
||||
Formats: []string{"deb", "rpm"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user