mirror of
https://github.com/Z3Prover/z3
synced 2025-06-03 12:51:22 +00:00
Bug fix for `MakeRuleCmd.create_relative_symbolic_link()
`.
create_relative_symbolic_link(out, '/usr/lib64/libz3.so', '/usr/lib/python3.5/site-package/libz3.so') would create an incorrect relative path because it would consider ``/usr/lib`` to a be a path prefix of ``/usr/lib64``.
This commit is contained in:
parent
f1d4f36ddf
commit
d205b176e8
1 changed files with 22 additions and 1 deletions
|
@ -3269,6 +3269,27 @@ class MakeRuleCmd(object):
|
||||||
install_root=cls.install_root(),
|
install_root=cls.install_root(),
|
||||||
dir=dir))
|
dir=dir))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _is_path_prefix_of(cls, temp_path, target_as_abs):
|
||||||
|
"""
|
||||||
|
Returns True iff ``temp_path`` is a path prefix
|
||||||
|
of ``target_as_abs``
|
||||||
|
"""
|
||||||
|
assert isinstance(temp_path, str)
|
||||||
|
assert isinstance(target_as_abs, str)
|
||||||
|
assert len(temp_path) > 0
|
||||||
|
assert len(target_as_abs) > 0
|
||||||
|
assert os.path.isabs(temp_path)
|
||||||
|
assert os.path.isabs(target_as_abs)
|
||||||
|
|
||||||
|
# Need to stick extra slash in front otherwise we might think that
|
||||||
|
# ``/lib`` is a prefix of ``/lib64``. Of course if ``temp_path ==
|
||||||
|
# '/'`` then we shouldn't else we would check if ``//`` (rather than
|
||||||
|
# ``/``) is a prefix of ``/lib64``, which would fail.
|
||||||
|
if len(temp_path) > 1:
|
||||||
|
temp_path += os.sep
|
||||||
|
return target_as_abs.startswith(temp_path)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_relative_symbolic_link(cls, out, target, link_name):
|
def create_relative_symbolic_link(cls, out, target, link_name):
|
||||||
assert isinstance(target, str)
|
assert isinstance(target, str)
|
||||||
|
@ -3294,7 +3315,7 @@ class MakeRuleCmd(object):
|
||||||
assert os.path.isabs(temp_path)
|
assert os.path.isabs(temp_path)
|
||||||
# Keep walking up the directory tree until temp_path
|
# Keep walking up the directory tree until temp_path
|
||||||
# is a prefix of targetAsAbs
|
# is a prefix of targetAsAbs
|
||||||
while not targetAsAbs.startswith(temp_path):
|
while not cls._is_path_prefix_of(temp_path, targetAsAbs):
|
||||||
assert temp_path != '/'
|
assert temp_path != '/'
|
||||||
temp_path = os.path.dirname(temp_path)
|
temp_path = os.path.dirname(temp_path)
|
||||||
relative_path += '../'
|
relative_path += '../'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue