[copr] master: [backend] do not create repo in destdir (f06a35b)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit f06a35b7fd43a8c8b2e5d26e3090164135a5b01a
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Feb 25 09:51:01 2014 +0100
[backend] do not create repo in destdir
it is not usefull at all to have repo of mixture of f19,f20,el5,el6 packages
>---------------------------------------------------------------
backend/mockremote.py | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/backend/mockremote.py b/backend/mockremote.py
index 20b2870..bba46e3 100755
--- a/backend/mockremote.py
+++ b/backend/mockremote.py
@@ -663,15 +663,14 @@ class MockRemote(object):
os.path.basename(pkg)))
built_pkgs.append(pkg)
# createrepo with the new pkgs
- for d in [self.destdir, chroot_dir]:
- rc, out, err = createrepo(d, self.lock)
- if err.strip():
- self.callback.error(
- "Error making local repo: {0}".format(d))
-
- self.callback.error(str(err))
- # FIXME - maybe clean up .repodata and .olddata
- # here?
+ rc, out, err = createrepo(chroot_dir, self.lock)
+ if err.strip():
+ self.callback.error(
+ "Error making local repo: {0}".format(chroot_dir))
+
+ self.callback.error(str(err))
+ # FIXME - maybe clean up .repodata and .olddata
+ # here?
if self.failed:
if len(self.failed) != len(to_be_built):
10 years, 2 months
[copr] master: [backend] ensure that only one createrepo is running at the same time (d742809)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit d74280948cb6ca5aabccfd1d743df19d8fd7ed66
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Feb 25 09:47:10 2014 +0100
[backend] ensure that only one createrepo is running at the same time
so multiple instances (which consumes 2+GB RAM each) does not take server down
>---------------------------------------------------------------
backend/dispatcher.py | 4 +++-
backend/mockremote.py | 11 ++++++++---
copr-be.py | 4 +++-
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index 77bf2ed..436b9e4 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -103,7 +103,7 @@ class WorkerCallback(object):
class Worker(multiprocessing.Process):
def __init__(self, opts, jobs, events, worker_num,
- ip=None, create=True, callback=None):
+ ip=None, create=True, callback=None, lock=None):
# base class initialization
multiprocessing.Process.__init__(self, name="worker-builder")
@@ -118,6 +118,7 @@ class Worker(multiprocessing.Process):
self.kill_received = False
self.callback = callback
self.create = create
+ self.lock = lock
self.frontend_callback = FrontendCallback(opts)
if not self.callback:
self.logfile = os.path.join(
@@ -469,6 +470,7 @@ class Worker(multiprocessing.Process):
recurse=True,
repos=chroot_repos,
macros=macros,
+ lock=lock,
buildroot_pkgs=job.buildroot_pkgs,
callback=mockremote.CliLogCallBack(
quiet=True, logfn=chrootlogfile))
diff --git a/backend/mockremote.py b/backend/mockremote.py
index ce1412d..20b2870 100755
--- a/backend/mockremote.py
+++ b/backend/mockremote.py
@@ -62,15 +62,19 @@ class SortedOptParser(optparse.OptionParser):
return optparse.OptionParser.format_help(self, formatter=None)
-def createrepo(path):
+def createrepo(path, lock):
if os.path.exists(path + '/repodata/repomd.xml'):
comm = ['/usr/bin/createrepo_c', '--database', '--ignore-lock',
'--update', path]
else:
comm = ['/usr/bin/createrepo_c', '--database', '--ignore-lock', path]
+ if lock:
+ lock.acquire()
cmd = subprocess.Popen(comm,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = cmd.communicate()
+ if lock:
+ lock.release()
return cmd.returncode, out, err
@@ -529,7 +533,7 @@ class MockRemote(object):
destdir=DEF_DESTDIR, chroot=DEF_CHROOT, cont=False,
recurse=False, repos=DEF_REPOS, callback=None,
remote_basedir=DEF_REMOTE_BASEDIR, remote_tempdir=None,
- macros=DEF_MACROS,
+ macros=DEF_MACROS, lock=None,
buildroot_pkgs=DEF_BUILDROOT_PKGS):
self.destdir = destdir
@@ -541,6 +545,7 @@ class MockRemote(object):
self.remote_basedir = remote_basedir
self.remote_tempdir = remote_tempdir
self.macros = macros
+ self.lock = lock
if not self.callback:
self.callback = DefaultCallBack()
@@ -659,7 +664,7 @@ class MockRemote(object):
built_pkgs.append(pkg)
# createrepo with the new pkgs
for d in [self.destdir, chroot_dir]:
- rc, out, err = createrepo(d)
+ rc, out, err = createrepo(d, self.lock)
if err.strip():
self.callback.error(
"Error making local repo: {0}".format(d))
diff --git a/copr-be.py b/copr-be.py
index f253920..e5f3554 100755
--- a/copr-be.py
+++ b/copr-be.py
@@ -270,8 +270,10 @@ class CoprBackend(object):
self.event("Spinning up more workers for jobs")
for _ in range(self.opts.num_workers - len(self.workers)):
worker_num = len(self.workers) + 1
+ lock = multiprocessing.Lock()
w = Worker(
- self.opts, self.jobs, self.events, worker_num)
+ self.opts, self.jobs, self.events, worker_num,
+ lock=lock)
self.workers.append(w)
w.start()
self.event("Finished starting worker processes")
10 years, 2 months
[copr] check-root: dnf-plugin: check for root with dnf api (3ea153b)
by Igor Gnatenko
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : check-root
>---------------------------------------------------------------
commit 3ea153b0ca429b40884322d48facbab41f674d52
Author: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
Date: Mon Feb 17 13:25:03 2014 +0400
dnf-plugin: check for root with dnf api
Signed-off-by: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
>---------------------------------------------------------------
dnf-plugin/copr_hook.py | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/dnf-plugin/copr_hook.py b/dnf-plugin/copr_hook.py
index eeddc8c..9a67651 100644
--- a/dnf-plugin/copr_hook.py
+++ b/dnf-plugin/copr_hook.py
@@ -47,9 +47,6 @@ disable name/project
list name""")
def run(self, extcmds):
- # FIXME this should do dnf itself (BZ#1062889)
- if os.geteuid() != 0:
- raise dnf.exceptions.Error(_('This command has to be run under the root user.'))
try:
subcommand = extcmds[0]
project_name = extcmds[1]
@@ -70,6 +67,7 @@ list name""")
repo_filename = "/etc/yum.repos.d/_copr_{}.repo".format(project_name.replace("/", "-"))
base_url = "http://copr.fedoraproject.org"
if subcommand == "enable":
+ self.is_root()
#http://copr.fedoraproject.org/coprs/larsks/rcm/repo/epel-7-x86_64/
api_path = "/coprs/{0}/repo/{1}/".format(project_name, chroot)
@@ -82,6 +80,7 @@ list name""")
raise dnf.exceptions.Error(str(e)), None, sys.exc_info()[2]
self.cli.logger.info(_("Repository successfully enabled."))
elif subcommand == "disable":
+ self.is_root()
# FIXME is it Copr repo ?
try:
os.remove(repo_filename)
10 years, 2 months
[copr] search: dnf-plugin: implement search (deed1b2)
by Igor Gnatenko
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : search
>---------------------------------------------------------------
commit deed1b22fc1c7d25d832c350d9c114176926c813
Author: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
Date: Sun Feb 16 17:39:22 2014 +0400
dnf-plugin: implement search
Signed-off-by: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
>---------------------------------------------------------------
dnf-plugin/copr_hook.py | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/dnf-plugin/copr_hook.py b/dnf-plugin/copr_hook.py
index eeddc8c..338d879 100644
--- a/dnf-plugin/copr_hook.py
+++ b/dnf-plugin/copr_hook.py
@@ -36,6 +36,7 @@ class CoprCommand(dnf.cli.Command):
copr enable ignatenkobrain/ocltoys
copr disable rhscl/perl516
copr list ignatenkobrain
+ copr search ocltoys
""")
@staticmethod
@@ -44,7 +45,8 @@ class CoprCommand(dnf.cli.Command):
return _("""
enable name/project [chroot]
disable name/project
-list name""")
+list name
+search project""")
def run(self, extcmds):
# FIXME this should do dnf itself (BZ#1062889)
@@ -102,6 +104,20 @@ list name""")
while i < len(json_parse["repos"]):
print "{0}/{1}".format(project_name, json_parse["repos"][i]["name"])
i += 1
+ elif subcommand == "search":
+ #http://copr.fedoraproject.org/api/coprs/search/ocltoys/
+ api_path = "/api/coprs/search/{}/".format(project_name)
+
+ opener = urllib.FanceURLopener({})
+ res = opener.open(base_url+api_path)
+ try:
+ json_parse = json.loads(res.read())
+ except ValueError:
+ raise dnf.Exceptions.Error(_("Can't parse search for '{}'.").format(project_name)), None, sys.exc_info()[2]
+ i = 0
+ while i < len(json_parse["repos"]):
+ print "{0}/{1}".format(json_parse["users"][i]["name"], project_name)
+ i += 1
else:
raise dnf.exceptions.Error(_('Unknown subcommand {}.').format(subcommand))
10 years, 2 months
[copr] search: api: implement search (8d9fd2a)
by Igor Gnatenko
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : search
>---------------------------------------------------------------
commit 8d9fd2a1eedd682b41b9df015dedb5263d803e9f
Author: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
Date: Sun Feb 16 17:38:59 2014 +0400
api: implement search
Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1064118
Signed-off-by: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
>---------------------------------------------------------------
coprs_frontend/coprs/logic/coprs_logic.py | 4 ++
coprs_frontend/coprs/templates/api.html | 39 ++++++++++++++++++++++
coprs_frontend/coprs/views/api_ns/api_general.py | 28 +++++++++++++++
3 files changed, 71 insertions(+), 0 deletions(-)
diff --git a/coprs_frontend/coprs/logic/coprs_logic.py b/coprs_frontend/coprs/logic/coprs_logic.py
index 7cab264..19cb5b9 100644
--- a/coprs_frontend/coprs/logic/coprs_logic.py
+++ b/coprs_frontend/coprs/logic/coprs_logic.py
@@ -47,6 +47,7 @@ class CoprsLogic(object):
def get_multiple(cls, user, **kwargs):
user_relation = kwargs.get("user_relation", None)
username = kwargs.get("username", None)
+ coprname = kwargs.get("coprname", None)
with_mock_chroots = kwargs.get("with_mock_chroots", None)
with_builds = kwargs.get("with_builds", None)
incl_deleted = kwargs.get("incl_deleted", None)
@@ -63,6 +64,9 @@ class CoprsLogic(object):
if isinstance(ids, list): # can be an empty list
query = query.filter(models.Copr.id.in_(ids))
+ if coprname:
+ query = query.filter(models.Copr.name == coprname)
+
if user_relation == "owned":
query = query.filter(
models.User.openid_name == models.User.openidize_name(username))
diff --git a/coprs_frontend/coprs/templates/api.html b/coprs_frontend/coprs/templates/api.html
index e835d0f..1e9ee9a 100644
--- a/coprs_frontend/coprs/templates/api.html
+++ b/coprs_frontend/coprs/templates/api.html
@@ -333,5 +333,44 @@ copr_url = http://copr.fedoraproject.org
}
</pre>
+ <h3>Search for project</h3>
+
+ <h4>URL:</h4>
+ <pre style="font-size:120%">/api/coprs/search/<project>/</pre>
+ <div>or</div>
+ <pre style="font-size:120%">/api/coprs/?search="<project>"</pre>
+
+ <h4>URL parameters:</h4>
+ <ul>
+ <li><b>project</b> – The name of the project whose you'd like
+ to find</li>
+ </ul>
+
+ <h4>Result:</h4>
+ <ul>
+ <li><b>"users"</b> – List of users in given format:
+ <ul>
+ <li><b>"name"</b> – Name of the user</li>
+ </ul>
+ </ul>
+
+ <h4>Example call URL</h4>
+ <pre style="font-size:120%">https://copr.fedoraproject.org/api/coprs/search/tests/</pre>
+
+ <h4>Example results</h4>
+ <pre>
+ {
+ "output": "ok",
+ "users": [
+ {
+ "name": "ignatenkobrain"
+ },
+ {
+ "name": "msuchy"
+ }
+ ]
+ }
+ </pre>
+
</div>
{% endblock %}
diff --git a/coprs_frontend/coprs/views/api_ns/api_general.py b/coprs_frontend/coprs/views/api_ns/api_general.py
index 0a673d2..527f49b 100644
--- a/coprs_frontend/coprs/views/api_ns/api_general.py
+++ b/coprs_frontend/coprs/views/api_ns/api_general.py
@@ -340,3 +340,31 @@ def copr_chroot_details(username, coprname, chrootname):
jsonout = flask.jsonify(output)
jsonout.status_code = httpcode
return jsonout
+
+(a)api_ns.route("/coprs/search/")
+(a)api_ns.route("/coprs/search/<project>/")
+def api_coprs_search_by_project(project=None):
+ """ Return the list of coprs found in search by the given project.
+ project is taken either from GET params or from the URL itself
+ (in this order).
+
+ :arg project: the project one would like find for coprs.
+
+ """
+ project = flask.request.args.get("project", None) or project
+ httpcode = 200
+ if project:
+ query = coprs_logic.CoprsLogic.get_multiple(
+ flask.g.user, coprname=project)
+
+ repos = query.all()
+ output = {"output": "ok", "users": []}
+ for repo in repos:
+ output["users"].append({"name": repo.owner})
+ else:
+ output = {"output": "notok", "error": "Invalid request"}
+ httpcode = 500
+
+ jsonout = flask.jsonify(output)
+ jsonout.status_code = httpcode
+ return jsonout
10 years, 2 months
[copr] master: [cli] allow to get data from sent build (6223352)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 6223352ffc47bd8301bcaef26cac0b2e7221d9fb
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Fri Feb 14 16:28:02 2014 +0100
[cli] allow to get data from sent build
>---------------------------------------------------------------
copr_cli/subcommands.py | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/copr_cli/subcommands.py b/copr_cli/subcommands.py
index c3247b4..53a4fab 100644
--- a/copr_cli/subcommands.py
+++ b/copr_cli/subcommands.py
@@ -183,9 +183,12 @@ def status(build_id):
(ret, value) = _fetch_status(build_id)
print(value)
+def build(copr, pkgs, memory, timeout, wait=True, result=None):
+ """ Build a new package into a given copr.
-def build(copr, pkgs, memory, timeout, wait=True):
- """ Build a new package into a given copr. """
+ Result is dictionary where is returned "errmsg" in case of error.
+ And "id" and "status" otherwise.
+ """
user = get_user()
copr_api_url = get_api_url()
URL = "{0}/coprs/{1}/{2}/new_build/".format(
@@ -211,11 +214,16 @@ def build(copr, pkgs, memory, timeout, wait=True):
print("Build ID: {0}".format(output["id"]))
print("Watching build (this may be safely interrupted)...")
prevstatus = None
+ if result is not None:
+ result['id'] = output["id"]
try:
while True:
(ret, status) = _fetch_status(output["id"])
if not ret:
- print("Unable to get build status: {0}".format(status))
+ errmsg = "Unable to get build status: {0}".format(status)
+ print errmsg
+ if result is not None:
+ result['errmsg'] = errmsg
return False
now = datetime.datetime.now()
@@ -224,6 +232,8 @@ def build(copr, pkgs, memory, timeout, wait=True):
prevstatus = status
if status in ["succeeded", "failed"]:
+ if result is not None:
+ result['status'] = status
return True
time.sleep(60)
10 years, 2 months