Truncated history
[rvm-ruby.git] / rpm / rvm-ruby.spec
1 %global rvm_dir /usr/lib/rvm
2 %global rvm_group rvm
3
4 # RVM can not be sourced with default /bin/sh
5 %define _buildshell /bin/bash
6
7 Name: rvm-ruby
8 Summary: Ruby Version Manager
9 Version: 3  # Version will be appended the commit date
10 Release: 1.el6_CS
11 License: ASL 2.0
12 URL: http://rvm.beginrescueend.com/
13 Group: Applications/System
14
15 Source: %{name}-%{version}.tar
16
17 #BuildArch: noarch
18 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
19
20 BuildRequires: bash curl git
21 BuildRequires: gcc-c++ patch chrpath readline readline-devel zlib-devel libyaml-devel libffi-devel openssl-devel
22 BuildRequires: sed grep tar gzip bzip2 make file
23
24 Requires(pre): shadow-utils
25 # For rvm
26 Requires: bash curl git
27 # Basics for building ruby 1.8/1.9
28 Requires: gcc-c++ patch readline readline-devel zlib-devel libyaml-devel libffi-devel openssl-devel
29 # Used by the scripts
30 Requires: sed grep tar gzip bzip2 make file
31
32 %description
33 RVM is the Ruby Version Manager (rvm). It manages Ruby interpreter environments
34 and switching between them.
35
36 This package is meant for use by multiple users maintaining a shared copy of
37 RVM. Users added to the '%{rvm_group}' group will be able to modify all aspects
38 of RVM. These users will also have their default umask modified ("g+w") to allow
39 group write permission (usually resulting in a umask of "0002") in order to
40 ensure correct permissions for the shared RVM content.
41
42 RVM is activated for all logins by default. To disable remove
43 %{_sysconfdir}/profile.d/rvm.sh and source rvm from each users shell.
44
45 Rubies in this package:
46 ruby-1.9.3-p0
47   bundler
48   bluepill
49   whenever
50
51 ruby-1.9.2-p290
52   bundler
53   bluepill
54   whenever
55
56
57 %prep
58 %setup -q
59
60 %build
61
62 %install
63 rm -rf %{buildroot}
64
65 # Clean the env
66 for i in `env | grep ^rvm_ | cut -d"=" -f1`; do
67   unset $i;
68 done
69
70 # Install everything into one directory
71 rvm_ignore_rvmrc=1 \
72   rvm_user_install_flag=0 \
73   rvm_path="%{buildroot}%{rvm_dir}" \
74   rvm_bin_path="%{buildroot}%{_bindir}" \
75   rvm_man_path="%{buildroot}%{_mandir}" \
76   ./install
77
78 # So members of the rvm group can write to it
79 find %{buildroot}%{rvm_dir} -exec chmod ug+w {} \;
80 find %{buildroot}%{rvm_dir} -type d -exec chmod g+s {} \;
81
82 mkdir -p %{buildroot}%{_sysconfdir}
83
84 # We use selfcontained so binaries end up in rvm/bin
85 cat > %{buildroot}%{_sysconfdir}/rvmrc <<END_OF_RVMRC
86 # Setup default configuration for rvm.
87 # If an rvm install exists in the home directory, don't load this.'
88 if [[ ! -s "\${HOME}/.rvm/scripts/rvm" ]]; then
89
90   # Only users in the rvm group need the umask modification
91   for i in \$(id -G -n); do
92     if [ \$i = "rvm" ]; then
93       umask g+w
94       break
95     fi
96   done
97
98   export rvm_user_install_flag=1
99   export rvm_path="%{rvm_dir}"
100 fi
101 END_OF_RVMRC
102
103 mkdir -p %{buildroot}%{_sysconfdir}/profile.d
104
105 cat > %{buildroot}%{_sysconfdir}/profile.d/rvm.sh <<END_OF_RVMSH
106 # rvm loading hook
107 #
108 if [ -s "\${HOME}/.rvm/scripts/rvm" ]; then
109   source "\${HOME}/.rvm/scripts/rvm"
110 elif [ -s "%{rvm_dir}/scripts/rvm" ]; then
111   source "%{rvm_dir}/scripts/rvm"
112 fi
113 END_OF_RVMSH
114
115 chmod 755 %{buildroot}%{_sysconfdir}/profile.d/rvm.sh
116
117 mv %{buildroot}%{_bindir}/rake %{buildroot}%{_bindir}/rvm-rake
118
119
120 # At this point, install of RVM is finished
121 # Now install some rubies
122
123 # Run this in a subshell so the rvm loading does not infect our current shell.
124 (
125 export rvm_ignore_rvmrc=1
126 export rvm_user_install_flag=0
127 export rvm_path="%{buildroot}%{rvm_dir}"
128 export rvm_bin_path="%{buildroot}%{_bindir}"
129 export rvm_man_path="%{buildroot}%{_mandir}"
130 source ${rvm_path}/scripts/rvm
131 gemi='gem install --no-ri --no-rdoc'
132
133 ruby_tag=ruby-1.9.3-p0
134 rvm install $ruby_tag
135 rvm use $ruby_tag
136 $gemi bundler
137 $gemi whenever
138 $gemi bluepill
139
140 ruby_tag=ruby-1.9.2-p290
141 rvm install $ruby_tag
142 rvm use $ruby_tag
143 $gemi bundler
144 $gemi whenever
145 $gemi bluepill
146
147 #ruby_tag=ruby-1.8.7-p352
148 #rvm install $ruby_tag
149 #rvm use $ruby_tag
150 )
151
152 export br=%{buildroot}
153
154 # Remove sources
155 rm -rf $br/usr/lib/rvm/src
156
157 # Strip binaries
158 #find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep 'not stripped' |cut -f1 -d: |xargs -r strip
159
160 # Strip and Fix bad paths in generated files
161 # That is not optimized, but that is not supposed to be done often
162 for f in `find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': ELF' |cut -f1 -d:`; do
163   strip $f
164   grep "$br" $f || continue
165   line=`chrpath -l $f` || continue
166   echo $line |grep "$br" || continue
167   chrpath -r `echo $line |cut -f2 -d= |sed "s,$br,,"` $f
168 done
169
170 # Replace bad paths in text files
171 find $br -type f \( -name \*.log -o -name \*.la \) -print0 |xargs -0 -r sed -i "s,$br,,g"
172 find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': .* text' |cut -f1 -d: |xargs -r sed -i "s,$br,,g"
173
174 # Strip object files in ar archives from bad path strings
175 for f in `find $br -type f -name \*.a`; do
176   td=`mktemp -d`
177   pushd $td
178   ar x $f
179
180   for g in `find . -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': ELF' |cut -f1 -d:`; do
181     strip $g
182     grep "$br" $g || continue
183
184     # Replace the bad path with the good one, padded by nulls
185     ruby -p -i -e '
186       $_.gsub!(/#{ENV["br"]}(.*?)\0/) do |s|
187       $1 + ( "\0" * ENV["br"].size ) + "\0"
188       end
189     ' $g
190   done
191
192   ar r $f *
193   popd
194   rm -rf $td
195 done
196
197 # Replace paths in libraries strings
198 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
199   grep "$br" $f || continue
200
201   # Replace the bad path with the good one, padded by nulls
202   ruby -p -i -e '
203     $_.gsub!(/#{ENV["br"]}(.*?)\0/) do |s|
204     $1 + ( "\0" * ENV["br"].size ) + "\0"
205     end
206   ' $f
207 done
208
209 # Fix symlinks with bad path
210 for f in `find $br -type l |grep "$br"`; do
211     ln -sf `readlink -f $f |sed "s,$br,,"` $f
212 done
213
214
215 %clean
216 rm -rf %{buildroot}
217
218 %pre
219 getent group %{rvm_group} >/dev/null || groupadd -r %{rvm_group}
220 exit 0
221
222 %files
223 %defattr(-,root,root)
224 %config(noreplace) /etc/rvmrc
225 %config(noreplace) /etc/profile.d/rvm.sh
226 %attr(-,root,%{rvm_group}) %{rvm_dir}
227 %{_bindir}
228 %{_mandir}/man1/*
229
230 %changelog
231 * Fri Mar 30 2012 Alexandre Fouche - 3.xxx
232 Add some rubies and gems to compile:
233 - 1.9.2-p290 + bundler, bluepill, whenever
234 - 1.9.3-p0 + bundler, bluepill, whenever
235
236 * Thu Mar 29 2012 Alexandre Fouche - 2.xxx
237 - Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
238 - Strip binaries, libraries, ...
239
240 * Thu Mar 29 2012 Alexandre Fouche - 1.xxx
241 - Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
242
243 * Tue Dec 13 2011 Matthew Kent <mkent@magoazul.com> - 1.10.0-2
244 - New upstream release
245 - Drop rvm_prefix
246 - Rename rvm_user_install to rvm_user_install_flag
247 - Rename rake wrapper to rvm-rake
248 - Add file dependency
249
250 * Thu Aug 4 2011 Matthew Kent <mkent@magoazul.com> - 1.6.32-1
251 - New upstream release
252
253 * Tue Apr 19 2011 Matthew Kent <mkent@magoazul.com> - 1.6.3-1
254 - Initial package based off Gentoo work