Archive:PackagingDrafts/RubyGem with C code spot


 * Add the following sentences at the end of Ruby packages with binary content/shared libraries

For packages which create C shared libraries using export CONFIGURE_ARGS="--with-cflags='%{optflags}'" should be used to pass  to   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,  stage must contain   to 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  is used to install Gem file, using   option is recommend to check if   is correctly honored.
 * Finally at  stage the whole tree under the directory created at %prep stage should be copied (not moved) to under.
 * When all tree under the directory created at %prep stage is moved to under,   will complain that the corresponding source files are missing.
 * Installed C codes (usually under ) may be removed even if   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