From 456fb55744a1acc6bd2f464b7656a9c33d0b7ac5 Mon Sep 17 00:00:00 2001 From: Ryan Harper Date: Fri, 24 Jul 2020 12:59:49 -0500 Subject: fix brpm building tools/read-dependencies: - Add parameters --build-requires, --runtime-requires - Sort dependency output before printing package/brpm - use --build-requires, --runtime-requires to separate build/vs runtime package reqs. LP: #1886107 --- packages/brpm | 18 +++++++++++------- tools/read-dependencies | 23 ++++++++++++++++++++--- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/packages/brpm b/packages/brpm index 56477d2e..a9fd0b70 100755 --- a/packages/brpm +++ b/packages/brpm @@ -46,15 +46,19 @@ def run_helper(helper, args=None, strip=True): def read_dependencies(distro): """Returns the Python package depedencies from requirements.txt files. - @returns a tuple of (requirements, test_requirements) + @returns a tuple of (build_deps, run_deps, test_deps) """ - pkg_deps = run_helper( - 'read-dependencies', args=['--distro', distro]).splitlines() + build_deps = run_helper( + 'read-dependencies',args=[ + '--distro', distro, '--build-requires']).splitlines() + run_deps = run_helper( + 'read-dependencies', args=[ + '--distro', distro, '--runtime-requires']).splitlines() test_deps = run_helper( 'read-dependencies', args=[ '--requirements-file', 'test-requirements.txt', '--system-pkg-names']).splitlines() - return (pkg_deps, test_deps) + return (build_deps, run_deps, test_deps) def read_version(): @@ -84,9 +88,9 @@ def generate_spec_contents(args, version_data, tmpl_fn, top_dir, arc_fn): rpm_upstream_version = version_data['version'] subs['rpm_upstream_version'] = rpm_upstream_version - deps, test_deps = read_dependencies(distro=args.distro) - subs['buildrequires'] = deps + test_deps - subs['requires'] = deps + build_deps, run_deps, test_deps = read_dependencies(distro=args.distro) + subs['buildrequires'] = build_deps + test_deps + subs['requires'] = run_deps if args.boot == 'sysvinit': subs['sysvinit'] = True diff --git a/tools/read-dependencies b/tools/read-dependencies index fd1946a5..6ad5f701 100755 --- a/tools/read-dependencies +++ b/tools/read-dependencies @@ -101,6 +101,14 @@ def get_parser(): parser.add_argument( '-d', '--distro', type=str, choices=DISTRO_PKG_TYPE_MAP.keys(), help='The name of the distro to generate package deps for.') + deptype = parser.add_mutually_exclusive_group() + deptype.add_argument( + '-R', '--runtime-requires', action='store_true', default=False, + dest='runtime_requires', + help='Print only runtime required packages') + deptype.add_argument( + '-b', '--build-requires', action='store_true', default=False, + dest='build_requires', help='Print only buildtime required packages') parser.add_argument( '--dry-run', action='store_true', default=False, dest='dry_run', help='Dry run the install, making no package changes.') @@ -222,15 +230,24 @@ def main(distro): translated_pip_names = translate_pip_to_system_pkg( pip_pkg_names, renames) all_deps = [] + select_requires = [args.build_requires, args.runtime_requires] if args.distro: - all_deps.extend( - translated_pip_names + deps_from_json['requires'] + - deps_from_json['build-requires']) + if not any(select_requires): + all_deps.extend( + translated_pip_names + deps_from_json['requires'] + + deps_from_json['build-requires']) + else: + if args.build_requires: + all_deps.extend(deps_from_json['build-requires']) + else: + all_deps.extend( + translated_pip_names + deps_from_json['requires']) else: if args.system_pkg_names: all_deps = translated_pip_names else: all_deps = pip_pkg_names + all_deps = sorted(all_deps) if args.install: pkg_install(all_deps, args.distro, args.test_distro, args.dry_run) else: -- cgit v1.2.3