Bläddra i källkod

Report non-transient errors as errors, not as warnings

This makes it easier to understand what really is an error
and what not.
Julian Andres Klode 10 år sedan
förälder
incheckning
f695e76199

+ 7 - 3
apt-pkg/update.cc

@@ -73,9 +73,13 @@ bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval,
       uri.User.clear();
       uri.Password.clear();
       string descUri = string(uri);
-      _error->Warning(_("Failed to fetch %s  %s"), descUri.c_str(),
-	      (*I)->ErrorText.c_str());
-
+      // Show an error for non-transient failures, otherwise only warn
+      if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError)
+	 _error->Warning(_("Failed to fetch %s  %s"), descUri.c_str(),
+			(*I)->ErrorText.c_str());
+      else
+	 _error->Error(_("Failed to fetch %s  %s"), descUri.c_str(),
+	       (*I)->ErrorText.c_str());
       if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError) 
       {
 	 TransientNetworkFailure = true;

+ 1 - 1
test/integration/test-apt-update-expected-size

@@ -36,7 +36,7 @@ test_packagestoobig() {
 		touch -d '+1hour' "$pkg"
 	done
 	NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages)"
-	testfailuremsg "W: Failed to fetch ${1}/dists/unstable/main/binary-i386/Packages  Writing more data than expected ($NEW_SIZE > $SIZE)
+	testfailuremsg "E: Failed to fetch ${1}/dists/unstable/main/binary-i386/Packages  Writing more data than expected ($NEW_SIZE > $SIZE)
 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::Transaction=0
 }
 

+ 1 - 1
test/integration/test-apt-update-failure-propagation

@@ -80,7 +80,7 @@ pretest
 rm "${NEWMETHODS}/https"
 testfailuremsg "E: The method driver ${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/methods/https could not be found.
 N: Is the package apt-transport-https installed?
-W: Failed to fetch https://localhost:${APTHTTPSPORT}/dists/stable/InRelease  
+E: Failed to fetch https://localhost:${APTHTTPSPORT}/dists/stable/InRelease  
 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
 posttest
 

+ 1 - 1
test/integration/test-apt-update-nofallback

@@ -149,7 +149,7 @@ test_subvert_inrelease()
     # replace InRelease with something else
     mv "$APTARCHIVE/dists/unstable/Release" "$APTARCHIVE/dists/unstable/InRelease"
 
-    testfailuremsg "W: Failed to fetch file:${APTARCHIVE}/dists/unstable/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
+    testfailuremsg "E: Failed to fetch file:${APTARCHIVE}/dists/unstable/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
 
     # ensure we keep the repo

+ 2 - 2
test/integration/test-apt-update-not-modified

@@ -48,7 +48,7 @@ Get:2 $1 unstable/main amd64 Packages [$SIZE B]
 Err:2 $1 unstable/main amd64 Packages
   Hash Sum mismatch
 Reading package lists...
-W: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz  Hash Sum mismatch
+E: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz  Hash Sum mismatch
 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
 	testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
 	rm -rf aptarchive/dists
@@ -109,7 +109,7 @@ Get:4 $1 unstable/main amd64 Packages [$SIZE B]
 Err:4 $1 unstable/main amd64 Packages
   Hash Sum mismatch
 Reading package lists...
-W: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz  Hash Sum mismatch
+E: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz  Hash Sum mismatch
 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
 	testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
 	rm -rf aptarchive/dists

+ 2 - 2
test/integration/test-apt-update-rollback

