diff --git a/manage.py b/manage.py index d4dacb79..afb6d6bd 100644 --- a/manage.py +++ b/manage.py @@ -32,7 +32,7 @@ from module_build_service import app, conf, db from module_build_service.config import Config from module_build_service.pdc import ( get_pdc_client_session, get_module, get_module_runtime_dependencies, - get_module_tag, get_module_build_dependencies) + get_module_tag, get_module_build_dependencies, get_module_repo) import module_build_service.auth @@ -86,6 +86,10 @@ def testpdc(): print ("build_deps=%s" % get_module_build_dependencies( pdc_session, module)) print ("tag=%s" % get_module_tag(pdc_session, module)) + + module2 = get_module(pdc_session, {"name": "coprtestmodule", "version": "4.3.43", "release": 1}) + print ("pdc_data=%s" % str(module)) + print ("repo=%s" % get_module_repo(pdc_session, module2)) else: print ('module was not found') diff --git a/module_build_service/pdc.py b/module_build_service/pdc.py index 328def36..309a13bb 100644 --- a/module_build_service/pdc.py +++ b/module_build_service/pdc.py @@ -28,6 +28,7 @@ import modulemd from pdc_client import PDCClient import six +import os @@ -153,6 +154,36 @@ def get_module_tag(session, module_info, strict=False): """ return get_module(session, module_info, strict=strict)['koji_tag'] +def get_module_repo(session, module_info, strict=False): + """ + :param session : PDCClient instance + :param module_info: list of module_info dicts + :param strict: Normally this function returns None if no module can be + found. If strict=True, then a ValueError is raised. + :return: URL to a DNF repository for the module + """ + module = get_module(session, module_info, strict=strict) + if not module: + return None + + # Module was built in Koji + # @TODO There should be implemented retrieveing URL to a module repofile in koji + if module["koji_tag"] != "-": + raise NotImplementedError + + # Module was built in Copr + # @TODO get the correct user + owner, project = "@copr", module["variant_id"] + + # Some user/group logic. We should really be using python-copr for that + g = "" + if owner[0] == "@": + g = "/g" + owner = owner[1:] + + base = "http://copr-fe-dev.cloud.fedoraproject.org" + return "{}/coprs{}/{}/{}/repo/modules".format(base, g, owner, project) + def module_depsolving_wrapper(session, module_list, strict=True): """ :param session : PDCClient instance