From cc489bde7a3a06354aa4e5c1dad3e3f9dbdb6564 Mon Sep 17 00:00:00 2001 From: Tomas Orsava Date: Tue, 25 May 2021 17:56:00 +0200 Subject: [PATCH] pythondistdeps.py: Catch all exceptions and terminate build if one is raised --- python-rpm-generators.spec | 6 +++++- pythondistdeps.py | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/python-rpm-generators.spec b/python-rpm-generators.spec index 072883b..6011515 100644 --- a/python-rpm-generators.spec +++ b/python-rpm-generators.spec @@ -1,7 +1,7 @@ Name: python-rpm-generators Summary: Dependency generators for Python RPMs Version: 12 -Release: 6%{?dist} +Release: 7%{?dist} # Originally all those files were part of RPM, so license is kept here License: GPLv2+ @@ -47,6 +47,10 @@ install -Dpm0755 -t %{buildroot}%{_rpmconfigdir} *.py %{_rpmconfigdir}/pythonbundles.py %changelog +* Tue May 25 2021 Tomas Orsava - 12-7 +- pythondistdeps.py: Detect missing or corrupted metadata +- pythondistdeps.py: Catch all exceptions and terminate the build if one is raised + * Mon Apr 19 2021 Miro HronĨok - 12-6 - Get rid of distutils deprecation warning (by not using it) - The distutils module is deprecated in Python 3.10+ diff --git a/pythondistdeps.py b/pythondistdeps.py index 25ca6cb..e8b5afd 100755 --- a/pythondistdeps.py +++ b/pythondistdeps.py @@ -260,10 +260,10 @@ def get_marker_env(dist, extra): "extra": extra} -if __name__ == "__main__": +def main(): """To allow this script to be importable (and its classes/functions - reused), actions are performed only when run as a main script.""" - + reused), actions are defined in the main function and are performed only + when run as a main script.""" parser = argparse.ArgumentParser(prog=argv[0]) group = parser.add_mutually_exclusive_group(required=True) group.add_argument('-P', '--provides', action='store_true', help='Print Provides') @@ -552,3 +552,14 @@ if __name__ == "__main__": else: # Print out unversioned provides, requires, recommends, conflicts print(name) + + +if __name__ == "__main__": + """To allow this script to be importable (and its classes/functions + reused), actions are performed only when run as a main script.""" + try: + main() + except Exception as exc: + print("*** PYTHONDISTDEPS_GENERATORS_FAILED ***", flush=True) + raise RuntimeError("Error: pythondistdeps.py generator encountered an unhandled exception and was terminated.") from exc +