archlinuxfr / package-query

Query alpm database and AUR
69 stars 17 forks source link

Fails to build on pacman from git master #147

Closed eli-schwartz closed 3 years ago

eli-schwartz commented 4 years ago
gcc -DLOCALEDIR=\"/usr/share/locale\" -DCONFFILE=\"/etc/pacman.conf\" -DROOTDIR=\"/\" -DDBPATH=\"/var/lib/pacman/\" -DAUR_BASE_URL=\"https://aur.archlinux.org\" -DHAVE_CONFIG_H -DGIT_VERSION=\"1.10\" -I. -I..    -D_GNU_SOURCE -g -O2 -MT aur.o -MD -MP -MF .deps/aur.Tpo -c -o aur.o aur.c
mv -f .deps/aur.Tpo .deps/aur.Po
gcc -DLOCALEDIR=\"/usr/share/locale\" -DCONFFILE=\"/etc/pacman.conf\" -DROOTDIR=\"/\" -DDBPATH=\"/var/lib/pacman/\" -DAUR_BASE_URL=\"https://aur.archlinux.org\" -DHAVE_CONFIG_H -DGIT_VERSION=\"1.10\" -I. -I..    -D_GNU_SOURCE -g -O2 -MT alpm-query.o -MD -MP -MF .deps/alpm-query.Tpo -c -o alpm-query.o alpm-query.c
alpm-query.c: In function ‘search_pkg’:
alpm-query.c:397:22: error: too few arguments to function ‘alpm_db_search’
  397 |  alpm_list_t *pkgs = alpm_db_search (db, targets);
      |                      ^~~~~~~~~~~~~~
In file included from util.h:23,
                 from alpm-query.c:28:
/usr/include/alpm.h:1076:5: note: declared here
 1076 | int alpm_db_search(alpm_db_t *db, const alpm_list_t *needles,
      |     ^~~~~~~~~~~~~~
make[2]: *** [Makefile:429: alpm-query.o] Error 1

See the following pacman commit which changed the way alpm_db_search worked: https://git.archlinux.org/pacman.git/commit/?id=27f354a7874b965bf223832bdf9749504cd1a590

f2404 commented 4 years ago

Thanks for the heads up! However, I'm reluctant to change anything at this point as that would probably break building against the current libalpm release. Do you have an idea when new pacman version is going to be released?

eli-schwartz commented 4 years ago

No release date has been scheduled yet.

You can use AC_COMPILE_IFELSE in configure.ac to check which version of the function successfully compiles a dummy code snippet, and use that to set e.g. DB_SEARCH_TWO_ARGS or DB_SEARCH_THREE_ARGS macros in config.h, then use that as an #if/#else in alpm-query.c.

That's the usual way to portably write code that works on multiple versions of a function. The resulting package-query binary would then compile on either version of libalpm, and since the latter case is a git development version without a distinguishing soname yet, using the wrong libalpm version would lead to a runtime crash instead of a missing shared library. (Since this only affects users of the git development version, they can live with that limitation.)

thaewrapt commented 3 years ago

https://github.com/archlinuxfr/package-query/issues/149 is the same issue but against a fresh release of pacman, so the changes are live now.

f2404 commented 3 years ago

This has been fixed with https://github.com/archlinuxfr/package-query/commit/ee70e6e618f112b5f5404a4af6a98adfbf6cf1a7, thanks.