From 5e5a2b4b49382c84b5154e508b911fff6bda74d1 Mon Sep 17 00:00:00 2001 From: Jerome Duval Date: Thu, 5 Sep 2024 19:34:01 +0200 Subject: [PATCH] Policy: automatically add libstdc++ in requires instead of ignoring it. * fixes #278 --- HaikuPorter/Package.py | 13 +++++++------ HaikuPorter/Policy.py | 13 +++++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/HaikuPorter/Package.py b/HaikuPorter/Package.py index 986b7db3..3c1f9bc7 100644 --- a/HaikuPorter/Package.py +++ b/HaikuPorter/Package.py @@ -213,6 +213,13 @@ def populatePackagingDir(self, port): def makeHpkg(self, requiresUpdater): """Create a package suitable for distribution""" + packageFile = self.hpkgDir + '/' + self.hpkgName + if os.path.exists(packageFile): + os.remove(packageFile) + + # policy check, add some requires + self.policy.checkPackage(self, packageFile) + if (requiresUpdater and self.type != PackageType.SOURCE): requiresList = self.recipeKeys['REQUIRES'] self.recipeKeys['UPDATED_REQUIRES'] \ @@ -224,10 +231,6 @@ def makeHpkg(self, requiresUpdater): self._generatePackageInfo(self.packagingDir + '/.PackageInfo', [requiresName], getOption('quiet'), False, True, self.architecture) - packageFile = self.hpkgDir + '/' + self.hpkgName - if os.path.exists(packageFile): - os.remove(packageFile) - # mimeset the files that shall go into the package info('mimesetting files for package ' + self.hpkgName + ' ...') dataDir = os.path.join(self.packagingDir, 'data') @@ -252,8 +255,6 @@ def makeHpkg(self, requiresUpdater): output = check_output([Configuration.getPackageCommand(), 'create', packageFile], cwd=self.packagingDir).decode('utf-8') info(output) - # policy check - self.policy.checkPackage(self, packageFile) # Clean up after ourselves shutil.rmtree(self.packagingDir) diff --git a/HaikuPorter/Policy.py b/HaikuPorter/Policy.py index 8ed30cfa..81fcf811 100644 --- a/HaikuPorter/Policy.py +++ b/HaikuPorter/Policy.py @@ -210,12 +210,17 @@ def _checkLibraryDependenciesOfFile(self, dirPath, path): for library in libraries: if self._isMissingLibraryDependency(library, dirPath, rpath): if (library.startswith('libgcc') or - library.startswith('libstdc++') or library.startswith('libsupc++')): continue - self._violation('"%s" needs library "%s", but the ' - 'package doesn\'t seem to declare that as a ' - 'requirement' % (path, library)) + if (library.startswith('libstdc++')): + suffixIndex = library.find('.so') + resolvableName = self._normalizeResolvableName( + 'lib:' + library[:suffixIndex] + self.secondaryArchSuffix) + self.package.recipeKeys['REQUIRES'] += [ resolvableName ] + else: + self._violation('"%s" needs library "%s", but the ' + 'package doesn\'t seem to declare that as a ' + 'requirement' % (path, library)) def _isMissingLibraryDependency(self, library, dirPath, rpath): if library.startswith('_APP_'):