we have swapped release and version, so this is required
[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 4
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 Requires: gcc-c++ patch readline readline-devel zlib-devel libyaml-devel libffi-devel openssl-devel autoconf automake libtool bison
32 # Used by the scripts
33 Requires: sed grep tar gzip bzip2 make file
34
35 %description
36 RVM is the Ruby Version Manager. It manages Ruby interpreter environments
37 and switching between them.
38
39 This package is meant for use by multiple users maintaining a shared copy of
40 RVM. Users added to the '%{rvm_group}' group will be able to modify all aspects
41 of RVM. These users will also have their default umask modified ("g+w") to allow
42 group write permission (usually resulting in a umask of "0002") in order to
43 ensure correct permissions for the shared RVM content.
44
45 RVM is activated for all logins by default. To disable remove
46 %{_sysconfdir}/profile.d/rvm.sh and source rvm from each users shell.
47
48 %install
49 rm -rf %{buildroot}
50
51 # Clean the env
52 for i in $(env | grep ^rvm_ | cut -d"=" -f1); do
53   unset $i;
54 done
55
56 # Install everything into one directory
57 (
58 export rvm_ignore_rvmrc=1 \
59   rvm_user_install_flag=0 \
60   rvm_path="%{buildroot}%{rvm_dir}" \
61   rvm_man_path="%{buildroot}%{_mandir}" \
62   HOME=%{buildroot}
63 \curl -L https://get.rvm.io | bash -s stable --version %{version}
64 )
65
66 # So members of the rvm group can write to it
67 find %{buildroot}%{rvm_dir} -exec chmod ug+w {} \;
68 find %{buildroot}%{rvm_dir} -type d -exec chmod g+s {} \;
69
70 mkdir -p %{buildroot}%{_sysconfdir}
71
72 # We use selfcontained so binaries end up in rvm/bin
73 cat > %{buildroot}%{_sysconfdir}/rvmrc <<END_OF_RVMRC
74 # Setup default configuration for rvm.
75 # If an rvm install exists in the home directory, don't load this.'
76 if [[ ! -s "\${HOME}/.rvm/scripts/rvm" ]]; then
77
78   # Only users in the rvm group need the umask modification
79   for i in \$(id -G -n); do
80     if [ \$i = "rvm" ]; then
81       umask g+w
82       break
83     fi
84   done
85
86   export rvm_user_install_flag=1
87   export rvm_path="%{rvm_dir}"
88 fi
89 END_OF_RVMRC
90
91 mkdir -p %{buildroot}%{_sysconfdir}/profile.d
92
93 cat > %{buildroot}%{_sysconfdir}/profile.d/rvm.sh <<END_OF_RVMSH
94 # rvm loading hook
95 #
96 if [ -s "\${HOME}/.rvm/scripts/rvm" ]; then
97   source "\${HOME}/.rvm/scripts/rvm"
98 elif [ -s "%{rvm_dir}/scripts/rvm" ]; then
99   source "%{rvm_dir}/scripts/rvm"
100 fi
101 END_OF_RVMSH
102
103 chmod 755 %{buildroot}%{_sysconfdir}/profile.d/rvm.sh
104
105 # At this point, install of RVM is finished
106 # Now install some rubies
107
108 # Run this in a subshell so the rvm loading does not infect our current shell.
109 (
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'
116
117 ruby_tag=ruby-1.9.3-p286
118 rvm install $ruby_tag
119 rvm use $ruby_tag
120 $gemi bundler
121 #$gemi whatever_gem_you_need
122
123 #ruby_tag=ruby-1.8.7-p352
124 #rvm install $ruby_tag
125 #rvm use $ruby_tag
126 rvm cleanup all
127 )
128
129 export br=%{buildroot}
130
131 # Strip binaries
132 #find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep 'not stripped' |cut -f1 -d: |xargs -r strip
133
134 # Strip and Fix bad paths in generated files
135 # That is not optimized, but that is not supposed to be done often
136 for f in $(find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': ELF' |cut -f1 -d:); do
137   strip $f
138   grep "$br" $f || continue
139   line=$(chrpath -l $f) || continue
140   echo $line |grep "$br" || continue
141   chrpath -r $(echo $line |cut -f2 -d= |sed "s,$br,,") $f
142 done
143
144 # Replace bad paths in text files
145 find $br -type f \( -name \*.log -o -name \*.la \) -print0 |xargs -0 -r sed -i "s,$br,,g"
146 find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': .* text' |cut -f1 -d: |xargs -r sed -i "s,$br,,g"
147
148 # Replace bad paths in all remaining files
149 # Padding with zeroes broke the LOAD_PATH in libruby, therefore prepend path with harmless forward slashes
150 printf -vch "%${#br}s" ""
151 slashes=$(printf "%s" "${ch// //}")
152 find $br -type f -print0 | xargs -0 sed -i "s,$br,$slashes,g"
153
154 # Fix symlinks with bad path
155 for f in $(find $br -type l |grep "$br"); do
156     ln -sfn $(readlink -f $f |sed "s,$br,,") $f
157 done
158
159 find $br -maxdepth 1 -name '.*' -exec rm -rf {} \;
160 rm $br/usr/share/man/man1/rvm.1.gz
161
162 %clean
163 rm -rf %{buildroot}
164
165 %pre
166 getent group %{rvm_group} >/dev/null || groupadd -r %{rvm_group}
167 exit 0
168
169 %files
170 %defattr(-,root,root)
171 %config(noreplace) /etc/rvmrc
172 %config(noreplace) /etc/profile.d/rvm.sh
173 %attr(-,root,%{rvm_group}) %{rvm_dir}
174 %{_mandir}/man1/*
175
176 %changelog
177 * Fri May 18 2013 Christoph Dwertmann - 4.xxx
178 - downloads RVM instead of relying on local sources
179 - works with latest RVM and Fedora
180 - removed ruby build dependency
181 - no more clashing with distribution ruby
182
183 * Fri Mar 30 2012 Alexandre Fouche - 3.xxx
184 Add some rubies and gems to compile:
185 - 1.9.2-p290 + bundler, bluepill, whenever
186 - 1.9.3-p0 + bundler, bluepill, whenever
187
188 * Thu Mar 29 2012 Alexandre Fouche - 2.xxx
189 - Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
190 - Strip binaries, libraries, ...
191
192 * Thu Mar 29 2012 Alexandre Fouche - 1.xxx
193 - Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
194
195 * Tue Dec 13 2011 Matthew Kent <mkent@magoazul.com> - 1.10.0-2
196 - New upstream release
197 - Drop rvm_prefix
198 - Rename rvm_user_install to rvm_user_install_flag
199 - Rename rake wrapper to rvm-rake
200 - Add file dependency
201
202 * Thu Aug 4 2011 Matthew Kent <mkent@magoazul.com> - 1.6.32-1
203 - New upstream release
204
205 * Tue Apr 19 2011 Matthew Kent <mkent@magoazul.com> - 1.6.3-1
206 - Initial package based off Gentoo work