Skip to content

Instantly share code, notes, and snippets.

@JayDoubleu
Last active January 7, 2021 00:25
Show Gist options
  • Save JayDoubleu/2d308871bf2317511f63cfd4053f5d74 to your computer and use it in GitHub Desktop.
Save JayDoubleu/2d308871bf2317511f63cfd4053f5d74 to your computer and use it in GitHub Desktop.
Ugly script to resolve dependencies for given rpm
import re
import sys
import yaml
import requests
from subprocess import check_output
flatpak_runtime_yaml = yaml.safe_load(
requests.get(
'https://src.fedoraproject.org/modules/flatpak-runtime/raw/f33/f/flatpak-runtime.yaml'
).content)
flatpak_common_yaml = yaml.safe_load(
requests.get(
'https://src.fedoraproject.org/modules/flatpak-common/raw/f33/f/flatpak-common.yaml'
).content)
app_package = sys.argv[1]
def get_source(pkgs, runtime):
if runtime:
command = ["dnf", "repoquery", "--quiet", "--source"]
else:
command = [
"dnf", "repoquery", "--quiet", "--requires", "--resolve",
"--recursive", "--source"
]
deps = check_output(command + pkgs).decode().splitlines()
return list(set([re.sub('-[0-9].*$', '', x) for x in deps]))
runtime_srpms = get_source(
flatpak_runtime_yaml['data']['profiles']['runtime']['rpms'], runtime=True)
runtime_sdk_srpms = get_source(
flatpak_runtime_yaml['data']['profiles']['sdk']['rpms'], runtime=True)
runtime_common_srpms = [
x for x in flatpak_common_yaml['data']['components']['rpms']
]
runtime_srpms_all = set(runtime_srpms + runtime_sdk_srpms +
runtime_common_srpms)
app_deps = get_source([app_package], runtime=False)
deps = [x for x in app_deps if x not in runtime_srpms_all]
print('package {}: {}'.format(app_package, str(deps)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment