[copr] master: [frontend][backend] specify rawhide name when calling rawhide_to_release (8098aea)
by frostyx@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 8098aeafed40a1fb9895387b616db7c166e5d885
Author: Jakub Kadl����k <jkadlcik(a)redhat.com>
Date: Wed Feb 3 11:39:41 2016 +0100
[frontend][backend] specify rawhide name when calling rawhide_to_release
>---------------------------------------------------------------
backend/backend/actions.py | 31 ++++++--------
copr-setup.txt | 3 +-
frontend/coprs_frontend/manage.py | 82 +++++++++++++++++++++----------------
3 files changed, 63 insertions(+), 53 deletions(-)
diff --git a/backend/backend/actions.py b/backend/backend/actions.py
index 9135f77..8048c15 100644
--- a/backend/backend/actions.py
+++ b/backend/backend/actions.py
@@ -234,23 +234,20 @@ class Action(object):
def handle_rawhide_to_release(self, result):
data = json.loads(self.data["data"])
-
- for chroot in data["chroots"]:
- rawhide_chroot = "fedora-rawhide-{}".format(chroot.split("-")[-1])
- try:
- chrootdir = os.path.join(self.opts.destdir, data["user"], data["copr"], chroot)
- if not os.path.exists(chrootdir):
- self.log.debug("Create directory: {}".format(chrootdir))
- os.makedirs(chrootdir)
-
- for build in data["builds"]:
- srcdir = os.path.join(self.opts.destdir, data["user"], data["copr"], rawhide_chroot, build)
- if os.path.exists(srcdir):
- destdir = os.path.join(chrootdir, build)
- self.log.debug("Copy directory: {} as {}".format(srcdir, destdir))
- shutil.copytree(srcdir, destdir)
- except:
- result.result = ActionResult.FAILURE
+ try:
+ chrootdir = os.path.join(self.opts.destdir, data["user"], data["copr"], data["dest_chroot"])
+ if not os.path.exists(chrootdir):
+ self.log.debug("Create directory: {}".format(chrootdir))
+ os.makedirs(chrootdir)
+
+ for build in data["builds"]:
+ srcdir = os.path.join(self.opts.destdir, data["user"], data["copr"], data["rawhide_chroot"], build)
+ if os.path.exists(srcdir):
+ destdir = os.path.join(chrootdir, build)
+ self.log.debug("Copy directory: {} as {}".format(srcdir, destdir))
+ shutil.copytree(srcdir, destdir)
+ except:
+ result.result = ActionResult.FAILURE
result.result = ActionResult.SUCCESS
diff --git a/copr-setup.txt b/copr-setup.txt
index f854ed9..59c90f7 100644
--- a/copr-setup.txt
+++ b/copr-setup.txt
@@ -155,7 +155,8 @@ First create new chroots:
And then copy data from rawhide into them:
- python manage.py rawhide_to_release fedora-24-i386 fedora-24-x86_64
+ python manage.py rawhide_to_release fedora-rawhide-i386 fedora-24-i386
+ # similarly for fedora-24-x86_64
DEBUGING
========
diff --git a/frontend/coprs_frontend/manage.py b/frontend/coprs_frontend/manage.py
index acd2373..a28b4e2 100755
--- a/frontend/coprs_frontend/manage.py
+++ b/frontend/coprs_frontend/manage.py
@@ -121,48 +121,60 @@ class CreateChrootCommand(ChrootCommand):
self.print_already_exists(chroot_name)
-class RawhideToReleaseCommand(ChrootCommand):
+class RawhideToReleaseCommand(Command):
- def run(self, chroot_names):
- for chroot_name in chroot_names:
- mock_chroot = coprs_logic.MockChrootsLogic.get_from_name(chroot_name).first()
- if not mock_chroot:
- print("Given chroot does not exist. Please run:")
- print(" sudo python manage.py create_chroot {}".format(chroot_name))
- print("Nothing was committed, rolling back")
- return
-
- for copr in coprs_logic.CoprsLogic.get_all():
- if not self.has_rawhide(copr):
- continue
-
- data = {"copr": copr.name,
- "user": copr.owner.name,
- "chroots": chroot_names,
- "builds": []}
-
- for package in packages_logic.PackagesLogic.get_all(copr.id):
- last_build = package.last_build(successful=True)
- if last_build:
- data["builds"].append("{}-{}".format(str(last_build.id).zfill(8), package.name))
-
- if len(data["builds"]):
- actions_logic.ActionsLogic.send_rawhide_to_release(data)
- self.turn_on_the_chroot_for_copr(copr, mock_chroot)
+ option_list = (
+ Option("rawhide_chroot", help="Rawhide chroot name, e.g. fedora-rawhide-x86_64."),
+ Option("dest_chroot", help="Destination chroot, e.g. fedora-24-x86_64."),
+ )
+
+ def run(self, rawhide_chroot, dest_chroot):
+ mock_chroot = coprs_logic.MockChrootsLogic.get_from_name(dest_chroot).first()
+ if not mock_chroot:
+ print("Given chroot does not exist. Please run:")
+ print(" sudo python manage.py create_chroot {}".format(dest_chroot))
+ return
+
+ mock_rawhide_chroot = coprs_logic.MockChrootsLogic.get_from_name(rawhide_chroot).first()
+ if not mock_rawhide_chroot:
+ print("Given rawhide chroot does not exist. Didnt you mistyped?:")
+ print(" {}".format(rawhide_chroot))
+ return
+
+ for copr in coprs_logic.CoprsLogic.get_all():
+ if not self.has_rawhide(copr):
+ continue
+
+ data = {"copr": copr.name,
+ "user": copr.owner.name,
+ "rawhide_chroot": rawhide_chroot,
+ "dest_chroot": dest_chroot,
+ "builds": []}
+
+ for package in packages_logic.PackagesLogic.get_all(copr.id):
+ last_build = package.last_build(successful=True)
+ if last_build:
+ data["builds"].append("{}-{}".format(str(last_build.id).zfill(8), package.name))
+
+ if len(data["builds"]):
+ actions_logic.ActionsLogic.send_rawhide_to_release(data)
+ self.turn_on_the_chroot_for_copr(copr, rawhide_chroot, mock_chroot)
db.session.commit()
- def turn_on_the_chroot_for_copr(self, copr, mock_chroot):
- rawhide_chroot = coprs_logic.CoprChrootsLogic.\
- get_by_name_safe(copr, "fedora-rawhide-{}".format(mock_chroot.name.split("-")[-1]))
+ def turn_on_the_chroot_for_copr(self, copr, rawhide_name, mock_chroot):
+ rawhide_chroot = coprs_logic.CoprChrootsLogic.get_by_name_safe(copr, rawhide_name)
+ dest_chroot = coprs_logic.CoprChrootsLogic.get_by_name_safe(copr, mock_chroot.name)
- if not rawhide_chroot or coprs_logic.CoprChrootsLogic.get_by_name_safe(copr, mock_chroot.name):
+ if not rawhide_chroot or dest_chroot:
return
- coprs_logic.CoprChrootsLogic.create_chroot(copr.owner, copr, mock_chroot,
- buildroot_pkgs=rawhide_chroot.buildroot_pkgs,
- comps=rawhide_chroot.comps,
- comps_name=rawhide_chroot.comps_name)
+ create_kwargs = {
+ "buildroot_pkgs": rawhide_chroot.buildroot_pkgs,
+ "comps": rawhide_chroot.comps,
+ "comps_name": rawhide_chroot.comps_name,
+ }
+ coprs_logic.CoprChrootsLogic.create_chroot(copr.owner, copr, mock_chroot, **create_kwargs)
def has_rawhide(self, copr):
return any(filter(lambda ch: ch.os_version == "rawhide", copr.mock_chroots))