php-pear package build problem

TASAKA Mamoru mtasaka at
Mon Sep 12 15:57:38 UTC 2011

Pavel Alexeev (aka Pahan-Hubbitus) wrote, at 09/11/2011 01:01 AM +9:00:

> Now I change it on:
> %if %( php -r "echo (version_compare(PHP_VERSION, '5.3.0', '>=') ? 1 : 0);" &>/dev/null || echo 0 )
> but on make srpm got error:
> error: /home/pasha/SOFT/git/php-pecl-runkit/master/php-pecl-runkit.spec:74: parseExpressionBoolean returns -1
> error: query of specfile /home/pasha/SOFT/git/php-pecl-runkit/master/php-pecl-runkit.spec failed, can't parse
> Could not make an srpm: Could not parse the spec, exited 1
Because this php command succeeds (perhaps) and return status (of php) is 0. Then php -r prints
the result "1" to stdout but this is redirected to /dev/null. The latter || echo 0 is not
evaluated because php -r succeeds. So (with php installed) this is %if (empty) , and
rpmbuild cannot parse it.

> Obviously it because () in construction, but they in quotes!?
See above

> Changing it to:
> %if %( php -r "echo \(version_compare\(PHP_VERSION, '5.3.0', '>='\) ? 1 : 0\);" &>/dev/null || echo 0 )
> give me chance build package.
> See but it also doesn't work as intended,
> patches doesn't applied:
> <>

Because with this php command fails to understand the part \(....\)
(perhaps) and return status is non-zero (perhaps), so the latter || echo 0 is
evaluated. So this is "%if 0", and patches are not applied.

> If I redirecting to null only stderr and remove parenthesis escaping:
> %if %( php -r "echo (version_compare(PHP_VERSION, '5.3.0', '>=') ? 1 : 0);" 2>/dev/null || echo 0 )
> package also built: and rpm do
> what I want:
> <>
See the first case you wrote, This time the output of php -r command "1" printed out to
stdout is used so this is actually %if 1, so the result is as expected.

> So, it seams I completely don't understand rpm expression parsing logic:
> 1) Why "&>/dev/null" is incorrect? Independent on shell were it intended to be parsed,
> macros just should pass content of macros %() to shell and return string value. Or not?
See above

> 2) Why "&>/dev/null" became correct if I escape parenthesis (even if command really not work)?
I don't see the corresponding example you tried for this case.

> 3) Why initial command work before and not now? Is it bug or expected change?
I think the current behavior is expected.


More information about the devel mailing list