Create binary rpm package with ease
Using a json
files to declare rules, it then performs necessary operations
to invoke rpmbuild
and build the package.
This tool is part of the go-github-release workflow
See the demo.
Check the release page!
mkdir -p $GOPATH/src/github.com/mh-cbon/go-bin-rpm
cd $GOPATH/src/github.com/mh-cbon/go-bin-rpm
git clone https://github.com/mh-cbon/go-bin-rpm.git .
glide install
go install
wget -O - https://raw.githubusercontent.com/mh-cbon/latest/master/bintray.sh \
| GH=mh-cbon/go-bin-rpm sh -xe
# or
curl -L https://raw.githubusercontent.com/mh-cbon/latest/master/bintray.sh \
| GH=mh-cbon/go-bin-rpm sh -xe
curl -L https://raw.githubusercontent.com/mh-cbon/latest/master/install.sh \
| GH=mh-cbon/go-bin-rpm sh -xe
# or
wget -q -O - --no-check-certificate \
https://raw.githubusercontent.com/mh-cbon/latest/master/install.sh \
| GH=mh-cbon/go-bin-rpm sh -xe
A centos/fedora/redhat system, vagrant, travis, docker, whatever.
To create a binary package you need to
- build your application binaries
- invoke
go-bin-rpm
to generate the package - create rpm repositories on
travis
hosted ongh-pages
using this script
For a real world example including service, shortcuts, env, see this
For a casual example to provide a simple binary, see this
Several tokens are provided to consume into the JSON file.
name | description | example |
---|---|---|
!version! | The version number provided in the command line, or in the JSON file. |
1.0.2 |
!arch! | The architecture short name provided in the command line or in the JSON file. |
amd64 |
!name! | The name of the project provided in the JSON file. |
hello |
NAME:
go-bin-rpm - Generate a binary rpm package
USAGE:
go-bin-rpm <cmd> <options>
VERSION:
1.0.0
COMMANDS:
generate-spec Generate the SPEC file
generate Generate the package
test Test the package json file
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--help, -h show help
--version, -v print the version
NAME:
go-bin-rpm generate-spec - Generate the SPEC file
USAGE:
go-bin-rpm generate-spec [command options] [arguments...]
OPTIONS:
--file value, -f value Path to the rpm.json file (default: "rpm.json")
-a value, --arch value Target architecture of the build
--version value Target version of the build
NAME:
go-bin-rpm generate - Generate the package
USAGE:
go-bin-rpm generate [command options] [arguments...]
OPTIONS:
--file value, -f value Path to the rpm.json file (default: "rpm.json")
-b value, --build-area value Path to the build area (default: "pkg-build")
-a value, --arch value Target architecture of the build
-o value, --output value File path to the resulting rpm file
--version value Target version of the build
NAME:
go-bin-rpm test - Test the package json file
USAGE:
go-bin-rpm test [command options] [arguments...]
OPTIONS:
--file value, -f value Path to the rpm.json file (default: "rpm.json")
TLDR
# install
sudo rpm -ivh pkg.rpm
# upgrade
sudo rpm -Uvh pkg.rpm
# remove
sudo rpm -evv nx pkg.rpm
Please check the demo app here
- get a github repo
- get a travis account
- connect your github account to travis and register your repo
- install travis client
gem install --user travis
- run
travis encrypt --add -r YOUR_USERNAME/dummy GH_TOKEN=xxxx
- run
travis setup releases
- personalize the
.travis.yml
sudo: required
services:
- docker
language: go
go:
- 1.8
- 1.9
env:
matrix:
- OKARCH=amd64 OSARCH=amd64
- OKARCH=386 OSARCH=i386
global:
- VERSION=${TRAVIS_TAG}
- GH_USER=${TRAVIS_REPO_SLUG%/*}
- GH_APP=${TRAVIS_REPO_SLUG#*/}
- JFROG_CLI_OFFER_CONFIG=false
- secure: iTmECM/2XzLk4/bMm4xCYcVyKJj6kV815wLlFyCMzcBHoQmOjYxWu6s36sQ9SecPu/fjE67+rJ6opPpeMz9SRTa34+L64vA0gRA61TynC3NUOIkvzs0y956fhxVGPF5knLnKGeWIHHObfxwo8ovvY+utWI4DqYwfWoIzGZ7Etc1Pp/zY4rIFYiNpRHH5zpvKG3+wjDx6ciUmZASM4ZFEY9OY5LlnOKxaxTFz71i0SZJO18fNTX1NrWEf55pU35CzVpk1rZ1V7cKt1i7k9MqWWwG5RXIzjLWjTx2aFJOchTj2kV7MM8FPk3FcQIiJ0JCPqkaVMNWTa3f++wH85fk2r4ErlVGvtG6xuHAy7uM4GBPX2nmUnEXIlg8qVHgYqUxg18qi92osJIVv3WZgNrL42dRQMHDcEf0b0NMEifpsPES65CnVQPMEZlN+eXzgVMMKS9s/Vf5B8HziDxkTy/crghqMQtff2HZ1eyH1gmLMA9HXQIFWCsAIEfrrgP5doNIfsHJaWP31agSyrHhGMI8y77kVj9K/cxL0XVq9mKlXtnI7S5OKgDD1Dn/PuUPkfrPFQ0wxCfXJ+FyqSyckUd7rTlihJKOlmEvHif3y7BK+qCbj/G7JveQGLKHt/fiIbo00PBvalLSSJDQEsFyO+cKLsR8uVyX/BgaMed6qt2RrzYE=
before_install:
- sudo apt-get -qq update
- mkdir -p ${GOPATH}/bin
- cd ~
- curl https://glide.sh/get | sh
install:
- cd $GOPATH/src/github.com/${TRAVIS_REPO_SLUG}
- glide install
- go install
script: echo "pass"
before_deploy:
- docker pull fedora
- mkdir -p build/$OSARCH
- GOOS=linux GOARCH=$OKARCH go build --ldflags "-X main.VERSION=$VERSION" -o build/$OSARCH/$GH_APP
main.go
- cp $GOPATH/bin/go-bin-rpm tmp
- |
docker run -v $PWD:/mnt/travis fedora /bin/sh -c "cd /mnt/travis && (curl -s -L https://bintray.com/bincrafters/public-rpm/rpm > /etc/yum.repos.d/w.repo) && dnf install go-bin-rpm changelog rpm-build -y --quiet && go-bin-rpm generate --file rpm.json -a $OSARCH --version $VERSION -o $GH_APP-$OSARCH-$VERSION.rpm"
- rm -f ./tmp
- cp $GH_APP-$OSARCH-$VERSION.rpm $GH_APP-$OKARCH.rpm
- curl -fL https://getcli.jfrog.io | sh
- ./jfrog bt pc --key=$BTKEY --user=$GH_USER --licenses=MIT --vcs-url=https://github.com/$GH_USER/rpm
$GH_USER/rpm/$GH_APP || echo "package already exists"
- ./jfrog bt upload --override=true --key $BTKEY --publish=true $GH_APP-$OSARCH-$VERSION.rpm
$GH_USER/rpm/$GH_APP/$VERSION pool/$POOL/$GH_APP/
- curl -X POST -u ${GH_USER}:${BTKEY} https://api.bintray.com/calc_metadata/${GH_USER}/rpm
deploy:
provider: releases
api_key:
secure: CY2nebPdr2CSCZW34QCtlw/IdbaHl5T77xPFlmvXB2Z+0SnO0RTW7JvFMa2mDYxa6ibZ6dR2br9YwdgJYnqV+PnXCizvZ5KPqpHxE31ta4s1IokZr+v9J+deGvUdk60oF5mxkqcGgAtScEGC5ZVJ/0EqAn64o4+H3fOQfA1pYTpzUBL/c9yUNqAFLFDVXz1sd7eSccPwf1uthdhndybMgatogfQuUBmm3vNJYYheAF8XCimBmrsIkPed+OKfhkDqUCTdgSTOQWvv0Uf8ib5VUH0w+UV8Wx69/KNKVhp/f7Nhf6GCKT1AKh/fQxjpRaWdkQLsn7nqPVuF0dHYV/mtdo4EP0FDj+2a3LvtGpEst90Mo0SRzauhqCQqCopyOf3JKkKPqTyMRDKAzYWAymjeLGaPda4wOxNROWV7yBuXNTTUmU2GDPUMULnLA7v+0ml6wd3gGCOMU5It8Iynkuxts8ATlpa0qels3memQITfhkTdR3CFT2mr/frkDiVOtqnp6BJoQIjhSMXoMRfnSpnNOszsiLNa9pM+hNG3HeZN0MQ+gTlRgqmTSitvllr751oUhgNzjv35FDxaywFwKlqtaJfX9UVCLxcBTvDcP4ZKHJRbgFOmffv2mnKi1S8K26LUkuLZDKvCZgrw8iM1KjvPX/GP9tXaxgLrfsfQOcOGGGs=
file_glob: true
file:
- $GH_APP-$OKARCH.rpm
skip_cleanup: true
overwrite: true
true:
tags: true
# check dependencies before install
rpm -qpR pkg.rpm
# show info of a package before install
rpm -qip pkg.rpm
# install with no dependencies
rpm -ivh --nodeps pkg.rpm
# show info of installed package
rpm -qi pkg
# check installed package
rpm -q pkg
# list files of installed package
rpm -ql pkg
- https://fedoraproject.org/wiki/Packaging:RPMMacros
- http://www.rpm.org/max-rpm/s1-rpm-build-creating-spec-file.html
- http://www.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html
- http://www.rpm.org/max-rpm/s1-rpm-inside-scripts.html
- http://www.rpm.org/max-rpm-snapshot/s1-rpm-depend-manual-dependencies.html
- https://fedoraproject.org/wiki/PackagingDrafts:SystemdClarification#Packaging
- https://fedoraproject.org/wiki/Packaging:Scriptlets?rd=Packaging:ScriptletSnippets#Systemd
- https://fedoraproject.org/wiki/Packaging:Guidelines#BuildRequires_2
- http://wiki.networksecuritytoolkit.org/nstwiki/index.php/RPM_Quick_Reference#Secret_.25pretrans_and_.25posttrans_RPM_Scriptlets
- https://fedoraproject.org/wiki/Packaging:Scriptlets?rd=Packaging:ScriptletSnippets#desktop-database
- https://fedoraproject.org/wiki/Archive:PackagingDrafts/DesktopVerify?rd=PackagingDrafts/DesktopVerify
- https://fedoraproject.org/wiki/Archive:PackagingDrafts/DesktopFiles?rd=PackagingDrafts/DesktopFiles
gump patch -d # check
gump patch # bump