rpm-ostree/tests/compose/test-excludes.sh
Colin Walters 5a0d3356ef treefile: Add exclude-packages
In FCOS we have a kola test that basically does `rpm -q python`.
It's...a bit silly to spawn a whole VM for this.  Ensuring that
some specific packages don't get included has come up in a few
cases.

I think FCOS/RHCOS at least will want to blacklist `dnf` for example.
And as noted above, FCOS could blacklist `python`.

One major benefit of doing this inside rpm-ostree is that one
gets the full "libsolv error message experience" when dependency
resolution fails, e.g. blacklisting `glibc` I get:

```
 Problem 79: conflicting requests
  - package coreos-installer-systemd-0.1.2-1.fc31.x86_64 requires coreos-installer = 0.1.2-1.fc31, but none of the providers can be installed
  - package coreos-installer-0.1.2-1.fc31.x86_64 requires rtld(GNU_HASH), but none of the providers can be installed
  - package glibc-2.30-10.fc31.x86_64 is filtered out by exclude filtering
  - package glibc-2.30-7.fc31.x86_64 is filtered out by exclude filtering
  - package glibc-2.30-8.fc31.x86_64 is filtered out by exclude filtering
  - package glibc-2.30-5.fc31.i686 is filtered out by exclude filtering
  - package glibc-2.30-5.fc31.x86_64 is filtered out by exclude filtering
  - package glibc-2.30-10.fc31.i686 is filtered out by exclude filtering
```
2020-02-05 21:02:06 +01:00

42 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -xeuo pipefail
dn=$(cd "$(dirname "$0")" && pwd)
# shellcheck source=libcomposetest.sh
. "${dn}/libcomposetest.sh"
# Add a local rpm-md repo for recommends testing
treefile_append "repos" '["test-repo"]'
build_rpm foodep
build_rpm foobar recommends foobar-rec requires foodep
build_rpm foobar-rec
echo gpgcheck=0 >> yumrepo.repo
ln "$PWD/yumrepo.repo" config/yumrepo.repo
# the top-level manifest doesn't have any packages, so just set it
treefile_append "packages" '["foobar"]'
treefile_set 'recommends' "True"
runcompose --dry-run >log.txt
assert_file_has_content_literal log.txt 'foobar-1.0'
assert_file_has_content_literal log.txt 'foobar-rec-1.0'
rm -f log.txt
echo "ok no exclude"
# Test exclude
treefile_append "exclude-packages" '["foobar-rec"]'
runcompose --dry-run >log.txt
assert_file_has_content_literal log.txt 'foobar-1.0'
assert_not_file_has_content_literal log.txt 'foobar-rec-1.0'
rm -f log.txt
echo "ok exclude recommend"
treefile_append "exclude-packages" '["foodep"]'
if runcompose --dry-run &>err.txt; then
fatal "compose unexpectedly succeeded"
fi
assert_file_has_content err.txt 'package foodep.*is filtered out by exclude filtering'
echo "ok exclude included"