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.
 
 
 
 
 
 

172 lines
6.3 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'i386'
  7. insertpackage 'unstable' 'unrelated' 'i386' '1'
  8. insertpackage 'unstable' 'ancientstuff' 'all' '1'
  9. insertpackage 'unstable' 'boringstuff' 'all' '1' '' '' 'shared short description'
  10. insertpackage 'unstable' 'coolstuff' 'all' '1'
  11. insertpackage 'unstable' 'dullstuff' 'all' '1' '' '' 'shared short description'
  12. insertpackage 'unstable' 'evilstuff' 'all' '1'
  13. insertpackage 'unstable' 'foostuff' 'all' '1' '' '' 'shared short description'
  14. insertpackage 'unstable' 'goodstuff' 'all' '1'
  15. insertpackage 'unstable' "longdesc" 'all' '1' '' '' "$(for i in $(seq 0 100); do printf '%s' 'lorem ipsum '; done)"
  16. setupaptarchive --no-update
  17. changetowebserver
  18. testsuccess aptget update
  19. PKGORDER='coolstuff foostuff coolstuff foostuff'
  20. msgtest 'Prepare expectation for' 'aptcache show'
  21. if aptcache show $PKGORDER | grep -v '^ ' > aptcacheshow.out 2>&1; then
  22. msgpass
  23. else
  24. cat aptcacheshow.out || true
  25. msgfail
  26. fi
  27. testsuccessequal '4' grep -c '^Package: ' aptcacheshow.out
  28. msgtest 'Prepare expectation for' 'apt show'
  29. if apt show $PKGORDER | grep -v -e '^ ' -e '^[A-Z][a-z]\+-Size: ' > aptshow.out 2>&1; then
  30. msgpass
  31. else
  32. cat aptshow.out || true
  33. msgfail
  34. fi
  35. testsuccessequal '4' grep -c '^Package: ' aptshow.out
  36. rm -rf rootdir/var/lib/apt/lists
  37. checkaptshow() {
  38. testsuccess aptcache show $PKGORDER
  39. sed -i -e 's#^Description: #Description-en: #' rootdir/tmp/testsuccess.output
  40. testequal "$(cat aptcacheshow.out)
  41. " grep -v '^ ' rootdir/tmp/testsuccess.output
  42. testsuccess apt show $PKGORDER
  43. sed -i -e 's#^Description-en: #Description: #' rootdir/tmp/testsuccess.output
  44. testequal "$(cat aptshow.out)
  45. " grep -v -e '^ ' -e '^[A-Z][a-z]\+-Size: ' rootdir/tmp/testsuccess.output
  46. if [ -n "$(ls rootdir/var/lib/apt/lists/*Translation* 2>/dev/null)" ]; then
  47. testsuccess find rootdir/var/lib/apt/lists/ -name '*Translation*' -delete
  48. testsuccess aptcache show $PKGORDER
  49. sed -i -e 's#^Description: #Description-en: #' rootdir/tmp/testsuccess.output
  50. testequal "$(cat aptcacheshow.out)
  51. " grep -v '^ ' rootdir/tmp/testsuccess.output
  52. testsuccess apt show $PKGORDER
  53. sed -i -e 's#^Description-en: #Description: #' rootdir/tmp/testsuccess.output
  54. testequal "$(cat aptshow.out)
  55. " grep -v -e '^ ' -e '^[A-Z][a-z]\+-Size: ' rootdir/tmp/testsuccess.output
  56. fi
  57. }
  58. translationslisted() {
  59. msgtest 'No download of non-existent locals' "$1"
  60. export LC_ALL=""
  61. testsuccess --nomsg aptget update -o Acquire::Languages=en
  62. testfailure grep -q -e 'Translation-[^e][^n] ' rootdir/tmp/testsuccess.output
  63. checkaptshow
  64. rm -rf rootdir/var/lib/apt/lists
  65. msgtest 'Download of existent locals' "$1"
  66. testsuccess --nomsg aptget update
  67. cp rootdir/tmp/testsuccess.output testsuccess.output
  68. testsuccess grep -q -e 'Translation-en ' testsuccess.output
  69. checkaptshow
  70. rm -rf rootdir/var/lib/apt/lists
  71. msgtest 'Download of en in LC_ALL=C' "$1"
  72. export LC_ALL=C
  73. testsuccess --nomsg aptget update
  74. cp rootdir/tmp/testsuccess.output testsuccess.output
  75. testsuccess grep -q -e 'Translation-en ' testsuccess.output
  76. checkaptshow
  77. rm -rf rootdir/var/lib/apt/lists
  78. unset LC_ALL
  79. msgtest 'Download of en as forced language' "$1"
  80. testsuccess --nomsg aptget update -o Acquire::Languages=en
  81. cp rootdir/tmp/testsuccess.output testsuccess.output
  82. testsuccess grep -q -e 'Translation-en ' testsuccess.output
  83. checkaptshow
  84. rm -rf rootdir/var/lib/apt/lists
  85. msgtest 'Download of nothing else in forced language' "$1"
  86. testsuccess --nomsg aptget update -o Acquire::Languages=en
  87. testfailure grep -q -e 'Translation-[^e][^n] ' rootdir/tmp/testsuccess.output
  88. checkaptshow
  89. rm -rf rootdir/var/lib/apt/lists
  90. msgtest 'Download no Translation- if forced language is non-existent' "$1"
  91. testsuccess --nomsg aptget update -o Acquire::Languages=ast_DE
  92. testfailure grep -q -e 'Translation-' rootdir/tmp/testsuccess.output
  93. checkaptshow
  94. rm -rf rootdir/var/lib/apt/lists
  95. msgtest 'Download of nothing if none is forced' "$1"
  96. testsuccess --nomsg aptget update -o Acquire::Languages=none
  97. testfailure grep -q -e 'Translation' rootdir/tmp/testsuccess.output
  98. checkaptshow
  99. rm -rf rootdir/var/lib/apt/lists
  100. }
  101. translationslisted 'with full Index'
  102. # No Release file at all, so no records about Translation files
  103. # (fallback to guessing)
  104. find aptarchive \( -name 'Release' -o -name 'InRelease' \) -delete
  105. echo 'Acquire::AllowInsecureRepositories "true";' > rootdir/etc/apt/apt.conf.d/allow-insecure-repositories.conf
  106. msgtest 'Download of en as forced language' 'without Index'
  107. testwarning --nomsg aptget update -o Acquire::Languages=en
  108. testsuccess grep -q -e 'Translation-en ' rootdir/tmp/testwarning.output
  109. checkaptshow
  110. rm -rf rootdir/var/lib/apt/lists
  111. msgtest 'Download of nothing else in forced language' 'without Index'
  112. testwarning --nomsg aptget update -o Acquire::Languages=en
  113. testfailure grep -q -e 'Translation-[^e][^n] ' rootdir/tmp/testwarning.output
  114. checkaptshow
  115. rm -rf rootdir/var/lib/apt/lists
  116. msgtest 'Download of ast_DE as forced language' 'without Index'
  117. testwarning --nomsg aptget update -o Acquire::Languages=ast_DE
  118. testsuccess grep -q -e 'Translation-ast_DE$' rootdir/tmp/testwarning.output
  119. checkaptshow
  120. rm -rf rootdir/var/lib/apt/lists
  121. msgtest 'Download of nothing else in forced language' 'without Index'
  122. testwarning --nomsg aptget update -o Acquire::Languages=ast_DE
  123. testfailure grep -q -e 'Translation-[^a][^s]' rootdir/tmp/testwarning.output
  124. checkaptshow
  125. rm -rf rootdir/var/lib/apt/lists
  126. msgtest 'Download of nothing if none is forced' 'without Index'
  127. testwarning --nomsg aptget update -o Acquire::Languages=none
  128. testfailure grep -q -e 'Translation' rootdir/tmp/testwarning.output
  129. checkaptshow
  130. rm -rf rootdir/var/lib/apt/lists
  131. mkdir -p rootdir/var/lib/apt/lists
  132. touch rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_i18n_Translation-ast_DE
  133. msgtest 'Download of builtin files' 'without Index'
  134. testwarning --nomsg aptget update
  135. testsuccess grep -q -e 'Translation-ast_DE' rootdir/tmp/testwarning.output
  136. checkaptshow
  137. rm -rf rootdir/var/lib/apt/lists
  138. mkdir -p rootdir/var/lib/apt/lists
  139. touch rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_i18n_Translation-ast_DE
  140. msgtest 'Download of nothing (even builtin) if none is forced' 'without Index'
  141. testwarning --nomsg aptget update -o Acquire::Languages=none
  142. testfailure grep -q -e 'Translation' rootdir/tmp/testwarning.output
  143. checkaptshow
  144. rm -rf rootdir/var/lib/apt/lists