rpmrpmbuildrpm-spec

rpm spec: How do you suppress the error 'Macro expanded in comment' without deleting the linke?


While troubleshooting issues with RPM .spec files, it is often convenient to comment lines from the %files section:

%files
#%{_datadir}/vala/vapi/libgdaui-%{apiver}.vapi

However, that can produce build errors like the following:

Macro expanded in comment on line 213: %{_datadir}/vala/vapi/libgdaui-%{apiver}.vapi

Question

Is there a way to tell rpmbuild to complete the build and treat "Macro expanded in comment" as a warning instead of an error?


Solution

  • This already is a warning, not an error. In a %files section where macros are of the type you show (expanding to a subset of a single path, not a list of paths), it's harmless. Ignore it, or double up your %s (as the documents advise) to prevent it from happening (and then undo that when uncommenting the same content).

    Only log messages with level CRIT trigger an automatic build failure. Log messages with level WARN are not even close.

    You might also consider using macros rather than comments to disable things temporarily (%if 0).


    Quoting from RPM's source code:

        if (*bufA != '\0' || *bufB != '\0')
            rpmlog(RPMLOG_WARNING,
            _("Macro expanded in comment on line %d: %s\n"),
            spec->lineNum, bufA);
    

    As you can see, the only thing we do when detecting the case is logging a warning -- nothing else.