diff --git a/.goreleaser.yml b/.goreleaser.yml index 05a106c47..42d6ae947 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -39,6 +39,7 @@ fpm: vendor: GoReleaser formats: - deb + - rpm dependencies: - git snapcraft: diff --git a/.travis.yml b/.travis.yml index 0d6817e39..c3fe5822c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b6673290a..29c7df15f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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`: diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index 25f885247..baac077cd 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -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)) } diff --git a/pipeline/fpm/fpm_test.go b/pipeline/fpm/fpm_test.go index 5c1c72776..2e8c0251b 100644 --- a/pipeline/fpm/fpm_test.go +++ b/pipeline/fpm/fpm_test.go @@ -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"}, }, }, }