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.
 
 
 
 
 
 

176 lines
12 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture 'i386'
  7. LISTS='rootdir/etc/apt/sources.list.d/test.list'
  8. ABSLISTS="$(readlink -f $LISTS)"
  9. SOURCES='rootdir/etc/apt/sources.list.d/test.sources'
  10. BASE='# some comment
  11. # that contains a : as well
  12. #Types: meep
  13. Types: deb
  14. URIs: http://ftp.debian.org/debian
  15. Suites: stable
  16. Components: main
  17. Description: summay
  18. and the long part'
  19. msgcleantest() {
  20. rm -f $LISTS $SOURCES
  21. msgtest "$@"
  22. }
  23. msgcleantest 'Test sources.list' 'old style'
  24. echo "deb http://ftp.debian.org/debian stable main" > $LISTS
  25. testsuccessequal --nomsg "'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0
  26. 'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.xz' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0
  27. 'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.xz' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris
  28. msgcleantest 'Test sources.list' 'old style with tabs'
  29. echo "deb http://ftp.debian.org/debian stable main" > $LISTS
  30. testsuccessequal --nomsg "'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0
  31. 'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.xz' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0
  32. 'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.xz' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris
  33. msgcleantest 'Test sources.list' 'old style with forgotten end for options'
  34. echo "deb [trusted=yes arch+=armel,powerpc http://ftp.debian.org/debian stable main" > $LISTS
  35. testfailureequal "E: Malformed entry 1 in list file $ABSLISTS ([option] not assignment)
  36. E: The list of sources could not be read." aptget update --print-uris
  37. msgcleantest 'Test sources.list' 'old style with stray ] instead of options'
  38. echo "deb ] http://ftp.debian.org/debian stable main" > $LISTS
  39. testfailureequal "E: Malformed entry 1 in list file $ABSLISTS (URI parse)
  40. E: The list of sources could not be read." aptget update --print-uris
  41. msgcleantest 'Test sources.list' 'old style options no key'
  42. echo "deb [=test] http://ftp.debian.org/debian stable main" > $LISTS
  43. testfailureequal "E: Malformed entry 1 in list file $ABSLISTS ([option] no key)
  44. E: The list of sources could not be read." aptget update --print-uris
  45. msgcleantest 'Test sources.list' 'old style options no value'
  46. echo "deb [test=] http://ftp.debian.org/debian stable main" > $LISTS
  47. testfailureequal "E: Malformed entry 1 in list file $ABSLISTS ([option] no value)
  48. E: The list of sources could not be read." aptget update --print-uris
  49. msgcleantest 'Test sources.list' 'old style with options'
  50. echo "deb [trusted=yes arch+=armel,powerpc] http://ftp.debian.org/debian stable main" > $LISTS
  51. testsuccessequal --nomsg "'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0
  52. 'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.xz' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0
  53. 'http://ftp.debian.org/debian/dists/stable/main/binary-armel/Packages.xz' ftp.debian.org_debian_dists_stable_main_binary-armel_Packages 0
  54. 'http://ftp.debian.org/debian/dists/stable/main/binary-powerpc/Packages.xz' ftp.debian.org_debian_dists_stable_main_binary-powerpc_Packages 0
  55. 'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.xz' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris
  56. msgcleantest 'Test sources.list' 'old style with comments'
  57. echo "deb http://ftp.debian.org/debian stable main # non-free" > $LISTS
  58. testsuccessequal --nomsg "'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0
  59. 'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.xz' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0
  60. 'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.xz' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris
  61. msgcleantest 'Test sources.list' 'old style with option comments'
  62. echo "deb [trusted=yes#yeahreally] http://ftp.debian.org/debian stable main # non-free" > $LISTS
  63. testsuccessequal --nomsg "'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0
  64. 'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.xz' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0
  65. 'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.xz' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris
  66. msgcleantest 'Test sources.list' 'simple deb822'
  67. echo "$BASE" > $SOURCES
  68. testsuccessequal --nomsg "'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0
  69. 'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.xz' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0
  70. 'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.xz' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris
  71. msgcleantest 'Test deb822 with' 'two entries'
  72. # Two entries
  73. echo "$BASE" > $SOURCES
  74. echo "" >> $SOURCES
  75. echo "$BASE" | sed s/stable/unstable/ >> $SOURCES
  76. testsuccessequal --nomsg "'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0
  77. 'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.xz' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0
  78. 'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.xz' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0
  79. 'http://ftp.debian.org/debian/dists/unstable/InRelease' ftp.debian.org_debian_dists_unstable_InRelease 0
  80. 'http://ftp.debian.org/debian/dists/unstable/main/binary-i386/Packages.xz' ftp.debian.org_debian_dists_unstable_main_binary-i386_Packages 0
  81. 'http://ftp.debian.org/debian/dists/unstable/main/i18n/Translation-en.xz' ftp.debian.org_debian_dists_unstable_main_i18n_Translation-en 0 " aptget update --print-uris
  82. # two suite entries
  83. msgcleantest 'Test deb822 with' 'two Suite entries'
  84. echo "$BASE" | sed -e "s/stable/stable unstable/" > $SOURCES
  85. testsuccessequal --nomsg "'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0
  86. 'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.xz' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0
  87. 'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.xz' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0
  88. 'http://ftp.debian.org/debian/dists/unstable/InRelease' ftp.debian.org_debian_dists_unstable_InRelease 0
  89. 'http://ftp.debian.org/debian/dists/unstable/main/binary-i386/Packages.xz' ftp.debian.org_debian_dists_unstable_main_binary-i386_Packages 0
  90. 'http://ftp.debian.org/debian/dists/unstable/main/i18n/Translation-en.xz' ftp.debian.org_debian_dists_unstable_main_i18n_Translation-en 0 " aptget update --print-uris
  91. msgcleantest 'Test deb822' 'architecture option'
  92. echo "$BASE" > $SOURCES
  93. echo "Architectures: amd64 armel" >> $SOURCES
  94. testsuccessequal --nomsg "'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0
  95. 'http://ftp.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz' ftp.debian.org_debian_dists_stable_main_binary-amd64_Packages 0
  96. 'http://ftp.debian.org/debian/dists/stable/main/binary-armel/Packages.xz' ftp.debian.org_debian_dists_stable_main_binary-armel_Packages 0
  97. 'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.xz' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris
  98. msgcleantest 'Test old-style' 'suite arch variable'
  99. echo 'deb http://ftp.tlh.debian.org/universe unstable/binary-$(ARCH)/' > $LISTS
  100. testsuccessequal --nomsg "'http://ftp.tlh.debian.org/universe/unstable/binary-i386/InRelease' ftp.tlh.debian.org_universe_unstable_binary-i386_InRelease 0
  101. 'http://ftp.tlh.debian.org/universe/unstable/binary-i386/Packages.xz' ftp.tlh.debian.org_universe_unstable_binary-i386_Packages 0
  102. 'http://ftp.tlh.debian.org/universe/unstable/binary-i386/en.xz' ftp.tlh.debian.org_universe_unstable_binary-i386_en 0 " aptget update --print-uris
  103. msgcleantest 'Test deb822' 'suite arch variable'
  104. echo 'Types: deb
  105. URIs: http://ftp.tlh.debian.org/universe
  106. Suites: stable/binary-$(ARCH)/' > $SOURCES
  107. testsuccessequal --nomsg "'http://ftp.tlh.debian.org/universe/stable/binary-i386/InRelease' ftp.tlh.debian.org_universe_stable_binary-i386_InRelease 0
  108. 'http://ftp.tlh.debian.org/universe/stable/binary-i386/Packages.xz' ftp.tlh.debian.org_universe_stable_binary-i386_Packages 0
  109. 'http://ftp.tlh.debian.org/universe/stable/binary-i386/en.xz' ftp.tlh.debian.org_universe_stable_binary-i386_en 0 " aptget update --print-uris
  110. msgcleantest 'Test old-style sources.list file which has' 'malformed dist'
  111. echo "deb http://ftp.debian.org" > $LISTS
  112. testfailureequal --nomsg "E: Malformed entry 1 in list file $TMPWORKINGDIRECTORY/$LISTS (Suite)
  113. E: The list of sources could not be read." aptget update --print-uris
  114. msgcleantest 'Test deb822 sources.list file which has' 'malformed URI'
  115. echo "Types: deb
  116. Suites: stable
  117. " > $SOURCES
  118. testfailureequal --nomsg "E: Malformed entry 1 in sources file $TMPWORKINGDIRECTORY/$SOURCES (URI)
  119. E: The list of sources could not be read." aptget update --print-uris
  120. # with Enabled: false
  121. echo "$BASE" > $SOURCES
  122. echo "Enabled: no" >> $SOURCES
  123. testempty aptget update --print-uris
  124. # multiple URIs
  125. msgcleantest 'Test deb822 sources.list file which has' 'Multiple URIs work'
  126. echo "$BASE" | sed -e 's#http://ftp.debian.org/debian#http://ftp.debian.org/debian http://ftp.de.debian.org/debian#' > $SOURCES
  127. testsuccessequal --nomsg "'http://ftp.de.debian.org/debian/dists/stable/InRelease' ftp.de.debian.org_debian_dists_stable_InRelease 0
  128. 'http://ftp.de.debian.org/debian/dists/stable/main/binary-i386/Packages.xz' ftp.de.debian.org_debian_dists_stable_main_binary-i386_Packages 0
  129. 'http://ftp.de.debian.org/debian/dists/stable/main/i18n/Translation-en.xz' ftp.de.debian.org_debian_dists_stable_main_i18n_Translation-en 0
  130. 'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0
  131. 'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.xz' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0
  132. 'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.xz' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris
  133. # multiple Type in one field
  134. msgcleantest 'Test deb822 sources.list file which has' 'Multiple Types work'
  135. echo "$BASE" | sed -e 's#Types: deb#Types: deb deb-src#' > $SOURCES
  136. testsuccessequal --nomsg "'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0
  137. 'http://ftp.debian.org/debian/dists/stable/main/source/Sources.xz' ftp.debian.org_debian_dists_stable_main_source_Sources 0
  138. 'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.xz' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0
  139. 'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.xz' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris
  140. # a Suite
  141. msgcleantest 'Test deb822 sources.list file which has' 'an exact path and no sections'
  142. cat > $SOURCES <<EOF
  143. Types: deb
  144. URIs: http://emacs.naquadah.org
  145. Suites: stable/
  146. EOF
  147. testsuccessequal --nomsg "'http://emacs.naquadah.org/stable/InRelease' emacs.naquadah.org_stable_InRelease 0
  148. 'http://emacs.naquadah.org/stable/Packages.xz' emacs.naquadah.org_stable_Packages 0
  149. 'http://emacs.naquadah.org/stable/en.xz' emacs.naquadah.org_stable_en 0 " aptget update --print-uris