Skip to content

Instantly share code, notes, and snippets.

@mdkent
Created March 9, 2011 22:19
Show Gist options
  • Save mdkent/863130 to your computer and use it in GitHub Desktop.
Save mdkent/863130 to your computer and use it in GitHub Desktop.
%global rvm_version_sha1 ddf3b50
%global rvm_dir /usr/lib/rvm
%global rvm_group rvm
Name: rvm-ruby
Summary: Ruby Version Manager
Version: 1.2.8
Release: 1%{?dist:%{dist}}
License: ASL 2.0
URL: http://rvm.beginrescueend.com/
Group: Applications/System
# Downloaded with
# wget --no-check-certificate http://github.com/wayneeseguin/rvm/tarball/<version>
Source: wayneeseguin-rvm-%{version}-0-g%{rvm_version_sha1}.tar.gz
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
Requires(pre): shadow-utils
# For rvm
Requires: bash curl git
# Basics for building ruby 1.8/1.9
Requires: gcc-c++ patch readline readline-devel zlib-devel libyaml-devel libffi-devel openssl-devel
# Used by the scripts
Requires: sed grep tar gzip bzip2 make
%description
RVM is the Ruby Version Manager (rvm). It manages Ruby interpreter environments
and switching between them.
This package is meant for use by multiple users maintaining a shared copy of
RVM. Users added to the '%{rvm_group}' group will be able to modify all aspects
of RVM. These users will also have their default umask changed to g+w (0022) to
ensure correct permissions for the shared RVM content.
RVM is activated for all logins by default. To disable remove
%{_sysconfdir}/profile.d/rvm.sh and source rvm from each users shell.
%prep
%setup -q -n wayneeseguin-rvm-%{rvm_version_sha1}
%build
%install
rm -rf %{buildroot}
# Install everything into one directory
rvm_selfcontained=1 \
rvm_prefix="$(dirname %{buildroot}%{rvm_dir})/" \
rvm_path="%{buildroot}%{rvm_dir}" \
./install
# So members of the rvm group can write to it
find %{buildroot}%{rvm_dir} -exec chmod ug+w {} \;
find %{buildroot}%{rvm_dir} -type d -exec chmod g+s {} \;
mkdir -p %{buildroot}%{_sysconfdir}
# We use selfcontained so binaries end up in rvm/bin
cat > %{buildroot}%{_sysconfdir}/rvmrc <<END_OF_RVMRC
# Setup default configuration for rvm.
# If an rvm install exists in the home directory, don't load this.'
if [[ ! -s "\${HOME}/.rvm/scripts/rvm" ]]; then
# Only users in the rvm group need the umask modification
for i in \$(id -G -n); do
if [ \$i = "rvm" ]; then
umask g+w
break
fi
done
export rvm_selfcontained=1
export rvm_prefix="$(dirname %{rvm_dir})/"
fi
END_OF_RVMRC
mkdir -p %{buildroot}%{_sysconfdir}/profile.d
cat > %{buildroot}%{_sysconfdir}/profile.d/rvm.sh <<END_OF_RVMSH
# rvm loading hook
#
if [ -s "\${HOME}/.rvm/scripts/rvm" ]; then
source "\${HOME}/.rvm/scripts/rvm"
elif [ -s "%{rvm_dir}/scripts/rvm" ]; then
source "%{rvm_dir}/scripts/rvm"
fi
END_OF_RVMSH
mkdir -p %{buildroot}/%{_bindir}
# Binary helpers as rvm is in rvm/bin/
for i in `find %{buildroot}%{rvm_dir}/bin/ -type f`; do
bin=$(basename $i)
ln -s %{rvm_dir}/bin/$bin %{buildroot}%{_bindir}/$bin
done
%clean
rm -rf %{buildroot}
%pre
getent group %{rvm_group} >/dev/null || groupadd -r %{rvm_group}
exit 0
%files
%defattr(-,root,root)
%config(noreplace) /etc/rvmrc
%config(noreplace) /etc/profile.d/rvm.sh
%attr(-,root,%{rvm_group}) %{rvm_dir}
%{_bindir}/rvm*
%changelog
* Tue Mar 8 2011 Matthew Kent <[email protected]> - 1.2.8-1
- Initial package based off Gentoo work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment