Bug 1315813 - inconsistent {%post,%pre}* -p behavior
Summary: inconsistent {%post,%pre}* -p behavior
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: 25
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Packaging Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-03-08 16:34 UTC by Kaleb KEITHLEY
Modified: 2016-10-12 09:24 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-10-12 09:24:33 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
xx.spec (655 bytes, text/plain)
2016-03-08 16:34 UTC, Kaleb KEITHLEY
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1312374 0 unspecified CLOSED glusterfs-libs postun scriptlet fail /sbin/ldconfig: relative path `1' used to build cache 2021-02-22 00:41:40 UTC
Red Hat Bugzilla 1315024 0 unspecified CLOSED glusterfs-libs postun scriptlet fail /sbin/ldconfig: relative path `1' used to build cache 2021-02-22 00:41:40 UTC

Internal Links: 1312374 1315024

Description Kaleb KEITHLEY 2016-03-08 16:34:06 UTC
Created attachment 1134247 [details]
xx.spec

Description of problem:

%post -p /sbin/ldconfig runs ldconfig differently if there's a following comment

Version-Release number of selected component (if applicable):

4.8 (rhel6), 4.11 (rhel7), 4.13 (f23) all do it.

How reproducible:


Steps to Reproduce:

using the attached xx.spec file

% cp xx.spec ~/rpmbuild/SPECS
% cd ~rpmbuild
% rpmbuild -ba SPECS/xx.spec
% rpm -vv -i RPMS/x86_64/xx-y-1.0-1.x86_64.rpm
notice that ldconfig runs successfully

% rpm -vv -i RPMS/x86_64/xx-y-1.0-1.x86_64.rpm
notice that ldconfig exits with an error and the error message
  /sbin/ldconfig: relative path `1' used to build cache

You can also strace them and see that installing xx-y runs ldconfig with a single argument ( ["/sbin/ldconfig ]), and installing xx-z runs ldconfig with three arguments ( ["/sbin/ldconfig", "/tmp/tmp.XXXXXX", "1" ] ). The /tmp/tmp.XXXXXX file contains the lines between the %post z -p ldconfile line and the %files line.


Actual results:


Expected results:


Additional info:

Comment 1 Ľuboš Kardoš 2016-03-09 14:24:26 UTC
Why this is happening is explained by Ville Skyttä in bug 1312374. Why the lines starting with "#" are not rpm comments in bodies of scripts? In scripts "#" can have other meaning than a begin of a comment and if in bodies of scripts the lines starting with "#" were rpm comments then it wouldn't be possible to put "#" into script. 

Yes this can be solved by escape characters but that is not implemented in rpm. Once it was implemented like this and now it is not easy to change that and preserve backward compatibility.

Comment 2 Ľuboš Kardoš 2016-03-09 14:38:31 UTC
One solution for this situation can be add a new parameter for scriptlets that would mean just use specified program and no script body follows after this line.

Comment 3 Kaleb KEITHLEY 2016-03-10 20:22:54 UTC
(In reply to Ľuboš Kardoš from comment #1)
> Why this is happening is explained by Ville Skyttä in bug 1312374. Why the
> lines starting with "#" are not rpm comments in bodies of scripts? In
> scripts "#" can have other meaning than a begin of a comment and if in
> bodies of scripts the lines starting with "#" were rpm comments then it
> wouldn't be possible to put "#" into script. 
> 
> Yes this can be solved by escape characters but that is not implemented in
> rpm. Once it was implemented like this and now it is not easy to change that
> and preserve backward compatibility.

Actually it was not, IMNSHO, explained very well in 1312374. Knowledge that only exists in the rpm developers heads is not useful to anyone. Repeating several times that # are not comments lines, when all the available documentation says it is, isn't a lot of help either.

This is too important of a tool for it to not be accurately documented.

Comment 4 Kaleb KEITHLEY 2016-03-10 20:27:47 UTC
(In reply to Ľuboš Kardoš from comment #2)
> One solution for this situation can be add a new parameter for scriptlets
> that would mean just use specified program and no script body follows after
> this line.

Isn't that what -p is for?

Why do two lines:

  %post y -p /sbin/ldconfig

  %post z -p /sbin/ldconfig

behave differently?

When even proven packagers tell us to use ... -p /sbin/ldconfig (in package reviews, e.g.) these things should work the same way. POLA (principle of least astonishment) would suggest to me that they would behave the same. When they don't, and the documentation doesn't explain why, then there's a problem.

Comment 5 Jan Kurik 2016-07-26 04:53:30 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 25 development cycle.
Changing version to '25'.

Comment 6 Panu Matilainen 2016-09-28 09:08:43 UTC
(In reply to Kaleb KEITHLEY from comment #4)
> (In reply to Ľuboš Kardoš from comment #2)
> > One solution for this situation can be add a new parameter for scriptlets
> > that would mean just use specified program and no script body follows after
> > this line.
> 
> Isn't that what -p is for?

No. -p is for specifying a different scriptlet interpreter from the default /bin/sh - think of for example -p /usr/bin/python or perl. In which case you certainly expect a scriptlet body to be there.

> Why do two lines:
> 
>   %post y -p /sbin/ldconfig
> 
>   %post z -p /sbin/ldconfig
> 
> behave differently?
> 
> When even proven packagers tell us to use ... -p /sbin/ldconfig (in package
> reviews, e.g.) these things should work the same way. POLA (principle of
> least astonishment) would suggest to me that they would behave the same.
> When they don't, and the documentation doesn't explain why, then there's a
> problem.

-p /sbin/ldconfig always was more of a hack / abuse rather than proper use of the feature - ldconfig is NOT a script interpreter so its up to the packager to ensure there is no body to the scriptlet because ldconfig cannot handle it.

See bug 564613 which is related in that section end markers are one solution to this issue:

%post y -p /sbin/ldconfig
# comment is considered %post body

%post z -p /sbin/ldconfig
%end
# comment is just a comment in a generic spec context

Comment 7 Panu Matilainen 2016-10-12 09:24:33 UTC
NOTABUG as explained above.


Note You need to log in before you can comment on or make changes to this bug.