Пример #1
0
    def resolve_deps(self):
        '''Uses the dockerize.DepSolver class to find all the shared
        library dependencies of files installed into the Docker image.'''

        deps = DepSolver()

        # Iterate over all files in the image.
        for root, dirs, files in os.walk(self.targetdir):
            for name in files:
                path = os.path.join(root, name)
                deps.add(path)

        for src in deps.deps:
            self.copy_file(src, symlinks=symlink_options.COPY_ALL)

        # Install some basic nss libraries to permit programs to resolve
        # users, groups, and hosts.
        for libdir in deps.prefixes():
            for nsslib in [
                    'libnss_dns.so.2', 'libnss_files.so.2',
                    'libnss_compat.so.2'
            ]:
                src = os.path.join(libdir, nsslib)
                LOG.info('looking for %s', src)
                if os.path.exists(src):
                    self.copy_file(src, symlinks=symlink_options.COPY_ALL)
Пример #2
0
    def dep_solve(self, nvrea_list, labels=None):
        if not labels:
            labels = self.channel_map.keys()
        repos = [{
            "id": label,
            "relative_path": repodata(label)
        } for label in labels]

        print "Copying repodata, please wait."

        # dep solver expects the metadata to be in /repodata directory;
        # create temporary symlinks
        temp_repo_links = []
        repo = None
        for repo in repos:
            yum_repodata_path = "%s/repodata" % (repo['relative_path'])
            create_repodata_link(repo['relative_path'], yum_repodata_path)
            temp_repo_links.append(yum_repodata_path)
        try:
            try:
                self.solver = DepSolver(repos)
                self.__dep_solve(nvrea_list)
                self.solver.cleanup()
            except RepoError, e:
                raise UserRepoError(repo["id"], e.value)
        finally:
            # clean up temporary symlinks
            for link in temp_repo_links:
                remove_repodata_link(link)
Пример #3
0
def expand_file(path, sym_set, files_set, found_set, no_cpy_all):
    if len([n for n in IGNORE if fnmatch.fnmatch(path, n)]) != 0:
        return

    if no_cpy_all != True:
        dirs = [
            n for n in COPYALL if fnmatch.fnmatch(path, os.path.join(n, '*'))
        ]
        if len(dirs) != 0:
            for roots in dirs:
                expand_dir(roots, sym_set, files_set, found_set, True)
            return

    if os.path.islink(path):
        sym_set.add(path)
        lnk = os.readlink(path)
        if os.path.isabs(lnk) == False:
            lnk = os.path.join(os.path.dirname(path), lnk)

        expand_file(lnk, sym_set, files_set, found_set, no_cpy_all)

    if os.path.isdir(path):
        expand_dir(path, sym_set, files_set, found_set, no_cpy_all)
        return

    if os.path.isfile(path):
        if path in files_set:
            return

        files_set.add(path)
        found_set.add(os.path.basename(path))

        deps = DepSolver()
        deps.add(path)
        for src in deps.deps:
            expand_file(src, sym_set, files_set, found_set, no_cpy_all)