diff --git a/mpcdf_push.py b/mpcdf_push.py index ba5cf1c7ab74e3d54a4a8ea602cb524c40551de3..91b56c2469da725609178aa46a50679a39fa93fe 100644 --- a/mpcdf_push.py +++ b/mpcdf_push.py @@ -53,32 +53,36 @@ def do_mpcdf_push(self, subcmd, opts, *args): print("Setting attribute", attribute) mpcdf_common.set_attribute(api_url, (to_project,), attr) - for package in from_packages: - if package not in to_packages: - filelist = osc.core.meta_get_filelist(api_url, from_project, package) + for orig_package in from_packages: + if orig_package not in to_packages: + filelist = osc.core.meta_get_filelist(api_url, from_project, orig_package) if "_link" in filelist: - print("Not branching package {0}, is a link".format(package)) + print("Not branching package {0}, is a link".format(orig_package)) else: - print("Branching package {0}".format(package)) + print("Branching package {0}".format(orig_package)) exists, targetprj, targetpkg, srcprj, srcpkg = \ - osc.core.branch_pkg(api_url, from_project, package, target_project=to_project, nodevelproject=True) + osc.core.branch_pkg(api_url, from_project, orig_package, target_project=to_project, nodevelproject=True) else: - print("Not branching package {0}, already present in target".format(package)) + print("Not branching package {0}, already present in target".format(orig_package)) for attribute in package_attributes: try: - attr = mpcdf_common.get_attribute(api_url, from_project, package, attribute) + attr = mpcdf_common.get_attribute(api_url, from_project, orig_package, attribute) except Exception: continue - mpcdf_common.set_attribute(api_url, (to_project, package), attr) + mpcdf_common.set_attribute(api_url, (to_project, orig_package), attr) - # Check if distribution is already set in to_project - to_prj_meta = mpcdf_common.project_meta(api_url, to_project) - sys_repo = to_prj_meta.find('./repository[@name="System"]') - if sys_repo is None: - distribution = mpcdf_common.project_meta(api_url, from_project).find('./repository[@name="System"]/path[@project="distributions"]').get("repository") - else: - distribution = sys_repo.find('./path[@project="distributions"]').get("repository") + if package is None: + # Check if distribution is already set in to_project + to_prj_meta = mpcdf_common.project_meta(api_url, to_project) + sys_repo = to_prj_meta.find('./repository[@name="System"]') + if sys_repo is None: + distribution = mpcdf_common.project_meta(api_url, from_project).find('./repository[@name="System"]/path[@project="distributions"]').get("repository") + else: + distribution = sys_repo.find('./path[@project="distributions"]').get("repository") - print("Creating repository configuration") - mpcdf_common.mpcdf_setup_repos(api_url, to_project, distribution, packages=[package] if package else None) + print("Creating repository configuration") + mpcdf_common.mpcdf_setup_repos(api_url, to_project, distribution) + else: + if not mpcdf_common.mpcdf_enable_repositories(api_url, to_project, package): + print("ATTENTION: Not changing unmanaged package {0}".format(package))