#34 Syntax check in 'spec' file

1.6
wont-fix
nobody
2014-08-21
2014-05-31
kdg1955
No

Hi,

Some syntax errors in the spec file that are not recognized by rpmlint, causes problems when we try to remove the package.
But then it is often too late and it can only be solved after a yum reinstall or rpm -i --replacepkgs of the improved rpm.

example :
 - erroneously:
    %preun
    if [ $1 = 0 ] : then
        /sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || :
    fi

 -correct:
    %preun
    if [ $1 = 0 ] ; then
        /sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || :
    fi

- the error when we try to remove the pakage (via yum or rpm): syntax error near unexpected token `fi
- version: rpmlint-1.5-9.fc19.noarch

Again: rpmlint, rpmbuild and the yum (local)install happens flawless.

I know that removing a package would be a standard test procedure. But still.
What is the cost if we want to add this and similar syntax checks?

Regards

Discussion

  • Ville Skyttä
    Ville Skyttä
    2014-06-02

    • status: open --> wont-fix
     
  • Ville Skyttä
    Ville Skyttä
    2014-06-02

    rpmlint already checks the syntax of shell scriptlets using the -n option to the script interpreter, for example:

    $ rpm -qp --scripts ./foo.rpm 
    postinstall scriptlet (using /bin/sh):
    if true; then
        echo hello
    fo # note "fo", not "fi"
    
    $ rpmlint ./foo.rpm 
    foo.x86_64: E: shell-syntax-error-in-%post
    

    If you want better syntax checks, I suggest contacting your shell author/maintainer.

     
  • Ville Skyttä
    Ville Skyttä
    2014-06-02

    BTW your example case does get flagged by rpmlint:

    $ rpm -qp --scripts ./foo.rpm 
    preuninstall scriptlet (using /bin/sh):
    if [ $1 = 0 ] : then
        /sbin/install-info --delete /usr/share/info/foo.info /usr/share/info/dir || :
    fi
    
    $ rpmlint ./foo.rpm | grep syntax
    foo.x86_64: E: shell-syntax-error-in-%preun