package: spec file
Provide a spec file for `image-builder-cli`. The spec file is based on `osbuild-composer`'s spec file except it is simplified as (some) usecases would currently cloud the intent of the specfile. We can add back RHEL conditionals when/if we start shipping and building for RHEL. Some tools from `osbuild-composer` are also included; most notably the one that generates bundled dependencies from vendored modules. Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This commit is contained in:
parent
cdf627389e
commit
60c22e3214
5 changed files with 332 additions and 0 deletions
63
tools/rpm_spec_vendor2provides
Executable file
63
tools/rpm_spec_vendor2provides
Executable file
|
|
@ -0,0 +1,63 @@
|
|||
#!/usr/bin/python3 -s
|
||||
|
||||
# Parse modules.txt files into rpm .spec file Provides for bundled dependencies.
|
||||
# Written by Fabio "decathorpe" Valentini <decathorpe@fedoraproject.org> for
|
||||
# the fedora syncthing package: https://src.fedoraproject.org/rpms/syncthing
|
||||
# SPDX-License-Identifier: CC0-1.0 OR Unlicense
|
||||
|
||||
# Modified by @gotmax23 to be used as a dependency generator
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# SPDX-FileCopyrightText: 2022 Maxwell G <gotmax@e.email>
|
||||
#
|
||||
# Minor modifications by Achilleas Koutsou <achilleas@koutsou.net> to be used in
|
||||
# the rpm spec file generator for https://github.com/osbuild/osbuild-composer
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
def process(path: str):
|
||||
with open(path, encoding="utf-8") as file:
|
||||
contents = file.read()
|
||||
|
||||
lines = contents.split("\n")
|
||||
|
||||
# dependencies = filter lines for "# package version"
|
||||
dependencies = list(filter(lambda line: line.startswith("# "), lines))
|
||||
|
||||
# parse vendored dependencies into (import path, version) pairs
|
||||
vendored = []
|
||||
# Handle => style replace directives
|
||||
replace_regex = re.compile(r"^.+( v[0-9-\.]+)? => ")
|
||||
for dep in dependencies:
|
||||
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:
|
||||
# return only 7 digits of git commit hash
|
||||
version = version[-12:-1][0:7]
|
||||
else:
|
||||
# strip off leading "v"
|
||||
version = version.lstrip("v")
|
||||
|
||||
vendored.append((ipath, version))
|
||||
|
||||
for ipath, version in vendored:
|
||||
print(f"Provides: bundled(golang({ipath})) = {version}")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
files = sys.argv[1:]
|
||||
for file in files:
|
||||
process(file)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue