BuildRequires: x11-server-xvfband run the command with xvfb-run, e.g.
xvfb-run make check
In ROSA Linux, packages are built with ld flag --no-undefined to prevent underlinking shared libraries.
gcc -shared foo.o -ldl /usr/lib/libglib-2.0.so /usr/lib/libXext.so ... -Wl,--no-undefined -o .libs/libkeymouselistener.so .libs/keymouselistener.o: In function `parse_line': .../gdm-2.20.6/gui/modules/keymouselistener.c:410: undefined reference to `XKeysymToKeycode' collect2: ld returned 1 exit status
Check underlinking to understand how to fix.
Subpackage foo with no %files foo raises a fatal error. It helps to detect dead subpackages, or typos in .spec file.
It also occurs in valid spec files, when "%files foo" appears inside a %if %ccc ... %endif. The fix is to put the whole %package foo section inside a %if %ccc ... %endif.
In modern gcc, things like printf(error_message) instead of printf("%s", error_message) are detected by -Werror=format-security which is used by default. The reason for this error is described on the following Wikipedia page: format string attack
Example of error:
fud.c:72: error: format not a string literal and no format arguments
The fix can be something like:
- printf(xkblayouttext); + printf("%s", xkblayouttext);
- syslog(LOG_ERR, error_message(r)); + syslog(LOG_ERR, "%s", error_message(r));
- snprintf(id_resp_command, MAXIDVALUELEN, *argv); + snprintf(id_resp_command, MAXIDVALUELEN, "%s", *argv);
(another example: nautilus fix)
Beware of C++ objects:
QCString msgText = substitute(outputFormat, "$file", fileSubst) + '\n'; fprintf(warnFile, msgText);
simply doing fprintf(warnFile, "%s", msgText) would introduce a crash, as warned by gcc:
message.cpp:150: warning: cannot pass objects of non-POD type 'class QCString' through '...'; call will abort at runtime message.cpp:150: warning: format '%s' expects type 'char*', but argument 3 has type 'int'
You must explicitly cast to (const char *):
fprintf(warnFile, "%s", (const char *) msgText);
or simpler:
fputs(msgText, warnFile);
Beware of weird code like (from doxygen):
QCString msgText = substitute(substitute(outputFormat, "$file", fileSubst), "%", "%%") + '\n'; fprintf(warnFile, msgText);
Doing fputs(msgText, warnFile) modifies the program's behaviour since % will be displayed %% since % is escaped in msgText. The correct fix is to also get rid of the %s escaping:
QCString msgText = substitute(outputFormat, "$file", fileSubst) + '\n'; fputs(msgText, warnFile);
but you can also disable the warning (see below) and keep the code unchanged, since the code is valid (even if ugly).
If the code is valid, you can disable the check using %define Werror_cflags %nil
The use of -Werror=format-security is inpired by Debian Hardening and Ubuntu CompilerFlags which use -Wformat-security to detect such issues.
If you experience problems with autotools stuff, you should first ensure that you follow the Autotools recommendations in your spec files.
If you get the error like
libtool: You should recreate aclocal.m4 with macros from libtool x.y.z
you should regenerate files created by autotools and shipped with upstream sources (see Autotools recommendations for details).
Fix is to replace AM_ACLOCAL_INCLUDE call in configure.in or configure.ac with ACLOCAL_AMFLAGS variable in Makefile.am. For example, if configure.in has AM_ACLOCAL_INCLUDE(macros), remove it and add this to Makefile.am:
ACLOCAL_AMFLAGS = -I macros
A file includes /usr/include/stdio.h but at the same time defines a local getline function. Fix is to rename the local getline, e.g. 'parseline'. You may do this automatically with this command:
perl -pi -e 's|getline|parseline|' path/to/src/*.c
To reduce overlinking, rpm can display some warnings alike:
Warning: unused libraries in /usr/bin/xdm: /usr/lib/libXext.so.6 /usr/lib/libXt.so.6 /usr/lib/libSM.so.6 /usr/lib/libXpm.so.4 /usr/lib/libxcb-xlib.so.0 /usr/lib/libxcb.so.1
Check overlinking to understand how to fix.
To reduce underlinking, rpm can display some warnings alike:
Warning: undefined symbols in /usr/lib/libgmodule-1.2.so.0.0.10: g_free g_thread_functions_for_glib_use g_threads_got_initialized ...
Check underlinking to understand how to fix.
Example: warning: LOOP: warning: removing libdrakx-net-0.94-1.1.noarch "Requires: /usr/share/locale/fr/LC_MESSAGES" from tsort relations. warning: removing harddrake-13.52-1.i586 "Requires: drakxtools-curses = 13.52-1" from tsort relations. warning: removing drakxtools-curses-13.52-1.i586 "Requires(hint): drakx-net-text" from tsort relations. warning: removing drakx-net-text-0.94-1.1.noarch "Requires: libdrakx-net = 0.94" from tsort relations.
The set of ordered dependencies, before rpm installation, so if rpm installation order is not correct, this may result in broken installations, it is important to prevent these erros in order to have a more robust installation system.
Remove unnecessary circular dependencies when encountered.
Often the loops may be harmless, but sometimes they might cause packages to be installed in the wrong order, ie. like one package requiring a specific user for ownership of directories which are created by another package, or maybe running a script requiring a file from another package that due to dependency loop gets installed only after the script is attempted to run..
Edit the spec file of the application to remove unnecessary circular dependencies.
If not possible, add the dependency detection to this bug report in bugzilla or create a new bug linking to it.
Rpmlint errors and warnings are described in a separate page