= SPEC の書き方 Tips = == with/without を使った条件分岐 == bcond_with または bcond_without を使うことで、条件ビルドの spec への記述が書きやすくなり、 rpmbuild への --with/--without スイッチで機能の追加削除の選択ができるようになります。 * {{{%bcond_with foo}}} は rpmbuild で --with foo が指定されていた場合に with_foo が定義される。 * {{{%bcond_without foo}}} は rpmbuild で --without foo が指定されて'''いない'''限り with_foo が定義される。 例:[[BR]] 以下の例ではデフォルトでビルドした場合は bar のみが定義されます。 {{{ %bcond_with foo %bcond_without bar %if %{with foo} BuildRequires: foo-devel %endif %if %{with bar} BuildRequires: bar-devel %endif %configure .... \ %{?with_foo:--with-foo} \ %{?with_bar:--with-bar} }}} == %{?_dist_release} による条件分岐 == `%if` における条件式内の論理積と論理和は、 それぞれ `&&`, `||` を用います。 シェルスクリプトの `if` 文における条件式内の論理積 `-a`、 論理和 `-o` と間違って使いかねないので、注意が必要です。 {{{ %if %{?_dist_release} == "vl5" || %{?_dist_release} == "vl6" Requires: mesa-libGL Requires(post): xorg-x11-devel Requires(post): mesa-libGL-devel %endif %if %{?_dist_release} == "vl4" Requires: XOrg-gl Requires(post): XOrg-devel Requires(post): XOrg-gl-devel %endif %if "%{?_dist_release}" >= "vl7" BuildRequires: vala-devel >= 0.18 %endif }}}