9.2. RubyGems spec ファイルの規則
RubyGems の spec ファイルの構造例と、そのような spec ファイルを作成する際に従うべき具体的な事項を確認してください。
RubyGems の 仕様 ファイルは、以下の規則に従う必要があります。
-
ファイルには、gem の仕様からの名前である
%{gem_name}の定義が含まれています。 - パッケージのソースは、リリースされた gem アーカイブへの完全な URL である必要があります。
- パッケージのバージョンは gem のバージョンと同じである必要があります。
ファイルには次の
BuildRequires:ディレクティブが含まれています。BuildRequires: rubygems-develrubygems-develパッケージにはビルドに必要なマクロが含まれています。-
このファイルには、追加の
rubygem(foo)RequiresまたはProvidesディレクティブは含まれていません。これらのディレクティブは gem のメタデータから自動生成されるためです。
9.2.1. RubyGems spec ファイルの例 リンクのコピーリンクがクリップボードにコピーされました!
リンクのコピーリンクがクリップボードにコピーされました!
以下の、gem をビルドするためのサンプル 仕様 ファイルのうち、RubyGems 固有の部分の詳細を確認してください。なお、仕様 ファイルの残りの部分は、一般的な 仕様 ファイル作成ガイドラインに従っています。
例9.1 サンプル spec ファイルの RubyGems 固有の部分
%prep
%setup -q -n %{gem_name}-%{version}
# Modify the gemspec if necessary
# Also apply patches to code if necessary
%patch 0 -p1
%build
# Create the gem as gem install only works on a gem file
gem build ../%{gem_name}-%{version}.gemspec
# %%gem_install compiles any C extensions and installs the gem into ./%%gem_dir
# by default, so that we can move it into the buildroot in %%install
%gem_install
%install
mkdir -p %{buildroot}%{gem_dir}
cp -a ./%{gem_dir}/* %{buildroot}%{gem_dir}/
# If there were programs installed:
mkdir -p %{buildroot}%{_bindir}
cp -a ./%{_bindir}/* %{buildroot}%{_bindir}
# If there are C extensions, copy them to the extdir.
mkdir -p %{buildroot}%{gem_extdir_mri}
cp -a .%{gem_extdir_mri}/{gem.build_complete,*.so} %{buildroot}%{gem_extdir_mri}/