#    rpmdeps.at: rpm dependency tests

AT_BANNER([RPM dependencies])

# ------------------------------
AT_SETUP([unversioned requires])
AT_KEYWORDS([install depends])
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs deptest-two" \
	  /data/SPECS/deptest.spec

runroot rpmbuild --quiet -bb \
	--define "pkg two" \
	--define "reqs deptest-one" \
	  /data/SPECS/deptest.spec

# missing dependency
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
],
[1],
[],
[error: Failed dependencies:
	deptest-two is needed by deptest-one-1.0-1.noarch
])

# cross-depending packages
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
],
[0],
[],
[])
RPMTEST_CLEANUP

# ------------------------------
# 
AT_SETUP([unsatisfied versioned require])
AT_KEYWORDS([install])
RPMTEST_CHECK([
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs deptest-two >= 2.0" \
	  /data/SPECS/deptest.spec

runroot rpmbuild --quiet -bb \
	--define "pkg two" \
	--define "provs deptest-foo = 1.0" \
	  /data/SPECS/deptest.spec

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
echo $?
runroot rpm -U --nodeps /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
echo $?
runroot rpm -e deptest-two
echo $?
],
[ignore],
[2
0
0
],
[error: Failed dependencies:
	deptest-two >= 2.0 is needed by deptest-one-1.0-1.noarch
])
RPMTEST_CLEANUP

# ------------------------------
# 
AT_SETUP([satisfied versioned require])
AT_KEYWORDS([install])
RPMTEST_CHECK([
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs deptest-foo >= 2.0" \
	  /data/SPECS/deptest.spec

runroot rpmbuild --quiet -bb \
	--define "pkg two" \
	--define "provs deptest-foo = 2.0" \
	  /data/SPECS/deptest.spec

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
],
[0],
[],
[])
RPMTEST_CLEANUP

# ------------------------------
# 
AT_SETUP([versioned conflicts])
AT_KEYWORDS([install])
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "cfls deptest-two < 2.0" \
	  /data/SPECS/deptest.spec

runroot rpmbuild --quiet -bb \
	--define "pkg two" \
	  /data/SPECS/deptest.spec

# versioned conflict in transaction
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
],
[2],
[],
[error: Failed dependencies:
	deptest-two < 2.0 conflicts with deptest-one-1.0-1.noarch
])

# versioned conflict in database
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
runroot rpm -U /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
],
[1],
[],
[error: Failed dependencies:
	deptest-two < 2.0 conflicts with (installed) deptest-one-1.0-1.noarch
])
RPMTEST_CLEANUP

AT_SETUP([install and verify self-conflicting package])
AT_KEYWORDS([install])
RPMTEST_CHECK([
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "provs something" \
	--define "cfls something" \
	  /data/SPECS/deptest.spec

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
runroot rpm -V --nofiles deptest-one
],
[0],
[],
[])
RPMTEST_CLEANUP

# explicit file conflicts
AT_SETUP([explicit file conflicts])
AT_KEYWORDS([install])
RPMTEST_CHECK([
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "cfls /opt/bar" \
	  /data/SPECS/deptest.spec

runroot rpmbuild --quiet -bb \
	--define "pkg two" \
	  /data/SPECS/deptest.spec

runroot rpm -U --test \
	/build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm \
	/build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
runroot rpm -U /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
runroot rpm -e deptest-one
# XXX FIXME: rpm's problem message for this case is higly bogus.
runroot rpm -U /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
runroot rpm -e deptest-two
],
[],
[],
[error: Failed dependencies:
	/opt/bar conflicts with deptest-one-1.0-1.noarch
error: Failed dependencies:
	/opt/bar conflicts with (installed) deptest-one-1.0-1.noarch
error: Failed dependencies:
	/opt/bar conflicts with deptest-one-1.0-1.noarch
])
RPMTEST_CLEANUP
# ------------------------------
# 
AT_SETUP([erase to break dependencies])
AT_KEYWORDS([install])
RPMTEST_CHECK([
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs deptest-foo >= 2.0" \
	  /data/SPECS/deptest.spec

runroot rpmbuild --quiet -bb \
	--define "pkg two" \
	--define "provs deptest-foo = 2.0" \
	  /data/SPECS/deptest.spec

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
runroot rpm -e deptest-two
],
[1],
[],
[error: Failed dependencies:
	deptest-foo >= 2.0 is needed by (installed) deptest-one-1.0-1.noarch
])
RPMTEST_CLEANUP

