Hint: PostgreSQL 13 issues when building gvmd or running pg_upgradecluster

If you’re getting the following message while building gvmd on a distro shipping a recent PostgreSQL version 13:

-- Looking for PostgreSQL...
CMake Error at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
  Could NOT find PostgreSQL (missing: PostgreSQL_TYPE_INCLUDE_DIR) (found
  version "13.0")

then this means that the cmake version doesn’t support PostgreSQL 13 yet. Basically you need to manually update the following file (example from Debian testing and the path depends on your distro) so that PostgreSQL 13 is getting recognized:

/usr/share/cmake-3.18/Modules/FindPostgreSQL.cmake

Just replace:

set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS}
    "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0")

by:

set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS}
    "13" "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0")

and gvmd should build again.

Note:

This is NOT the same as the message below where only the PostgreSQL development files (e.g. libpq-dev) is missing:

-- Looking for PostgreSQL...
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find PostgreSQL (missing: PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR)
4 Likes

I haven’t tested this yet but passing the following to the cmake call might help as well without the need to modify the cmake file:

-DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql

Source:

1 Like

Note that if you still have the PostgreSQL 12 development header files (called postgresql-server-dev-12 on Debian) installed the above might not happen while building. This is due to cmake picking up the PostgreSQL 12 libraries instead.

If you want to run pg_upgradecluster for the upgrade you might hit the message below which means that you need to:

  1. remove the PostgreSQL 12 development header files
  2. apply one of the two solutions above
  3. rebuild gvmd
  4. run pg_upgradecluster again
ERROR:  function public.hosts_contains(text, text) does not exist
ERROR:  could not load library "/opt/gvm/lib/libgvm-pg-server.so": /opt/gvm/lib/libgvm-pg-server.so: undefined symbol: elog_finish
ERROR:  function public.max_hosts(text, text) does not exist
ERROR:  could not load library "/opt/gvm/lib/libgvm-pg-server.so": /opt/gvm/lib/libgvm-pg-server.so: undefined symbol: elog_finish
ERROR:  function public.next_time_ical(text, text) does not exist
ERROR:  could not load library "/opt/gvm/lib/libgvm-pg-server.so": /opt/gvm/lib/libgvm-pg-server.so: undefined symbol: elog_finish
ERROR:  function public.next_time_ical(text, text, integer) does not exist
ERROR:  could not load library "/opt/gvm/lib/libgvm-pg-server.so": /opt/gvm/lib/libgvm-pg-server.so: undefined symbol: elog_finish
ERROR:  function public.regexp(text, text) does not exist
ERROR:  could not load library "/opt/gvm/lib/libgvm-pg-server.so": /opt/gvm/lib/libgvm-pg-server.so: undefined symbol: elog_finish
ERROR:  function public.severity_matches_ov(double precision, double precision) does not exist
ERROR:  function public.regexp(text, text) does not exist
ERROR:  operator does not exist: text public.?~# text
ERROR:  function public.hosts_contains(text, text) does not exist
LINE 41: ...IS NULL) OR ("overrides"."hosts" = ''::"text") OR "public"."...
                                                              ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
ERROR:  relation "public.result_overrides" does not exist
ERROR:  relation "public.result_overrides" does not exist
LINE 10:                    FROM "public"."result_overrides"
                                 ^
ERROR:  relation "public.result_new_severities" does not exist

Not directly related to building gvmd but if you get the following error with gvm-setup on Kali:

ERROR: The default postgresql version is not 13 required by libgvmd
Error: Use pg_upgradecluster to update your postgres cluster

please check the following posting for this GVM unrelated problem in your PostgreSQL / Kali setup / environment: