From Fedora Project Wiki

Revision as of 10:17, 18 July 2009 by Remi (talk | contribs) (→‎File Placement: - rephrase by tim)

[[TableOfContents(3)]

Proposed Changes to PHP Guidelines

Synopsis

This page describes items that need to be changed in the PHP Guidelines or other items that need to be reviewed or ratified by the Fedora Packaging Comittee and FESCo .


Actual Guidelines

Naming scheme

  • PECL packages from standard pecl channel should be named php-pecl-PECLPackageName-%{version}-%{release}.%{arch}.rpm.
  • PEAR packages from standard pear channel should be named php-pear-PEARPackageName-%{version}-%{release}.noarch.rpm.
  • CHANNEL packages should be named php-channel-ChannelAlias-%{version}-%{release}.noarch.rpm
  • Packages from another channel should be named php-ChannelAlias-PackageName-%{version}-%{release}.noarch.rpm.
  • Other packages should be named php-PackageName-%{version}-%{release}.%{arch}.rpm; %{arch} can be "noarch" where appropriate.

Please make sure that the PEAR package is correctly being built for noarch.

The PECLPackageName and the PEARPackageName should be consistent with the upstream naming scheme. The Crack PHP Extension would thus be named php-pecl-crack with the resulting packages being php-pecl-crack-0.4-1.i386.rpm and php-pecl-crack-0.4-1.src.rpm.

Note that web applications that happen to be written in PHP do not belong under the php-* namespace.

Change proposal (underscore/dash)

Naming scheme

  • PECL packages from standard pecl channel "Package_Name" should be named php-pecl-Package-Name-%{version}-%{release}.%{arch}.rpm.
  • PEAR packages from standard pear channel "Package_Name" should be named php-pear-Package-Name-%{version}-%{release}.noarch.rpm.
  • CHANNEL packages should be named php-channel-ChannelAlias-%{version}-%{release}.noarch.rpm
  • Packages from another channel should be named php-ChannelAlias-PackageName-%{version}-%{release}.noarch.rpm.
  • Other packages should be named php-PackageName-%{version}-%{release}.%{arch}.rpm; %{arch} can be "noarch" where appropriate.

Please, note that an underscore in upstream name should be replace by a dash in package name.

Please make sure that the PEAR package is correctly being built for noarch.

The PECLPackageName and the PEARPackageName should be consistent with the upstream naming scheme. The Crack PHP Extension would thus be named php-pecl-crack with the resulting packages being php-pecl-crack-0.4-1.i386.rpm and php-pecl-crack-0.4-1.src.rpm.

Note that web applications that happen to be written in PHP do not belong under the php-* namespace.


Actual Guidelines

File Placement

Non-PEAR PHP extensions should put their Class files in /usr/share/php.


Change proposal (subfolder)

File Placement

Non-PEAR PHP software which provides shared libraries should put its PHP source files for such shared libraries in a subfolder of /usr/share/php, named according to the name of the software. For example, a library called "Whizz_Bang" (with a RPM called php-something-Whizz-Bang) would put the PHP source files for its shared libraries in /usr/share/php/Whizz_Bang.

Actual Guidelines

Requires and Provides

PECL Packages

A PECL package MUST have:

BuildRequires: php-devel, php-pear
Requires(post): %{__pecl}
Requires(postun): %{__pecl}

%if %{?php_zend_api}0
Requires:     php(zend-abi) = %{php_zend_api}
Requires:     php(api) = %{php_core_api}
%else
Requires:     php-api = %{php_apiver}
%endif

Provides:     php-pecl(foo) = %{version}


Change proposal (ABI Check)

Requires and Provides

C extensions (PECL and others)

Each C extension instantiate a zend_module_entry with the ZEND_MODULE_API_NO constant. PHP check that the value for the extension is egal to the value for PHP (standard ABI check).

A C extension MUST have:

BuildRequires: php-devel
%if %{?php_zend_api}0
Requires:     php(zend-abi) = %{php_zend_api}
Requires:     php(api) = %{php_core_api}
%else
Requires:     php-api = %{php_apiver}
%endif

Condition around Requires could be removed if the extension requires php >= 5.2.0, where php_zend_api always defined. So it is only mandatory for EPEL packages.

PECL Packages

PECL extension MUST have ABI check (see previous)

A PECL package MUST also have:

BuildRequires: php-pear
Requires(post): %{__pecl}
Requires(postun): %{__pecl}

Provides:     php-pecl(foo) = %{version}


Actual Guidelines

Macros and scriptlets

PECL Modules

The php-pear package in Fedora Core 5 and above (version 1:1.4.9-1.2) provides several useful macros:

  • %{pecl_phpdir}
  • %{pecl_docdir}
  • %{pecl_testdir}
  • %{pecl_datadir}
  • %{pecl_xmldir}

You may need to define a few additional macros to extract some information from PHP. It is recommended that you use the following:

%global php_apiver  %((echo 0; php -i 2>/dev/null | sed -n 's/^PHP API => //p') | tail -1)
%{!?__pecl:     %{expand: %%global __pecl     %{_bindir}/pecl}}
%{!?php_extdir: %{expand: %%global php_extdir %(php-config --extension-dir)}}

And here are some recommended scriptlets for properly registering and unregistering the module:

%if 0%{?pecl_install:1}
%post
%{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || :
%endif


%if 0%{?pecl_uninstall:1}
%postun
if [ $1 -eq 0 ]  ; then
%{pecl_uninstall} %{pecl_name} >/dev/null || :
fi
%endif

Change proposal (just a additional comment)

Conditions around the post/postun scriplets can be removed if the extension requires php >= 5.2.0, where pecl_install always defined. So it is only mandatory for EPEL packages.