Package commands :: Module rawhide_to_release
[hide private]
[frames] | no frames]

Source Code for Module commands.rawhide_to_release

 1  from flask_script import Command, Option 
 2  from copr_common.enums import StatusEnum 
 3  from coprs import db 
 4  from coprs import models 
 5  from coprs.logic import coprs_logic, actions_logic, builds_logic 
 6   
 7   
8 -class RawhideToReleaseCommand(Command):
9 10 option_list = ( 11 Option("rawhide_chroot", help="Rawhide chroot name, e.g. fedora-rawhide-x86_64."), 12 Option("dest_chroot", help="Destination chroot, e.g. fedora-24-x86_64."), 13 ) 14
15 - def run(self, rawhide_chroot, dest_chroot):
16 mock_chroot = coprs_logic.MockChrootsLogic.get_from_name(dest_chroot).first() 17 if not mock_chroot: 18 print("Given chroot does not exist. Please run:") 19 print(" sudo python3 manage.py create_chroot {}".format(dest_chroot)) 20 return 21 22 mock_rawhide_chroot = coprs_logic.MockChrootsLogic.get_from_name(rawhide_chroot).first() 23 if not mock_rawhide_chroot: 24 print("Given rawhide chroot does not exist. Didnt you mistyped?:") 25 print(" {}".format(rawhide_chroot)) 26 return 27 28 for copr in coprs_logic.CoprsLogic.get_all(): 29 if not self.has_rawhide(copr) or not copr.follow_fedora_branching: 30 continue 31 32 self.turn_on_the_chroot_for_copr(copr, rawhide_chroot, mock_chroot) 33 34 data = {"projectname": copr.name, 35 "ownername": copr.owner_name, 36 "rawhide_chroot": rawhide_chroot, 37 "dest_chroot": dest_chroot, 38 "builds": []} 39 40 for build in builds_logic.BuildsLogic.get_multiple_by_copr(copr): 41 # rbc means rawhide_build_chroot (we needed short variable) 42 rbc = builds_logic.BuildChrootsLogic.get_by_build_id_and_name(build.id, rawhide_chroot).first() 43 dbc = builds_logic.BuildChrootsLogic.get_by_build_id_and_name(build.id, dest_chroot).first() 44 45 if not rbc or rbc.status != StatusEnum("succeeded"): 46 continue 47 48 data["builds"].append(rbc.result_dir) 49 50 if rbc and not dbc: 51 dest_build_chroot = models.BuildChroot(**rbc.to_dict()) 52 dest_build_chroot.mock_chroot_id = mock_chroot.id 53 dest_build_chroot.mock_chroot = mock_chroot 54 dest_build_chroot.status = StatusEnum("forked") 55 db.session.add(dest_build_chroot) 56 57 if len(data["builds"]): 58 actions_logic.ActionsLogic.send_rawhide_to_release(data) 59 60 db.session.commit()
61
62 - def turn_on_the_chroot_for_copr(self, copr, rawhide_name, mock_chroot):
63 rawhide_chroot = coprs_logic.CoprChrootsLogic.get_by_name_safe(copr, rawhide_name) 64 dest_chroot = coprs_logic.CoprChrootsLogic.get_by_name_safe(copr, mock_chroot.name) 65 66 if not rawhide_chroot or dest_chroot: 67 return 68 69 create_kwargs = { 70 "buildroot_pkgs": rawhide_chroot.buildroot_pkgs, 71 "comps": rawhide_chroot.comps, 72 "comps_name": rawhide_chroot.comps_name, 73 } 74 coprs_logic.CoprChrootsLogic.create_chroot(copr.user, copr, mock_chroot, **create_kwargs)
75
76 - def has_rawhide(self, copr):
77 return any(filter(lambda ch: ch.os_version == "rawhide", copr.mock_chroots))
78