1 %global rvm_dir /usr/lib/rvm
4 # RVM can not be sourced with default /bin/sh
5 %define _buildshell /bin/bash
9 # pick a RVM version from https://github.com/wayneeseguin/rvm/tags
10 %define version 1.20.10
12 %define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
14 Summary: Ruby Version Manager (including Rubies and Gems)
20 Group: Applications/System
21 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
23 BuildRequires: bash curl git
24 BuildRequires: gcc-c++ patch chrpath readline readline-devel zlib-devel libyaml-devel libffi-devel openssl-devel autoconf automake libtool bison
25 BuildRequires: sed grep tar gzip bzip2 make file
27 Requires(pre): shadow-utils
29 Requires: bash curl git
30 # Basics for building ruby 1.8/1.9
31 # We expect all the building to take place .. at build-time, so let's take this out
32 #Requires: gcc-c++ patch readline readline-devel zlib-devel libyaml-devel libffi-devel openssl-devel autoconf automake libtool bison
34 Requires: sed grep tar gzip bzip2 make file
37 RVM is the Ruby Version Manager. It manages Ruby interpreter environments
38 and switching between them.
40 This package is meant for use by multiple users maintaining a shared copy of
41 RVM. Users added to the '%{rvm_group}' group will be able to modify all aspects
42 of RVM. These users will also have their default umask modified ("g+w") to allow
43 group write permission (usually resulting in a umask of "0002") in order to
44 ensure correct permissions for the shared RVM content.
46 RVM is activated for all logins by default. To disable remove
47 %{_sysconfdir}/profile.d/rvm.sh and source rvm from each users shell.
53 for i in $(env | grep ^rvm_ | cut -d"=" -f1); do
57 # Install everything into one directory
59 export rvm_ignore_rvmrc=1 \
60 rvm_user_install_flag=0 \
61 rvm_path="%{buildroot}%{rvm_dir}" \
62 rvm_man_path="%{buildroot}%{_mandir}" \
64 \curl -L https://get.rvm.io | bash -s stable --version %{version}
67 # So members of the rvm group can write to it
68 find %{buildroot}%{rvm_dir} -exec chmod ug+w {} \;
69 find %{buildroot}%{rvm_dir} -type d -exec chmod g+s {} \;
71 mkdir -p %{buildroot}%{_sysconfdir}
73 # We use selfcontained so binaries end up in rvm/bin
74 cat > %{buildroot}%{_sysconfdir}/rvmrc <<END_OF_RVMRC
75 # Setup default configuration for rvm.
76 # If an rvm install exists in the home directory, don't load this.'
77 if [[ ! -s "\${HOME}/.rvm/scripts/rvm" ]]; then
79 # Only users in the rvm group need the umask modification
80 for i in \$(id -G -n); do
81 if [ \$i = "rvm" ]; then
87 export rvm_user_install_flag=1
88 export rvm_path="%{rvm_dir}"
92 mkdir -p %{buildroot}%{_sysconfdir}/profile.d
94 cat > %{buildroot}%{_sysconfdir}/profile.d/rvm.sh <<END_OF_RVMSH
97 if [ -s "\${HOME}/.rvm/scripts/rvm" ]; then
98 source "\${HOME}/.rvm/scripts/rvm"
99 elif [ -s "%{rvm_dir}/scripts/rvm" ]; then
100 source "%{rvm_dir}/scripts/rvm"
104 chmod 755 %{buildroot}%{_sysconfdir}/profile.d/rvm.sh
106 # At this point, install of RVM is finished
107 # Now install some rubies
109 # Run this in a subshell so the rvm loading does not infect our current shell.
111 export rvm_ignore_rvmrc=1
112 export rvm_user_install_flag=0
113 export rvm_path="%{buildroot}%{rvm_dir}"
114 export rvm_man_path="%{buildroot}%{_mandir}"
115 source ${rvm_path}/scripts/rvm
116 gemi='gem install --no-ri --no-rdoc'
118 ruby_tag=ruby-1.9.3-p286
119 rvm install $ruby_tag
121 rvm gemset create omf
122 rvm use $ruby_tag@omf
124 #$gemi whatever_gem_you_need
126 #ruby_tag=ruby-1.8.7-p352
127 #rvm install $ruby_tag
132 export br=%{buildroot}
135 #find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep 'not stripped' |cut -f1 -d: |xargs -r strip
137 # Strip and Fix bad paths in generated files
138 # That is not optimized, but that is not supposed to be done often
139 for f in $(find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': ELF' |cut -f1 -d:); do
141 grep "$br" $f || continue
142 line=$(chrpath -l $f) || continue
143 echo $line |grep "$br" || continue
144 chrpath -r $(echo $line |cut -f2 -d= |sed "s,$br,,") $f
147 # Replace bad paths in text files
148 find $br -type f \( -name \*.log -o -name \*.la \) -print0 |xargs -0 -r sed -i "s,$br,,g"
149 find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': .* text' |cut -f1 -d: |xargs -r sed -i "s,$br,,g"
151 # Replace bad paths in all remaining files
152 # Padding with zeroes broke the LOAD_PATH in libruby, therefore prepend path with harmless forward slashes
153 printf -vch "%${#br}s" ""
154 slashes=$(printf "%s" "${ch// //}")
155 find $br -type f -print0 | xargs -0 sed -i "s,$br,$slashes,g"
157 # Fix symlinks with bad path
158 # the canonical path of the build root
159 brc=$(readlink -f $br)
160 for f in $(find $br -type l); do
161 # some symlinks are relative, in which case we want to preserve them
162 # do *not* mention -f here as it would always return an absolute path
164 # relative symlinks have $dest not starting with a /
165 first_step=$(echo $dest | cut -d / -f1)
166 # absolute paths have a void first_step
167 if [ -z "$first_step" ] ; then
168 # destination is an absolute path, let's fix it
169 # call readlink with -f so all symlinmks are solved
170 # and so we can reliably substitute $brc that is also canonicalized
171 destc=$(readlink -f $f | sed -e "s,^$brc,,")
176 find $br -maxdepth 1 -name '.*' -exec rm -rf {} \;
177 rm $br/usr/share/man/man1/rvm.1.gz
181 # it appears that, because we build as root, rvm installs stuff in /etc on the build box
182 # which is not desirable, so let us get rid of that - don't worry if that fails
183 find /etc -name 'rvm*' | xargs rm || :
186 getent group %{rvm_group} >/dev/null || groupadd -r %{rvm_group}
190 %defattr(-,root,root)
191 %config(noreplace) /etc/rvmrc
192 %config(noreplace) /etc/profile.d/rvm.sh
193 %attr(-,root,%{rvm_group}) %{rvm_dir}
197 * Tue Jun 25 2013 Thierry Parmentelat - rvm-ruby-1.20.10-6
198 - add omf-rc in the mix
200 * Fri May 18 2013 Christoph Dwertmann - 4.xxx
201 - downloads RVM instead of relying on local sources
202 - works with latest RVM and Fedora
203 - removed ruby build dependency
204 - no more clashing with distribution ruby
206 * Fri Mar 30 2012 Alexandre Fouche - 3.xxx
207 Add some rubies and gems to compile:
208 - 1.9.2-p290 + bundler, bluepill, whenever
209 - 1.9.3-p0 + bundler, bluepill, whenever
211 * Thu Mar 29 2012 Alexandre Fouche - 2.xxx
212 - Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
213 - Strip binaries, libraries, ...
215 * Thu Mar 29 2012 Alexandre Fouche - 1.xxx
216 - Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
218 * Tue Dec 13 2011 Matthew Kent <mkent@magoazul.com> - 1.10.0-2
219 - New upstream release
221 - Rename rvm_user_install to rvm_user_install_flag
222 - Rename rake wrapper to rvm-rake
223 - Add file dependency
225 * Thu Aug 4 2011 Matthew Kent <mkent@magoazul.com> - 1.6.32-1
226 - New upstream release
228 * Tue Apr 19 2011 Matthew Kent <mkent@magoazul.com> - 1.6.3-1
229 - Initial package based off Gentoo work