test-apt-update-filesize-mismatch 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture 'i386'
  7. configcompression 'gz'
  8. insertpackage 'testing' 'foo' 'all' '1'
  9. insertpackage 'testing' 'foo2' 'all' '1'
  10. insertsource 'testing' 'foo' 'all' '1'
  11. insertsource 'testing' 'foo2' 'all' '1'
  12. setupaptarchive --no-update
  13. changetowebserver
  14. find aptarchive \( -name 'Packages' -o -name 'Sources' -o -name 'Translation-en' \) -delete
  15. for release in $(find aptarchive -name 'Release'); do
  16. cp "$release" "${release}.backup"
  17. done
  18. testsuccess aptget update
  19. testsuccess aptcache show foo
  20. testsuccess aptget install foo -s
  21. for get in $(sed -n 's#^GET /\([^ ]\+\.gz\) HTTP.\+$#\1#p' aptarchive/webserver.log); do
  22. for ext in '' '.gz'; do
  23. COMPRESSFILE="$get"
  24. get="${get}${ext}"
  25. FILE="$(basename "$get" '.gz')"
  26. msgmsg 'Test filesize mismatch with file' "$FILE"
  27. rm -rf rootdir/var/lib/apt/lists
  28. for release in $(find aptarchive -name 'Release'); do
  29. SIZE="$(awk "/$FILE\$/ { print \$2; exit }" "${release}.backup")"
  30. sed "s# $SIZE # $(($SIZE + 111)) #" "${release}.backup" > "$release"
  31. done
  32. signreleasefiles
  33. TEST='testfailure'
  34. if expr match "$COMPRESSFILE" '^.*Translation-.*$' >/dev/null; then
  35. TEST='testsuccess'
  36. unset COMPRESSFILE
  37. fi
  38. $TEST aptget update -o Debug::pkgAcquire::Worker=1
  39. cp rootdir/tmp/${TEST}.output rootdir/tmp/update.output
  40. testsuccess grep -E "$(basename -s '.gz' "$COMPRESSFILE").*Hash Sum mismatch" rootdir/tmp/update.output
  41. $TEST aptcache show foo
  42. $TEST aptget install foo -s
  43. testfailure aptcache show bar
  44. testfailure aptget install bar -s
  45. done
  46. done