stages/dnf: support --exclude

This allows given packages to be excluded from the transaction. This
is useful if you want to install a group with certain exceptions.

A common thing to do in kicktstart files is:
```
rm -f /boot/*-rescue*
```

By instead excluding the dracut-rescue-config package we end up
with:
```
"deleted_files": [
  "/etc/kernel/postinst.d",
  "/usr/lib/dracut/dracut.conf.d/02-rescue.conf",
  "/usr/lib/kernel/install.d/51-dracut-rescue.install",
  "/boot/initramfs-0-rescue-ffffffffffffffffffffffffffffffff.img",
  "/boot/vmlinuz-0-rescue-ffffffffffffffffffffffffffffffff"
],
```

Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
Tom Gundersen 2019-09-30 23:17:18 +02:00 committed by Lars Karlitski
parent adf5989de2
commit 8f9dd5ec7d
2 changed files with 6 additions and 0 deletions

View file

@ -23,6 +23,9 @@
"qemu-guest-agent",
"xen-libs",
"langpacks-en"
],
"exclude-packages": [
"dracut-config-rescue"
]
}
},

View file

@ -60,6 +60,7 @@ def main(tree, options):
basearch = options["basearch"]
operation = options.get("operation", "install")
weak_deps = options.get("install_weak_deps", True)
exclude_packages = options.get("exclude-packages", [])
with open("/tmp/dnf.conf", "w") as conf:
for repoid, repo in enumerate(repos):
@ -101,6 +102,8 @@ def main(tree, options):
]
cmd = base_cmd + [operation] + packages
for x in exclude_packages:
cmd += ["--exclude", x]
print(" ".join(cmd), flush=True)
subprocess.run(cmd, check=True)