1 %global rvm_dir /usr/lib/rvm
4 # RVM can not be sourced with default /bin/sh
5 %define _buildshell /bin/bash
8 Summary: Ruby Version Manager (including Rubies and Gems)
9 Version: 4 # Commit date will be appended
10 # pick a RVM version from https://github.com/wayneeseguin/rvm/tags
14 Group: Applications/System
15 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
17 BuildRequires: bash curl git
18 BuildRequires: gcc-c++ patch chrpath readline readline-devel zlib-devel libyaml-devel libffi-devel openssl-devel autoconf automake libtool bison
19 BuildRequires: sed grep tar gzip bzip2 make file
21 Requires(pre): shadow-utils
23 Requires: bash curl git
24 # Basics for building ruby 1.8/1.9
25 Requires: gcc-c++ patch readline readline-devel zlib-devel libyaml-devel libffi-devel openssl-devel autoconf automake libtool bison
27 Requires: sed grep tar gzip bzip2 make file
30 RVM is the Ruby Version Manager. It manages Ruby interpreter environments
31 and switching between them.
33 This package is meant for use by multiple users maintaining a shared copy of
34 RVM. Users added to the '%{rvm_group}' group will be able to modify all aspects
35 of RVM. These users will also have their default umask modified ("g+w") to allow
36 group write permission (usually resulting in a umask of "0002") in order to
37 ensure correct permissions for the shared RVM content.
39 RVM is activated for all logins by default. To disable remove
40 %{_sysconfdir}/profile.d/rvm.sh and source rvm from each users shell.
46 for i in $(env | grep ^rvm_ | cut -d"=" -f1); do
50 # Install everything into one directory
52 export rvm_ignore_rvmrc=1 \
53 rvm_user_install_flag=0 \
54 rvm_path="%{buildroot}%{rvm_dir}" \
55 rvm_man_path="%{buildroot}%{_mandir}" \
57 \curl -L https://get.rvm.io | bash -s stable --version %{release}
60 # So members of the rvm group can write to it
61 find %{buildroot}%{rvm_dir} -exec chmod ug+w {} \;
62 find %{buildroot}%{rvm_dir} -type d -exec chmod g+s {} \;
64 mkdir -p %{buildroot}%{_sysconfdir}
66 # We use selfcontained so binaries end up in rvm/bin
67 cat > %{buildroot}%{_sysconfdir}/rvmrc <<END_OF_RVMRC
68 # Setup default configuration for rvm.
69 # If an rvm install exists in the home directory, don't load this.'
70 if [[ ! -s "\${HOME}/.rvm/scripts/rvm" ]]; then
72 # Only users in the rvm group need the umask modification
73 for i in \$(id -G -n); do
74 if [ \$i = "rvm" ]; then
80 export rvm_user_install_flag=1
81 export rvm_path="%{rvm_dir}"
85 mkdir -p %{buildroot}%{_sysconfdir}/profile.d
87 cat > %{buildroot}%{_sysconfdir}/profile.d/rvm.sh <<END_OF_RVMSH
90 if [ -s "\${HOME}/.rvm/scripts/rvm" ]; then
91 source "\${HOME}/.rvm/scripts/rvm"
92 elif [ -s "%{rvm_dir}/scripts/rvm" ]; then
93 source "%{rvm_dir}/scripts/rvm"
97 chmod 755 %{buildroot}%{_sysconfdir}/profile.d/rvm.sh
99 # At this point, install of RVM is finished
100 # Now install some rubies
102 # Run this in a subshell so the rvm loading does not infect our current shell.
104 export rvm_ignore_rvmrc=1
105 export rvm_user_install_flag=0
106 export rvm_path="%{buildroot}%{rvm_dir}"
107 export rvm_man_path="%{buildroot}%{_mandir}"
108 source ${rvm_path}/scripts/rvm
109 gemi='gem install --no-ri --no-rdoc'
111 ruby_tag=ruby-1.9.3-p286
112 rvm install $ruby_tag
115 #$gemi whatever_gem_you_need
117 #ruby_tag=ruby-1.8.7-p352
118 #rvm install $ruby_tag
123 export br=%{buildroot}
126 #find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep 'not stripped' |cut -f1 -d: |xargs -r strip
128 # Strip and Fix bad paths in generated files
129 # That is not optimized, but that is not supposed to be done often
130 for f in $(find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': ELF' |cut -f1 -d:); do
132 grep "$br" $f || continue
133 line=$(chrpath -l $f) || continue
134 echo $line |grep "$br" || continue
135 chrpath -r $(echo $line |cut -f2 -d= |sed "s,$br,,") $f
138 # Replace bad paths in text files
139 find $br -type f \( -name \*.log -o -name \*.la \) -print0 |xargs -0 -r sed -i "s,$br,,g"
140 find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': .* text' |cut -f1 -d: |xargs -r sed -i "s,$br,,g"
142 # Replace bad paths in all remaining files
143 # Padding with zeroes broke the LOAD_PATH in libruby, therefore prepend path with harmless forward slashes
144 printf -vch "%${#br}s" ""
145 slashes=$(printf "%s" "${ch// //}")
146 find $br -type f -print0 | xargs -0 sed -i "s,$br,$slashes,g"
148 # Fix symlinks with bad path
149 for f in $(find $br -type l |grep "$br"); do
150 ln -sfn $(readlink -f $f |sed "s,$br,,") $f
153 find $br -maxdepth 1 -name '.*' -exec rm -rf {} \;
154 rm $br/usr/share/man/man1/rvm.1.gz
160 getent group %{rvm_group} >/dev/null || groupadd -r %{rvm_group}
164 %defattr(-,root,root)
165 %config(noreplace) /etc/rvmrc
166 %config(noreplace) /etc/profile.d/rvm.sh
167 %attr(-,root,%{rvm_group}) %{rvm_dir}
171 * Fri May 18 2013 Christoph Dwertmann - 4.xxx
172 - downloads RVM instead of relying on local sources
173 - works with latest RVM and Fedora
174 - removed ruby build dependency
175 - no more clashing with distribution ruby
177 * Fri Mar 30 2012 Alexandre Fouche - 3.xxx
178 Add some rubies and gems to compile:
179 - 1.9.2-p290 + bundler, bluepill, whenever
180 - 1.9.3-p0 + bundler, bluepill, whenever
182 * Thu Mar 29 2012 Alexandre Fouche - 2.xxx
183 - Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
184 - Strip binaries, libraries, ...
186 * Thu Mar 29 2012 Alexandre Fouche - 1.xxx
187 - Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
189 * Tue Dec 13 2011 Matthew Kent <mkent@magoazul.com> - 1.10.0-2
190 - New upstream release
192 - Rename rvm_user_install to rvm_user_install_flag
193 - Rename rake wrapper to rvm-rake
194 - Add file dependency
196 * Thu Aug 4 2011 Matthew Kent <mkent@magoazul.com> - 1.6.32-1
197 - New upstream release
199 * Tue Apr 19 2011 Matthew Kent <mkent@magoazul.com> - 1.6.3-1
200 - Initial package based off Gentoo work