You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

108 lines
6.1 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'native'
  7. buildsimplenativepackage 'foo' 'all' '1.0' 'stable'
  8. buildsimplenativepackage 'libbar' 'all' '1.0' 'stable'
  9. getlabelfromsuite() { echo 'Testcases'; }
  10. getoriginfromsuite() { echo 'Debian'; }
  11. setupaptarchive --no-update
  12. changetowebserver
  13. testsuccess aptget update
  14. testsuccessequal "'http://metadata.ftp-master.debian.org/changelogs/main/f/foo/foo_1.0_changelog' foo.changelog
  15. 'http://metadata.ftp-master.debian.org/changelogs/main/libb/libbar/libbar_1.0_changelog' libbar.changelog" aptget changelog foo libbar --print-uris
  16. releasechanger() {
  17. # modifying the Release files in lists… bad stuff. Good that this is only a test…
  18. sed -i "s#^${1}: .*#${1}: ${2}#" $(find rootdir/var/lib/apt/lists -name '*Release')
  19. rm -f rootdir/var/cache/apt/*.bin
  20. }
  21. releasechanger 'Origin' 'Ubuntu'
  22. testsuccessequal "'http://changelogs.ubuntu.com/changelogs/pool/main/f/foo/foo_1.0/changelog' foo.changelog
  23. 'http://changelogs.ubuntu.com/changelogs/pool/main/libb/libbar/libbar_1.0/changelog' libbar.changelog" aptget changelog foo libbar --print-uris
  24. releasechanger 'Label' 'Debian'
  25. testsuccessequal "'http://changelogs.ubuntu.com/changelogs/pool/main/f/foo/foo_1.0/changelog' foo.changelog
  26. 'http://changelogs.ubuntu.com/changelogs/pool/main/libb/libbar/libbar_1.0/changelog' libbar.changelog" aptget changelog foo libbar --print-uris
  27. testsuccessequal "'http://localhost:${APTHTTPPORT}/main/f/foo/foo_1.0.changelog' foo.changelog
  28. 'http://localhost:${APTHTTPPORT}/main/libb/libbar/libbar_1.0.changelog' libbar.changelog" aptget changelog foo libbar --print-uris -o Acquire::Changelogs::URI::Label::Debian="http://localhost:${APTHTTPPORT}/@CHANGEPATH@.changelog"
  29. sed -i '/^Origin: / a\
  30. Changelogs: http://example.org/@CHANGEPATH@-changelog' $(find rootdir/var/lib/apt/lists -name '*Release')
  31. rm -f rootdir/var/cache/apt/*.bin
  32. testsuccessequal "'http://example.org/main/f/foo/foo_1.0-changelog' foo.changelog
  33. 'http://example.org/main/libb/libbar/libbar_1.0-changelog' libbar.changelog" aptget changelog foo libbar --print-uris -o Acquire::Changelogs::URI::Label::Debian="http://localhost:${APTHTTPPORT}/@CHANGEPATH@.changelog"
  34. testsuccessequal "'http://localhost:${APTHTTPPORT}/main/f/foo/foo_1.0.changelog' foo.changelog
  35. 'http://localhost:${APTHTTPPORT}/main/libb/libbar/libbar_1.0.changelog' libbar.changelog" aptget changelog foo libbar --print-uris -o Acquire::Changelogs::URI::Override::Label::Debian="http://localhost:${APTHTTPPORT}/@CHANGEPATH@.changelog"
  36. releasechanger 'Changelogs' 'no'
  37. if [ "$(id -u)" = '0' ]; then
  38. testfailuremsg "W: Can't drop privileges for downloading as file 'foo.changelog' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
  39. E: Failed to fetch changelog:/foo.changelog Changelog unavailable for foo=1.0" aptget changelog foo -d
  40. else
  41. testfailuremsg 'E: Failed to fetch changelog:/foo.changelog Changelog unavailable for foo=1.0' aptget changelog foo -d
  42. fi
  43. sed -i '/^Changelogs: / d' $(find rootdir/var/lib/apt/lists -name '*Release')
  44. releasechanger 'Label' 'Testcases'
  45. echo "Acquire::Changelogs::URI::Label::Testcases \"http://localhost:${APTHTTPPORT}/@CHANGEPATH@/change.txt\";" > rootdir/etc/apt/apt.conf.d/changelog.conf
  46. testsuccessequal "'http://localhost:${APTHTTPPORT}/main/f/foo/foo_1.0/change.txt' foo.changelog
  47. 'http://localhost:${APTHTTPPORT}/main/libb/libbar/libbar_1.0/change.txt' libbar.changelog" aptget changelog foo libbar --print-uris
  48. echo "Acquire::Changelogs::URI::Label::Testcases \"http://localhost:${APTHTTPPORT}/pool/@CHANGEPATH@/changelog\";" > rootdir/etc/apt/apt.conf.d/changelog.conf
  49. testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog" aptget changelog foo --print-uris
  50. testsuccess aptget changelog foo -qq
  51. testfileequal 'rootdir/tmp/testsuccess.output' "$(cat aptarchive/pool/main/f/foo/foo_1.0/changelog)"
  52. testsuccess aptget changelog foo libbar -qq
  53. testfileequal 'rootdir/tmp/testsuccess.output' "$(cat aptarchive/pool/main/f/foo/foo_1.0/changelog)
  54. $(cat aptarchive/pool/main/libb/libbar/libbar_1.0/changelog)"
  55. cd downloaded
  56. testsuccess aptget changelog foo -d
  57. testfilestats 'foo.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
  58. testfileequal 'foo.changelog' "$(cat ../aptarchive/pool/main/f/foo/foo_1.0/changelog)"
  59. rm -f foo.changelog
  60. testsuccess aptget changelog libbar foo -d
  61. testfilestats 'libbar.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
  62. testfilestats 'foo.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
  63. testfileequal 'libbar.changelog' "$(cat ../aptarchive/pool/main/libb/libbar/libbar_1.0/changelog)"
  64. testfileequal 'foo.changelog' "$(cat ../aptarchive/pool/main/f/foo/foo_1.0/changelog)"
  65. rm -f libbar.changelog foo.changelog
  66. # as such bogus, but can happen with multiple binaries from the same source
  67. testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog
  68. 'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog" aptget changelog foo foo --print-uris
  69. testsuccess aptget changelog foo foo -qq
  70. testfileequal '../rootdir/tmp/testsuccess.output' "$(cat ../aptarchive/pool/main/f/foo/foo_1.0/changelog)
  71. $(cat ../aptarchive/pool/main/f/foo/foo_1.0/changelog)"
  72. testsuccess aptget changelog foo foo -d
  73. testfilestats 'foo.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
  74. testfileequal 'foo.changelog' "$(cat ../aptarchive/pool/main/f/foo/foo_1.0/changelog)"
  75. rm -f foo.changelog
  76. # no @CHANGEPATH@ in the URI
  77. testequal 'E: Failed to fetch changelog:/foo.changelog Changelog unavailable for foo=1.0
  78. ' aptget changelog foo -qq -d -o Acquire::Changelogs::URI::Label::Testcases="http://localhost:${APTHTTPPORT}/change.txt"
  79. testfailure test -e foo.changelog
  80. testequal "E: Failed to fetch http://localhost:${APTHTTPPORT}/does/not/exist/main/f/foo/foo_1.0/change.txt Changelog unavailable for foo=1.0 (404 Not Found)
  81. " aptget changelog foo -qq -d -o Acquire::Changelogs::URI::Label::Testcases="http://localhost:${APTHTTPPORT}/does/not/exist/@CHANGEPATH@/change.txt"
  82. testfailure test -e foo.changelog