3000-throwaway-new 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #! /bin/bash
  2. #
  3. # © 2019 Ivo De Decker <ivodd@debian.org>
  4. # License: GPL-2+
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. set -e
  19. set -u
  20. . ${DAK_ROOT:?}/integration-tests/common
  21. . ${DAK_ROOT:?}/integration-tests/setup
  22. . ${DAK_ROOT:?}/integration-tests/dinstall
  23. dumpdir=$DAKBASE/dumps
  24. mkdir -p $dumpdir
  25. check_dump() {
  26. filename="$1"
  27. match="$2"
  28. expected="$3"
  29. filter="$4"
  30. description="$5"
  31. in="in"
  32. if [ "$expected" = "1" ]
  33. then
  34. in="not in"
  35. fi
  36. if [ -z "$description" ]
  37. then
  38. description="$match"
  39. if [ -n "$filter" ]
  40. then
  41. description="$description with filter $filter"
  42. fi
  43. description="$description $in"
  44. fi
  45. dumpfile="$dumpdir/$filename"
  46. set +e
  47. (
  48. if [ -n "$filter" ]
  49. then
  50. grep -v "$filter" $dumpfile
  51. else
  52. cat $dumpfile
  53. fi
  54. ) | grep "$match" > /dev/null
  55. ret=$?
  56. set -e
  57. if [ "$ret" = "$expected" ]
  58. then
  59. echo "check $description $filename - OK"
  60. else
  61. echo "E: check $description $filename"
  62. exit 1
  63. fi
  64. }
  65. echo "Dinstall::AllowSourceOnlyUploads true;" >> ${DAKBASE}/etc/dak.conf
  66. cat >> ${DAKBASE}/etc/dak.conf << EOF
  67. Dinstall {
  68. ThrowAwayNewBinarySuites {
  69. "unstable";
  70. };
  71. ThrowAwayNewBinaryComponents {
  72. "main";
  73. };
  74. };
  75. Dinstall::AllowSourceOnlyNewSources {
  76. "linux";
  77. };
  78. Dir::BuildinfoArchive "${DAKBASE}/buildinfo/";
  79. EOF
  80. import-fixture-signing-key
  81. setup_empty_archive
  82. setup_unstable
  83. dinstall
  84. make_dumps() {
  85. PREFIX=$1
  86. pg_dump -a --inserts -n audit > ${PREFIX}_pgdump_audit
  87. pg_dump -a --inserts -N audit > ${PREFIX}_pgdump_noaudit
  88. (cd $DAKBASE; find | sort > ${PREFIX}_files)
  89. }
  90. make_dumps $dumpdir/before-upload
  91. (
  92. packages=$(fixture-package-dir)
  93. upload_changes ${packages:?}/pkgnew_0.1-1_amd64.changes
  94. upload_changes ${packages:?}/nonfree-package_0.1-1_amd64.changes
  95. upload_changes ${packages:?}/main-contrib-with-debug_0.1-1_amd64.changes
  96. upload_changes ${packages:?}/linux_42.0-1_source.changes
  97. process_uploads
  98. )
  99. make_dumps $dumpdir/package-in-new
  100. # upload different types of NEW package
  101. # main - with binaries
  102. echo a | dak process-new pkgnew_0.1-1_amd64.changes
  103. # non-free - with binaries
  104. echo a | dak process-new nonfree-package_0.1-1_amd64.changes
  105. # source in main, has binaries in main and contrib
  106. echo a | dak process-new main-contrib-with-debug_0.1-1_amd64.changes
  107. # source-only NEW upload (whitelisted souce)
  108. echo a | dak process-new linux_42.0-1_source.changes
  109. do_new
  110. check_all_suites package-accepted-from-new
  111. make_dumps $dumpdir/package-accepted-from-new
  112. dinstall
  113. make_dumps $dumpdir/package-accepted-from-new-afterdinstall
  114. upload_changes ${packages:?}/pkgnew_0.1-1_all-buildd.changes
  115. process_uploads
  116. upload_changes ${packages:?}/pkgnew_0.1-1_amd64-buildd.changes
  117. process_uploads
  118. make_dumps $dumpdir/packages-binary-accepted
  119. dinstall
  120. check_all_suites after-dinstall
  121. make_dumps $dumpdir/afterdinstall
  122. for list in package-accepted-from-new package-accepted-from-new-afterdinstall
  123. do
  124. echo "checking files in $list"
  125. for file in pkg-any1 pkg-all1
  126. do
  127. dumpf="${list}_files"
  128. # package should be in morgue
  129. check_dump "$dumpf" "/morgue/.*/$file" 0 "" "$file in morgue in"
  130. # package should not be outside of morgue
  131. check_dump "$dumpf" "$file" 1 "/morgue/" "$file not outside morgue in"
  132. done
  133. echo ""
  134. done
  135. echo checking buildinfo files
  136. dumpf="afterdinstall_files"
  137. for bi in nonfree-package_0.1-1_amd64.buildinfo pkgnew_0.1-1_amd64.buildinfo pkgnew_0.1-1_amd64-buildd.buildinfo
  138. do
  139. check_dump "$dumpf" "/buildinfo/.*$bi" 0 "" "$bi in buildinfo dir in"
  140. done
  141. echo ""
  142. echo checking database dumps
  143. for file in pkg-all1_0.1-1_all.deb pkg-any1_0.1-1_amd64.deb
  144. do
  145. filename=${packages}/$file
  146. sha256sum=`sha256sum $filename | awk '{ print $1 }'`
  147. for list in package-in-new packages-binary-accepted
  148. do
  149. dumpf="${list}_pgdump_noaudit"
  150. for val in $file $sha256sum
  151. do
  152. check_dump "$dumpf" "$val" 0 "" "$val in database dump"
  153. done
  154. done
  155. for list in package-accepted-from-new
  156. do
  157. dumpf="${list}_pgdump_noaudit"
  158. for val in $file $sha256sum
  159. do
  160. check_dump "$dumpf" "$val" 1 "" "$val not in database dump"
  161. done
  162. done
  163. done
  164. echo "done"