bump taglevel
[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 $gemi omf_rc
122 #$gemi whatever_gem_you_need
123
124 #ruby_tag=ruby-1.8.7-p352
125 #rvm install $ruby_tag
126 #rvm use $ruby_tag
127 rvm cleanup all
128 )
129
130 export br=%{buildroot}
131
132 # Strip binaries
133 #find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep 'not stripped' |cut -f1 -d: |xargs -r strip
134
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
138   strip $f
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
143 done
144
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"
148
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"
154
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
161     dest=$(readlink $f)
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,,")
170         ln -sfn $destc $f
171     fi
172 done
173
174 find $br -maxdepth 1 -name '.*' -exec rm -rf {} \;
175 rm $br/usr/share/man/man1/rvm.1.gz
176
177 %clean
178 rm -rf %{buildroot}
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 || :
182
183 %pre
184 getent group %{rvm_group} >/dev/null || groupadd -r %{rvm_group}
185 exit 0
186
187 %files
188 %defattr(-,root,root)
189 %config(noreplace) /etc/rvmrc
190 %config(noreplace) /etc/profile.d/rvm.sh
191 %attr(-,root,%{rvm_group}) %{rvm_dir}
192 %{_mandir}/man1/*
193
194 %changelog
195 * Tue Jun 25 2013 Thierry Parmentelat - rvm-ruby-1.20.10-6
196 - add omf-rc in the mix
197
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
203
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
208
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, ...
212
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
215
216 * Tue Dec 13 2011 Matthew Kent <mkent@magoazul.com> - 1.10.0-2
217 - New upstream release
218 - Drop rvm_prefix
219 - Rename rvm_user_install to rvm_user_install_flag
220 - Rename rake wrapper to rvm-rake
221 - Add file dependency
222
223 * Thu Aug 4 2011 Matthew Kent <mkent@magoazul.com> - 1.6.32-1
224 - New upstream release
225
226 * Tue Apr 19 2011 Matthew Kent <mkent@magoazul.com> - 1.6.3-1
227 - Initial package based off Gentoo work