diff options
-rw-r--r-- | apt-pkg/policy.cc | 18 | ||||
-rw-r--r-- | debian/changelog | 4 | ||||
-rw-r--r-- | test/integration/framework | 23 | ||||
-rwxr-xr-x | test/integration/test-bug-407511-fail-invalid-default-release | 47 |
4 files changed, 86 insertions, 6 deletions
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index bd213e0ce..c5028d822 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -56,8 +56,22 @@ pkgPolicy::pkgPolicy(pkgCache *Owner) : Pins(0), PFPriority(0), Cache(Owner) // The config file has a master override. string DefRel = _config->Find("APT::Default-Release"); if (DefRel.empty() == false) - CreatePin(pkgVersionMatch::Release,"",DefRel,990); - + { + bool found = false; + // FIXME: make ExpressionMatches static to use it here easily + pkgVersionMatch vm("", pkgVersionMatch::None); + for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); ++F) + { + if ((F->Archive != 0 && vm.ExpressionMatches(DefRel, F.Archive()) == true) || + (F->Codename != 0 && vm.ExpressionMatches(DefRel, F.Codename()) == true) || + (F->Version != 0 && vm.ExpressionMatches(DefRel, F.Version()) == true)) + found = true; + } + if (found == false) + _error->Error(_("The value '%s' is invalid for APT::Default-Release as such a release is not available in the sources"), DefRel.c_str()); + else + CreatePin(pkgVersionMatch::Release,"",DefRel,990); + } InitDefaults(); } /*}}}*/ diff --git a/debian/changelog b/debian/changelog index a834bca91..607f7c64a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -28,8 +28,10 @@ apt (0.8.15.3) UNRELEASED; urgency=low - remove /etc/apt/secring.gpg if it is an empty file * doc/apt-cache.8.xml: - apply madison typofix from John Feuerstein, thanks! (Closes: #633455) + * apt-pkg/policy.cc: + - emit an error on unknown APT::Default-Release value (Closes: #407511) - -- David Kalnischkies <kalnischkies@gmail.com> Sat, 16 Jul 2011 14:55:03 +0200 + -- David Kalnischkies <kalnischkies@gmail.com> Sat, 16 Jul 2011 16:43:37 +0200 apt (0.8.15.2) unstable; urgency=high diff --git a/test/integration/framework b/test/integration/framework index 96cdb5f5e..702e352a3 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -481,6 +481,10 @@ buildaptarchivefromfiles() { generatereleasefiles } +# can be overridden by testcases for their pleasure +getcodenamefromsuite() { echo -n "$1"; } +getreleaseversionfromsuite() { true; } + generatereleasefiles() { msgninfo "\tGenerate Release files… " local DATE="${1:-now}" @@ -489,9 +493,22 @@ generatereleasefiles() { aptftparchive -qq release $dir -o APT::FTPArchive::Release::Patterns::='Translation-*' > $dir/Index done for dir in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do - local CODENAME="$(echo "$dir" | cut -d'/' -f 4)" - aptftparchive -qq release $dir -o APT::FTPArchive::Release::Suite="${CODENAME}" -o APT::FTPArchive::Release::Codename="${CODENAME}" | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference - if [ "$CODENAME" = "experimental" -o "$CODENAME" = "experimental2" ]; then + local SUITE="$(echo "$dir" | cut -d'/' -f 4)" + local CODENAME="$(getcodenamefromsuite $SUITE)" + local VERSION="$(getreleaseversionfromsuite $SUITE)" + if [ -z "$VERSION" ]; then + aptftparchive -qq release $dir \ + -o APT::FTPArchive::Release::Suite="${SUITE}" \ + -o APT::FTPArchive::Release::Codename="${CODENAME}" \ + | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference + else + aptftparchive -qq release $dir \ + -o APT::FTPArchive::Release::Suite="${SUITE}" \ + -o APT::FTPArchive::Release::Codename="${CODENAME}" \ + -o APT::FTPArchive::Release::Version="${VERSION}" \ + | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference + fi + if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then sed -i '/^Date: / a\ NotAutomatic: yes' $dir/Release fi diff --git a/test/integration/test-bug-407511-fail-invalid-default-release b/test/integration/test-bug-407511-fail-invalid-default-release new file mode 100755 index 000000000..d0a73af7d --- /dev/null +++ b/test/integration/test-bug-407511-fail-invalid-default-release @@ -0,0 +1,47 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'i386' + +insertpackage 'unstable' 'cool' 'all' '1.0-1' + +getcodenamefromsuite() { + if [ "$SUITE" = 'unstable' ]; then + echo -n 'sid' + else + echo -n "$SUITE" + fi +} +getreleaseversionfromsuite() { + if [ "$SUITE" = 'unstable' ]; then + echo -n '42.0' + else + echo -n '0.8.15' + fi +} + +setupaptarchive + +passdist() { + msgtest "Test that target-release is accepted" $1 + aptget dist-upgrade -t $1 -qq && msgpass || msgfail +} + +faildist() { + msgtest "Test that target-release is refused" $1 + aptget dist-upgrade -t $1 -qq 2> /dev/null && msgfail || msgpass +} + +passdist unstable +passdist sid +faildist sidd +faildist stable +passdist 42.0 +passdist 42.* +passdist 42* +passdist 4*.0 +faildist 21.0 +faildist 21* |