diff options
-rw-r--r-- | apt-pkg/update.cc | 21 | ||||
-rw-r--r-- | apt-private/private-cmndline.cc | 1 | ||||
-rw-r--r-- | doc/apt-get.8.xml | 4 | ||||
-rw-r--r-- | doc/examples/configure-index | 1 | ||||
-rwxr-xr-x | test/integration/test-apt-update-failure-propagation | 6 |
5 files changed, 31 insertions, 2 deletions
diff --git a/apt-pkg/update.cc b/apt-pkg/update.cc index 1b25bafd6..1bf818ad7 100644 --- a/apt-pkg/update.cc +++ b/apt-pkg/update.cc @@ -46,6 +46,20 @@ bool ListUpdate(pkgAcquireStatus &Stat, bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval, bool const RunUpdateScripts, bool const ListCleanup) { + enum class ErrorMode + { + Persistent, + Any + }; + std::string errorModeS = _config->Find("APT::Update::Error-Mode", "persistent"); + ErrorMode errorMode = ErrorMode::Persistent; + if (errorModeS == "persistent") + errorMode = ErrorMode::Persistent; + else if (errorModeS == "any") + errorMode = ErrorMode::Any; + else + return _error->Error("Unknown update error mode %s", errorModeS.c_str()); + // Run scripts if (RunUpdateScripts == true) RunScripts("APT::Update::Pre-Invoke"); @@ -69,7 +83,10 @@ bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval, AllFailed = false; continue; case pkgAcquire::Item::StatTransientNetworkError: - TransientNetworkFailure = true; + if (errorMode == ErrorMode::Any) + Failed = true; + else + TransientNetworkFailure = true; break; case pkgAcquire::Item::StatIdle: case pkgAcquire::Item::StatFetching: @@ -91,7 +108,7 @@ bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval, uri.Path = DeQuoteString(uri.Path); std::string const descUri = std::string(uri); // Show an error for non-transient failures, otherwise only warn - if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError) + if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError && errorMode != ErrorMode::Any) _error->Warning(_("Failed to fetch %s %s"), descUri.c_str(), (*I)->ErrorText.c_str()); else diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc index 2049842db..2884dccba 100644 --- a/apt-private/private-cmndline.cc +++ b/apt-private/private-cmndline.cc @@ -206,6 +206,7 @@ static bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const addArg(0, "allow-releaseinfo-change-codename", "Acquire::AllowReleaseInfoChange::Codename", 0); addArg(0, "allow-releaseinfo-change-suite", "Acquire::AllowReleaseInfoChange::Suite", 0); addArg(0, "allow-releaseinfo-change-defaultpin", "Acquire::AllowReleaseInfoChange::DefaultPin", 0); + addArg('e', "error-on", "APT::Update::Error-Mode", CommandLine::HasArg); } else if (CmdMatches("source")) { diff --git a/doc/apt-get.8.xml b/doc/apt-get.8.xml index 38a8c253a..0bdece955 100644 --- a/doc/apt-get.8.xml +++ b/doc/apt-get.8.xml @@ -646,6 +646,10 @@ </para></listitem> </varlistentry> + <varlistentry><term><option>-e<replaceable>any</replaceable></option></term><term><option>--error-on=<replaceable>any</replaceable></option></term> + <listitem><para>Fail the update command if any error occured, even a transient one.</para></listitem> + </varlistentry> + &apt-commonoptions; </variablelist> diff --git a/doc/examples/configure-index b/doc/examples/configure-index index 5ddf4132c..ecd54b6ba 100644 --- a/doc/examples/configure-index +++ b/doc/examples/configure-index @@ -166,6 +166,7 @@ APT { Pre-Invoke {"touch /var/lib/apt/pre-update-stamp"; }; Post-Invoke {"touch /var/lib/apt/post-update-stamp"; }; + Error-Mode "<STRING>"; }; /* define a new supported compressor on the fly diff --git a/test/integration/test-apt-update-failure-propagation b/test/integration/test-apt-update-failure-propagation index 44f2e7048..8c7fd3b7e 100755 --- a/test/integration/test-apt-update-failure-propagation +++ b/test/integration/test-apt-update-failure-propagation @@ -88,3 +88,9 @@ testwarning aptget update -o Dir::Bin::Methods::https="${OLDMETHODS}/https" testsuccess grep '^W: Failed to fetch https://localhost:666/dists/stable/InRelease ' rootdir/tmp/testwarning.output testequal 'W: Some index files failed to download. They have been ignored, or old ones used instead.' tail -n 1 rootdir/tmp/testwarning.output posttest + +pretest 'error-mode=any' 'doom port' +testfailure aptget update -o Dir::Bin::Methods::https="${OLDMETHODS}/https" -eany +testsuccess grep '^E: Failed to fetch https://localhost:666/dists/stable/InRelease ' rootdir/tmp/testfailure.output +testequal 'E: Some index files failed to download. They have been ignored, or old ones used instead.' tail -n 1 rootdir/tmp/testfailure.output +posttest |