File tree Expand file tree Collapse file tree
typecode_libmagic_system_provided/src/typecode_libmagic Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717
1818class SevenzipPaths (LocationProviderPlugin ):
1919
20+ def get_like_distro (self ):
21+ info = platform .freedesktop_os_release ()
22+ ids = [info ["ID" ]]
23+ if "ID_LIKE" in info :
24+ # ids are space separated and ordered by precedence
25+ ids .extend (info ["ID_LIKE" ].split ())
26+ return ids
27+
28+
2029 def get_locations (self ):
2130 """
2231 Return a mapping of {location key: location} providing the installation
@@ -29,14 +38,14 @@ def get_locations(self):
2938 mainstream_system = platform .system ().lower ()
3039
3140 if mainstream_system == 'linux' :
32- distribution = platform . linux_distribution ()[ 0 ]. lower ()
41+ distribution = self . get_like_distro ()
3342 debian_based_distro = ['ubuntu' , 'mint' , 'debian' ]
34- rpm_based_distro = ['fedora' , 'redhat ' ]
43+ rpm_based_distro = ['fedora' , 'rhel ' ]
3544
36- if distribution in debian_based_distro :
45+ if any ( dist in debian_based_distro for dist in distribution ) :
3746 lib_dir = '/usr/lib/p7zip'
3847 lib_7z = path .join (lib_dir , '7zr' )
39- elif distribution in rpm_based_distro :
48+ elif any ( dist in rpm_based_distro for dist in distribution ) :
4049 lib_dir = '/usr/libexec/p7zip'
4150 lib_7z = path .join (lib_dir , '7za' )
4251 else :
Original file line number Diff line number Diff line change 1515
1616
1717class LibarchivePaths (LocationProviderPlugin ):
18+
19+ def get_like_distro (self ):
20+ info = platform .freedesktop_os_release ()
21+ ids = [info ["ID" ]]
22+ if "ID_LIKE" in info :
23+ # ids are space separated and ordered by precedence
24+ ids .extend (info ["ID_LIKE" ].split ())
25+ return ids
26+
1827 def get_locations (self ):
1928 """
2029 Return a mapping of {location key: location} providing the installation
@@ -27,13 +36,16 @@ def get_locations(self):
2736 mainstream_system = platform .system ().lower ()
2837
2938 if mainstream_system == 'linux' :
30- distribution = platform . linux_distribution ()[ 0 ]. lower ()
39+ distribution = self . get_like_distro ()
3140 debian_based_distro = ['ubuntu' , 'mint' , 'debian' ]
32- rpm_based_distro = ['fedora' , 'redhat ' ]
41+ rpm_based_distro = ['fedora' , 'rhel ' ]
3342
34- if distribution in debian_based_distro :
43+ if any (dist in debian_based_distro for dist in distribution ):
44+ db_dir = '/usr/lib/file'
3545 lib_dir = '/usr/lib/' + system_arch + '-linux-gnu'
36- elif distribution in rpm_based_distro :
46+
47+ elif any (dist in rpm_based_distro for dist in distribution ):
48+ db_dir = '/usr/share/misc'
3749 lib_dir = '/usr/lib64'
3850 else :
3951 raise Exception (
Original file line number Diff line number Diff line change 2929
3030
3131class LibmagicPaths (LocationProviderPlugin ):
32+
33+ def get_like_distro (self ):
34+ info = platform .freedesktop_os_release ()
35+ ids = [info ["ID" ]]
36+ if "ID_LIKE" in info :
37+ # ids are space separated and ordered by precedence
38+ ids .extend (info ["ID_LIKE" ].split ())
39+ return ids
40+
3241 def get_locations (self ):
3342 """
3443 Return a mapping of {location key: location} providing the installation
@@ -37,15 +46,15 @@ def get_locations(self):
3746 """
3847 mainstream_system = platform .system ().lower ()
3948 if mainstream_system == 'linux' :
40- system_arch = platform .machine ()
41- distribution = platform .linux_distribution ()[0 ].lower ()
49+ distribution = self .get_like_distro ()
4250 debian_based_distro = ['ubuntu' , 'mint' , 'debian' ]
43- rpm_based_distro = ['fedora' , 'redhat ' ]
51+ rpm_based_distro = ['fedora' , 'rhel ' ]
4452
45- if distribution in debian_based_distro :
53+ if any ( dist in debian_based_distro for dist in distribution ) :
4654 db_dir = '/usr/lib/file'
4755 lib_dir = '/usr/lib/' + system_arch + '-linux-gnu'
48- elif distribution in rpm_based_distro :
56+
57+ elif any (dist in rpm_based_distro for dist in distribution ):
4958 db_dir = '/usr/share/misc'
5059 lib_dir = '/usr/lib64'
5160 else :
You can’t perform that action at this time.
0 commit comments