Exemplo n.º 1
0
 def repo(self):
     if not os.path.exists(self.ostree_repo):
         #  Remove the cache, if the repo. is gone ... or rpm-ostree is very
         # confused.
         shutil.rmtree(self.rpmostree_cache_dir)
         os.makedirs(self.ostree_repo)
         subprocess.check_call(
             ['ostree', 'init', "--repo=" + self.ostree_repo])
     if self._repo is None:
         self._repo = OSTree.Repo(
             path=Gio.File.new_for_path(self.ostree_repo))
         self._repo.open(None)
     return self._repo
Exemplo n.º 2
0
def open_repository(repo_path):
    # Open repository
    repo_file = Gio.File.new_for_path(repo_path)
    repo = OSTree.Repo(path=repo_file)

    if os.path.exists(os.path.join(repo_path, 'config')):
        logging.info('Opening repo at %s', repo_path)
        repo.open()
    else:
        logging.info('Creating archive-z2 repo at %s', repo_path)
        try:
            os.makedirs(repo_path)
        except OSError as err:
            if err.errno != errno.EEXIST:
                raise
        repo.create(OSTree.RepoMode.ARCHIVE_Z2)

    return repo
Exemplo n.º 3
0
    def repo(self):
        if not os.path.exists(self.ostree_repo):
            #  Remove the cache, if the repo. is gone ... or rpm-ostree is very
            # confused.
            if (self.rpmostree_cache_dir is not None and
                os.path.exists(self.rpmostree_cache_dir)):
                shutil.rmtree(self.rpmostree_cache_dir)
            os.makedirs(self.ostree_repo)
            subprocess.check_call(['ostree', 'init',
                                   "--repo="+self.ostree_repo, '--mode=archive-z2'])
        if self._repo is None:
            self._repo = OSTree.Repo(path=Gio.File.new_for_path(self.ostree_repo))

            try:
                self._repo.open(None)
            except:
                fail_msg("The repo location {0} has not been initialized.  Use 'ostree --repo={0} init --mode=archive-z2' to initialize and re-run rpm-ostree-toolbox".format(self.ostree_repo))

        return self._repo