test-apt-update-failure-propagation 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 amd64 Packages
  36. 1 500
  37. 500 https://localhost:${APTHTTPSPORT} stable/main amd64 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. testfailureequal "Hit:1 http://localhost:${APTHTTPPORT} sid InRelease
  42. Ign:2 https://localhost:${APTHTTPSPORT} stable InRelease
  43. 404 Not Found
  44. Err:3 https://localhost:${APTHTTPSPORT} stable Release
  45. 404 Not Found
  46. Reading package lists...
  47. E: The repository 'https://localhost:${APTHTTPSPORT} stable Release' does not have a Release file.
  48. N: Updating such a repository securily is impossible and therefore disabled by default.
  49. N: See apt-secure(8) manpage for repository creation and user configuration details." aptget update -q=0 --no-allow-insecure-repositories
  50. mv aptarchive/dists/stable.good aptarchive/dists/stable
  51. posttest() {
  52. testsuccessequal "foo:
  53. Installed: (none)
  54. Candidate: 2
  55. Version table:
  56. 2 500
  57. 500 http://localhost:${APTHTTPPORT} sid/main amd64 Packages" aptcache policy foo
  58. }
  59. posttest
  60. pretest
  61. rm "${NEWMETHODS}/https"
  62. testfailuremsg "E: The method driver ${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/methods/https could not be found.
  63. W: Failed to fetch https://localhost:${APTHTTPSPORT}/dists/stable/InRelease
  64. E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
  65. posttest
  66. ln -s "$OLDMETHODS/https" "$NEWMETHODS"
  67. pretest
  68. for FILE in rootdir/etc/apt/sources.list.d/*-stable-* ; do
  69. # lets see how many testservers run also Doom
  70. sed -i -e "s#:${APTHTTPSPORT}/#:666/#" "$FILE"
  71. done
  72. testwarningmsg "W: Failed to fetch https://localhost:666/dists/stable/InRelease Failed to connect to localhost port 666: Connection refused
  73. W: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
  74. posttest