21. Mai 2011


In: Allgemein, OpenSUSE, Tech

Kommentare deaktiviert für Howto: Packaging 3rd party pear channel software with %php_pear_gen_filelist macro

The %php_pear_gen_filelist macro, maintained by Christian Wittmer, is really handy for packaging php pear software packages. It generates rpmlint-happy filelists and if you manage to get the dependencies right, packaging pear stuff for rpm is really a no-brainer. But the standard recipe for using this macro has one drawback: It’s ignorant of installed 3rd party roles and channels. 3rd party pear packages which depend on their channel being registered normally fail.

The workaround is easy: Copy the channel file to the build location.


# spec file for package php5-pear-Horde_Auth (Version 1.0.3)
# Copyright (c) 2011 Ralf Lang.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An „Open Source License“ is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative
# Please submit bugfixes or comments via http://bugs.opensuse.org/

# norootforbuild

Name: php5-pear-Horde_Auth
%define pear_name Horde_Auth
%define pear_sname horde_auth
Summary: PEAR: Horde Authentication API
Version: 1.0.3
Release: 1
License: LGPL
Group: Development/Libraries/PHP
Source0: http://pear.horde.org/get/Horde_Auth-%{version}.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-root-%(%{__id_u} -n)
URL: http://pear.horde.org/package/Horde_Auth
BuildRequires: php5-pear >= 1.4.7
Requires: php5-pear-Horde_Exception < 2.0.0, php5-pear-Horde_Util < 2.0.0, php5-pear >= 1.7.0
Conflicts: php5-pear-Horde_Exception = 2.0.0, php5-pear-Horde_Util = 2.0.0
BuildRequires: php5-pear-channel-horde
Requires: php5-pear-channel-horde
BuildArch: noarch
BuildRequires: php-macros

# Fix for renaming (package convention)
Provides: php5-pear-%{pear_sname} = %{version}
Provides: php-pear-%{pear_sname} = %{version}
Provides: pear-%{pear_sname} = %{version}
Obsoletes: php5-pear-%{pear_sname} < %{version}
Obsoletes: php-pear-%{pear_sname} < %{version}
Obsoletes: pear-%{pear_sname} < %{version}

The Horde_Auth package provides a common interface into the various
backends for the Horde authentication system.

%setup -c

%{__mv} package*.xml %{pear_name}-%{version}
cd %{pear_name}-%{version}
PHP_PEAR_PHP_BIN=“$(which php) -d memory_limit=50m“
%{__mkdir_p} %{buildroot}%{php_peardir}/.channels/
%{__cp} %{php_peardir}/.channels/pear.horde.org.reg \

%{__pear} -v \
-d doc_dir=/doc \
-d bin_dir=%{_bindir} \
-d data_dir=%{php_peardir}/data \
-d test_dir=%{php_peardir}/tests \
install –offline –nodeps -R „%{buildroot}“ package.xml

%{__install} -D -m 0644 package.xml %{buildroot}%{php_pearxmldir}/%{pear_name}.xml

%{__rm} -rf %{buildroot}/{doc,tmp}
%{__rm} -rf %{buildroot}%{php_peardir}/.{filemap,lock,registry,channels,depdb,depdblock}

cd ..


rm -rf %{buildroot}

if [ „$1“ = „1“ ]; then
%{__pear} install –nodeps –soft –force –register-only %{php_pearxmldir}/%{pear_name}.xml
if [ „$1“ = „2“ ]; then
%{__pear} upgrade –offline –register-only %{php_pearxmldir}/%{pear_name}.xml

if [ „$1“ = „0“ ]; then
%{__pear} uninstall –nodeps –ignore-errors –register-only pear.horde.org/%{pear_name}

%files -f %{name}.files

Two parts are marked black: First you have to include the channel package with „BuildRequires:“. Second marked part copies the channel file from the installed location to the buildroot location.
Feel free to reuse or criticise this solution.

Tags: , , , , ,