Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.3.0

Request #6375 "pear makerpm" misc. improvements (rpm-depname, rpm-release options)
Submitted: 2005-12-30 14:01 UTC
From: bugs at timj dot co dot uk Assigned: timj
Status: Closed Package: PEAR_Command_Packaging
PHP Version: 5.1.1 OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2005-12-30 14:01 UTC] bugs at timj dot co dot uk
Description: ------------ The current "pear makerpm" code is good, but has some limitations. It: - internally duplicates code that works out the channel alias (from the channel name) when working out RPM package names. - does not support having virtual Provides, used by some distributions, that differ from the actual RPM package names - is limited in the options available for customising the RPM package name. A "%s" substitution in the rpm-pkgname option that is replaced with the package name allows for some customisation, but does not support (for example) RPM package naming conventions that substitute hyphens for underscores in package names. Additionally, a generic placeholder for the channel alias is not provided (e.g. "%C::%s" vs "PEAR::%s") which is significant for non PEAR/PECL channels, for which the "[channel]::[package]" format is hardcoded. - does not try to distinguish between PEAR and PECL when generating RPM names (actually, there is no way of doing this reliably as far as I can tell, though it is possible to make a guess that if that if the package name starts with a lowercase letter, it's PECL rather than PEAR) - does not provide an option to specify the RPM release version from the command line These issues have been identified as I have been working to build PEAR package RPMs that match Fedora Project naming conventions, which look something like the following for an example package "Some_Package" version "x.y.z" which requires "Other_Package" version "a.b.c": Name: php-pear-Some-Package Version: x.y.z Provides: php-pear(Some_Package) = x.y.z Requires: php-pear(Other_Package) >= a.b.c and, for PECL packages, the same with "php-pear" replaced with "php-pecl". At present, there is no way to achieve the above without hacking the PEAR source which is in itself not simple because the "[channel]::[package]" naming convention is assumed and hardcoded in several places. A desirable situation would be that it is possible to generate spec files with headers like the above simply by changing options on the command line, and additionally make it possible to make any further distribution-specific patches to the source clean and simple and touching as few lines as possible. To solve this, I developed a patch: http://www.timj.co.uk/linux/sources/php-pear-1.4.5-makerpm-cleanup.patch which cleans up the code slightly and generalises the generation of RPM package and dependency names. The patch mostly involves internal refactoring and is fully backwards-compatible and transparent from a user point of view; it does not change any existing functionality or defaults (with one exception, see [1]). Briefly, it: - Abstracts out the conversion of a channel name to a channel alias via the _getChannelAlias() function (i.e. purely internal refactoring). This simplifies some sections of code considerably by removing duplicated logic and facilitates clean distribution-specific patching. - Adds a CLI "rpm-depname" (-d) option, which allows specification of the format that is used for RPM dependency names. This is used for the generation of both "Provides" and "Requires" headers; a "Provides" header is generated if the rpm-depname format differs from the rpm-pkgname format. The Requires header is generated in any case but the format of this will be based on the rpm-depname option. The rpm-depname format is, by default, the same as the rpm-pkgname format which means that no additional "Provides" header is generated and "Requires" headers will be in the same format as before, matching existing behaviour. - Adds three additional sprintf-style substitution variables for both the rpm-pkgname and rpm-depname options: a) %S - same as the existing %s but with underscores in the package name replaced with hyphens b) %C - the channel alias c) %c - the channel alias, lowercased These should allow a lot more flexibility in package naming, and add support for naming like Fedora's, for which the rpm-pkgname and rpm-depname formats in the above syntax are "php-%c-%S" and "php-%c(%s)" respectively. At the same time, the default is modified from "PEAR::%s" to the generalised version "%C::%s" which has no practical effect since that's how PEAR worked by default in any case. - Abstracts out the generation of RPM names (for both the package itself and dependencies) via the _getRPMNameFromFormat() function - Adds a "-r"/"--rpm-release" option which defaults to 1 (as before) but allows the user to override the RPM release version which will be inserted into the spec file - Does a couple of trivial text tweaks: - remove comment about generating RPM deps, as this is now fixed :) - fix the "pear makerpm" example, which confusingly mixes up Net_Socket and Net_Geo [1]. One change that is made is that PECL packages detected as such will now have a channel alias of "PECL" rather than "PEAR", i.e. the RPM name will be "PECL::Package_Name" as opposed to "PEAR::Package_Name". However, this is academic since a) "pear makerpm" does not currently work for PECL packages (at least not for me) and b) using "PECL" rather than "PEAR" is probably a good thing anyway. Test script: --------------- pear makerpm --rpm-pkgname "php-%c-%S" --rpm-depname "php-%c(%s)" --rpm-release 3 HTTP-1.4.0.tgz && head -n 13 php-pear-HTTP-1.4.0.spec Expected result: ---------------- Summary: PEAR: Miscellaneous HTTP utilities Name: php-pear-HTTP Version: 1.4.0 Release: 3 License: PHP License Group: Development/Libraries Source: http://pear.php.net/get/HTTP-%{version}.tgz BuildRoot: %{_tmppath}/%{name}-root URL: http://pear.php.net/package/HTTP Prefix: %{_prefix} BuildArchitectures: noarch Provides: php-pear(HTTP) = 1.4.0 Requires: php-pear(PEAR)

Comments

 [2006-02-10 11:57 UTC] timj at php dot net
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.