1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-28 05:29:48 +00:00

Make the tool working even if there is a symlink in a given path to a port's

file. For example I'm usually keeping all working directories in /tmp using
WRKDIRPREFIX, while for the quick access to a port's files creating a symlink
to this directory in skeleton's dir (i.e. ports/foo/bar/src -->
/tmp/usr/ports/foo/bar/work/bar-0.0) and with this patch the tool correctly
works when I'm specifying `src/foo.c' as an argument.
This commit is contained in:
Maxim Sobolev 2001-12-05 08:13:40 +00:00
parent c43bef046c
commit 9da70731a8
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=51066

View File

@ -108,7 +108,7 @@ def locateportdir(path, wrkdirprefix= '', strict = False):
#
# Get value of a make(1) variable called varname. Optionally maintain a cache
# for resolved varname:makepath pairs to speed-up operation if the same variable
# from the exactly same file is requiested repeatedly (invocation of make(1) is
# from the exactly same file is requested repeatedly (invocation of make(1) is
# very expensive operation...)
#
def querymakevar(varname, path = 'Makefile', strict = False, cache = {}):
@ -456,6 +456,31 @@ class PatchesCollection:
return self.patches.values()
#
# Resolve all symbolic links in the given path to a file
#
def truepath(path):
if not os.path.isfile(path):
raise IOError(errno.ENOENT, path)
result = ''
while len(path) > 0:
path, lastcomp = os.path.split(path)
if len(lastcomp) == 0:
lastcomp = path
path = ''
result = os.path.join(lastcomp, result)
if len(path) == 0:
break
if os.path.islink(path):
linkto = os.path.normpath(os.readlink(path))
if linkto[0] != '/':
path = os.path.join(path, linkto)
else:
path = linkto
return result[:-1]
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], 'afui')
@ -508,6 +533,8 @@ def generate(args, automatic, force, ignoremtime):
raise IOError(errno.ENOENT, filepath)
# Not reached #
filepath = truepath(filepath)
wrkdirprefix = querymakevar('WRKDIRPREFIX', Vars.ETC_MAKE_CONF, False)
portdir = locateportdir(os.path.dirname(filepath), wrkdirprefix, True)
wrksrc = querymakevar('WRKSRC', portdir, True)