Last active
April 13, 2021 10:43
-
-
Save msehnout/1f071ffd6134723083e6dd9a51859e87 to your computer and use it in GitHub Desktop.
dnf resolve 2 package sets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import dnf | |
base = dnf.Base() | |
conf = base.conf | |
conf.cachedir = '/tmp/my_cache_dir' | |
conf.substitutions['releasever'] = '33' | |
conf.substitutions['basearch'] = 'x86_64' | |
base.repos.add_new_repo('my-repo', conf, | |
baseurl=["http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/"]) | |
base.fill_sack(load_system_repo=False) | |
print("Enabled repositories:") | |
for repo in base.repos.iter_enabled(): | |
print("id: {}".format(repo.id)) | |
print("baseurl: {}".format(repo.baseurl)) | |
# First include and exclude packages and groups that define the OS | |
print("First run:") | |
include = [ | |
"vim-minimal" | |
] | |
exclude = [ | |
"logrotate" | |
] | |
base.install_specs( | |
include, | |
exclude=exclude, | |
strict=True | |
) | |
base.resolve() | |
for tsi in base.transaction: | |
# Avoid using the install_set() helper, as it does not guarantee | |
# a stable order | |
if tsi.action not in dnf.transaction.FORWARD_ACTIONS: | |
continue | |
print(f"Pkg to install: {tsi.pkg}") | |
# Second, apply the customizations from the user. Ideally this would override whatever | |
# excludes from the first run, but THIS DOESN'T WORK YET. | |
print("Second run:") | |
include = [ | |
"vsftpd" | |
] | |
exclude = [] | |
base.install_specs( | |
include, | |
exclude=exclude, | |
strict=False | |
) | |
base.resolve() | |
for tsi in base.transaction: | |
# Avoid using the install_set() helper, as it does not guarantee | |
# a stable order | |
if tsi.action not in dnf.transaction.FORWARD_ACTIONS: | |
continue | |
print(f"Pkg to install: {tsi.pkg}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment