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
@@ -28,14 +37,14 @@ def get_locations(self):
2837 if not lib_7z :
2938 mainstream_system = platform .system ().lower ()
3039 if mainstream_system == 'linux' :
31- distribution = platform . linux_distribution ()[ 0 ]. lower ()
40+ distribution = self . get_like_distro ()
3241 debian_based_distro = ['ubuntu' , 'mint' , 'debian' ]
33- rpm_based_distro = ['fedora' , 'redhat ' ]
42+ rpm_based_distro = ['fedora' , 'rhel ' ]
3443
35- if distribution in debian_based_distro :
44+ if any ( dist in debian_based_distro for dist in distribution ) :
3645 lib_dir = '/usr/lib/p7zip'
3746
38- elif distribution in rpm_based_distro :
47+ elif any ( dist in rpm_based_distro for dist in distribution ) :
3948 lib_dir = '/usr/libexec/p7zip'
4049
4150 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
@@ -26,14 +35,16 @@ def get_locations(self):
2635 system_arch = platform .machine ()
2736 mainstream_system = platform .system ().lower ()
2837 if mainstream_system == 'linux' :
29- distribution = platform . linux_distribution ()[ 0 ]. lower ()
38+ distribution = self . get_like_distro ()
3039 debian_based_distro = ['ubuntu' , 'mint' , 'debian' ]
31- rpm_based_distro = ['fedora' , 'redhat ' ]
40+ rpm_based_distro = ['fedora' , 'rhel ' ]
3241
33- if distribution in debian_based_distro :
42+ if any (dist in debian_based_distro for dist in distribution ):
43+ db_dir = '/usr/lib/file'
3444 lib_dir = '/usr/lib/' + system_arch + '-linux-gnu'
3545
36- elif distribution in rpm_based_distro :
46+ elif any (dist in rpm_based_distro for dist in distribution ):
47+ db_dir = '/usr/share/misc'
3748 lib_dir = '/usr/lib64'
3849
3950 else :
Original file line number Diff line number Diff line change 3030
3131
3232class LibmagicPaths (LocationProviderPlugin ):
33+
34+ def get_like_distro (self ):
35+ info = platform .freedesktop_os_release ()
36+ ids = [info ["ID" ]]
37+ if "ID_LIKE" in info :
38+ # ids are space separated and ordered by precedence
39+ ids .extend (info ["ID_LIKE" ].split ())
40+ return ids
41+
3342 def get_locations (self ):
3443 """
3544 Return a mapping of {location key: location} providing the installation
@@ -40,15 +49,15 @@ def get_locations(self):
4049 system_arch = platform .machine ()
4150 mainstream_system = platform .system ().lower ()
4251 if mainstream_system == 'linux' :
43- distribution = platform . linux_distribution ()[ 0 ]. lower ()
52+ distribution = self . get_like_distro ()
4453 debian_based_distro = ['ubuntu' , 'mint' , 'debian' ]
45- rpm_based_distro = ['fedora' , 'redhat ' ]
54+ rpm_based_distro = ['fedora' , 'rhel ' ]
4655
47- if distribution in debian_based_distro :
56+ if any ( dist in debian_based_distro for dist in distribution ) :
4857 db_dir = '/usr/lib/file'
4958 lib_dir = '/usr/lib/' + system_arch + '-linux-gnu'
5059
51- elif distribution in rpm_based_distro :
60+ elif any ( dist in rpm_based_distro for dist in distribution ) :
5261 db_dir = '/usr/share/misc'
5362 lib_dir = '/usr/lib64'
5463
You can’t perform that action at this time.
0 commit comments