main: small refactor to simplify decision logic
This commit is contained in:
parent
ec8dcf58d0
commit
722ace88d5
1 changed files with 49 additions and 49 deletions
|
@ -104,8 +104,56 @@ def main():
|
|||
else:
|
||||
tomlconf = load_config(set(), args.target)
|
||||
|
||||
# package for a workspace project
|
||||
if metadata.is_workspace():
|
||||
try:
|
||||
main_package = guess_main_package(metadata, hint=project, interactive=args.interactive)
|
||||
except ValueError:
|
||||
sys.exit(1)
|
||||
|
||||
spec_contents = spec_render_workspace(
|
||||
metadata=metadata,
|
||||
main_package=main_package,
|
||||
target=args.target,
|
||||
rpm_name=rpm_name,
|
||||
license_files=license_files,
|
||||
doc_files=doc_files,
|
||||
tomlconf=tomlconf,
|
||||
feature_flags=FeatureFlags(all_features=args.all_features),
|
||||
rpmautospec=args.rpmautospec,
|
||||
auto_changelog_entry=args.auto_changelog_entry,
|
||||
packager=packager,
|
||||
)
|
||||
|
||||
# package for non-crate, non-workspace project
|
||||
elif is_local:
|
||||
package = metadata.packages[0]
|
||||
|
||||
if build_meta := Version.parse(package.version).build:
|
||||
log.error(f"Crate version {package.version!r} contains build metadata: '+{build_meta}'")
|
||||
log.error(f"This is not supported by rust2rpm; remove the '+{build_meta}' suffix.")
|
||||
sys.exit(1)
|
||||
|
||||
warn_if_package_uses_restrictive_dependencies(package)
|
||||
|
||||
spec_contents = spec_render_project(
|
||||
metadata=metadata,
|
||||
upstream_version=version,
|
||||
target=args.target,
|
||||
rpm_name=rpm_name,
|
||||
patch_file_automatic=patch_files[0],
|
||||
patch_file_manual=patch_files[1],
|
||||
license_files=license_files,
|
||||
doc_files=doc_files,
|
||||
tomlconf=tomlconf,
|
||||
feature_flags=FeatureFlags(all_features=args.all_features),
|
||||
rpmautospec=args.rpmautospec,
|
||||
auto_changelog_entry=args.auto_changelog_entry,
|
||||
packager=packager,
|
||||
)
|
||||
|
||||
# package for an actual Rust crate
|
||||
if not metadata.is_workspace() and not is_local:
|
||||
else:
|
||||
package = metadata.packages[0]
|
||||
|
||||
if build_meta := Version.parse(package.version).build:
|
||||
|
@ -132,54 +180,6 @@ def main():
|
|||
packager=packager,
|
||||
)
|
||||
|
||||
# package for non-crate, non-workspace project
|
||||
elif not metadata.is_workspace() and is_local:
|
||||
package = metadata.packages[0]
|
||||
|
||||
if build_meta := Version.parse(package.version).build:
|
||||
log.error(f"Crate version {package.version!r} contains build metadata: '+{build_meta}'")
|
||||
log.error(f"This is not supported by rust2rpm; remove the '+{build_meta}' suffix.")
|
||||
sys.exit(1)
|
||||
|
||||
warn_if_package_uses_restrictive_dependencies(package)
|
||||
|
||||
spec_contents = spec_render_project(
|
||||
metadata=metadata,
|
||||
upstream_version=version,
|
||||
target=args.target,
|
||||
rpm_name=rpm_name,
|
||||
patch_file_automatic=patch_files[0],
|
||||
patch_file_manual=patch_files[1],
|
||||
license_files=license_files,
|
||||
doc_files=doc_files,
|
||||
tomlconf=tomlconf,
|
||||
feature_flags=FeatureFlags(all_features=args.all_features),
|
||||
rpmautospec=args.rpmautospec,
|
||||
auto_changelog_entry=args.auto_changelog_entry,
|
||||
packager=packager,
|
||||
)
|
||||
|
||||
# package for a workspace project
|
||||
else:
|
||||
try:
|
||||
main_package = guess_main_package(metadata, hint=project, interactive=args.interactive)
|
||||
except ValueError:
|
||||
sys.exit(1)
|
||||
|
||||
spec_contents = spec_render_workspace(
|
||||
metadata=metadata,
|
||||
main_package=main_package,
|
||||
target=args.target,
|
||||
rpm_name=rpm_name,
|
||||
license_files=license_files,
|
||||
doc_files=doc_files,
|
||||
tomlconf=tomlconf,
|
||||
feature_flags=FeatureFlags(all_features=args.all_features),
|
||||
rpmautospec=args.rpmautospec,
|
||||
auto_changelog_entry=args.auto_changelog_entry,
|
||||
packager=packager,
|
||||
)
|
||||
|
||||
if args.stdout:
|
||||
print(f"# {spec_file}")
|
||||
print(spec_contents)
|
||||
|
|
Loading…
Reference in a new issue