conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
971 stars 1.79k forks source link

[bug] libpq: package contains dead symlinks in include/catalog #25427

Open michael-brade opened 2 months ago

michael-brade commented 2 months ago

Describe the bug

conan 1.64.1, Linux, gcc 13. However, I don't think this is too relevant. Just download libpq/14.9 with, say, id 0508f825aee0fe3099a5dae626a5316104c6db0a. There you will find:

-rw-r--r-- 0/0            2591 1970-01-01 01:00 include/catalog/catversion.h
-rw-r--r-- 0/0           10005 1970-01-01 01:00 include/catalog/dependency.h
-rw-r--r-- 0/0            5803 1970-01-01 01:00 include/catalog/genbki.h
-rw-r--r-- 0/0            5396 1970-01-01 01:00 include/catalog/heap.h
-rw-r--r-- 0/0            6577 1970-01-01 01:00 include/catalog/index.h
-rw-r--r-- 0/0            1824 1970-01-01 01:00 include/catalog/indexing.h
-rw-r--r-- 0/0            7371 1970-01-01 01:00 include/catalog/namespace.h
-rw-r--r-- 0/0            6588 1970-01-01 01:00 include/catalog/objectaccess.h
-rw-r--r-- 0/0            3196 1970-01-01 01:00 include/catalog/objectaddress.h
-rw-r--r-- 0/0            1196 1970-01-01 01:00 include/catalog/partition.h
-rw-r--r-- 0/0            6019 1970-01-01 01:00 include/catalog/pg_aggregate.h
lrw-r--r-- 0/0               0 1970-01-01 01:00 include/catalog/pg_aggregate_d.h -> /home/conan/workspace/prod-v1/bsr/74852/aadae/.conan/data/libpq/14.9/_/_/build/0508f825aee0fe3099a5dae626a5316104c6db0a/src/src/backend/catalog/pg_aggregate_d.h
-rw-r--r-- 0/0            1620 1970-01-01 01:00 include/catalog/pg_am.h
lrw-r--r-- 0/0               0 1970-01-01 01:00 include/catalog/pg_am_d.h -> /home/conan/workspace/prod-v1/bsr/74852/aadae/.conan/data/libpq/14.9/_/_/build/0508f825aee0fe3099a5dae626a5316104c6db0a/src/src/backend/catalog/pg_am_d.h
-rw-r--r-- 0/0            3965 1970-01-01 01:00 include/catalog/pg_amop.h
lrw-r--r-- 0/0               0 1970-01-01 01:00 include/catalog/pg_amop_d.h -> /home/conan/workspace/prod-v1/bsr/74852/aadae/.conan/data/libpq/14.9/_/_/build/0508f825aee0fe3099a5dae626a5316104c6db0a/src/src/backend/catalog/pg_amop_d.h
-rw-r--r-- 0/0            2695 1970-01-01 01:00 include/catalog/pg_amproc.h
lrw-r--r-- 0/0               0 1970-01-01 01:00 include/catalog/pg_amproc_d.h -> /home/conan/workspace/prod-v1/bsr/74852/aadae/.conan/data/libpq/14.9/_/_/build/0508f825aee0fe3099a5dae626a5316104c6db0a/src/src/backend/catalog/pg_amproc_d.h
-rw-r--r-- 0/0            1794 1970-01-01 01:00 include/catalog/pg_attrdef.h
lrw-r--r-- 0/0               0 1970-01-01 01:00 include/catalog/pg_attrdef_d.h -> /home/conan/workspace/prod-v1/bsr/74852/aadae/.conan/data/libpq/14.9/_/_/build/0508f825aee0fe3099a5dae626a5316104c6db0a/src/src/backend/catalog/pg_attrdef_d.h
-rw-r--r-- 0/0            7853 1970-01-01 01:00 include/catalog/pg_attribute.h
lrw-r--r-- 0/0               0 1970-01-01 01:00 include/catalog/pg_attribute_d.h -> /home/conan/workspace/prod-v1/bsr/74852/aadae/.conan/data/libpq/14.9/_/_/build/0508f825aee0fe3099a5dae626a5316104c6db0a/src/src/backend/catalog/pg_attribute_d.h

and so on. You can choose any package, actually. The bug is in conanfile.py, package(), I just don't know what the right fix is. For me, this works:

--- a/recipes/libpq/all/conanfile.py
+++ b/recipes/libpq/all/conanfile.py
@@ -2,7 +2,7 @@ from conan import ConanFile
 from conan.tools.apple import fix_apple_shared_install_name
 from conan.tools.build import cross_building
 from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv
-from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, replace_in_file, rm, rmdir
+from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, replace_in_file, rm, rmdir, symlinks
 from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps
 from conan.tools.layout import basic_layout
 from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path, VCVars
@@ -251,7 +251,8 @@ class LibpqConan(ConanFile):
             rmdir(self, os.path.join(self.package_folder, "include", "postgresql", "server"))
             self._remove_unused_libraries_from_package()
             fix_apple_shared_install_name(self)
-        copy(self, "*.h", src=os.path.join(self.build_folder, "src", "backend", "catalog"),
+        symlinks.remove_external_symlinks(self, self.package_folder)
+        copy(self, "*.h", src=os.path.join(self.source_folder, "src", "backend", "catalog"),
                           dst=os.path.join(self.package_folder, "include", "catalog"))

     def package_info(self):

How to reproduce it

No response

AbrilRBS commented 2 months ago

Hi @michael-brade thanks a lot for the report.

https://github.com/conan-io/conan-center-index/pull/25355 was submitted a few days ago tackling this issue in a different manner. We'll need to check what actually makes the most sense in this case, so I appreciate any insight you might have!

I'm moving this to the Conan Center Index repo, where it fits better so we can continue the discussion there

michael-brade commented 2 months ago

ah, darn, I thought I was in Conan Center Index already, and I also missed 25355. Oh well. I am not an expert in conan internals, so either way is fine for me. A third option might be to follow the symlinks when copying, but I couldn't figure out how to do that.

scandyna commented 2 months ago

If you just remove the symlinks in the package, some headers will be missing, I think. Maybe you could look https://github.com/conan-io/conan-center-index/issues/24895