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
122 #$gemi whatever_gem_you_need
124 #ruby_tag=ruby-1.8.7-p352
125 #rvm install $ruby_tag
130 export br=%{buildroot}
133 #find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep 'not stripped' |cut -f1 -d: |xargs -r strip
135 # Strip and Fix bad paths in generated files
136 # That is not optimized, but that is not supposed to be done often
137 for f in $(find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': ELF' |cut -f1 -d:); do
139 grep "$br" $f || continue
140 line=$(chrpath -l $f) || continue
141 echo $line |grep "$br" || continue
142 chrpath -r $(echo $line |cut -f2 -d= |sed "s,$br,,") $f
145 # Replace bad paths in text files
146 find $br -type f \( -name \*.log -o -name \*.la \) -print0 |xargs -0 -r sed -i "s,$br,,g"
147 find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': .* text' |cut -f1 -d: |xargs -r sed -i "s,$br,,g"
149 # Replace bad paths in all remaining files
150 # Padding with zeroes broke the LOAD_PATH in libruby, therefore prepend path with harmless forward slashes
151 printf -vch "%${#br}s" ""
152 slashes=$(printf "%s" "${ch// //}")
153 find $br -type f -print0 | xargs -0 sed -i "s,$br,$slashes,g"
155 # Fix symlinks with bad path
156 # the canonical path of the build root
157 brc=$(readlink -f $br)
158 for f in $(find $br -type l); do
159 # some symlinks are relative, in which case we want to preserve them
160 # do *not* mention -f here as it would always return an absolute path
162 # relative symlinks have $dest not starting with a /
163 first_step=$(echo $dest | cut -d / -f1)
164 # absolute paths have a void first_step
165 if [ -z "$first_step" ] ; then
166 # destination is an absolute path, let's fix it
167 # call readlink with -f so all symlinmks are solved
168 # and so we can reliably substitute $brc that is also canonicalized
169 destc=$(readlink -f $f | sed -e "s,^$brc,,")
174 find $br -maxdepth 1 -name '.*' -exec rm -rf {} \;
175 rm $br/usr/share/man/man1/rvm.1.gz
179 # it appears that, because we build as root, rvm installs stuff in /etc on the build box
180 # which is not desirable, so let us get rid of that - don't worry if that fails
181 find /etc -name 'rvm*' | xargs rm || :
184 getent group %{rvm_group} >/dev/null || groupadd -r %{rvm_group}
188 %defattr(-,root,root)
189 %config(noreplace) /etc/rvmrc
190 %config(noreplace) /etc/profile.d/rvm.sh
191 %attr(-,root,%{rvm_group}) %{rvm_dir}
195 * Tue Jun 25 2013 Thierry Parmentelat - rvm-ruby-1.20.10-6
196 - add omf-rc in the mix
198 * Fri May 18 2013 Christoph Dwertmann - 4.xxx
199 - downloads RVM instead of relying on local sources
200 - works with latest RVM and Fedora
201 - removed ruby build dependency
202 - no more clashing with distribution ruby
204 * Fri Mar 30 2012 Alexandre Fouche - 3.xxx
205 Add some rubies and gems to compile:
206 - 1.9.2-p290 + bundler, bluepill, whenever
207 - 1.9.3-p0 + bundler, bluepill, whenever
209 * Thu Mar 29 2012 Alexandre Fouche - 2.xxx
210 - Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
211 - Strip binaries, libraries, ...
213 * Thu Mar 29 2012 Alexandre Fouche - 1.xxx
214 - Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
216 * Tue Dec 13 2011 Matthew Kent <mkent@magoazul.com> - 1.10.0-2
217 - New upstream release
219 - Rename rvm_user_install to rvm_user_install_flag
220 - Rename rake wrapper to rvm-rake
221 - Add file dependency
223 * Thu Aug 4 2011 Matthew Kent <mkent@magoazul.com> - 1.6.32-1
224 - New upstream release
226 * Tue Apr 19 2011 Matthew Kent <mkent@magoazul.com> - 1.6.3-1
227 - Initial package based off Gentoo work