def install(context, from_str, to_str=""):
to = Path(to_str)
if not is_subdir(context.pkgins / to, context.pkgins):
raise Exception("Package tried to copy to directory outside its own")
from_ = Path(from_str).normpath()
if from_.isabs():
raise Exception("From glob is not allowed to be absolute")
from_ = context.source_lookup.translate(from_)
for d in Path().glob(from_):
from_ = d
if not is_subdir(from_, context.pkgsrc):
raise Exception("Package tried to copy from directory outside its own")
name = from_.name
if from_.isdir():
rel_from = from_.relpath(context.pkgsrc)
context.add_package_file( (rel_from, to / name) )
for e in from_.walk():
rel_to = e.relpath(from_)
rel_from = e.relpath(context.pkgsrc)
context.add_package_file( (rel_from, to / name / rel_to) )
else:
rel_from = from_.relpath(context.pkgsrc)
context.add_package_file( (rel_from, to / name) )
评论列表
文章目录