Or at least fix the anaconda side of it, the repo itself is still pretty busted.
From: David Shea dshea@redhat.com
Make use of --cost, --includepkgs and --excludepkgs, and save --includepkgs and --excludepkgs to the installed repo file. --- pyanaconda/packaging/dnfpayload.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py index 608a636..c24aaf1 100644 --- a/pyanaconda/packaging/dnfpayload.py +++ b/pyanaconda/packaging/dnfpayload.py @@ -255,6 +255,15 @@ def _add_repo(self, ksrepo): log.error("Failed to parse proxy for _add_repo %s: %s", ksrepo.proxy, e)
+ if ksrepo.cost: + repo.cost = ksrepo.cost + + if ksrepo.includepkgs: + repo.include = ksrepo.includepkgs + + if ksrepo.excludepkgs: + repo.exclude = ksrepo.excludepkgs + # If this repo is already known, it's one of two things: # (1) The user is trying to do "repo --name=updates" in a kickstart file # and we should just know to enable the already existing on-disk @@ -874,6 +883,12 @@ def _writeDNFRepo(self, repo, repo_path): if ks_repo.cost: f.write("cost=%d\n" % ks_repo.cost)
+ if ks_repo.includepkgs: + f.write("include=%s\n" % ",".join(ks_repo.includepkgs)) + + if ks_repo.excludepkgs: + f.write("exclude=%s\n" % ",".join(ks_repo.excludepkgs)) + def postInstall(self): """ Perform post-installation tasks. """ # Write selected kickstart repos to target system
In reply to line 262 of pyanaconda/packaging/dnfpayload.py:
It's worth noting that this doesn't actually work, at least not how it's supposed to work, which is why I didn't add it to the test. dnf (and yum) take includepkgs to mean that everything else from the repo should be excluded, while we want it to just prefer the repo for that particular list of packages. But things have been that way for a good while so I figured for now it's good enough to just put things back into the same broken state we had with yumpayload.
From: David Shea dshea@redhat.com
This seems a little easier to deal with than deciphering that big comment in the kickstart. --- tests/Makefile.am | 1 + tests/kickstart_tests/make-addon-pkgs.py | 101 +++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100755 tests/kickstart_tests/make-addon-pkgs.py
diff --git a/tests/Makefile.am b/tests/Makefile.am index 22626ff..c4b7043 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -52,6 +52,7 @@ dist_check_SCRIPTS = $(srcdir)/glade/*.py \ install/run_install_test.sh \ $(srcdir)/kickstart_tests/*.ks \ $(srcdir)/kickstart_tests/*.sh \ + $(srcdir)/kickstart_tests/*.py \ $(srcdir)/kickstart_tests/kstest-runner \ $(srcdir)/gui/*.ks \ $(srcdir)/gui/*.sh \ diff --git a/tests/kickstart_tests/make-addon-pkgs.py b/tests/kickstart_tests/make-addon-pkgs.py new file mode 100755 index 0000000..c88601c --- /dev/null +++ b/tests/kickstart_tests/make-addon-pkgs.py @@ -0,0 +1,101 @@ +#!/usr/bin/python3 + +# This script creates all the packages used by nfs-repo-and-addon.ks. +# The packages are created in two directories, http and nfs. After all the rpms +# are made just copy everything to the locations set in $KSTEST_ADDON_HTTP_REPO +# and $KSTEST_ADDON_NFS_REPO. +# +# This script imports things from tests/lib/mkdud.py, so tests/lib needs to be +# in $PYTHONPATH. + +# Ignore interuptible calls +# pylint: disable=interruptible-system-call + +import os +from subprocess import check_call +from mkdud import make_rpm +import rpmfluff + +# Start with http +os.mkdir('http') + +# Empty package to be added to @core +pkg = rpmfluff.SimpleRpmBuild('testpkg-http-core', '1.0', '1') +make_rpm(pkg, 'http') + +# Another empty package +pkg = rpmfluff.SimpleRpmBuild('testpkg-http-addon', '1.0', '1') +make_rpm(pkg, 'http') + +# Three packages with marker files +pkg = rpmfluff.SimpleRpmBuild('testpkg-share1', '1.0', '1') +pkg.add_installed_file('/usr/share/testpkg-1/http', + rpmfluff.SourceFile('http', '')) +make_rpm(pkg, 'http') + +pkg = rpmfluff.SimpleRpmBuild('testpkg-share2', '1.0', '1') +pkg.add_installed_file('/usr/share/testpkg-2/http', + rpmfluff.SourceFile('http', '')) +make_rpm(pkg, 'http') + +pkg = rpmfluff.SimpleRpmBuild('testpkg-share3', '1.0', '1') +pkg.add_installed_file('/usr/share/testpkg-3/http', + rpmfluff.SourceFile('http', '')) +make_rpm(pkg, 'http') + +# Create a comps file and create the repo +with open('http/comps.xml', 'wt') as comps: + comps.write('''<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE comps PUBLIC "-//Red Hat, Inc.//DTD Comps info//EN" "comps.dtd"> +<comps> + <group> + <id>core</id> + <packagelist> + <packagereq type="mandatory">testpkg-http-core</packagereq> + </packagelist> + </group> +</comps>''') + +check_call(['createrepo_c', '-g', 'comps.xml', 'http']) + +# Do the same thing again for nfs +os.mkdir('nfs') + +# Empty package to be added to @core +pkg = rpmfluff.SimpleRpmBuild('testpkg-nfs-core', '1.0', '1') +make_rpm(pkg, 'nfs') + +# Another empty package +pkg = rpmfluff.SimpleRpmBuild('testpkg-nfs-addon', '1.0', '1') +make_rpm(pkg, 'nfs') + +# Three packages with marker files +pkg = rpmfluff.SimpleRpmBuild('testpkg-share1', '1.0', '1') +pkg.add_installed_file('/usr/share/testpkg-1/nfs', + rpmfluff.SourceFile('nfs', '')) +make_rpm(pkg, 'nfs') + +pkg = rpmfluff.SimpleRpmBuild('testpkg-share2', '1.0', '1') +pkg.add_installed_file('/usr/share/testpkg-2/nfs', + rpmfluff.SourceFile('nfs', '')) +make_rpm(pkg, 'nfs') + +pkg = rpmfluff.SimpleRpmBuild('testpkg-share3', '1.0', '1') +pkg.add_installed_file('/usr/share/testpkg-3/nfs', + rpmfluff.SourceFile('nfs', '')) +make_rpm(pkg, 'nfs') + +# Create a comps file and create the repo +with open('nfs/comps.xml', 'wt') as comps: + comps.write('''<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE comps PUBLIC "-//Red Hat, Inc.//DTD Comps info//EN" "comps.dtd"> +<comps> + <group> + <id>core</id> + <packagelist> + <packagereq type="mandatory">testpkg-nfs-core</packagereq> + </packagelist> + </group> +</comps>''') + +check_call(['createrepo_c', '-g', 'comps.xml', 'nfs'])
From: David Shea dshea@redhat.com
Make the file checks actually match the comments, and add checks for whether the repo file that is supposed to be installed is actually installed. --- tests/kickstart_tests/nfs-repo-and-addon.ks | 46 +++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 9 deletions(-)
diff --git a/tests/kickstart_tests/nfs-repo-and-addon.ks b/tests/kickstart_tests/nfs-repo-and-addon.ks index 9d57b85..5c58624 100644 --- a/tests/kickstart_tests/nfs-repo-and-addon.ks +++ b/tests/kickstart_tests/nfs-repo-and-addon.ks @@ -4,16 +4,17 @@ nfs --server=NFS-SERVER --dir=NFS-PATH # NFS: # - testpkg-nfs-core, to be installed with @core # - testpkg-nfs-addon, to be installed because we ask for it -# - testpkg-share1, contains a file /usr/share/testpkg-2/nfs. To be installed by excluding -# the HTTP version. -# - testpkg-share2, contains a file /usr/share/testpkg-3/nfs. To be excluded via cost +# - testpkg-share1, contains a file /usr/share/testpkg-1/nfs. To be installed by excluding +# the HTTP version, despite http's lower cost. +# - testpkg-share2, contains a file /usr/share/testpkg-2/nfs. To be excluded via cost # HTTP: # - testpkg-http-core, to be installed with @core # - testpkg-http-addon, to be installed because we ask for it -# - testpkg-share1, contains a file /usr/share/testpkg-2/http. To be excluded via excludepkgs. -# - testpkg-share2, contains a file /usr/share/testpkg-3/http. To be included via cost. -repo --name=kstest-nfs --baseurl=NFS-ADDON-REPO --cost=50 --install -repo --name=kstest-http --baseurl=HTTP-ADDON-REPO --cost=25 --excludepkgs=testpkg-share2 --install +# - testpkg-share1, contains a file /usr/share/testpkg-1/http. To be excluded via excludepkgs. +# - testpkg-share2, contains a file /usr/share/testpkg-2/http. To be included because the cost +# is lower. +repo --name=kstest-nfs --baseurl=NFS-ADDON-REPO --cost=50 +repo --name=kstest-http --baseurl=HTTP-ADDON-REPO --cost=25 --excludepkgs=testpkg-share1 --install
install network --bootproto=dhcp @@ -61,17 +62,44 @@ if [[ "${status}" -eq 0 ]]; then fi
# Double check that the correct marker files are in place - if [[ -e /usr/share/testpkg-1/nfs ]]; then + if [[ ! -e /usr/share/testpkg-1/nfs ]]; then echo "*** unable to find marker for testpkg-share1" >> /root/RESULT status=1 fi
- if [[ -e /usr/share/testpkg-2/http ]]; then + if [[ ! -e /usr/share/testpkg-2/http ]]; then echo "*** unable to find marker for testpkg-share2" >> /root/RESULT status=1 fi fi
+repofile=/etc/yum.repos.d/kstest-http.repo +if [[ "${status}" -eq 0 ]]; then + # Check that the repo file got installed + if [[ ! -e $repofile ]]; then + echo "*** kstest-http.repo was not installed" >> /root/RESULT + status=1 + # Check that is has all the options + elif ! grep -q '^baseurl=HTTP-ADDON-REPO$' $repofile ; then + echo "*** kstest-http.repo is missing the baseurl" >> /root/RESULT + status=1 + elif ! grep -q '^cost=25$' $repofile; then + echo "*** kstest-http.repo is missing the cost" >> /root/RESULT + status=1 + elif ! grep -q '^exclude=testpkg-share1$' $repofile; then + echo "*** kstest-http.repo is missing the exclude" >> /root/RESULT + status=1 + fi +fi + +if [[ "${status}" -eq 0 ]]; then + # Check that the NFS repo file was not installed + if [[ -e /etc/yum.repos.d/kstest-nfs.repo ]]; then + echo "*** kstest-nfs.repo was installed with --install" >> /root/RESULT + status=1 + fi +fi + if [[ "${status}" -eq 0 ]]; then echo SUCCESS > /root/RESULT fi
In reply to line 82 of tests/kickstart_tests/nfs-repo-and-addon.ks:
*it* has all... ^?
@@ -0,0 +1,101 @@ +#!/usr/bin/python3
+# This script creates all the packages used by nfs-repo-and-addon.ks. +# The packages are created in two directories, http and nfs. After all the rpms +# are made just copy everything to the locations set in $KSTEST_ADDON_HTTP_REPO +# and $KSTEST_ADDON_NFS_REPO. +# +# This script imports things from tests/lib/mkdud.py, so tests/lib needs to be +# in $PYTHONPATH.
May as well add the standard copyright statement here.
Added label: ACK.
I like the use of rpmfluff here!
Looks good to me too otherwise.
Corrected and pushed.
Closed.
anaconda-patches@lists.fedorahosted.org