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