Skip to content

Instantly share code, notes, and snippets.

@vinzent
Created June 5, 2015 07:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinzent/57c1448403e68aaf1650 to your computer and use it in GitHub Desktop.
Save vinzent/57c1448403e68aaf1650 to your computer and use it in GitHub Desktop.
Howto: easily create rpms from ruby gems for use with puppet-agent AIO
#!/bin/bash
# Author: Thomas Mueller <thomas@chaschperli.ch>
# Date: 2015-06-05
# enable to exit on first error
# set -e
# list gem's to create rpm's seperated by space
# example for 2 gems: gem_list="r10k trocla"
gem_list="r10k"
export PATH="/opt/puppetlabs/bin:/opt/puppetlabs/puppet/bin:$PATH"
# requires the IMHO nice packaging tool fpm
# (https://github.com/jordansissel/fpm)
# try to install fpm if not found
which fpm >/dev/null || gem install fpm
# install gem's to a temp directory
gem install --no-ri --no-rdoc --install-dir /tmp/gems $gem_list
timestamp=$(date +%Y%m%d%H%M%S)
pkg_path="/tmp/gems/pkg_${timestamp}"
mkdir -p "$pkg_path"
cd "$pkg_path"
# gem v.1.2.0 fpm produces dependency to exact version 1.2 (without .0)
# use gem-disable-dependency to disable this one
find /tmp/gems/cache -name '*.gem' | \
xargs -rn1 \
fpm \
--depends 'puppet-agent >= 1.0.0' \
--iteration 0.el6 \
--epoch 0 \
--gem-package-name-prefix puppet-agent-rubygem \
--gem-disable-dependency colored \
-s gem \
-t rpm
echo "RPM's are in folder: ${pkg_path}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment