def mount_lowerdirs(self):
# First, build a dependency graph in order to avoid duplicate entries
dependencies = {}
def dependency_path(dep):
container = self.__class__(dep['imageName'])
path = dep.get('path', os.readlink(os.path.join(container.path, 'overlay.fs')))
return os.path.join(dep['imageName'], path)
pending_deps = set(map(dependency_path, self.dependencies))
while len(pending_deps) > 0:
path = pending_deps.pop()
name = path.split('/')[-2]
if name not in dependencies:
dependencies[path] = set(map(dependency_path, self.__class__(name).dependencies))
pending_deps |= dependencies[path]
# Then sort it topologically. The list is reversed, because overlayfs
# will check the mounts in order they are given, so the base fs has to
# be the last one.
dependencies = reversed(list(toposort_flatten(dependencies)))
return ':'.join(os.path.join(self.metadata_dir, dep) for dep in dependencies)
评论列表
文章目录