@@ -60,7 +60,7 @@ test_inrelease_to_broken_hash_reverts_all() {
     break_repository_sources_index '+1hour'
 
     # test the error condition
-    testfailureequal "W: Failed to fetch file:${APTARCHIVE}/dists/unstable/main/source/Sources.gz  Hash Sum mismatch
+    testfailureequal "E: Failed to fetch file:${APTARCHIVE}/dists/unstable/main/source/Sources.gz  Hash Sum mismatch
 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq
     # ensure that the Packages file is also rolled back
     testfileequal lists.before "$(listcurrentlistsdirectory)"
@@ -126,7 +126,7 @@ E: There were unauthenticated packages and -y was used without --allow-unauthent
     add_new_package '+1hour'
     break_repository_sources_index '+1hour'
 
-    testfailureequal "W: Failed to fetch file:$APTARCHIVE/dists/unstable/main/source/Sources.gz  Hash Sum mismatch
+    testfailureequal "E: Failed to fetch file:$APTARCHIVE/dists/unstable/main/source/Sources.gz  Hash Sum mismatch
 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq
 
     testfileequal lists.before "$(listcurrentlistsdirectory)"

+ 1 - 1
test/integration/test-apt-update-stale

@@ -39,6 +39,6 @@ cp -p aptarchive/dists/unstable/main/binary-i386/saved/Packages* \
      aptarchive/dists/unstable/main/binary-i386/
 
 # ensure this raises an error
-testfailuremsg "W: Failed to fetch http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-i386/Packages.gz  Hash Sum mismatch
+testfailuremsg "E: Failed to fetch http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-i386/Packages.gz  Hash Sum mismatch
 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
 testfileequal lists.before "$(listcurrentlistsdirectory)"

+ 2 - 2
test/integration/test-apt-update-weak-hashes

@@ -17,7 +17,7 @@ APTARCHIVE="$(readlink -f ./aptarchive)"
 msgmsg 'Release contains only weak hashes'
 FILENAME="${APTARCHIVE}/dists/unstable/InRelease"
 MANGLED="$(readlink -f ./rootdir)/var/lib/apt/lists/partial/$(echo "$FILENAME" | sed 's#/#_#g')"
-testfailuremsg "W: Failed to fetch file:${FILENAME}  No Hash entry in Release file ${MANGLED}, which is considered strong enough for security purposes
+testfailuremsg "E: Failed to fetch file:${FILENAME}  No Hash entry in Release file ${MANGLED}, which is considered strong enough for security purposes
 E: Some index files failed to download. They have been ignored, or old ones used instead." apt update
 testnopackage foo
 testnosrcpackage foo
@@ -25,7 +25,7 @@ testnosrcpackage foo
 msgmsg 'Release contains no hashes'
 sed -i -e '/^ / d' -e '/^MD5Sum:/ d' "$APTARCHIVE/dists/unstable/Release"
 signreleasefiles
-testfailuremsg "W: Failed to fetch file:${FILENAME}  No Hash entry in Release file ${MANGLED}
+testfailuremsg "E: Failed to fetch file:${FILENAME}  No Hash entry in Release file ${MANGLED}
 E: Some index files failed to download. They have been ignored, or old ones used instead." apt update
 testnopackage foo
 testnosrcpackage foo

+ 2 - 2
test/integration/test-bug-595691-empty-and-broken-archive-files

@@ -55,7 +55,7 @@ Reading package lists..." "empty archive Packages.$COMPRESS over file"
 Err:2 file:$APTARCHIVE  Packages
   Empty files can't be valid archives
 Reading package lists...
-W: Failed to fetch store:$(readlink -f rootdir/var/lib/apt/lists/partial/$(echo "$APTARCHIVE" | sed -e 's#/#_#g')_Packages.${COMPRESS})  Empty files can't be valid archives
+E: Failed to fetch store:$(readlink -f rootdir/var/lib/apt/lists/partial/$(echo "$APTARCHIVE" | sed -e 's#/#_#g')_Packages.${COMPRESS})  Empty files can't be valid archives
 E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over file"
 }
 
@@ -72,7 +72,7 @@ Reading package lists..." "empty archive Packages.$COMPRESS over http"
 Err:2 http://localhost:${APTHTTPPORT}  Packages
   Empty files can't be valid archives
 Reading package lists...
-W: Failed to fetch store:$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:${APTHTTPPORT}_Packages.${COMPRESS})  Empty files can't be valid archives
+E: Failed to fetch store:$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:${APTHTTPPORT}_Packages.${COMPRESS})  Empty files can't be valid archives
 E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http"
 }
 

+ 3 - 3
test/integration/test-ubuntu-bug-346386-apt-get-update-paywall

@@ -37,7 +37,7 @@ ensure_n_canary_strings_in_dir() {
 LISTS='rootdir/var/lib/apt/lists'
 rm -rf rootdir/var/lib/apt/lists
 testfailure aptget update
-testsuccess grep '^W:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output
+testsuccess grep '^E:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output
 
 ensure_n_canary_strings_in_dir "$LISTS" 'ni ni ni' 0
 testequal 'lock
@@ -50,7 +50,7 @@ for f in Release Release.gpg main_binary-amd64_Packages main_source_Sources; do
 done
 
 testfailure aptget update
-testsuccess grep '^W:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output
+testsuccess grep '^E:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output
 
 ensure_n_canary_strings_in_dir "$LISTS" 'peng neee-wom' 4
 ensure_n_canary_strings_in_dir "$LISTS" 'ni ni ni' 0
@@ -61,7 +61,7 @@ chmod 644 "$LISTS/localhost:${APTHTTPPORT}_dists_stable_InRelease"
 rm -f "$LISTS/localhost:${APTHTTPPORT}_dists_stable_Release" "$LISTS/localhost:${APTHTTPPORT}_dists_stable_Release.gpg"
 msgtest 'excpected failure of' 'apt-get update'
 testfailure aptget update
-testsuccess grep '^W:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output
+testsuccess grep '^E:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output
 
 ensure_n_canary_strings_in_dir "$LISTS" 'peng neee-wom' 3
 ensure_n_canary_strings_in_dir "$LISTS" 'ni ni ni' 0

+ 1 - 1
test/integration/test-ubuntu-bug-784473-InRelease-one-message-only

@@ -28,7 +28,7 @@ MD5Sum:
 done
 
 testfailure aptget update
-testsuccess grep '^W:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output
+testsuccess grep '^E:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output
 
 
 ROOTDIR="$(readlink -f .)"