diff options
-rw-r--r-- | apt-pkg/update.cc | 15 | ||||
-rwxr-xr-x | test/integration/test-apt-update-hooks | 43 |
2 files changed, 53 insertions, 5 deletions
diff --git a/apt-pkg/update.cc b/apt-pkg/update.cc index ca87c6976..0d901eab1 100644 --- a/apt-pkg/update.cc +++ b/apt-pkg/update.cc @@ -61,11 +61,14 @@ bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval, bool Failed = false; bool TransientNetworkFailure = false; + bool AllFailed = true; for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I) { - if ((*I)->Status == pkgAcquire::Item::StatDone) + if ((*I)->Status == pkgAcquire::Item::StatDone) { + AllFailed = false; continue; + } (*I)->Finished(); @@ -101,22 +104,24 @@ bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval, // something went wrong with the clean return false; } + + bool Res = true; if (TransientNetworkFailure == true) - _error->Warning(_("Some index files failed to download. They have been ignored, or old ones used instead.")); + Res = _error->Warning(_("Some index files failed to download. They have been ignored, or old ones used instead.")); else if (Failed == true) - return _error->Error(_("Some index files failed to download. They have been ignored, or old ones used instead.")); + Res = _error->Error(_("Some index files failed to download. They have been ignored, or old ones used instead.")); // Run the success scripts if all was fine if (RunUpdateScripts == true) { - if(!TransientNetworkFailure && !Failed) + if(AllFailed == false) RunScripts("APT::Update::Post-Invoke-Success"); // Run the other scripts RunScripts("APT::Update::Post-Invoke"); } - return true; + return Res; } /*}}}*/ diff --git a/test/integration/test-apt-update-hooks b/test/integration/test-apt-update-hooks new file mode 100755 index 000000000..0a4ee59b4 --- /dev/null +++ b/test/integration/test-apt-update-hooks @@ -0,0 +1,43 @@ +#!/bin/sh +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" + +setupenvironment +configarchitecture 'i386' +confighashes 'SHA512' + +insertpackage 'unstable' 'foo' 'i386' '1.0' +insertpackage 'testing' 'foo' 'any' '1.0' + +setupaptarchive --no-update +APTARCHIVE="$(readlink -f ./aptarchive)" + +signreleasefiles 'Joe Sixpack' + +echo 'APT::Update::Post-Invoke-Success { "echo SUCCESS"; };' >> rootdir/etc/apt/apt.conf.d/display-success.conf +echo 'APT::Update::Post-Invoke { "echo RUN"; };' >> rootdir/etc/apt/apt.conf.d/display-success.conf + + +msgmsg "All sources OK => run Post-Invoke-Success and Post-Invoke" +testsuccess aptget update +cp rootdir/tmp/testsuccess.output aptupdate.output +testsuccess grep "RUN" aptupdate.output +testsuccess grep "SUCCESS" aptupdate.output + +msgmsg "Some sources broken => run Post-Invoke-Success and Post-Invoke" +sed -i -e '/^ / d' -e '/^SHA512:/ d' "$APTARCHIVE/dists/unstable/Release" +signreleasefiles +testfailure aptget update +cp rootdir/tmp/testfailure.output aptupdate.output +testsuccess grep "RUN" aptupdate.output +testsuccess grep "SUCCESS" aptupdate.output + +msgmsg "All sources broken => run Post-Invoke" +sed -i -e '/^ / d' -e '/^SHA512:/ d' "$APTARCHIVE/dists/testing/Release" +signreleasefiles +testfailure aptget update +cp rootdir/tmp/testfailure.output aptupdate.output +testsuccess grep "RUN" aptupdate.output +testfailure grep "SUCCESS" aptupdate.output |