From cbd1397a7a053c12656d08cf75e619cd3191adb0 Mon Sep 17 00:00:00 2001 From: "Lars T. Kyllingstad" Date: Wed, 6 Mar 2024 09:38:29 +0100 Subject: [PATCH] Copy licence files more selectively --- conanfile.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/conanfile.py b/conanfile.py index a09eb4a..0e95fc5 100644 --- a/conanfile.py +++ b/conanfile.py @@ -76,19 +76,21 @@ def _import_executables(self, dependency, target_dir, patterns=["*"]): files = copy(self, patternx, bindir, target_dir, keep_path=False) self._update_rpath(files, "$ORIGIN/../lib") - def _import_license(self, dependency, target_dir): - dep_license_dir = os.path.join(target_dir, dependency.ref.name) - copy(self, "licenses/*", dependency.package_folder, dep_license_dir, keep_path=False) - copy(self, "license*", dependency.package_folder, dep_license_dir, keep_path=False) - copy(self, "*/license*", dependency.package_folder, dep_license_dir, keep_path=False) - copy(self, "copying*", dependency.package_folder, dep_license_dir, keep_path=False) - copy(self, "*/copying*", dependency.package_folder, dep_license_dir, keep_path=False) - copy(self, "notice*", dependency.package_folder, dep_license_dir, keep_path=False) - copy(self, "*/notice*", dependency.package_folder, dep_license_dir, keep_path=False) - copy(self, "authors*", dependency.package_folder, dep_license_dir, keep_path=False) - copy(self, "*/authors*", dependency.package_folder, dep_license_dir, keep_path=False) - copy(self, "copyright*", dependency.package_folder, dep_license_dir, keep_path=False) - copy(self, "*/copyright*", dependency.package_folder, dep_license_dir, keep_path=False) + def _import_license(self, dependency, licenses_dir): + src_licenses_dir = os.path.join(dependency.package_folder, "licenses") + tgt_licenses_dir = os.path.join(licenses_dir, dependency.ref.name) + if os.path.isdir(src_licenses_dir): + # Copy the full contents of '/licenses/' if it exists, + # which it does for virtually all conan-center packages. + copy(self, "*", src_licenses_dir, tgt_licenses_dir) + else: + # Copy everything that looks like it might contain license and + # copyright information. + copy(self, "*license*", dependency.package_folder, tgt_licenses_dir, keep_path=False) + copy(self, "*copying*", dependency.package_folder, tgt_licenses_dir, keep_path=False) + copy(self, "*notice*", dependency.package_folder, tgt_licenses_dir, keep_path=False) + copy(self, "*authors*", dependency.package_folder, tgt_licenses_dir, keep_path=False) + copy(self, "*copyright*", dependency.package_folder, tgt_licenses_dir, keep_path=False) def _update_rpath(self, files, new_rpath): if files and self.settings.os == "Linux":