AT_BANNER([RPM install/erase ordering])

AT_SETUP([basic install/erase order 1])
AT_KEYWORDS([install erase order])
AT_CHECK([
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 "ord deptest-three" \
	/data/SPECS/deptest.spec
runroot rpmbuild --quiet -bb \
	--define "pkg three" \
	/data/SPECS/deptest.spec

echo INSTALL:
runroot rpm -Uv --justdb \
	/build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm \
	/build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm \
	/build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
echo ERASE:
runroot rpm -ev --justdb \
        deptest-three \
	deptest-one \
	deptest-two
],
[0],
[INSTALL:
Verifying packages...
Preparing packages...
deptest-three-1.0-1.noarch
deptest-two-1.0-1.noarch
deptest-one-1.0-1.noarch
ERASE:
Preparing packages...
deptest-one-1.0-1.noarch
deptest-two-1.0-1.noarch
deptest-three-1.0-1.noarch
],
[])
AT_CLEANUP

# same as above but with weak dependencies
AT_SETUP([basic install/erase order 2])
AT_KEYWORDS([install erase order])
AT_CHECK([
RPMDB_INIT

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

echo INSTALL:
runroot rpm -Uv --justdb \
	/build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm \
	/build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm \
	/build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
echo ERASE:
runroot rpm -ev --justdb \
        deptest-three \
	deptest-one \
	deptest-two
],
[0],
[INSTALL:
Verifying packages...
Preparing packages...
deptest-three-1.0-1.noarch
deptest-two-1.0-1.noarch
deptest-one-1.0-1.noarch
ERASE:
Preparing packages...
deptest-one-1.0-1.noarch
deptest-two-1.0-1.noarch
deptest-three-1.0-1.noarch
],
[])
AT_CLEANUP

# same as above but with weak reverse dependencies
AT_SETUP([basic install/erase order 3])
AT_KEYWORDS([install erase order])
AT_CHECK([
RPMDB_INIT

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

echo INSTALL:
runroot rpm -Uv --justdb \
	/build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm \
	/build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm \
	/build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
echo ERASE:
runroot rpm -ev --justdb \
        deptest-three \
	deptest-one \
	deptest-two
],
[0],
[INSTALL:
Verifying packages...
Preparing packages...
deptest-three-1.0-1.noarch
deptest-two-1.0-1.noarch
deptest-one-1.0-1.noarch
ERASE:
Preparing packages...
deptest-one-1.0-1.noarch
deptest-two-1.0-1.noarch
deptest-three-1.0-1.noarch
],
[])
AT_CLEANUP
