diff --git a/pungi/wrappers/fus.py b/pungi/wrappers/fus.py index 28a03442..3711d192 100644 --- a/pungi/wrappers/fus.py +++ b/pungi/wrappers/fus.py @@ -37,9 +37,9 @@ def get_cmd( cmd = ["fus", "--verbose", "--arch", arch] for idx, repo in enumerate(repos): - cmd.append("--repo=repo-%s,repo,%s" % (idx, repo)) + cmd.append("--repo=repo-%s,repo,%s" % (idx, _prep_path(repo))) for idx, repo in enumerate(lookasides): - cmd.append("--repo=lookaside-%s,lookaside,%s" % (idx, repo)) + cmd.append("--repo=lookaside-%s,lookaside,%s" % (idx, _prep_path(repo))) if platform: cmd.append("--platform=%s" % platform) @@ -52,6 +52,17 @@ def get_cmd( return cmd +def _prep_path(path): + """Strip file:// from the path if present or raise exception for other + protocols. + """ + if "://" in path: + proto, path = path.split("://", 2) + if proto != "file": + raise ValueError("Only repositories on local filesystem are supported.") + return path + + def parse_output(output): """Read output of fus from the given filepath, and return a set of tuples (NVR, arch, flags) and a set of module NSVCs. diff --git a/tests/test_fus_wrapper.py b/tests/test_fus_wrapper.py index c8170110..c62c6478 100644 --- a/tests/test_fus_wrapper.py +++ b/tests/test_fus_wrapper.py @@ -47,6 +47,27 @@ class TestGetCmd(unittest.TestCase): ], ) + def test_strip_file_protocol(self): + cmd = fus.get_cmd("x86_64", ["file:///tmp"], [], [], [], []) + self.assertEqual( + cmd, ["fus", "--verbose", "--arch", "x86_64", "--repo=repo-0,repo,/tmp"] + ) + + def test_fail_on_http_repo(self): + with self.assertRaises(ValueError): + fus.get_cmd("x86_64", ["http:///tmp"], [], [], [], []) + + def test_strip_file_protocol_lookaside(self): + cmd = fus.get_cmd("x86_64", [], ["file:///r"], [], [], []) + self.assertEqual( + cmd, + ["fus", "--verbose", "--arch", "x86_64", "--repo=lookaside-0,lookaside,/r"] + ) + + def test_fail_on_http_repo_lookaside(self): + with self.assertRaises(ValueError): + fus.get_cmd("x86_64", [], ["http:///tmp"], [], [], []) + class TestParseOutput(unittest.TestCase): def setUp(self):