From 08e5c53d31893f9f4534f63272f75894edffe91c Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 18 Jul 2023 11:23:49 -0700 Subject: [PATCH] tools: Add support for local go package replacement Local packages do not have a version number. Fake it with 'HEAD' to indicate it's using whatever the working directory is pointing at. The Provides line will then look like: Provides: bundled(golang(../osbuild-images)) = HEAD which rpmbuild is happy to process into an rpm. This is ONLY for test builds on local systems and should never be seen in the wild. --- tools/rpm_spec_vendor2provides | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/rpm_spec_vendor2provides b/tools/rpm_spec_vendor2provides index 8cab58330..ef3b9c3d5 100755 --- a/tools/rpm_spec_vendor2provides +++ b/tools/rpm_spec_vendor2provides @@ -30,7 +30,14 @@ def process(path: str): # Handle => style replace directives replace_regex = re.compile("^.+( v[0-9-\.]+)? => ") for dep in dependencies: - ipath, version = replace_regex.sub("", dep[2:]).split(" ")[:2] + fields = replace_regex.sub("", dep[2:]).split(" ") + if len(fields) == 2: + ipath, version = fields + elif len(fields) == 1: + ipath = fields[0] + version = "HEAD" + else: + raise RuntimeError(f"Failed to parse dependency: {dep}") # check for git snapshots if len(version) > 27: