async def sign_mbs_build(build: Build, mbs_build): tasks = mbs_build.get("tasks") if not tasks: return rpms = tasks.get("rpms") if not rpms: return for rpm_name in rpms.keys(): if rpm_name == "module-build-macros": continue rpm = rpms[rpm_name] if rpm["state"] != 1: continue build_rpms = koji_session.listBuildRPMs(rpm["nvr"]) if len(build_rpms) > 0: await sign_build_rpms(build_rpms) package_modules = await PackageModule.filter( module_parent_package_id=build.package.id).prefetch_related( "package").all() for package_module in package_modules: package_module_package = await Package.filter(id=package_module.package.id).first() package_module_package.last_build = datetime.datetime.now() await package_module_package.save() name = mbs_build["name"] name_devel = f"{name}-devel" koji_session.packageListAdd(tags.module_compose(), name, "distrobuild") koji_session.packageListAdd(tags.module_compose(), name_devel, "distrobuild") koji_tag = mbs_build["koji_tag"] context = mbs_build["context"] nvr = koji_tag.replace("module-", "").replace(f"-{context}", f".{context}") nvr_devel = nvr.replace(name, name_devel) koji_session.tagBuild(tags.module_compose(), nvr) koji_session.tagBuild(tags.module_compose(), nvr_devel) build.signed = True await build.save()
async def atomic_sign_unsigned_builds(build: Build): if build.koji_id: koji_session.packageListAdd(tags.compose(), build.package.name, "distrobuild") build_tasks = koji_session.listBuilds(taskID=build.koji_id) for build_task in build_tasks: build_history = koji_session.queryHistory(build=build_task["build_id"]) tag_if_not_tagged(build_history, build_task["nvr"], tags.compose()) build_rpms = koji_session.listBuildRPMs(build_task["build_id"]) await sign_build_rpms(build_rpms) build.signed = True await build.save() elif build.mbs_id: mbs_build = await mbs_client.get_build(build.mbs_id) await sign_mbs_build(build, mbs_build) siblings = mbs_build.get("siblings") if siblings: for sibling in siblings: n_mbs_build = await mbs_client.get_build(sibling) await sign_mbs_build(build, n_mbs_build)