rpmbuild check-rpath 错误地报告路径不是绝对路径的错误

rpmbuild check-rpath reports error that path is not absolute, incorrectly

几个月来,我一直在 OEL7 上使用 CMake 和 CPack 3.13.4 构建 RPM,没有出现任何问题。我的 CMake 配置包含这些行:

SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)

这使我能够确保在安装任何版本之前使用库的本地构建版本。在不对这些行进行任何更改的情况下,我突然无法再构建 RPM。我现在收到此错误消息:

+ /usr/lib/rpm/check-rpaths
*******************************************************************************
*
* WARNING: 'check-rpaths' detected a broken RPATH and will cause 'rpmbuild'
*          to fail. To ignore these errors, you can set the '$QA_RPATHS'
*          environment variable which is a bitmask allowing the values
*          below. The current value of QA_RPATHS is 0x0000.
*
*    0x0001 ... standard RPATHs (e.g. /usr/lib); such RPATHs are a minor
*               issue but are introducing redundant searchpaths without
*               providing a benefit. They can also cause errors in multilib
*               environments.
*    0x0002 ... invalid RPATHs; these are RPATHs which are neither absolute
*               nor relative filenames and can therefore be a SECURITY risk
*    0x0004 ... insecure RPATHs; these are relative RPATHs which are a
*               SECURITY risk
*    0x0008 ... the special '$ORIGIN' RPATHs are appearing after other
*               RPATHs; this is just a minor issue but usually unwanted
*    0x0010 ... the RPATH is empty; there is no reason for such RPATHs
*               and they cause unneeded work while loading libraries
*    0x0020 ... an RPATH references '..' of an absolute path; this will break
*               the functionality when the path before '..' is a symlink
*          
*
* Examples:
* - to ignore standard and empty RPATHs, execute 'rpmbuild' like
*   $ QA_RPATHS=$[ 0x0001|0x0010 ] rpmbuild my-package.src.rpm
* - to check existing files, set $RPM_BUILD_ROOT and execute check-rpaths like
*   $ RPM_BUILD_ROOT=<top-dir> /usr/lib/rpm/check-rpaths
*  
*******************************************************************************
ERROR   0002: file '/opt/project/lib/libConfigLoader.so.4.0.0' contains an invalid rpath '/opt/project/lib' in [/opt/project/lib]
ERROR   0002: file '/opt/project/lib/libConfigLoaderDb.so.4.0.0' contains an invalid rpath '/opt/project/lib' in [/opt/project/lib]

这似乎是错误的,因为它表明 /opt/project/lib 不是绝对路径,而它确实是。

/opt/project/lib的权限是:

[user@c7 ]$ ll -d /opt/
drwxrwxr-x. 10 root root 139 Oct 11 14:31 /opt/
[user@c7 ]$ ll -d /opt/project/
drwxrwx--- 11 root project 114 Oct 11 14:32 /opt/project/
[user@c7 ]$ ll -d /opt/project/lib
drwxrwx--- 2 root project 4096 Oct 11 14:53 /opt/project/lib

我可以通过在我的 make 命令前添加 QA_RPATHS=0x0002 来抑制错误,但我担心这样做可能会掩盖将来的其他错误。

我查看了 check-rpaths 脚本(以及它使用的 check-rpaths-worker 脚本),问题似乎出在这部分,其中 j 已设置为rpath,在本例中为 /opt/project/lib:

            case "$j" in
                (/lib/*|/usr/lib/*|/usr/X11R6/lib/*|/usr/local/lib/*)
                    badness=0;;
                (/lib64/*|/usr/lib64/*|/usr/X11R6/lib64/*|/usr/local/lib64/*)
                    badness=0;;

                ($ORIGIN|${ORIGINX}|$ORIGIN/*|${ORIGINX}/*)
                    test $allow_ORIGIN -eq 0 && badness=8 || {
                        badness=0
                        new_allow_ORIGIN=1
                    }
                    ;;
                (/*$PLATFORM*|/*${PLATFORM}*|/*$LIB*|/*${LIB}*)
                    badness=0;;

                (/lib|/usr/lib|/usr/X11R6/lib)
                    badness=1;;
                (/lib64|/usr/lib64|/usr/X11R6/lib64)
                    badness=1;;

                (.*)
                    badness=4;;
                (*) badness=2;;
            esac

(Source)

我不明白这是怎么让 /opt/project/lib 通过的,因为从那个 'case' 语句开始,它总是会下降到 (*) 的情况并设置 badness=2

我还能尝试什么?

似乎在某些 versions/platforms cmake / cpack 中假定用于“make”步骤的路径将影响 rpm-distribution 的二进制文件。例如,在我的项目中,多个 CMakeList.txt 文件每个 link 二进制文件和相关的共享对象。有定义的包含和库目录,它们与构建每个二进制文件相关,但与分发的结果 rpms 无关。 因此有两种类型的目录,一种用于构建二进制文件和共享对象,另一种用于在 rpms 中分发二进制文件和相关共享对象(通常在系统路径和目标平台上的 LD_LIBRARY_PATH 中定义)。 所以在我的例子中,我在“make”步骤中没有得到 rpath error/warning,这本来是可以理解的,但我在“cpack”步骤中得到了它们,这根本没有意义。我通过设置环境变量绕过了它 出口QA_SKIP_RPATHS=1 在“make”之后和“cpack”步骤之前。

我遇到了同样的问题。

就我而言,removing the ~/.rpmmacros file 已经解决了问题。

(我是 运行 make package 在共享机器上使用 cmake/cpack-generated Makefile。可能是某人或某事更改了该文件的内容,导致出现以下行或未评论:

%__arch_install_post   /usr/lib/rpm/check-rpaths   /usr/lib/rpm/check-buildroot

这似乎是我遇到问题的原因。)