2012-07-26 09:22:03 +02:00
|
|
|
#! /bin/bash
|
|
|
|
|
2012-07-28 22:30:18 +02:00
|
|
|
set -e
|
|
|
|
|
2012-07-26 09:22:03 +02:00
|
|
|
# options may be followed by one colon to indicate they have a required argument
|
|
|
|
if ! options=$(getopt -o dEf -l ignore-dependencies,force,no-rdoc,rdoc,no-ri,ri,env-shebang,no-env-shebang,default-gem:,build-root:,gem-binary: -- "$@")
|
|
|
|
then
|
|
|
|
# something went wrong, getopt will put out an error message for us
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
eval set -- "$options"
|
|
|
|
|
|
|
|
gem_binary=gem
|
|
|
|
defaultgem=
|
|
|
|
gemfile=
|
|
|
|
otheropts=
|
2012-07-27 16:03:20 +02:00
|
|
|
buildroot=
|
2012-07-26 09:22:03 +02:00
|
|
|
|
|
|
|
while [ $# -gt 0 ]
|
|
|
|
do
|
|
|
|
case $1 in
|
|
|
|
--default-gem) defaultgem=$2 ; shift;;
|
|
|
|
--gem-binary) gem_binary="$2" ; shift;;
|
2012-07-27 16:03:20 +02:00
|
|
|
--build-root) otheropts="$otheropts $1=$2"; buildroot=$2; shift;;
|
2012-07-26 09:22:03 +02:00
|
|
|
(--) ;;
|
|
|
|
(-*) otheropts="$otheropts $1";;
|
|
|
|
(*) gemfile=$1; otheropts="$otheropts $1"; break;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "x$gemfile" = "x" ] ; then
|
|
|
|
gemfile=$(find . -maxdepth 2 -type f -name "$defaultgem")
|
2012-07-27 16:03:20 +02:00
|
|
|
# if still empty, we pick the sources
|
|
|
|
if [ "x$gemfile" = "x" ] ; then
|
|
|
|
gemfile=$(find $RPM_SOURCE_DIR -name "$defaultgem")
|
|
|
|
fi
|
2012-07-26 09:22:03 +02:00
|
|
|
otheropts="$otheropts $gemfile"
|
|
|
|
fi
|
|
|
|
set -x
|
|
|
|
$gem_binary install --verbose --local $otheropts
|
|
|
|
if test -d $RPM_BUILD_ROOT/usr/bin; then
|
|
|
|
cd $RPM_BUILD_ROOT/usr/bin
|
|
|
|
bins=`ls -1 *1.9 2> /dev/null`
|
|
|
|
if test -n "$bins"; then
|
|
|
|
for bin in $bins; do
|
|
|
|
mv -v $bin $(echo "$bin" | sed -e 's,1.9$,,')
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2012-07-27 16:03:20 +02:00
|
|
|
if [ -d "$buildroot" ]; then
|
|
|
|
find $buildroot -type f -perm /u+x | while read file; do
|
|
|
|
sed -i -e 's,#!/usr/local/bin/ruby,#!/usr/bin/ruby,' "$file"
|
|
|
|
done
|
|
|
|
fi
|