# ------------------------------
AT_SETUP([erase to break colored file dependency])
AT_KEYWORDS([install])
RPMTEST_CHECK([
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg hello" \
	--define "reqs /usr/bin/hello" \
	  /data/SPECS/deptest.spec

runroot rpm -U --ignoreos --ignorearch --nodeps \
	--define "_transaction_color 3" \
	--define "_prefer_color 2" \
	/data/RPMS/hello-2.0-1.i686.rpm \
	/data/RPMS/hello-2.0-1.x86_64.rpm \
	/build/RPMS/noarch/deptest-hello-1.0-1.noarch.rpm

runroot rpm -e hello.x86_64
],
[1],
[],
[error: Failed dependencies:
	/usr/bin/hello is needed by (installed) deptest-hello-1.0-1.noarch
])
RPMTEST_CLEANUP

# ------------------------------
AT_SETUP([erase on wrong-colored file dependency])
AT_KEYWORDS([install])
RPMTEST_CHECK([
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg hello" \
	--define "reqs /usr/bin/hello" \
	  /data/SPECS/deptest.spec

runroot rpm -U --ignoreos --ignorearch --nodeps \
	--define "_transaction_color 3" \
	--define "_prefer_color 2" \
	/data/RPMS/hello-2.0-1.i686.rpm \
	/data/RPMS/hello-2.0-1.x86_64.rpm \
	/build/RPMS/noarch/deptest-hello-1.0-1.noarch.rpm

runroot rpm -e hello.i686
],
[0],
[],
[])
RPMTEST_CLEANUP

# ------------------------------
#
AT_SETUP([unsatisfied WITH requires])
AT_KEYWORDS([install, boolean])

RPMDB_INIT
runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs (deptest-two with flavor = dekstop)" \
	  /data/SPECS/deptest.spec

runroot rpmbuild --quiet -bb \
	--define "pkg two" \
	--define "provs flavor = server" \
	  /data/SPECS/deptest.spec

runroot rpmbuild --quiet -bb \
	--define "pkg three" \
	--define "provs flavor = desktop" \
	  /data/SPECS/deptest.spec

# unsatisfied WITH require in transaction
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm
],
[3],
[],
[error: Failed dependencies:
	(deptest-two with flavor = dekstop) is needed by deptest-one-1.0-1.noarch
])

# unsatisfied WITH require in rpmdb
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
],
[1],
[],
[error: Failed dependencies:
	(deptest-two with flavor = dekstop) is needed by deptest-one-1.0-1.noarch
])
RPMTEST_CLEANUP

AT_SETUP([satisfied WITH requires])
AT_KEYWORDS([install, boolean])
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs (deptest-two with flavor = desktop)" \
	  /data/SPECS/deptest.spec

runroot rpmbuild --quiet -bb \
	--define "pkg two" \
	--define "provs flavor = desktop" \
	  /data/SPECS/deptest.spec

# satisfied WITH require in transaction
RPMTEST_CHECK([
RPMDB_INIT
runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
],
[0],
[],
[])

# satisfied WITH require in rpmdb
RPMTEST_CHECK([
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs (deptest-two with flavor = desktop)" \
	  /data/SPECS/deptest.spec

runroot rpmbuild --quiet -bb \
	--define "pkg two" \
	--define "provs flavor = desktop" \
	  /data/SPECS/deptest.spec

runroot rpm -U /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
],
[0],
[],
[])
RPMTEST_CLEANUP

# ------------------------------
#
AT_SETUP([unsatisfied WITHOUT requires])
AT_KEYWORDS([install, boolean])
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs (deptest-two without flavor)" \
	  /data/SPECS/deptest.spec

runroot rpmbuild --quiet -bb \
	--define "pkg two" \
	--define "provs flavor = server" \
	  /data/SPECS/deptest.spec

