diff --git a/builtins/extractcode_7z_system_provided/src/extractcode_7z/__init__.py b/builtins/extractcode_7z_system_provided/src/extractcode_7z/__init__.py index 3708973..7d448b9 100755 --- a/builtins/extractcode_7z_system_provided/src/extractcode_7z/__init__.py +++ b/builtins/extractcode_7z_system_provided/src/extractcode_7z/__init__.py @@ -30,7 +30,7 @@ def get_locations(self): """ Return a mapping of {location key: location} providing the installation locations of the 7zip exe and shared libraries as installed on various - Linux distros or on FreeBSD. + Linux distros, FreeBSD, macOS, and other POSIX. """ lib_dir = None lib_7z = environ.get('EXTRACTCODE_7Z_PATH') @@ -62,6 +62,12 @@ def get_locations(self): # This assumes that 7zip was installed using Homebrew lib_dir = '/opt/homebrew/bin' lib_7z = path.join(lib_dir, '7zz') + elif mainstream_system == 'sunos': + lib_dir = '/usr/bin' + lib_7z = path.join(lib_dir, '7z') + elif mainstream_system == 'haiku': + lib_dir = '/bin' + lib_7z = path.join(lib_dir, '7z') else: lib_dir = path.dirname(lib_7z) diff --git a/builtins/extractcode_libarchive_system_provided/src/extractcode_libarchive/__init__.py b/builtins/extractcode_libarchive_system_provided/src/extractcode_libarchive/__init__.py index 41ba7f6..91c4f6d 100755 --- a/builtins/extractcode_libarchive_system_provided/src/extractcode_libarchive/__init__.py +++ b/builtins/extractcode_libarchive_system_provided/src/extractcode_libarchive/__init__.py @@ -28,12 +28,13 @@ def get_locations(self): """ Return a mapping of {location key: location} providing the installation locations of the libarchive shared library as installed on various Linux - distros or on FreeBSD. + distros, FreeBSD, macOS, and other POSIX. """ lib_archive = environ.get('EXTRACTCODE_LIBARCHIVE_PATH') if not lib_archive: - system_arch = platform.machine() mainstream_system = platform.system().lower() + system_arch = platform.machine() + system_arch_bit_width = platform.architecture()[0] if mainstream_system == 'linux': distribution = self.get_like_distro() @@ -42,16 +43,14 @@ def get_locations(self): if any(dist in debian_based_distro for dist in distribution): lib_dir = ( - '/usr/lib' if platform.architecture()[0] == '32bit' + '/usr/lib' if system_arch_bit_width == '32bit' else f'/usr/lib/{system_arch}-linux-gnu' ) - elif any(dist in rpm_based_distro for dist in distribution): lib_dir = ( - '/usr/lib' if platform.architecture()[0] == '32bit' + '/usr/lib' if system_arch_bit_width == '32bit' else '/usr/lib64' ) - else: raise Exception( 'Unsupported system: {}'.format(distribution)) @@ -68,6 +67,14 @@ def get_locations(self): # This assumes that libarchive was installed using Homebrew lib_dir = '/opt/homebrew/opt/libarchive/lib' lib_archive = path.join(lib_dir, 'libarchive.dylib') + elif mainstream_system == 'sunos': + lib_dir = '/usr/lib' + if system_arch == 'i86pc' and system_arch_bit_width == '64bit': + lib_dir = path.join(lib_dir, 'amd64') + lib_archive = path.join(lib_dir, 'libarchive.so') + elif mainstream_system == 'haiku': + lib_dir = '/system/lib' + lib_archive = path.join(lib_dir, 'libarchive.so.13') else: lib_dir = path.dirname(lib_archive) diff --git a/builtins/typecode_libmagic_system_provided/src/typecode_libmagic/__init__.py b/builtins/typecode_libmagic_system_provided/src/typecode_libmagic/__init__.py index b1dd5aa..443a3f3 100755 --- a/builtins/typecode_libmagic_system_provided/src/typecode_libmagic/__init__.py +++ b/builtins/typecode_libmagic_system_provided/src/typecode_libmagic/__init__.py @@ -42,29 +42,29 @@ def get_locations(self): """ Return a mapping of {location key: location} providing the installation locations of the libmagic shared library as installed on various Linux - distros or on FreeBSD. + distros, FreeBSD, macOS, and other POSIX. """ mainstream_system = platform.system().lower() + system_arch = platform.machine() + system_arch_bit_width = platform.architecture()[0] + if mainstream_system == 'linux': distribution = self.get_like_distro() debian_based_distro = ['ubuntu', 'mint', 'debian'] rpm_based_distro = ['fedora', 'rhel'] - system_arch = platform.machine() if any(dist in debian_based_distro for dist in distribution): db_dir = '/usr/lib/file' lib_dir = ( - '/usr/lib' if platform.architecture()[0] == '32bit' + '/usr/lib' if system_arch_bit_width == '32bit' else f'/usr/lib/{system_arch}-linux-gnu' ) - elif any(dist in rpm_based_distro for dist in distribution): db_dir = '/usr/share/misc' lib_dir = ( - '/usr/lib' if platform.architecture()[0] == '32bit' + '/usr/lib' if system_arch_bit_width == '32bit' else '/usr/lib64' ) - else: raise Exception('Unsupported system: {}'.format(distribution)) @@ -72,18 +72,29 @@ def get_locations(self): elif mainstream_system == 'freebsd': dll_loc = '' db_dir = '' - for lib_dir in ('/usr/local/', '/usr'): - possible_dll_loc = path.join(lib_dir, 'lib/libmagic.so') - possible_db_loc = path.join(lib_dir, 'share/misc/magic.mgc') + for usr_dir in ('/usr/local', '/usr'): + lib_dir = path.join(usr_dir, 'lib') + possible_dll_loc = path.join(lib_dir, 'libmagic.so') + possible_db_loc = path.join(usr_dir, 'share/misc/magic.mgc') if path.exists(possible_dll_loc) and path.exists(possible_db_loc): dll_loc = possible_dll_loc db_dir = path.dirname(possible_db_loc) break elif mainstream_system == 'darwin': # This assumes that libmagic was installed using Homebrew - lib_dir = '/opt/homebrew' - dll_loc = path.join(lib_dir, 'lib/libmagic.dylib') - db_dir = path.join(lib_dir, 'share/misc') + lib_dir = '/opt/homebrew/lib' + dll_loc = path.join(lib_dir, 'libmagic.dylib') + db_dir = '/opt/homebrew/share/misc' + elif mainstream_system == 'sunos': + lib_dir = '/usr/lib' + if system_arch == 'i86pc' and system_arch_bit_width == '64bit': + lib_dir = path.join(lib_dir, 'amd64') + dll_loc = path.join(lib_dir, 'libmagic.so') + db_dir = '/usr/share/misc' + elif mainstream_system == 'haiku': + lib_dir = '/system/lib' + dll_loc = path.join(lib_dir, 'libmagic.so.1') + db_dir = '/system/data/misc' magicdb_loc = path.join(db_dir, 'magic.mgc')