#!/bin/sh
. ./Common

###############################################################################

qpkg "prefer later version (1)" prereq foo <<EOF
Package: bar
Version: 0
Architecture: test
Filename: bar_0

Package: bar
Version: 1
Architecture: test
Filename: bar_1

Package: foo
Version: 0
Architecture: test
Depends: bar
Filename: foo
EOF
expect <<EOF
bar_1
EOF

###############################################################################

qpkg "prefer later version (2)" prereq foo <<EOF
Package: bar
Version: 1
Architecture: test
Filename: bar_1

Package: bar
Version: 0
Architecture: test
Filename: bar_0

Package: foo
Version: 0
Architecture: test
Depends: bar
Filename: foo
EOF
expect <<EOF
bar_1
EOF

###############################################################################

qpkg "dependency trumps preference (1)" prereq foo <<EOF
Package: bar
Version: 0
Architecture: test
Filename: bar_0

Package: bar
Version: 1
Architecture: test
Depends: bad
Filename: bar_1

Package: foo
Version: 0
Architecture: test
Depends: bar
Filename: foo
EOF
expect <<EOF
bar_0
EOF

###############################################################################

qpkg "dependency trumps preference (2)" prereq foo <<EOF
Package: bar
Version: 1
Architecture: test
Depends: bad
Filename: bar_1

Package: bar
Version: 0
Architecture: test
Filename: bar_0

Package: foo
Version: 0
Architecture: test
Depends: bar
Filename: foo
EOF
expect <<EOF
bar_0
EOF