Skip to content

Instantly share code, notes, and snippets.

@mrichar1
Created November 11, 2013 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrichar1/7416008 to your computer and use it in GitHub Desktop.
Save mrichar1/7416008 to your computer and use it in GitHub Desktop.
hacky script to generate fpm rpms from sensu-admin Gemfile, using ruby bundled with sensu and ignoring already existing gems
########################################################
# install sensu (epel rpms)
# you will also need some (all?) of sqlite-devel, mysql2-devel, rpm-build, libxslt-devel,libxml2-devel rpms
# use it's embedded gem to install bundler and fpm
mkdir /tmp/sensugems
/opt/sensu/embedded/bin/gem install --no-rdoc --no-ri -i /tmp/sensugems/ bundler
/opt/sensu/embedded/bin/gem install --no-rdoc --no-ri -i /tmp/sensugems/ fpm
# Set GEM_PATH to include /tmp/sensugems
export GEM_PATH=/tmp/sensugems:$GEM_PATH
# Test it works - make sure ruby version is 2.0.0
/tmp/sensugems/bin/bundle env
# download sensu-admin.zip and extract to /tmp/sensu-admin-master
# Download gem deps for sensu-admin (this assumes you don't want mysql support)
mkdir /tmp/gems
/opt/sensu/embedded/bin/bundle install --path=/tmp/gems --gemfile=/tmp/sensu-admin-master/Gemfile --without mysql
# Remove gems that are already in sensu, as rpms built from them will clash
for file in /opt/sensu/embedded/lib/ruby/gems/2.0.0/cache/*; do rm -f /tmp/gems/ruby/2.0.0/cache/${file##*/}; done
# install mini_portile for nokogiri install
/opt/sensu/embedded/bin/gem install --no-rdoc --no-ri -i /tmp/sensugems/ mini_portile
# Create a 'sensugem' rpm for each needed gem - turn off deps or the rpms will depend on the 'built-in' gems in some cases
find /tmp/gems/ruby/2.0.0/cache -name '*.gem' | xargs -rn1 /tmp/sensugems/bin/fpm --no-auto-depends -d sensu -s gem -t rpm --gem-bin /opt/sensu/embedded/usr/bin --gem-gem /opt/sensu/embedded/bin/gem --gem-package-name-prefix sensugem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment