Exemple #1
0
 def create_repo(reponame):
     if not backend.is_allowed_reponame(reponame):
         return ('%s not an allowed reponame' % reponame, 403)
     log.info("create_repo %s" % reponame)
     if 'link_to' in request.args:
         link_to = request.args['link_to']
         if not backend.exists(link_to):
             return ('%s not a repo' % link_to, 404)
         return backend.create_repo_link(reponame, link_to)
     return backend.create_repo(reponame)
Exemple #2
0
 def create_repo(reponame):
     if not backend.is_allowed_reponame(reponame):
         return ('%s not an allowed reponame' % reponame, 403)
     log.info("create_repo %s" % reponame)
     if 'link_to' in request.args:
         link_to = request.args['link_to']
         if not backend.exists(link_to):
             return ('%s not a repo' % link_to, 404)
         return backend.create_repo_link(reponame, link_to)
     return backend.create_repo(reponame)
Exemple #3
0
 def _precheck_stage_or_copy(reponame, rpmname, targetreponame):
     if not targetreponame:
         return ("no stageto or copyto parameter given?!", 400)
     if not backend.exists(reponame, rpmname):
         return ("rpm '%s/%s' does not exist" % (reponame, rpmname), 404)
     log.info("target repo name: %s" % targetreponame)
     if not backend.exists(targetreponame):
         return ("target repo '%s' does not exist" % targetreponame, 404)
     if backend.exists(targetreponame, rpmname):
         return ("", 409)
     return None  # no problems found
Exemple #4
0
 def update_all_metadata(self):
     self.commit_actions()
     for reponame in self.walk_repos():
         self.create_repo_metadata(reponame)
     for rpmname in os.listdir(self.md_folder):
         if rpmname == "__empty__":
             continue
         nr_links = os.stat(os.path.join(self.md_folder, rpmname, rpmname)).st_nlink
         if nr_links <= 1:
             log.info("rpm %s not referenced, removing its metadata" % rpmname)
             shutil.rmtree(os.path.join(self.md_folder, rpmname))
Exemple #5
0
 def update_all_metadata(self):
     for reponame in self.walk_repos():
         self.create_repo_metadata(reponame)
     for rpmname in os.listdir(self.md_folder):
         if rpmname == "__empty__":
             continue
         nr_links = os.stat(os.path.join(self.md_folder, rpmname,
                                         rpmname)).st_nlink
         if nr_links <= 1:
             log.info("rpm %s not referenced, removing its metadata" %
                      rpmname)
             shutil.rmtree(os.path.join(self.md_folder, rpmname))
Exemple #6
0
    def __init__(self,
                 repos_folder,
                 createrepo_bins=['createrepo_c'],
                 mergerepo_bins=['mergerepo_c'],
                 allowed_extensions=None):
        self.repos_folder = os.path.abspath(repos_folder)
        self.md_folder = os.path.join(self.repos_folder, ".metadata")
        self.allowed_extensions = allowed_extensions if allowed_extensions else set(
            ["rpm"])
        self.createrepo_bin = None
        for createrepo_bin in createrepo_bins:
            if find_executable(createrepo_bin):
                self.createrepo_bin = createrepo_bin
                break
        self.mergerepo_bin = None
        for mergerepo_bin in mergerepo_bins:
            if find_executable(mergerepo_bin):
                self.mergerepo_bin = mergerepo_bin
                break

        for dirname in (self.repos_folder, self.md_folder):
            mkdir(dirname)

        log.info("repo folder: %s" % self.repos_folder)
        log.info("md folder: %s" % self.md_folder)
        log.info("createrepo binary: %s" % self.createrepo_bin)
        log.info("mergerepo binary: %s" % self.mergerepo_bin)

        empty_repo = os.path.join(self.md_folder, "__empty__")
        self.create_repodata(empty_repo)
Exemple #7
0
    def __init__(self,
                 repos_folder,
                 createrepo_bins=['createrepo_c'],
                 mergerepo_bins=['mergerepo_c'],
                 allowed_extensions=None):
        self.repos_folder = os.path.abspath(repos_folder)
        self.md_folder = os.path.join(self.repos_folder, ".metadata")
        self.allowed_extensions = allowed_extensions if allowed_extensions else set(["rpm"])
        self.createrepo_bin = None
        for createrepo_bin in createrepo_bins:
            if find_executable(createrepo_bin):
                self.createrepo_bin = createrepo_bin
                break
        self.mergerepo_bin = None
        for mergerepo_bin in mergerepo_bins:
            if find_executable(mergerepo_bin):
                self.mergerepo_bin = mergerepo_bin
                break

        for dirname in (self.repos_folder, self.md_folder):
            mkdir(dirname)

        log.info("repo folder: %s" % self.repos_folder)
        log.info("md folder: %s" % self.md_folder)
        log.info("createrepo binary: %s" % self.createrepo_bin)
        log.info("mergerepo binary: %s" % self.mergerepo_bin)

        empty_repo = os.path.join(self.md_folder, "__empty__")
        self.create_repodata(empty_repo)
Exemple #8
0
 def create_bulk_repos():
     spec = request.form.get('pathspec')
     if not spec:
         return ('no pathspec parameter given?!', 400)
     log.info("pathspec: %s" % spec)
     reponames = list(braceexpand(spec))
     log.info("expanded pathes: %s" % ", ".join(reponames))
     for reponame in reponames:
         if not backend.is_allowed_reponame(reponame):
             return ('%s not an allowed reponame' % reponame, 403)
     for reponame in reponames:
         text, status = backend.create_repo(reponame)
         if status != 201:
             return (text, status)
     return ('', 201)
Exemple #9
0
 def create_repo(self, reponame):
     if not self.is_allowed_reponame(reponame):
         return ('', 403)
     try:
         log.debug("trying to create_repo %s" % self._to_path(reponame))
         os.mkdir(self._to_path(reponame))
     except OSError as e:
         if e.errno != 17:
             log.error(e)
             if e.errno == 2:
                 return ('', 404)
             raise
     log.info("repo %s created!" % reponame)
     self.create_repo_metadata(reponame)
     return ('', 201)
Exemple #10
0
 def create_repo(self, reponame):
     if not self.is_allowed_reponame(reponame):
         return ('', 403)
     try:
         log.debug("trying to create_repo %s" % self._to_path(reponame))
         mkdir(self._to_path(reponame))
     except OSError as e:
         if e.errno != 17:
             log.error(e)
             if e.errno == 2:
                 return ('', 404)
             raise
     path = reponame
     while path:
         self.create_repo_metadata(path)
         path, tail = os.path.split(path)
     log.info("repo %s created!" % reponame)
     return ('', 201)
Exemple #11
0
 def is_ready():
     log.info("/ready called (log)")
     return ('', 204)
Exemple #12
0
 def is_ready():
     log.info("/ready called (log)")
     return ('', 204)