Creates an 'omf' gemset
[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 # PL conventions
8 %define name rvm-ruby
9 # pick a RVM version from https://github.com/wayneeseguin/rvm/tags
10 %define version 1.20.10
11 %define taglevel 6
12 %define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
13
14 Summary: Ruby Version Manager (including Rubies and Gems)
15 Name: %{name}
16 Version: %{version}
17 Release: %{release}
18 License: ASL 2.0
19 URL: http://rvm.io/
20 Group: Applications/System
21 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
22
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
26
27 Requires(pre): shadow-utils
28 # For rvm
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
33 # Used by the scripts
34 Requires: sed grep tar gzip bzip2 make file
35
36 %description
37 RVM is the Ruby Version Manager. It manages Ruby interpreter environments
38 and switching between them.
39
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.
45
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.
48
49 %install
50 rm -rf %{buildroot}
51
52 # Clean the env
53 for i in $(env | grep ^rvm_ | cut -d"=" -f1); do
54   unset $i;
55 done
56
57 # Install everything into one directory
58 (
59 export rvm_ignore_rvmrc=1 \
60   rvm_user_install_flag=0 \
61   rvm_path="%{buildroot}%{rvm_dir}" \
62   rvm_man_path="%{buildroot}%{_mandir}" \
63   HOME=%{buildroot}
64 \curl -L https://get.rvm.io | bash -s stable --version %{version}
65 )
66
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 {} \;
70
71 mkdir -p %{buildroot}%{_sysconfdir}
72
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
78
79   # Only users in the rvm group need the umask modification
80   for i in \$(id -G -n); do
81     if [ \$i = "rvm" ]; then
82       umask g+w
83       break
84     fi
85   done
86
87   export rvm_user_install_flag=1
88   export rvm_path="%{rvm_dir}"
89 fi
90 END_OF_RVMRC
91
92 mkdir -p %{buildroot}%{_sysconfdir}/profile.d
93
94 cat > %{buildroot}%{_sysconfdir}/profile.d/rvm.sh <<END_OF_RVMSH
95 # rvm loading hook
96 #
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"
101 fi
102 END_OF_RVMSH
103
104 chmod 755 %{buildroot}%{_sysconfdir}/profile.d/rvm.sh
105
106 # At this point, install of RVM is finished
107 # Now install some rubies
108
109 # Run this in a subshell so the rvm loading does not infect our current shell.
110 (
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'
117
118 ruby_tag=ruby-1.9.3-p286
119 rvm install $ruby_tag
120 rvm use $ruby_tag
121 rvm gemset create omf
122 rvm use $ruby_tag@omf
123 $gemi omf_rc
124 #$gemi whatever_gem_you_need
125
126 #ruby_tag=ruby-1.8.7-p352
127 #rvm install $ruby_tag
128 #rvm use $ruby_tag
129 rvm cleanup all
130 )
131
132 export br=%{buildroot}
133
134 # Strip binaries
135 #find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep 'not stripped' |cut -f1 -d: |xargs -r strip
136
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
140   strip $f
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
145 done
146
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"
150
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"
156
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
163     dest=$(readlink $f)
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,,")
172         ln -sfn $destc $f
173     fi
174 done
175
176 find $br -maxdepth 1 -name '.*' -exec rm -rf {} \;
177 rm $br/usr/share/man/man1/rvm.1.gz
178
179 %clean
180 rm -rf %{buildroot}
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 || :
184
185 %pre
186 getent group %{rvm_group} >/dev/null || groupadd -r %{rvm_group}
187 exit 0
188
189 %files
190 %defattr(-,root,root)
191 %config(noreplace) /etc/rvmrc
192 %config(noreplace) /etc/profile.d/rvm.sh
193 %attr(-,root,%{rvm_group}) %{rvm_dir}
194 %{_mandir}/man1/*
195
196 %changelog
197 * Tue Jun 25 2013 Thierry Parmentelat - rvm-ruby-1.20.10-6
198 - add omf-rc in the mix
199
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
205
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
210
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, ...
214
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
217
218 * Tue Dec 13 2011 Matthew Kent <mkent@magoazul.com> - 1.10.0-2
219 - New upstream release
220 - Drop rvm_prefix
221 - Rename rvm_user_install to rvm_user_install_flag
222 - Rename rake wrapper to rvm-rake
223 - Add file dependency
224
225 * Thu Aug 4 2011 Matthew Kent <mkent@magoazul.com> - 1.6.32-1
226 - New upstream release
227
228 * Tue Apr 19 2011 Matthew Kent <mkent@magoazul.com> - 1.6.3-1
229 - Initial package based off Gentoo work