36
36
def resolve (path , pkgroot ):
37
37
"""Resolve references to ${pkgroot} with the given value, resolve $topdir with `topdir`"""
38
38
if path .find ("${pkgroot}" ) != - 1 :
39
- return path .strip ("\" " ).replace ("${pkgroot}" , pkgroot )
39
+ norm_path = os .path .normpath (path .strip ("\" " ).replace ("${pkgroot}" , pkgroot ))
40
+ if not os .path .isabs (norm_path ) and norm_path .startswith ('..' ):
41
+ return resolve (path , os .path .realpath (pkgroot ))
42
+ else :
43
+ return norm_path
40
44
elif path .startswith ("$topdir" ):
41
45
return os .path .normpath (path .replace ("$topdir" , topdir )).replace ('\\ ' , '/' )
42
46
else :
@@ -48,12 +52,12 @@ def path_to_label(path, pkgroot):
48
52
# determine if the given path is inside the repository root
49
53
# if it is not, return None to signal it needs to be symlinked into the
50
54
# repository
51
- real_path = os .path .realpath (resolve (path , pkgroot ))
52
- relative_path = os .path .relpath (real_path , start = repo_root )
55
+ norm_path = os .path .normpath (resolve (path , pkgroot ))
56
+ relative_path = os .path .relpath (norm_path , start = repo_root )
53
57
54
58
return None if relative_path .startswith ('..' ) else relative_path .replace ('\\ ' , '/' )
55
59
56
- topdir_relative_path = path .replace (pkgroot , "$topdir" )
60
+ topdir_relative_path = path .replace (os . path . realpath ( pkgroot ) , "$topdir" )
57
61
if topdir_relative_path .find ("$topdir" ) != - 1 :
58
62
return os .path .normpath (topdir_relative_path .replace ("$topdir" , topdir )).replace ('\\ ' , '/' )
59
63
@@ -104,15 +108,16 @@ def hs_library_pattern(name, mode = "static", profiling = False):
104
108
# Accumulate package id to package name mappings.
105
109
pkg_id_map = []
106
110
111
+ # pkgroot is not part of .conf files. It's a computed value. It is
112
+ # defined to be the directory enclosing the package database
113
+ # directory.
114
+ pkgroot = os .path .dirname (package_conf_dir )
115
+
116
+
107
117
for conf in glob .glob (os .path .join (package_conf_dir , '*.conf' )):
108
118
with open (conf , 'r' ) as f :
109
119
pkg = package_configuration .parse_package_configuration (f )
110
120
111
- # pkgroot is not part of .conf files. It's a computed value. It is
112
- # defined to be the directory enclosing the package database
113
- # directory.
114
- pkgroot = os .path .dirname (os .path .dirname (os .path .realpath (conf )))
115
-
116
121
pkg_id_map .append ((pkg .name , pkg .id ))
117
122
118
123
# Haddock handling
0 commit comments