# unsatisfied WITHOUT require in transaction
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
],
[2],
[],
[error: Failed dependencies:
	(deptest-two without flavor) is needed by deptest-one-1.0-1.noarch
])

# unsatisfied WITHOUT require in rpmdb
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
],
[1],
[],
[error: Failed dependencies:
	(deptest-two without flavor) is needed by deptest-one-1.0-1.noarch
])
RPMTEST_CLEANUP

AT_SETUP([satisfied WITHOUT requires])
AT_KEYWORDS([install, boolean])
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs (deptest-two without flavor)" \
	  /data/SPECS/deptest.spec

runroot rpmbuild --quiet -bb \
	--define "pkg two" \
	  /data/SPECS/deptest.spec

# satisfied WITHOUT require in transaction
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
],
[0],
[],
[])

# satisfied WITHOUT require in rpmdb
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
],
[0],
[],
[])
RPMTEST_CLEANUP

# ------------------------------
#
AT_SETUP([AND requires])
AT_KEYWORDS([install, boolean])
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs (deptest-two and deptest-three)" \
	  /data/SPECS/deptest.spec

for pkg in two three; do
    runroot rpmbuild --quiet -bb \
	--define "pkg ${pkg}" \
	  /data/SPECS/deptest.spec
done

RPMTEST_CHECK([
RPMDB_INIT
# unsatisfied AND require - all missing
runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
],
[1],
[],
[error: Failed dependencies:
	(deptest-two and deptest-three) is needed by deptest-one-1.0-1.noarch
])

# unsatisfied AND require - first is missing
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm
],
[2],
[],
[error: Failed dependencies:
	(deptest-two and deptest-three) is needed by deptest-one-1.0-1.noarch
])

# unsatisfied AND require - second is missing
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
],
[2],
[],
[error: Failed dependencies:
	(deptest-two and deptest-three) is needed by deptest-one-1.0-1.noarch
])

# satisfied AND require
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm
],
[0],
[],
[])
RPMTEST_CLEANUP

# ------------------------------
#
AT_SETUP([OR requires])
AT_KEYWORDS([install, boolean])
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs (deptest-two or deptest-three)" \
	  /data/SPECS/deptest.spec

for pkg in two three; do
    runroot rpmbuild --quiet -bb \
	--define "pkg ${pkg}" \
	  /data/SPECS/deptest.spec
done

# unsatisfied OR require - all missing
RPMTEST_CHECK([
RPMDB_INIT
runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
],
[1],
[],
[error: Failed dependencies:
	(deptest-two or deptest-three) is needed by deptest-one-1.0-1.noarch
])

# satisfied OR require - first is missing
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm
],
[0],
[],
[])

# satisfied OR require - second is missing
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
],
[0],
[],
[])

# satisfied OR require - both present
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm
],
[0],
[],
[])
RPMTEST_CLEANUP

# ------------------------------
#
AT_SETUP([IF requires])
AT_KEYWORDS([install, boolean])
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs (deptest-two if deptest-three)" \
	  /data/SPECS/deptest.spec

for pkg in two three; do
    runroot rpmbuild --quiet -bb \
	--define "pkg ${pkg}" \
	  /data/SPECS/deptest.spec
done

# unsatisfied IF require
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm
],
[2],
[],
[error: Failed dependencies:
	(deptest-two if deptest-three) is needed by deptest-one-1.0-1.noarch
])

# satisfied IF require
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
],
[0],
[],
[])
RPMTEST_CLEANUP

AT_SETUP([IF-ELSE requires])
AT_KEYWORDS([install, boolean])
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs (deptest-two if deptest-three else deptest-four)" \
	  /data/SPECS/deptest.spec

for pkg in two three four; do
    runroot rpmbuild --quiet -bb \
	--define "pkg ${pkg}" \
	  /data/SPECS/deptest.spec
done

# unsatisfied IF-ELSE require
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
],
[1],
[],
[error: Failed dependencies:
	(deptest-two if deptest-three else deptest-four) is needed by deptest-one-1.0-1.noarch
])

# satisfied IF-ELSE require - right clause
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-four-1.0-1.noarch.rpm
],
[0],
[],
[])

