test-apt-update-failure-propagation 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64'
  7. buildsimplenativepackage 'foo' 'all' '1' 'stable'
  8. buildsimplenativepackage 'foo' 'all' '2' 'sid'
  9. setupaptarchive --no-update
  10. NEWMETHODS="$(readlink -f rootdir)/usr/lib/apt/methods"
  11. OLDMETHODS="$(readlink -f rootdir/usr/lib/apt/methods)"
  12. rm "$NEWMETHODS"
  13. mkdir "$NEWMETHODS"
  14. backupIFS="$IFS"
  15. IFS="$(printf "\n\b")"
  16. for METH in $(find "$OLDMETHODS" ! -type d); do
  17. ln -s "$OLDMETHODS/$(basename "$METH")" "$NEWMETHODS"
  18. done
  19. IFS="$backupIFS"
  20. changetohttpswebserver
  21. for FILE in rootdir/etc/apt/sources.list.d/*-sid-* ; do
  22. sed -i -e 's#https:#http:#' -e "s#:${APTHTTPSPORT}/#:${APTHTTPPORT}/#" "$FILE"
  23. done
  24. pretest() {
  25. rm -rf rootdir/var/lib/apt/lists
  26. testsuccessequal 'N: Unable to locate package foo' aptcache policy foo -q=0
  27. }
  28. pretest
  29. testsuccess aptget update
  30. testsuccessequal "foo:
  31. Installed: (none)
  32. Candidate: 2
  33. Version table:
  34. 2 500
  35. 500 http://localhost:${APTHTTPPORT} sid/main all Packages
  36. 1 500
  37. 500 https://localhost:${APTHTTPSPORT} stable/main all Packages" aptcache policy foo
  38. pretest
  39. mv aptarchive/dists/stable aptarchive/dists/stable.good
  40. testfailuremsg "E: The repository 'https://localhost:${APTHTTPSPORT} stable Release' does not have a Release file." apt update
  41. testfailure aptget update -q=0 --no-allow-insecure-repositories
  42. testequalor2 "Hit:1 http://localhost:${APTHTTPPORT} sid InRelease
  43. Ign:2 https://localhost:${APTHTTPSPORT} stable InRelease
  44. 404 Not Found
  45. Err:3 https://localhost:${APTHTTPSPORT} stable Release
  46. 404 Not Found
  47. Reading package lists...
  48. E: The repository 'https://localhost:${APTHTTPSPORT} stable Release' does not have a Release file.
  49. N: Updating such a repository securily is impossible and therefore disabled by default.
  50. N: See apt-secure(8) manpage for repository creation and user configuration details." "Ign:1 https://localhost:${APTHTTPSPORT} stable InRelease
  51. 404 Not Found
  52. Err:2 https://localhost:${APTHTTPSPORT} stable Release
  53. 404 Not Found
  54. Hit:3 http://localhost:${APTHTTPPORT} sid InRelease
  55. Reading package lists...
  56. E: The repository 'https://localhost:${APTHTTPSPORT} stable Release' does not have a Release file.
  57. N: Updating such a repository securily is impossible and therefore disabled by default.
  58. N: See apt-secure(8) manpage for repository creation and user configuration details." cat rootdir/tmp/testfailure.output
  59. mv aptarchive/dists/stable.good aptarchive/dists/stable
  60. posttest() {
  61. testsuccessequal "foo:
  62. Installed: (none)
  63. Candidate: 2
  64. Version table:
  65. 2 500
  66. 500 http://localhost:${APTHTTPPORT} sid/main all Packages" aptcache policy foo
  67. }
  68. posttest
  69. pretest
  70. rm "${NEWMETHODS}/https"
  71. testfailuremsg "E: The method driver ${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/methods/https could not be found.
  72. W: Failed to fetch https://localhost:${APTHTTPSPORT}/dists/stable/InRelease
  73. E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
  74. posttest
  75. ln -s "$OLDMETHODS/https" "$NEWMETHODS"
  76. pretest
  77. for FILE in rootdir/etc/apt/sources.list.d/*-stable-* ; do
  78. # lets see how many testservers run also Doom
  79. sed -i -e "s#:${APTHTTPSPORT}/#:666/#" "$FILE"
  80. done
  81. testwarning aptget update
  82. testequalor2 "W: Failed to fetch https://localhost:666/dists/stable/InRelease Failed to connect to localhost port 666: Connection refused
  83. W: Some index files failed to download. They have been ignored, or old ones used instead." "W: Failed to fetch https://localhost:666/dists/stable/InRelease couldn't connect to host
  84. W: Some index files failed to download. They have been ignored, or old ones used instead." tail -n 2 rootdir/tmp/testwarning.output
  85. posttest