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
9 Version: 3 # Version will be appended the commit date
12 URL: http://rvm.beginrescueend.com/
13 Group: Applications/System
14 #Source: %{name}-%{version}.tar
16 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
18 BuildRequires: bash curl git
19 BuildRequires: gcc-c++ patch chrpath readline readline-devel zlib-devel libyaml-devel libffi-devel openssl-devel
20 BuildRequires: sed grep tar gzip bzip2 make file ruby
22 Requires(pre): shadow-utils
24 Requires: bash curl git
25 # Basics for building ruby 1.8/1.9
26 #Requires: gcc-c++ patch readline readline-devel zlib-devel libyaml-devel libffi-devel openssl-devel
28 Requires: sed grep tar gzip bzip2 make file
31 RVM is the Ruby Version Manager (rvm). It manages Ruby interpreter environments
32 and switching between them.
34 This package is meant for use by multiple users maintaining a shared copy of
35 RVM. Users added to the '%{rvm_group}' group will be able to modify all aspects
36 of RVM. These users will also have their default umask modified ("g+w") to allow
37 group write permission (usually resulting in a umask of "0002") in order to
38 ensure correct permissions for the shared RVM content.
40 RVM is activated for all logins by default. To disable remove
41 %{_sysconfdir}/profile.d/rvm.sh and source rvm from each users shell.
49 for i in `env | grep ^rvm_ | cut -d"=" -f1`; do
54 # Install everything into one directory
55 export rvm_ignore_rvmrc=1 \
56 rvm_user_install_flag=0 \
57 rvm_path="%{buildroot}%{rvm_dir}" \
58 rvm_bin_path="%{buildroot}%{_bindir}" \
59 rvm_man_path="%{buildroot}%{_mandir}" \
61 \curl -L https://get.rvm.io | bash -s stable --version %{release}
65 # So members of the rvm group can write to it
66 find %{buildroot}%{rvm_dir} -exec chmod ug+w {} \;
67 find %{buildroot}%{rvm_dir} -type d -exec chmod g+s {} \;
69 mkdir -p %{buildroot}%{_sysconfdir}
71 # We use selfcontained so binaries end up in rvm/bin
72 cat > %{buildroot}%{_sysconfdir}/rvmrc <<END_OF_RVMRC
73 # Setup default configuration for rvm.
74 # If an rvm install exists in the home directory, don't load this.'
75 if [[ ! -s "\${HOME}/.rvm/scripts/rvm" ]]; then
77 # Only users in the rvm group need the umask modification
78 for i in \$(id -G -n); do
79 if [ \$i = "rvm" ]; then
85 export rvm_user_install_flag=1
86 export rvm_path="%{rvm_dir}"
90 mkdir -p %{buildroot}%{_sysconfdir}/profile.d
92 cat > %{buildroot}%{_sysconfdir}/profile.d/rvm.sh <<END_OF_RVMSH
95 if [ -s "\${HOME}/.rvm/scripts/rvm" ]; then
96 source "\${HOME}/.rvm/scripts/rvm"
97 elif [ -s "%{rvm_dir}/scripts/rvm" ]; then
98 source "%{rvm_dir}/scripts/rvm"
102 chmod 755 %{buildroot}%{_sysconfdir}/profile.d/rvm.sh
104 #mv %{buildroot}%{_bindir}/rake %{buildroot}%{_bindir}/rvm-rake
107 # At this point, install of RVM is finished
108 # Now install some rubies
110 # Run this in a subshell so the rvm loading does not infect our current shell.
112 export rvm_ignore_rvmrc=1
113 export rvm_user_install_flag=0
114 export rvm_path="%{buildroot}%{rvm_dir}"
115 export rvm_bin_path="%{buildroot}%{_bindir}"
116 export rvm_man_path="%{buildroot}%{_mandir}"
117 source ${rvm_path}/scripts/rvm
118 gemi='gem install --no-ri --no-rdoc'
120 #touch $rvm_path/RELEASE
121 ruby_tag=ruby-1.9.3-p286
122 rvm install $ruby_tag
126 #ruby_tag=ruby-1.8.7-p352
127 #rvm install $ruby_tag
131 export br=%{buildroot}
134 rm -rf $br/usr/lib/rvm/src
136 rm -rf $br/usr/lib/rvm/log/*
140 #find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep 'not stripped' |cut -f1 -d: |xargs -r strip
142 # Strip and Fix bad paths in generated files
143 # That is not optimized, but that is not supposed to be done often
144 for f in `find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': ELF' |cut -f1 -d:`; do
146 grep "$br" $f || continue
147 line=`chrpath -l $f` || continue
148 echo $line |grep "$br" || continue
149 chrpath -r `echo $line |cut -f2 -d= |sed "s,$br,,"` $f
152 # Replace bad paths in text files
153 find $br -type f \( -name \*.log -o -name \*.la \) -print0 |xargs -0 -r sed -i "s,$br,,g"
154 find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': .* text' |cut -f1 -d: |xargs -r sed -i "s,$br,,g"
156 # Strip object files in ar archives from bad path strings
157 for f in `find $br -type f -name \*.a`; do
162 for g in `find . -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': ELF' |cut -f1 -d:`; do
164 grep "$br" $g || continue
166 # Replace the bad path with the good one, padded by nulls
168 require "iconv" unless String.method_defined?(:encode)
169 if String.method_defined?(:encode)
170 $_.encode!("UTF-8", "UTF-8", :invalid => :replace)
172 ic = Iconv.new("UTF-8", "UTF-8//IGNORE")
175 $_.gsub!(/#{ENV["br"]}(.*?)\0/) do |s|
176 $1 + ( "\0" * ENV["br"].size ) + "\0"
186 # Replace paths in libraries strings
187 for f in `find $br/usr/lib/rvm/rubies -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': ELF' |cut -f1 -d:`; do
188 grep "$br" $f || continue
190 # Replace the bad path with the good one, padded by nulls
192 $_.encode!("UTF-8", "UTF-8", :invalid => :replace).gsub!(/#{ENV["br"]}(.*?)\0/) do |s|
193 $1 + ( "\0" * ENV["br"].size ) + "\0"
198 # Fix symlinks with bad path
199 for f in `find $br -type l |grep "$br"`; do
200 ln -sfn `readlink -f $f |sed "s,$br,,"` $f
203 find $br -maxdepth 1 -name '.*' -exec rm -rf {} \;
209 getent group %{rvm_group} >/dev/null || groupadd -r %{rvm_group}
213 %defattr(-,root,root)
214 %config(noreplace) /etc/rvmrc
215 %config(noreplace) /etc/profile.d/rvm.sh
216 %attr(-,root,%{rvm_group}) %{rvm_dir}
221 * Fri Mar 30 2012 Alexandre Fouche - 3.xxx
222 Add some rubies and gems to compile:
223 - 1.9.2-p290 + bundler, bluepill, whenever
224 - 1.9.3-p0 + bundler, bluepill, whenever
226 * Thu Mar 29 2012 Alexandre Fouche - 2.xxx
227 - Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
228 - Strip binaries, libraries, ...
230 * Thu Mar 29 2012 Alexandre Fouche - 1.xxx
231 - Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
233 * Tue Dec 13 2011 Matthew Kent <mkent@magoazul.com> - 1.10.0-2
234 - New upstream release
236 - Rename rvm_user_install to rvm_user_install_flag
237 - Rename rake wrapper to rvm-rake
238 - Add file dependency
240 * Thu Aug 4 2011 Matthew Kent <mkent@magoazul.com> - 1.6.32-1
241 - New upstream release
243 * Tue Apr 19 2011 Matthew Kent <mkent@magoazul.com> - 1.6.3-1
244 - Initial package based off Gentoo work