- Add the following sentences at the end of Ruby packages with binary content/shared libraries
For packages which create C shared libraries using extconf.rb
export CONFIGURE_ARGS="--with-cflags='%{optflags}'"
should be used to pass CFLAGS to Makefile correctly.
This also applies to Ruby Gems.
- Add the below section:
Ruby Gem with extension libraries written in C
When Ruby Gem contains extension libraries written in C,
- First,
%prepstage must contain%setup -q -c -Tto create the directory where C libraries are compiled. - Then at %build stage the Ruby Gem must be installed under the directory created at %prep stage to get C libraries compiled under there.
- When
gem installis used to install Gem file, using-Voption is recommend to check ifCFLAGSis correctly honored. - Finally at
%installstage the whole tree under the directory created at %prep stage should be copied (not moved) to under%{buildroot}%{gemdir}.- When all tree under the directory created at %prep stage is moved to under
%{buildroot},find_debuginfo.shwill complain that the corresponding source files are missing.
- When all tree under the directory created at %prep stage is moved to under
- Installed C codes (usually under
%{geminstdir}/etc) may be removed even ifgem contents %{gemname}reports that installed C codes should be found there.
If the Gem contains binary content (e.g., for a database driver), it must be marked as architecture specific, and all architecture specific content must be moved from the %{gemdir} to the [#ruby_sitearch %{ruby_sitearch} directory] during %install
Example
%prep
%setup -q -T -c
%build
mkdir -p ./%{gemdir}
export CONFIGURE_ARGS="--with-cflags='%{optflags}'"
gem install --local --install-dir ./%{gemdir} -V --force %{SOURCE0}
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}%{gemdir}
cp -a ./%{gemdir}/* %{buildroot}%{gemdir}
mkdir -p %{buildroot}%{ruby_sitearch}
mv %{buildroot}%{geminstdir}/lib/*.so %{buildroot}%{ruby_sitearch}
rm -rf %{buildroot}%{geminstdir}/ext
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%{ruby_sitearch}/*.so
%{geminstdir}/
%{gemdir}/cache/%{gemname}-%{version}.gem
%{gemdir}/specifications/%{gemname}-%{version}.gemspec
