rpm-software-management / librepo

A library providing C and Python (libcURL like) API for downloading packages and linux repository metadata in rpm-md format
http://rpm-software-management.github.io/librepo/
GNU Lesser General Public License v2.1
74 stars 91 forks source link

1.15.1: gpgme not found -> cmake continues -> build fails #269

Open kloczek opened 1 year ago

kloczek commented 1 year ago

From camek output

-- Found PkgConfig: /usr/bin/pkg-config (found version "1.9.3")
-- Checking for modules 'glib-2.0>=2.28;gio-2.0'
--   Found glib-2.0, version 2.75.0
--   Found gio-2.0, version 2.75.0
-- Checking for one of the modules 'libcrypto;openssl'
-- Checking for module 'libxml-2.0'
--   Found libxml-2.0, version 2.10.3
-- Found CURL: /usr/lib64/libcurl.so (found suitable version "7.86.0", minimum required is "7.52.0")
-- No usable gpgme flavours found.                                      <<<<===== HERE
-- Checking for module 'zck>=0.9.11'
--   Found zck, version 1.2.3
-- Found PythonInterp: /usr/bin/python3 (found suitable exact version "3.8.16")
-- Found PythonLibs: /usr/lib64/libpython3.8.so (found version "3.8.16")
Building python bindings
-- Python3 install dir is /usr/lib64/python3.8/site-packages
-- Checking for module 'check'
--   Found check, version 0.15.2
-- Found Doxygen: /usr/bin/doxygen (found version "1.9.5") found components: doxygen dot
-- Configuring done
-- Generating done

and build fails with

[ 67%] Linking C executable test_main
cd /home/tkloczko/rpmbuild/BUILD/librepo-1.15.1/x86_64-redhat-linux-gnu/tests && /usr/bin/cmake -E cmake_link_script CMakeFiles/test_main.dir/link.txt --verbose=1
/usr/bin/gcc -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -std=c99 -Wall -DWITH_ZCHUNK -DNDEBUG -Wl,--as-needed -Wl,--gc-sections -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto=auto -flto-partition=none -fuse-linker-plugin -Wl,--build-id=sha1 -rdynamic CMakeFiles/test_main.dir/fixtures.c.o CMakeFiles/test_main.dir/test_checksum.c.o CMakeFiles/test_main.dir/test_downloader.c.o CMakeFiles/test_main.dir/test_gpg.c.o CMakeFiles/test_main.dir/test_handle.c.o CMakeFiles/test_main.dir/test_lrmirrorlist.c.o CMakeFiles/test_main.dir/test_main.c.o CMakeFiles/test_main.dir/test_metalink.c.o CMakeFiles/test_main.dir/test_mirrorlist.c.o CMakeFiles/test_main.dir/test_package_downloader.c.o CMakeFiles/test_main.dir/test_repoconf.c.o CMakeFiles/test_main.dir/test_repomd.c.o CMakeFiles/test_main.dir/test_repo_zck.c.o CMakeFiles/test_main.dir/testsys.c.o CMakeFiles/test_main.dir/test_url_substitution.c.o CMakeFiles/test_main.dir/test_util.c.o CMakeFiles/test_main.dir/test_version.c.o -o test_main  -Wl,-rpath,/home/tkloczko/rpmbuild/BUILD/librepo-1.15.1/x86_64-redhat-linux-gnu/librepo ../librepo/librepo.so.0 -L/usr/lib64 -lcheck -lxml2 -lcurl -lcrypto -lgio-2.0 -lglib-2.0 -lgobject-2.0 -lzck
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_op_verify'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_key_release'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_strerror'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_op_keylist_start'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_release'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_data_rewind'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_data_new_from_mem'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_set_protocol'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_op_keylist_next'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_new'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_data_release'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_op_import'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_set_armor'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_op_keylist_end'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_data_seek'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_ctx_set_engine_info'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_data_new_from_fd'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_op_export'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_check_version_internal'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_engine_check_version'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_op_verify_result'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_data_read'
/usr/bin/ld: ../librepo/librepo.so.0: undefined reference to `gpgme_data_new'
collect2: error: ld returned 1 exit status

If gpgme dependency is not optional cmake should fail.

kloczek commented 1 year ago

Looks like even with installed gpgme devel librepo is not able to find gpgme.

-- Found CURL: /usr/lib64/libcurl.so (found suitable version "7.86.0", minimum required is "7.52.0")
-- No usable gpgme flavours found.

and ..

tkloczko@pers-jacek SPECS]$ pkgconf --list-all | grep gpgme
gpgme-glib                     gpgme-glib - GnuPG Made Easy to access GnuPG with Glib
gpgme                          gpgme - GnuPG Made Easy to access GnuPG
kloczek commented 1 year ago

Looks like https://github.com/rpm-software-management/librepo/blob/master/cmake/Modules/FindGpgme.cmake does not contain actual gpgme library detection (it was copied from some other project) and whole that file can be replaced by single pkg_check_modules() call.

j-mracek commented 1 year ago

Please could you try to run - dnf builddep librepo.spec. It should install missing dependencies. Anyway we will try to fix reported issue, but right now it has low priority.

kloczek commented 1 year ago

My build infrastructure uses always dnf builddep to install all build dependencies in build env. Relaying on indirect dependencies is always bad practice because some of them may be optional.

AdrianBunk commented 1 year ago

The patch from Andreas Metzler in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1024576#12 was used in Debian to fix this problem.

kloczek commented 1 year ago

Updated patch for 1.15.1

--- a/librepo/CMakeLists.txt
+++ b/librepo/CMakeLists.txt
@@ -50,7 +50,7 @@ TARGET_LINK_LIBRARIES(librepo
                         ${LIBXML2_LIBRARIES}
                         ${CURL_LIBRARY}
                         ${LIBCRYPTO_LIBRARIES}
-                        ${GPGME_VANILLA_LIBRARIES}
+                        ${GPGME_LIBRARIES}
                         ${GLIB2_LIBRARIES}
                      )
 IF (WITH_ZCHUNK)
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,9 +31,8 @@
 PKG_CHECK_MODULES(GLIB2 glib-2.0>=2.28 gio-2.0 REQUIRED)
 PKG_SEARCH_MODULE(LIBCRYPTO REQUIRED libcrypto openssl)
 PKG_CHECK_MODULES(LIBXML2 libxml-2.0 REQUIRED)
+PKG_SEARCH_MODULE(GPGME REQUIRED gpgme)
 FIND_PACKAGE(CURL 7.52.0 REQUIRED)
-FIND_PACKAGE(Gpgme REQUIRED)
-

 IF (WITH_ZCHUNK)
 PKG_CHECK_MODULES(ZCHUNKLIB zck>=0.9.11 REQUIRED)
jelly commented 1 year ago

gpgme dropped gpgme-config which is used on *nix, so this should be changed in a PR to support both scenario's. The path above is drops Windows support.