continue;
// Skip conflicts and replaces
- if (End.IsNegative() == true)
+ if (End.IsNegative() == true || End->Type == pkgCache::Dep::Replaces)
continue;
// Verify the or group
break;
}
delete [] VList;
-
+
if (Start == End)
break;
++Start;
}
getarchitectures() {
- echo "$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
+ aptconfig dump --no-empty --format '%v%n' APT::Architecture APT::Architectures | sort -u | tr '\n' ' '
}
getarchitecturesfromcommalist() {
for CMD in 'apt-dump-solver' 'apt-internal-solver'; do
checkoptions "$(echo "$CMD" | tr -d '-')"
done
+
+# in times of need, we all look for super cow to save the day
+testsuccess aptget moo
+testsuccess aptget moo -q=2
+testsuccess aptget moo moo
+testsuccess aptget moo moo -q=2
+testsuccess aptget moo moo --color
+testsuccess aptget moo moo moo
+testsuccess aptget moo moo moo -q=2
+testsuccess aptget moo moo moo moo
+testsuccess aptget moo moo moo moo -q=2
--- /dev/null
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+DESCR='Some description
+ That has multiple lines'
+insertpackage 'unstable' 'fancy' 'all' '1'
+insertpackage 'unstable,installed' 'foo' 'all' '1' 'Depends: bar
+Conflicts: foobar
+Recommends: cool (>= 2) | cooler (<< 5)' "$DESCR"
+insertpackage 'unstable' 'bar' 'all' '1' 'Depends: bar
+Breaks: foo (<< 1)
+Replaces: foo (<< 1)' "$DESCR"
+
+setupaptarchive
+
+# dpkg is installed by our framework
+testdpkginstalled 'dpkg'
+testempty aptcache unmet dpkg
+
+# FIXME: Find some usecase for unmet as it seems kinda useless/broken
+#testsuccess aptcache unmet
+#testsuccess aptcache unmet foo
+
+# not too useful to test, but makes coverage green…
+testsuccess aptcache stats
+cp rootdir/tmp/testsuccess.output stats.output
+testsuccess test -s stats.output
+testsuccess aptcache xvcg foo
+cp rootdir/tmp/testsuccess.output xvcg.output
+testsuccess test -s xvcg.output
+testsuccess aptcache dotty foo
+cp rootdir/tmp/testsuccess.output dotty.output
+testsuccess test -s dotty.output
+# for this, even the sourcecode says it is useless (expect debugging)
+testsuccess aptcache dump
+cp rootdir/tmp/testsuccess.output dump.output
+testsuccess test -s dump.output
+
+testequal 'dpkg
+bar
+fancy
+foo' aptcache pkgnames
+testequal 'bar' aptcache pkgnames bar
+testequal 'fancy
+foo' aptcache pkgnames f
+
+testequal " foo | 1 | file:$(readlink -f .)/aptarchive/ unstable/main amd64 Packages" aptcache madison foo
+
+### depends
+
+testequal 'foo
+ Depends: bar
+ |Recommends: <cool>
+ Recommends: <cooler>
+ Conflicts: <foobar>
+ Conflicts: <foobar:i386>' aptcache depends foo
+testequal 'foo
+ Depends: bar
+ Recommends: <cool>
+ Conflicts: <foobar>
+ Conflicts: <foobar:i386>' aptcache depends foo -o APT::Cache::ShowOnlyFirstOr=1
+testequal 'foo
+ Depends: bar
+ |Recommends: <cool> (>= 2)
+ Recommends: <cooler> (<< 5)
+ Conflicts: <foobar>
+ Conflicts: <foobar:i386>' aptcache depends foo -o APT::Cache::ShowVersion=1
+testequal 'foo
+ Depends: bar
+ Conflicts: <foobar>
+ Conflicts: <foobar:i386>' aptcache depends foo --no-recommends
+testequal 'foo
+ Depends: bar' aptcache depends foo --important
+testequal 'foo
+ Conflicts: <foobar>
+ Conflicts: <foobar:i386>' aptcache depends foo --important --no-depends --conflicts
+testequal 'foo
+ Depends: bar
+ |Recommends: <cool>
+ Recommends: <cooler>
+ Conflicts: <foobar>
+ Conflicts: <foobar:i386>
+bar
+ Depends: bar
+ Breaks: foo
+ Breaks: <foo:i386>
+ Replaces: foo
+ Replaces: <foo:i386>
+<cool>
+<cooler>
+<foobar>
+<foobar:i386>
+<foo:i386>' aptcache depends foo --recurse
+testequal 'foo
+ Depends: bar
+bar
+ Depends: bar
+ Replaces: foo
+ Replaces: <foo:i386>
+<foo:i386>' aptcache depends foo --recurse --important --replaces
+
+## rdpends
+
+testequal 'foo
+Reverse Depends:
+ bar
+ bar' aptcache rdepends foo
+testequal 'foo
+Reverse Depends:
+ Replaces: bar
+ Breaks: bar' aptcache rdepends foo -o APT::Cache::ShowDependencyType=1
+testequal 'foo
+Reverse Depends:
+ Replaces: bar (<< 1)
+ Breaks: bar (<< 1)' aptcache rdepends foo -o APT::Cache::ShowDependencyType=1 -o APT::Cache::ShowVersion=1
+testequal 'foo
+Reverse Depends:
+ Breaks: bar (<< 1)' aptcache rdepends foo -o APT::Cache::ShowDependencyType=1 -o APT::Cache::ShowVersion=1 --important --breaks
APTARCHIVE=$(readlink -f ./aptarchive)
+testequal 'E: You must give at least one search pattern' aptcache search
+testequal 'E: You must give at least one search pattern' apt search
+
# with OP progress
testequal "Sorting...
Full Text Search...
Description: Some description
That has multiple lines
" apt show foo
+
+# this is the default, but disabled by the testcases
+testsuccess apt show foo -o Apt::Cmd::Disable-Script-Warning=0
+cp rootdir/tmp/testsuccess.output aptshow.output
+testsuccess grep '^WARNING: ' aptshow.output
+
+if [ "$(id -u)" != '0' ]; then
+ testsuccess apt install foo -s -o APT::Get::Show-User-Simulation-Note=1
+ cp rootdir/tmp/testsuccess.output aptshow.output
+ testsuccess grep '^NOTE: ' aptshow.output
+fi
configarchitecture "i386"
insertpackage 'unstable' 'foo' 'all' '2.0'
+cp rootdir/var/lib/dpkg/status dpkg.status
insertinstalledpackage 'foo' 'all' '1.0'
setupaptarchive --no-update
APTARCHIVE=$(readlink -f ./aptarchive)
+testequal 'E: The update command takes no arguments' apt update -q arguments
+
testequal "1 package can be upgraded. Run 'apt list --upgradable' to see it." apt update -q
+
+cp dpkg.status rootdir/var/lib/dpkg/status
+insertinstalledpackage 'foo' 'all' '2.0'
+testequal 'All packages are up to date.' apt update -q
--- /dev/null
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture 'amd64'
+
+testsuccess aptconfig dump
+testequal 'APT::Architecture "amd64";' aptconfig dump APT::Architecture
+testempty aptconfig dump config::which::does::not::exist
+
+testequal 'APT::Architectures "";
+APT::Architectures:: "amd64";' aptconfig dump APT::Architectures
+testequal 'APT::Architectures:: "amd64";' aptconfig dump --no-empty APT::Architectures
+testequal 'amd64' aptconfig dump --no-empty --format='%v%n' APT::Architectures
+
+testempty aptconfig shell
+testequal 'E: Arguments not in pairs' aptconfig shell APT::Architecture
+testempty aptconfig shell APT::Architecture ARCH # incorrect order
+testequal "ARCH='amd64'" aptconfig shell ARCH APT::Architecture
+
+ROOTDIR="$(readlink -f rootdir)"
+testequal "CONFIG='apt.conf'" aptconfig shell CONFIG Dir::Etc::main
+testequal "CONFIG='${ROOTDIR}/etc/apt/apt.conf'" aptconfig shell CONFIG Dir::Etc::main/f
+testequal "CONFIG='etc/apt/'" aptconfig shell CONFIG Dir::Etc
+testequal "CONFIG='${ROOTDIR}/etc/apt/'" aptconfig shell CONFIG Dir::Etc/ # old style
+testequal "CONFIG='${ROOTDIR}/etc/apt/'" aptconfig shell CONFIG Dir::Etc/d
+
+testempty aptconfig dump --no-empty --format='%v%n' APT::Build-Profiles
+export DEB_BUILD_PROFILES='nodoc stage1'
+testequal 'nodoc
+stage1' aptconfig dump --no-empty --format='%v%n' APT::Build-Profiles
+unset DEB_BUILD_PROFILES
+testempty aptconfig dump --no-empty --format='%v%n' APT::Build-Profiles
EOF
chmod 755 apt-proxy-detect
echo "Acquire::http::Proxy-Auto-Detect \"$(pwd)/apt-proxy-detect\";" > rootdir/etc/apt/apt.conf.d/02proxy-detect
-
+
testequal "Using proxy 'http://some-proxy' for URL 'http://www.example.com/'" apthelper auto-detect-proxy http://www.example.com
EOF
chmod 755 apt-proxy-detect
echo "Acquire::https::Proxy-Auto-Detect \"$(pwd)/apt-proxy-detect\";" > rootdir/etc/apt/apt.conf.d/02proxy-detect
-
- testequal "Using proxy 'https://https-proxy' for URL 'https://ssl.example.com/'" apthelper auto-detect-proxy https://ssl.example.com
-
-
+ testequal "Using proxy 'https://https-proxy' for URL 'https://ssl.example.com/'" apthelper auto-detect-proxy https://ssl.example.com
}
test_apt_helper_download
test_apt_helper_detect_proxy
+# test failure modes
+testequal 'E: Invalid operation download' apthelper download
+testequal 'E: Must specify at least one pair url/filename' apthelper download-file
+testequal 'E: Must specify at least one pair url/filename' apthelper download-file http://example.org/
+testequal 'E: Need one URL as argument' apthelper auto-detect-proxy
testnoautopkg() {
testempty aptmark showauto
+ testempty aptcache showauto
testequal 'bar
dpkg
foo' aptmark showmanual
testequal 'bar
foo' aptmark showmanual bar foo uninstalled
}
-testmarkonpkgasauto() {
- testsuccess aptmark $1 foo
+testfooisauto() {
testequal 'foo' aptmark showauto
+ testequal 'foo' aptcache showauto
testequal 'foo' aptmark showauto foo
+ testequal 'foo' aptcache showauto foo
testequal 'bar
dpkg' aptmark showmanual
testequal 'bar' aptmark showmanual bar
+}
+testmarkonpkgasauto() {
+ testsuccess $1 $2 foo
+ testfooisauto
+ testsuccess $1 $2 foo
+ testfooisauto
- testsuccess aptmark $2 foo
+ testsuccess $1 $3 foo
+ testnoautopkg
+ testsuccess $1 $3 foo
testnoautopkg
}
testequal 'E: No packages found' aptmark manual
testnoautopkg
-testmarkonpkgasauto 'auto' 'manual'
-testmarkonpkgasauto 'markauto' 'unmarkauto'
+testmarkonpkgasauto 'aptmark' 'auto' 'manual'
+testmarkonpkgasauto 'aptmark' 'markauto' 'unmarkauto'
+testmarkonpkgasauto 'aptget' 'markauto' 'unmarkauto'
testnoholdpkg() {
testempty aptmark showhold
testempty aptmark showhold dpkg
testempty aptmark showholds dpkg
}
-testmarkonepkgashold() {
- testsuccess aptmark hold $1
+testpkgonhold() {
testequal "$1" aptmark showhold
testequal "$1" aptmark showholds
+ testequal "$1" aptmark showhold $1
+ testequal "$1" aptmark showholds $1
+}
+testmarkonepkgashold() {
+ testsuccess aptmark hold $1
+ testpkgonhold $1
+ testsuccess aptmark hold $1
+ testpkgonhold $1
+ testsuccess aptmark unhold $1
+ testnoholdpkg
testsuccess aptmark unhold $1
testnoholdpkg
}
insertpackage 'unstable' 'foo' 'all' '1.0'
-setupaptarchive
+setupaptarchive --no-update
changetowebserver
-aptget update -qq
+
+echo "Acquire::Languages \"none\";" > rootdir/etc/apt/apt.conf.d/00nolanguages
+testsuccess aptget update
listcurrentlistsdirectory > lists.before
# insert new version
insertpackage 'unstable' 'cool' 'all' '2' 'Multi-Arch: foreign'
insertpackage 'unstable' 'stuff' 'all' '2' 'Multi-Arch: foreign'
insertpackage 'unstable' 'coolstuff' 'i386,amd64' '2' 'Depends: cool, stuff'
-insertpackage 'unstable' 'awesome' 'all' '2' 'Multi-Arch: foreign'
+insertpackage 'unstable' 'awesome' 'all' '2' 'Multi-Arch: foreign
+Conflicts: badstuff'
+insertpackage 'unstable' 'badstuff' 'all' '2' 'Multi-Arch: foreign
+Conflicts: awesome'
insertpackage 'unstable' 'awesomecoolstuff' 'i386' '2' 'Depends: coolstuff, awesome'
insertpackage 'experimental' 'cool' 'all' '3' 'Multi-Arch: foreign'
Inst coolstuff (3 experimental [amd64])
Conf coolstuff (3 experimental [amd64])' aptget install --solver apt coolstuff -s
+testequal 'Reading package lists...
+Building dependency tree...
+Execute external solver...
+The following packages will be REMOVED:
+ cool*
+0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded.
+Purg cool [1]' aptget purge --solver apt cool -s
+
testsuccess aptget install awesomecoolstuff:i386 -s
testsuccess aptget install --solver apt awesomecoolstuff:i386 -s
testsuccess aptget upgrade -s
testsuccess aptget upgrade -s --solver apt
+testfailure aptget install awesome badstuff -s
+testfailure aptget install awesome badstuff -s --solver apt
+testsuccess grep 'ERR_UNSOLVABLE' rootdir/tmp/testfailure.output
+
configarchitecture 'armel'
msgtest 'Test direct calling is okay for' 'apt-internal-solver'
-cat /tmp/dump.edsp | aptinternalsolver > solver.result 2>&1 || true
+cat /tmp/dump.edsp | aptinternalsolver -q=0 > solver.result 2>&1 || true
if [ "$(tail -n2 solver.result | head -n1 )" = "Message: Done" ]; then
msgpass
else
rm -f /tmp/dump.edsp
testfailure aptget install --solver apt awesomecoolstuff:i386 -s
+
+testsuccess aptinternalsolver scenario
+testequal 'Package: stuff
+Source: stuff
+Architecture: all
+Version: 1
+Installed: yes
+APT-ID: 2
+Priority: optional
+Section: other
+APT-Pin: 100
+APT-Candidate: yes
+' aptinternalsolver scenario stuff