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: 4 # 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
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
53 # 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_man_path="%{buildroot}%{_mandir}" \
60 \curl -L https://get.rvm.io | bash -s stable --version %{release}
63 # So members of the rvm group can write to it
64 find %{buildroot}%{rvm_dir} -exec chmod ug+w {} \;
65 find %{buildroot}%{rvm_dir} -type d -exec chmod g+s {} \;
67 mkdir -p %{buildroot}%{_sysconfdir}
69 # We use selfcontained so binaries end up in rvm/bin
70 cat > %{buildroot}%{_sysconfdir}/rvmrc <<END_OF_RVMRC
71 # Setup default configuration for rvm.
72 # If an rvm install exists in the home directory, don't load this.'
73 if [[ ! -s "\${HOME}/.rvm/scripts/rvm" ]]; then
75 # Only users in the rvm group need the umask modification
76 for i in \$(id -G -n); do
77 if [ \$i = "rvm" ]; then
83 export rvm_user_install_flag=1
84 export rvm_path="%{rvm_dir}"
88 mkdir -p %{buildroot}%{_sysconfdir}/profile.d
90 cat > %{buildroot}%{_sysconfdir}/profile.d/rvm.sh <<END_OF_RVMSH
93 if [ -s "\${HOME}/.rvm/scripts/rvm" ]; then
94 source "\${HOME}/.rvm/scripts/rvm"
95 elif [ -s "%{rvm_dir}/scripts/rvm" ]; then
96 source "%{rvm_dir}/scripts/rvm"
100 chmod 755 %{buildroot}%{_sysconfdir}/profile.d/rvm.sh
102 #mv %{buildroot}%{_bindir}/rake %{buildroot}%{_bindir}/rvm-rake
105 # At this point, install of RVM is finished
106 # Now install some rubies
108 # Run this in a subshell so the rvm loading does not infect our current shell.
110 export rvm_ignore_rvmrc=1
111 export rvm_user_install_flag=0
112 export rvm_path="%{buildroot}%{rvm_dir}"
113 export rvm_man_path="%{buildroot}%{_mandir}"
114 source ${rvm_path}/scripts/rvm
115 gemi='gem install --no-ri --no-rdoc'
117 #touch $rvm_path/RELEASE
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
129 export br=%{buildroot}
132 rm -rf $br/usr/lib/rvm/src/*
134 rm -rf $br/usr/lib/rvm/log/*
137 #find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep 'not stripped' |cut -f1 -d: |xargs -r strip
139 # Strip and Fix bad paths in generated files
140 # That is not optimized, but that is not supposed to be done often
141 for f in `find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': ELF' |cut -f1 -d:`; do
143 grep "$br" $f || continue
144 line=`chrpath -l $f` || continue
145 echo $line |grep "$br" || continue
146 chrpath -r `echo $line |cut -f2 -d= |sed "s,$br,,"` $f
149 # Replace bad paths in text files
150 find $br -type f \( -name \*.log -o -name \*.la \) -print0 |xargs -0 -r sed -i "s,$br,,g"
151 find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': .* text' |cut -f1 -d: |xargs -r sed -i "s,$br,,g"
153 # courtesy http://everydaywithlinux.blogspot.com.au/2012/11/patch-strings-in-binary-files-with-sed.html
154 function patch_strings_in_file() {
157 local REPLACEMENT="$3"
159 # Find all unique strings in FILE that contain the pattern
160 STRINGS=$(strings ${FILE} | grep ${PATTERN} | sort -u -r)
162 if [ "${STRINGS}" != "" ] ; then
163 echo "File '${FILE}' contain strings with '${PATTERN}' in them:"
165 for OLD_STRING in ${STRINGS} ; do
166 # Create the new string with a simple bash-replacement
167 NEW_STRING=${OLD_STRING//${PATTERN}/${REPLACEMENT}}
169 # Create null terminated ASCII HEX representations of the strings
170 OLD_STRING_HEX="$(echo -n ${OLD_STRING} | xxd -g 0 -u -ps -c 256)00"
171 NEW_STRING_HEX="$(echo -n ${NEW_STRING} | xxd -g 0 -u -ps -c 256)00"
173 if [ ${#NEW_STRING_HEX} -le ${#OLD_STRING_HEX} ] ; then
174 # Pad the replacement string with null terminations so the
175 # length matches the original string
176 while [ ${#NEW_STRING_HEX} -lt ${#OLD_STRING_HEX} ] ; do
177 NEW_STRING_HEX="${NEW_STRING_HEX}00"
180 # Now, replace every occurrence of OLD_STRING with NEW_STRING
181 echo -n "Replacing ${OLD_STRING} with ${NEW_STRING}... "
182 hexdump -ve '1/1 "%.2X"' ${FILE} | \
183 sed "s/${OLD_STRING_HEX}/${NEW_STRING_HEX}/g" | \
184 xxd -r -p > ${FILE}.tmp
185 mv ${FILE}.tmp ${FILE}
188 echo "New string '${NEW_STRING}' is longer than old" \
189 "string '${OLD_STRING}'. Skipping."
195 # Strip object files in ar archives from bad path strings
196 for f in `find $br -type f -name \*.a`; do
201 for g in `find . -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': ELF' |cut -f1 -d:`; do
203 grep "$br" $g || continue
205 # Replace the bad path with the good one, padded by nulls
206 patch_strings_in_file $g "$br"
214 # Replace paths in libraries strings
215 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
216 grep "$br" $f || continue
218 # Replace the bad path with the good one, padded by nulls
219 patch_strings_in_file $f "$br"
222 # Fix symlinks with bad path
223 for f in `find $br -type l |grep "$br"`; do
224 ln -sfn `readlink -f $f |sed "s,$br,,"` $f
227 find $br -maxdepth 1 -name '.*' -exec rm -rf {} \;
228 rm $br/usr/share/man/man1/rvm.1.gz
234 getent group %{rvm_group} >/dev/null || groupadd -r %{rvm_group}
238 %defattr(-,root,root)
239 %config(noreplace) /etc/rvmrc
240 %config(noreplace) /etc/profile.d/rvm.sh
241 %attr(-,root,%{rvm_group}) %{rvm_dir}
245 * Fri May 18 2013 Christoph Dwertmann - 4.xxx
246 - downloads RVM instead of relying on local sources
247 - works with latest RVM and Fedora
248 - removed ruby build dependency
249 - no more clashing with distribution ruby
251 * Fri Mar 30 2012 Alexandre Fouche - 3.xxx
252 Add some rubies and gems to compile:
253 - 1.9.2-p290 + bundler, bluepill, whenever
254 - 1.9.3-p0 + bundler, bluepill, whenever
256 * Thu Mar 29 2012 Alexandre Fouche - 2.xxx
257 - Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
258 - Strip binaries, libraries, ...
260 * Thu Mar 29 2012 Alexandre Fouche - 1.xxx
261 - Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
263 * Tue Dec 13 2011 Matthew Kent <mkent@magoazul.com> - 1.10.0-2
264 - New upstream release
266 - Rename rvm_user_install to rvm_user_install_flag
267 - Rename rake wrapper to rvm-rake
268 - Add file dependency
270 * Thu Aug 4 2011 Matthew Kent <mkent@magoazul.com> - 1.6.32-1
271 - New upstream release
273 * Tue Apr 19 2011 Matthew Kent <mkent@magoazul.com> - 1.6.3-1
274 - Initial package based off Gentoo work