Bug 192506

Summary: rpmlint incorrectly sees comments as code in %post and %postun
Product: [Fedora] Fedora Reporter: Chris Petersen <lists>
Component: rpmlintAssignee: Ville Skyttä <scop>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 5CC: extras-qa
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-05-20 07:19:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Chris Petersen 2006-05-20 06:44:24 UTC
Description of problem:

rpmlint incorrectly sees comments as code in %post and %postun

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

0.76

How reproducible:

always

Steps to Reproduce:

see http://forevermore.net/files/packages/lineak/lineakd.spec

I use long strings of comment characters to separate files in some of the more
complex specs I produce.  To keep consistent, I add them to the simpler ones,
too (I think it makes the a LOT easier to read).

Anyway, the comments around %post and %postun produce the following errors from
rpmlint:

E: lineakd postin-without-ldconfig /usr/lib64/liblineak.so.0.8.0
E: lineakd postun-without-ldconfig /usr/lib64/liblineak.so.0.8.0
E: lineakd non-empty-%post /sbin/ldconfig
W: lineakd one-line-command-in-%post ####################################
E: lineakd non-empty-%postun /sbin/ldconfig
W: lineakd one-line-command-in-%postun ####################################

(I've shortened that #### stuff to make it fir on one line here)

Removing the comment lines after %post and %postun clears up the problem, as
does replacing:

   %post -n /sbin/ldconfig

with:

   %post
   /sbin/ldconfig

(and the same with %postun)

Anyway, seems prudent to me to ignore non-executable comments in those fields
(whether separators or actual comments) before warning or erroring out about them.

Just for reference, this spec is from a pending package for extras:

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=191604

Comment 1 Chris Petersen 2006-05-20 07:02:05 UTC
Turns out that the problematic formatting mentioned above also causes script
execution errors during rpm installation and removal.

Since I'm trying to update this package to work, I've replaced the broken script
with one that works...

Works:   http://forevermore.net/files/packages/lineak/lineakd.spec
Broken:  http://forevermore.net/files/packages/lineak/lineakd.brokenscript.spec

The only difference between these (for now) is that I applied the fix I
mentioned above.

Anyway, I still think this is a bug, but obviously extends beyond just rpmlint.
 Feel free to close this or move it over to rpm as needed.

Comment 2 Ville Skyttä 2006-05-20 07:19:55 UTC
Try running "rpm -q --specfile lineakd.spec --scripts" on your specfile.

The problem with those comments is that they get passed on to the corresponding
script interpreter (/bin/bash by default, /sbin/ldconfig if you use eg. %post -p
/sbin/ldconfig).  So depending on the interpreter, they may not be actually
comments, and some versions of ldconfig at least used to choke on things like
"###########" being fed to it.

So, you're looking for comment syntax for specfiles.  As far as I know, such a
thing doesn't not exist.

When you don't use the %post -p /sbin/ldconfig syntax, your %post script is
executed with the default script interpreter, /bin/bash.  ######... is a comment
in bash, so it works.  However, because you're not using the %post -p
/sbin/ldconfig syntax, rpmbuild won't autogenerate the dependency on
/sbin/ldconfig for your %post and friends scripts, and results in a unneeded
shell invocation to run your one-liner script, which is why rpmlint whines about
one line commands in scriptlets and asks one to use the -p syntax instead.