From Fedora Project Wiki
(Once save) |
(First draft) |
||
Line 16: | Line 16: | ||
beginning at [https://www.redhat.com/archives/fedora-packaging/2009-February/msg00113.html here] and continues to [https://www.redhat.com/archives/fedora-packaging/2009-March/msg00000.html this]. | beginning at [https://www.redhat.com/archives/fedora-packaging/2009-February/msg00113.html here] and continues to [https://www.redhat.com/archives/fedora-packaging/2009-March/msg00000.html this]. | ||
* When we want to apply some needed patches after expanding Gem files, with current guidelines <code>%patchXXX</code> macro canot be used because <code>%patchXXX</code> macro can be used only at %prep | * When we want to apply some needed patches after expanding Gem files, with current guidelines <code>%patchXXX</code> macro canot be used because <code>%patchXXX</code> macro can be used only at %prep | ||
* When we want to execute some check | * When we want to execute some check programs to verify if the Gems to be installed really work, we usually create <code>%check</code> stage and execute them at the stage. With current guidelines we must execute these check programs under <code>%{buildroot}</code>. | ||
** This is troublesome if executing such programs create additional files (under <code>%{buildroot}</code>) | ** This is troublesome if executing such programs create additional files (under <code>%{buildroot}</code>) | ||
* Note that when Gem file creates C extension libraries, we have already moved the stage to expand Gem file from <code>%install</code> to <code>%build</code> (not <code>%prep</code>, however) to create <code>debuginfo</code> rpm correctly. | * Note that when Gem file creates C extension libraries, we have already moved the stage to expand Gem file from <code>%install</code> to <code>%build</code> (not <code>%prep</code>, however) to create <code>debuginfo</code> rpm correctly. | ||
== Proposal == | == Proposal == | ||
All RubyGem files '''should''' be expanded at <code>%prep</code>. i.e. | All RubyGem files '''should''' be expanded at <code>%prep</code> first. i.e. | ||
* RubyGem files '''should''' be expanded under <code>%{_builddir}/%{name}-%{version}%{gemdir}</code> at prep first. This can usually be performed by the folloing lines: | * RubyGem files '''should''' be expanded under <code>%{_builddir}/%{name}-%{version}%{gemdir}</code> at prep first. This can usually be performed by the folloing lines: | ||
<pre> | <pre> | ||
%prep | %prep | ||
%setup -q -c T | %setup -q -c -T | ||
mkdir -p .%{gemdir} | mkdir -p .%{gemdir} | ||
(If RubyGem creates C extension modules, adding the following line | |||
( | is recommend: | ||
export CONFIGURE_ARGS="--with-cflags='%{optflags}'" | export CONFIGURE_ARGS="--with-cflags='%{optflags}'" | ||
) | ) | ||
gem install -V --local \ | gem install -V --local \ | ||
--install-dir $(pwd)/%{gemdir} \ | --install-dir $(pwd)/%{gemdir} \ | ||
Line 37: | Line 37: | ||
%{SOURCE0} | %{SOURCE0} | ||
</pre> | </pre> | ||
* <code>%build</code> stage can be empty. | |||
* Then at <code>%install</code> stage the whole tree under the directory created at <code>%prep stage</code> '''should''' be '''copied''' (not moved) to under <code>%{buildroot}%{gemdir}</code> by the following for example. | |||
<pre> | |||
%install | |||
rm -rf %{buildroot} | |||
mkdir -p %{buildroot}%{gemdir} | |||
cp -a .%{gemdir}/* %{buildroot}%{gemdir}/ | |||
</pre> | |||
* Executing some test program at <code>%check</code> stage is '''recommended''' if there exists. This can performed by the following for example: | |||
<pre> | |||
%global geminstdir %{gemdir}/gems/%{gemname}-%{version} | |||
BuildRequires: rubygem(rake) | |||
%check | |||
export GEM_PATH=.%{gemdir} | |||
pushd .%{geminstdir} | |||
rake test | |||
popd | |||
</pre> | |||
== Some notes == | |||
* There is an annoying discussion about whether expanding RubyGems should be at %prep or %build when Gem creates C extension modules. However as current Gem mechanism cannot allow for us to "expand" Gems and "build" them separately, I came to think that moving expansion stage from <code>%build</code> to <code>%prep</code> does not matter. |
Revision as of 16:41, 18 June 2009
Propoposal to change the stage to expand RubyGem file
Current guidelines
Current guidelines for packaging RubyGem files here says:
- The
%prep
and%build
sections of the specfile should be empty. - The install should be performed with the command
gem install --local --install-dir %{buildroot}%{gemdir} --force %{SOURCE0}
This means that
- usually RubyGem files should be expanded under
%{buildroot}
directly without using%prep
or%build
stage.
Issues with current guidelines
Some of the issues with current guidelines are already discussed on the thread beginning at here and continues to this.
- When we want to apply some needed patches after expanding Gem files, with current guidelines
%patchXXX
macro canot be used because%patchXXX
macro can be used only at %prep - When we want to execute some check programs to verify if the Gems to be installed really work, we usually create
%check
stage and execute them at the stage. With current guidelines we must execute these check programs under%{buildroot}
.- This is troublesome if executing such programs create additional files (under
%{buildroot}
)
- This is troublesome if executing such programs create additional files (under
- Note that when Gem file creates C extension libraries, we have already moved the stage to expand Gem file from
%install
to%build
(not%prep
, however) to createdebuginfo
rpm correctly.
Proposal
All RubyGem files should be expanded at %prep
first. i.e.
- RubyGem files should be expanded under
%{_builddir}/%{name}-%{version}%{gemdir}
at prep first. This can usually be performed by the folloing lines:
%prep %setup -q -c -T mkdir -p .%{gemdir} (If RubyGem creates C extension modules, adding the following line is recommend: export CONFIGURE_ARGS="--with-cflags='%{optflags}'" ) gem install -V --local \ --install-dir $(pwd)/%{gemdir} \ --force --rdoc \ %{SOURCE0}
%build
stage can be empty.- Then at
%install
stage the whole tree under the directory created at%prep stage
should be copied (not moved) to under%{buildroot}%{gemdir}
by the following for example.
%install rm -rf %{buildroot} mkdir -p %{buildroot}%{gemdir} cp -a .%{gemdir}/* %{buildroot}%{gemdir}/
- Executing some test program at
%check
stage is recommended if there exists. This can performed by the following for example:
%global geminstdir %{gemdir}/gems/%{gemname}-%{version} BuildRequires: rubygem(rake) %check export GEM_PATH=.%{gemdir} pushd .%{geminstdir} rake test popd
Some notes
- There is an annoying discussion about whether expanding RubyGems should be at %prep or %build when Gem creates C extension modules. However as current Gem mechanism cannot allow for us to "expand" Gems and "build" them separately, I came to think that moving expansion stage from
%build
to%prep
does not matter.