Simplify handling of package suffix
Instead of constructing the package name from "rust-" prefix, the name, and the suffix, let's just do it once.
This commit is contained in:
parent
598c5e3972
commit
aa2bacbad6
2 changed files with 9 additions and 12 deletions
|
@ -136,6 +136,10 @@ def remove_on_error(path):
|
|||
os.unlink(path)
|
||||
raise
|
||||
|
||||
def package_name_suffixed(name, suffix):
|
||||
joiner = '_' if suffix and name[-1].isdigit() else ''
|
||||
return 'rust-' + name + joiner + (suffix or '')
|
||||
|
||||
def local_toml(toml, version):
|
||||
if os.path.isdir(toml):
|
||||
doc_files = get_doc_files(toml)
|
||||
|
@ -504,21 +508,14 @@ def main():
|
|||
raise ValueError("No bins and no libs")
|
||||
kwargs["include_devel"] = is_lib
|
||||
|
||||
if args.suffix is not None:
|
||||
if metadata.name[-1].isdigit():
|
||||
suffix = f'_{args.suffix}'
|
||||
else:
|
||||
suffix = args.suffix
|
||||
else:
|
||||
suffix = ""
|
||||
kwargs["pkg_suffix"] = suffix
|
||||
spec_file = pathlib.Path(f"rust-{metadata.name}{suffix}.spec")
|
||||
kwargs["pkg_name"] = pkg_name = package_name_suffixed(metadata.name, args.suffix)
|
||||
spec_file = pathlib.Path(f"{pkg_name}.spec")
|
||||
|
||||
if args.target in {"fedora"} and args.existence_check and not os.path.exists(spec_file):
|
||||
# No specfile, so this is probably a new package
|
||||
package_info = get_package_info(f"rust-{metadata.name}{suffix}")
|
||||
package_info = get_package_info(pkg_name)
|
||||
if package_info:
|
||||
print(f"Crate {metadata.name}{suffix} is already packaged in Fedora ({package_info['full_url']}).")
|
||||
print(f"Crate {pkg_name} is already packaged in Fedora ({package_info['full_url']}).")
|
||||
print("Re-run with --no-existence-check if you still want to convert it.")
|
||||
sys.exit(1)
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
%global real_crate {{ crate }}
|
||||
{% endif %}
|
||||
|
||||
Name: rust-%{crate}{{ pkg_suffix }}
|
||||
Name: {{ pkg_name }}
|
||||
Version: {{ md.version }}
|
||||
Release: {{ pkg_release }}
|
||||
{% if md.description is none %}
|
||||
|
|
Loading…
Reference in a new issue