# satisfied IF-ELSE require - left clause
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
],
[0],
[],
[])
RPMTEST_CLEANUP

# ------------------------------
#
AT_SETUP([nested AND-OR requires])
AT_KEYWORDS([install, boolean])
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs (deptest-two and (deptest-three or deptest-four))" \
	  /data/SPECS/deptest.spec

for pkg in two three; do
    runroot rpmbuild --quiet -bb \
	--define "pkg ${pkg}" \
	  /data/SPECS/deptest.spec
done

RPMTEST_CHECK([
RPMDB_INIT
# unsatisfied nested AND-OR require
runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
],
[2],
[],
[error: Failed dependencies:
	(deptest-two and (deptest-three or deptest-four)) is needed by deptest-one-1.0-1.noarch
])

# satisfied nested AND-OR require
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm
],
[0],
[],
[])
RPMTEST_CLEANUP

# ------------------------------
#
AT_SETUP([nested AND-IF requires])
AT_KEYWORDS([install, boolean])
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs (deptest-two and (deptest-three if deptest-four))" \
	  /data/SPECS/deptest.spec

for pkg in two three four; do
    runroot rpmbuild --quiet -bb \
	--define "pkg ${pkg}" \
	  /data/SPECS/deptest.spec
done

# satisfied nested AND-IF require - without right clause
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
],
[0],
[],
[])

# satisfied nested AND-IF require - with right clause
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-four-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm
],
[0],
[],
[])
RPMTEST_CLEANUP

# ------------------------------
#
AT_SETUP([install to break installed rich dependency])
AT_KEYWORDS([install, boolean])
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "cfls (deptest-three or deptest-five)" \
	  /data/SPECS/deptest.spec
runroot rpmbuild --quiet -bb \
	--define "pkg two" \
	--define "reqs (deptest-five if deptest-four)" \
	  /data/SPECS/deptest.spec
runroot rpmbuild --quiet -bb \
	--define "pkg three" \
	  /data/SPECS/deptest.spec
runroot rpmbuild --quiet -bb \
	--define "pkg four" \
	  /data/SPECS/deptest.spec

# installed conflict with "or" clause
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
runroot rpm -U /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm
],
[1],
[],
[error: Failed dependencies:
	(deptest-three or deptest-five) conflicts with (installed) deptest-one-1.0-1.noarch
])

# installed requires with "if" clause
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
runroot rpm -U /build/RPMS/noarch/deptest-four-1.0-1.noarch.rpm
],
[1],
[],
[error: Failed dependencies:
	(deptest-five if deptest-four) is needed by (installed) deptest-two-1.0-1.noarch
])
RPMTEST_CLEANUP

# ------------------------------
#
AT_SETUP([erase to break installed rich dependency])
AT_KEYWORDS([install, boolean])
RPMDB_INIT

runroot rpmbuild --quiet -bb \
	--define "pkg one" \
	--define "reqs (deptest-three or deptest-five)" \
	  /data/SPECS/deptest.spec
runroot rpmbuild --quiet -bb \
	--define "pkg two" \
	--define "cfls (deptest-five unless deptest-four)" \
	  /data/SPECS/deptest.spec
runroot rpmbuild --quiet -bb \
	--define "pkg three" \
	  /data/SPECS/deptest.spec
runroot rpmbuild --quiet -bb \
	--define "pkg four" \
	  /data/SPECS/deptest.spec
runroot rpmbuild --quiet -bb \
	--define "pkg five" \
	  /data/SPECS/deptest.spec

# installed requires with "or" clause
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm
runroot rpm -e deptest-three
],
[1],
[],
[error: Failed dependencies:
	(deptest-three or deptest-five) is needed by (installed) deptest-one-1.0-1.noarch
])

# installed conflicts with "unless" clause
RPMTEST_CHECK([
RPMDB_INIT

runroot rpm -U /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-four-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-five-1.0-1.noarch.rpm
runroot rpm -e deptest-four
],
[1],
[],
[error: Failed dependencies:
	(deptest-five unless deptest-four) conflicts with (installed) deptest-two-1.0-1.noarch
])
RPMTEST_CLEANUP
