From f8e82a9e3e2bf8a2179849c624f6663c5932cd5d Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Mar 13 2023 19:53:02 +0000 Subject: Add rpm2flatpak --kde flag This helps simplify the creation of new apps using the KDE 5 runtime. --- diff --git a/_fedmod/cli.py b/_fedmod/cli.py index 44a4825..e264df8 100644 --- a/_fedmod/cli.py +++ b/_fedmod/cli.py @@ -127,7 +127,9 @@ def repo2module(repopath, apipkgs, out_file, in_file): @click.option("--flathub", metavar="ID_OR_SEARCH_TERM", help="Initialize from a Flathub Flatpak.") @click.option("--flatpak-common", "-c", is_flag=True, - help="Use dependencies from the flatpak-common module") + help="Use dependencies from the common module") +@click.option("--kde", "-K", is_flag=True, + help="Use dependencies from the KDE runtime") @click.option("--output-modulemd", metavar="FILE", help="Write modulemd to FILE instead of .yaml.") @click.option("--output-containerspec", metavar="FILE", @@ -136,11 +138,11 @@ def repo2module(repopath, apipkgs, out_file, in_file): @click.option("--force", "-f", is_flag=True, help="Overwriting existing output files") @click.argument("pkg", metavar='PKG', required=True) -def rpm2flatpak(pkg, output_modulemd, output_containerspec, force, flathub, flatpak_common): +def rpm2flatpak(pkg, output_modulemd, output_containerspec, force, flathub, flatpak_common, kde): """Generate modulemd from an RPM""" fg = flatpak_generator.FlatpakGenerator(pkg) fg.run(output_modulemd, output_containerspec, force=force, flathub=flathub, - include_flatpak_common=flatpak_common) + include_flatpak_common=flatpak_common, kde=kde) @_cli_commands.command('flatpak-report') diff --git a/_fedmod/flatpak_generator.py b/_fedmod/flatpak_generator.py index 7332274..bb2941b 100644 --- a/_fedmod/flatpak_generator.py +++ b/_fedmod/flatpak_generator.py @@ -55,8 +55,8 @@ def dataset_release_branch(): return release_name -def _get_runtime_packages(): - builds = get_module_builds('flatpak-runtime', dataset_release_branch()) +def _get_runtime_packages(runtime_module): + builds = get_module_builds(runtime_module, dataset_release_branch()) # Each flatpak-runtime stream should be built against a single context assert len(builds) == 1 build = builds[0] @@ -67,8 +67,8 @@ def _get_runtime_packages(): return set(mmd.peek_profiles()['runtime'].peek_rpms().get()) -def _get_common_packages(): - builds = get_module_builds('flatpak-common', dataset_release_branch(), include_rpms=True) +def _get_common_packages(common_module): + builds = get_module_builds(common_module, dataset_release_branch(), include_rpms=True) # Each flatpak-common stream should be built against a single context assert len(builds) == 1 build = builds[0] @@ -139,9 +139,16 @@ class FlatpakGenerator(ModuleGenerator): self.api_srpms = {rpm_name_only(_depchase.get_srpm_for_rpm(pool, pkg))} - hint_packages = _get_runtime_packages() + if self.kde: + runtime_module = 'flatpak-kde5-runtime' + common_module = 'flatpak-kde5-common' + else: + runtime_module = 'flatpak-runtime' + common_module = 'flatpak-common' + + hint_packages = _get_runtime_packages(runtime_module) if self.include_flatpak_common: - hint_packages.update(_get_common_packages()) + hint_packages.update(_get_common_packages(common_module)) all_needed_packages = _depchase.ensure_installable( pool, [pkg], hints=hint_packages) @@ -152,9 +159,9 @@ class FlatpakGenerator(ModuleGenerator): for dep in pkgs} self.run_srpms = run_srpms - self.api_srpms - self.module_run_deps = {'flatpak-runtime': [dataset_release_branch()]} + self.module_run_deps = {runtime_module: [dataset_release_branch()]} if self.include_flatpak_common: - self.module_run_deps['flatpak-common'] = [dataset_release_branch()] + self.module_run_deps[common_module] = [dataset_release_branch()] self.module_run_deps['platform'] = [dataset_release_branch()] def _update_module_md(self): @@ -236,10 +243,11 @@ class FlatpakGenerator(ModuleGenerator): f" Please edit appropriately.") def run(self, output_modulemd, output_containerspec, - force=False, flathub=None, include_flatpak_common=False): + force=False, flathub=None, include_flatpak_common=False, kde=False): flathub_manifest = _load_flathub_manifest(flathub) if flathub else None self.include_flatpak_common = include_flatpak_common + self.kde = kde if output_modulemd is None: pkg = self.pkgs[0] @@ -263,7 +271,7 @@ class FlatpakGenerator(ModuleGenerator): def do_flatpak_report(pkgs, quiet=False): if not quiet: print("Initializing", file=sys.stderr) - runtime_packages = _get_runtime_packages() + runtime_packages = _get_runtime_packages('flatpak-runtime') pool = _depchase.make_pool() packages = {}