Skip to content

Commit ff21d52

Browse files
authored
Merge pull request #36 from nexB/update-system-provided-plugins
Update system provided plugins
2 parents 4df0cf0 + 5f3df6d commit ff21d52

7 files changed

Lines changed: 72 additions & 34 deletions

File tree

builtins/extractcode_7z_system_provided/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
setup(
1616
name='extractcode_7z_system_provided',
17-
version='16.5.210531',
17+
version='32.0.0',
1818
license='apache-2.0 AND lgpl-2.1 and unrar and brian-gladman-3-clause',
1919
description=desc,
2020
long_description=desc,

builtins/extractcode_7z_system_provided/src/extractcode_7z/__init__.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,41 @@ def get_locations(self):
2727
lib_7z = environ.get('EXTRACTCODE_7Z_PATH')
2828
if not lib_7z:
2929
mainstream_system = platform.system().lower()
30+
3031
if mainstream_system == 'linux':
3132
distribution = platform.linux_distribution()[0].lower()
3233
debian_based_distro = ['ubuntu', 'mint', 'debian']
3334
rpm_based_distro = ['fedora', 'redhat']
3435

3536
if distribution in debian_based_distro:
3637
lib_dir = '/usr/lib/p7zip'
37-
38+
lib_7z = path.join(lib_dir, '7zr')
3839
elif distribution in rpm_based_distro:
3940
lib_dir = '/usr/libexec/p7zip'
40-
41+
lib_7z = path.join(lib_dir, '7za')
4142
else:
4243
raise Exception('Unsupported system: {}'.format(distribution))
4344
elif mainstream_system == 'freebsd':
44-
lib_dir = '/usr/local/libexec/p7zip'
45-
lib_7z = path.join(lib_dir, '7z')
45+
lib_dir = '/usr/local/bin'
46+
lib_7z = path.join(lib_dir, '7z')
47+
elif mainstream_system == 'darwin':
48+
# This assumes that p7zip was installed using Homebrew
49+
lib_dir = '/opt/homebrew/lib/p7zip'
50+
lib_7z = path.join(lib_dir, '7z')
4651
else:
4752
lib_dir = path.dirname(lib_7z)
4853

54+
# Check that path exist
55+
if not path.exists(lib_7z):
56+
raise Exception(
57+
'p7zip not found. Please refer to the scancode-toolkit '
58+
'documentation on how to install p7zip for your system.'
59+
)
60+
4961
locations = {
5062
# extractcode.sevenzip.libdir is not used anymore and deprecated
5163
# but we are keeping it around for now for backward compatibility
5264
'extractcode.sevenzip.libdir': lib_dir,
5365
'extractcode.sevenzip.exe': lib_7z,
5466
}
55-
5667
return locations

builtins/extractcode_libarchive_system_provided/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
setup(
1616
name='extractcode_libarchive_system_provided',
17-
version='3.5.1.210531',
17+
version='32.0.0',
1818
license='apache-2.0 AND bsd-simplified',
1919
description=desc,
2020
long_description=desc,

builtins/extractcode_libarchive_system_provided/src/extractcode_libarchive/__init__.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,41 @@ def get_locations(self):
2525
if not lib_archive:
2626
system_arch = platform.machine()
2727
mainstream_system = platform.system().lower()
28+
2829
if mainstream_system == 'linux':
2930
distribution = platform.linux_distribution()[0].lower()
3031
debian_based_distro = ['ubuntu', 'mint', 'debian']
3132
rpm_based_distro = ['fedora', 'redhat']
3233

3334
if distribution in debian_based_distro:
3435
lib_dir = '/usr/lib/'+system_arch+'-linux-gnu'
35-
3636
elif distribution in rpm_based_distro:
3737
lib_dir = '/usr/lib64'
38-
3938
else:
4039
raise Exception('Unsupported system: {}'.format(distribution))
4140

41+
lib_archive = path.join(lib_dir, 'libarchive.so.13')
4242
elif mainstream_system == 'freebsd':
43-
if path.isdir('/usr/local/'):
44-
lib_dir = '/usr/local/lib'
45-
else:
46-
lib_dir = '/usr/lib'
47-
lib_archive = path.join(lib_dir, 'libarchive.so')
43+
lib_archive = ''
44+
for lib_dir in ('/usr/local/lib', '/usr/lib'):
45+
possible_lib_archive = path.join(lib_dir, 'libarchive.so')
46+
if path.exists(possible_lib_archive):
47+
lib_archive = possible_lib_archive
48+
break
49+
elif mainstream_system == 'darwin':
50+
# This assumes that libarchive was installed using Homebrew
51+
lib_dir = '/opt/homebrew/opt/libarchive/lib'
52+
lib_archive = path.join(lib_dir, 'libarchive.dylib')
4853
else:
4954
lib_dir = path.dirname(lib_archive)
5055

56+
# Check that path exists
57+
if not path.exists(lib_archive):
58+
raise Exception(
59+
'libarchive not found. Please refer to the scancode-toolkit '
60+
'documentation on how to install libarchive for your system.'
61+
)
62+
5163
locations = {
5264
'extractcode.libarchive.dll': lib_archive,
5365
}

builtins/typecode_libmagic_system_provided/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
desc = '''A ScanCode path provider plugin to provide a system package provided libmagic binary and database.'''
1414

1515
setup(
16-
name='typecode_libmagic-system-provided',
17-
version='5.39.210531',
16+
name='typecode_libmagic_system_provided',
17+
version='32.0.0',
1818
license=(
1919
'apache-2.0 AND bsd-simplified-darwin AND (bsd-simplified AND public-domain AND '
2020
'bsd-new AND isc AND (bsd-new OR gpl-1.0-plus) AND bsd-original)'

builtins/typecode_libmagic_system_provided/src/typecode_libmagic/__init__.py

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# Copyright (c) nexB Inc. and others.
33
# Redistribution and use in source and binary forms, with or without modification,
44
# are permitted provided that the following conditions are met:
5-
#
5+
#
66
# Redistributions of source code must retain the above copyright notice, this list
77
# of conditions and the following disclaimer.
8-
#
8+
#
99
# Redistributions in binary form must reproduce the above copyright notice, this
1010
# list of conditions and the following disclaimer in the documentation and/or
1111
# other materials provided with the distribution.
12-
#
12+
#
1313
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1414
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1515
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -23,7 +23,6 @@
2323

2424

2525
import platform
26-
from os import environ
2726
from os import path
2827

2928
from plugincode.location_provider import LocationProviderPlugin
@@ -36,38 +35,54 @@ def get_locations(self):
3635
locations of the libmagic shared library as installed on various Linux
3736
distros or on FreeBSD.
3837
"""
39-
40-
system_arch = platform.machine()
4138
mainstream_system = platform.system().lower()
4239
if mainstream_system == 'linux':
40+
system_arch = platform.machine()
4341
distribution = platform.linux_distribution()[0].lower()
4442
debian_based_distro = ['ubuntu', 'mint', 'debian']
4543
rpm_based_distro = ['fedora', 'redhat']
4644

4745
if distribution in debian_based_distro:
4846
db_dir = '/usr/lib/file'
4947
lib_dir = '/usr/lib/'+system_arch+'-linux-gnu'
50-
5148
elif distribution in rpm_based_distro:
5249
db_dir = '/usr/share/misc'
5350
lib_dir = '/usr/lib64'
54-
5551
else:
5652
raise Exception('Unsupported system: {}'.format(distribution))
5753

58-
dll_loc = path.join(lib_dir, 'libmagic.so')
59-
54+
dll_loc = path.join(lib_dir, 'libmagic.so.1')
6055
elif mainstream_system == 'freebsd':
61-
if path.isdir('/usr/local/'):
62-
lib_dir = '/usr/local'
63-
else:
64-
lib_dir = '/usr'
65-
66-
dll_loc = path.join(lib_dir, 'lib/libmagic.so')
67-
db_dir = path.join(lib_dir,'share/file')
56+
dll_loc = ''
57+
db_dir = ''
58+
for lib_dir in ('/usr/local/', '/usr'):
59+
possible_dll_loc = path.join(lib_dir, 'lib/libmagic.so')
60+
possible_db_loc = path.join(lib_dir, 'share/misc/magic.mgc')
61+
if path.exists(possible_dll_loc) and path.exists(possible_db_loc):
62+
dll_loc = possible_dll_loc
63+
db_dir = path.dirname(possible_db_loc)
64+
break
65+
elif mainstream_system == 'darwin':
66+
# This assumes that libmagic was installed using Homebrew
67+
lib_dir = '/opt/homebrew'
68+
dll_loc = path.join(lib_dir, 'lib/libmagic.dylib')
69+
db_dir = path.join(lib_dir, 'share/misc')
6870

6971
magicdb_loc = path.join(db_dir, 'magic.mgc')
7072

73+
# Check that paths exist
74+
if not path.exists(dll_loc):
75+
raise Exception(
76+
'libmagic not found. Please refer to the scancode-toolkit '
77+
'documentation on how to install libmagic for your operating system.'
78+
)
79+
80+
if not path.exists(magicdb_loc):
81+
raise Exception(
82+
'magic.mgc not found. Please refer to the scancode-toolkit '
83+
'documentation on how to install libmagic for your system.'
84+
)
85+
7186
locations = {
7287
# typecode.libmagic.libdir is not used anymore and deprecated
7388
# but we are keeping it around for now for backward compatibility

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fi
2020

2121

2222
if [[ "$PYTHON_EXE" == "" ]]; then
23-
PYTHON_EXE=python3.6
23+
PYTHON_EXE=python3
2424
fi
2525

2626

0 commit comments

Comments
 (0)