test-apt-source-and-build-dep 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'i386'
  7. # we need to insert a package into "unstable" so that a Release file is
  8. # create for the test
  9. insertpackage 'wheezy' 'build-essential' 'all' '1.0'
  10. # a "normal" package with source and binary
  11. insertpackage 'unstable' 'foo' 'all' '2.0'
  12. insertsource 'unstable' 'foo' 'all' '2.0'
  13. # binary packages with Source-field
  14. insertpackage 'unstable,testing' 'bin' 'i386' '3-2+b1' 'Source: bin (3-2)'
  15. insertsource 'unstable,testing' 'bin' 'any' '3-2'
  16. insertpackage 'stable' 'bin' 'i386' '2-2+b1' 'Source: bin-backport (2-2)'
  17. insertsource 'stable' 'bin-backport' 'any' '2-2'
  18. # its possible to have multiple src versions in the sources file, ensure
  19. # to pick the correct one in this case (bts #731853)
  20. insertsource 'stable' 'foo' 'all' '1.5'
  21. insertsource 'stable' 'foo' 'all' '0.5'
  22. insertpackage 'stable' 'foo' 'all' '1.0'
  23. insertsource 'stable' 'foo' 'all' '1.0'
  24. # this packages exists only as sources, add two versions to ensure that
  25. # apt will pick the higher version number (bts #731853)
  26. insertsource 'wheezy' 'foo' 'all' '0.0.1'
  27. insertsource 'wheezy' 'foo' 'all' '0.1'
  28. # the order of these versions is chosen to ensure that
  29. # * apt will pick the one in the correct release, despite a higher version coming later and
  30. # * apt will pick the highest version in a release, despite a lower version coming later.
  31. # (bts #746412)
  32. insertsource 'stable' 'baz' 'all' '1.0'
  33. insertsource 'unstable' 'baz' 'all' '2.0'
  34. insertsource 'unstable' 'baz' 'all' '1.5'
  35. # ensure we really have the situation we wanted (first 2.0 is foo above)
  36. testequal 'Version: 2.0
  37. Version: 3-2
  38. Version: 2.0
  39. Version: 1.5' grep '^Version:' aptarchive/dists/unstable/main/source/Sources
  40. insertsource 'stable' 'bar' 'any' '1.1' 'Vcs-Browser: https://anonscm.debian.org/cgit/bar/bar.git
  41. Vcs-Git: git://anonscm.debian.org/bar/bar.git -b debian/experimental'
  42. setupaptarchive
  43. APTARCHIVE=$(readlink -f ./aptarchive)
  44. # normal operation gets highest version number
  45. HEADER='Reading package lists...'
  46. DOWNLOAD1="Need to get 0 B/25 B of source archives.
  47. 'file://${APTARCHIVE}/foo_1.0.dsc' foo_1.0.dsc 11 SHA256:ed7c25c832596339bee13e4e7c45cf49f869b60d2bf57252f18191d75866c2a7
  48. 'file://${APTARCHIVE}/foo_1.0.tar.gz' foo_1.0.tar.gz 14 SHA256:f3da8c6ebc62c8ef2dae439a498dddcdacc1a07f45ff67ad12f44b6e2353c239"
  49. DOWNLOAD2="Need to get 0 B/25 B of source archives.
  50. 'file://${APTARCHIVE}/foo_2.0.dsc' foo_2.0.dsc 11 SHA256:0fcb803ffbeef26db884625aaf06e75f3eda5c994634980e7c20fd37ed1fc104
  51. 'file://${APTARCHIVE}/foo_2.0.tar.gz' foo_2.0.tar.gz 14 SHA256:ca9b0b828ca22372502af2b80f61f0bd9063910ece9fc34eeaf9d9e31aa8195a"
  52. DOWNLOAD3="Need to get 0 B/25 B of source archives.
  53. 'file://${APTARCHIVE}/baz_1.0.dsc' baz_1.0.dsc 11 SHA256:322245f56092b466801dda62d79c8687bba9724af6d16d450d655d29e41d3d7b
  54. 'file://${APTARCHIVE}/baz_1.0.tar.gz' baz_1.0.tar.gz 14 SHA256:0870bc73164ff5ba1f52153fdcb48e140137f9c7c122d57592cea136a57f73c0"
  55. DOWNLOAD4="Need to get 0 B/25 B of source archives.
  56. 'file://${APTARCHIVE}/baz_2.0.dsc' baz_2.0.dsc 11 SHA256:47d062d29070b3f592d1c8aed8c1e7913804bbb67ca1d64877c8219dac5e0420
  57. 'file://${APTARCHIVE}/baz_2.0.tar.gz' baz_2.0.tar.gz 14 SHA256:11c1b202c94a64ab6433d9f0ed5515fce1dc7b20e6bcf51cec9ef8b9455f5a41"
  58. testsuccessequal "$HEADER
  59. $DOWNLOAD2" apt source -q --print-uris foo
  60. testsuccessequal "$HEADER
  61. $DOWNLOAD2" apt source -q --print-uris foo foo
  62. getbuilddep() {
  63. echo 'Reading package lists...'
  64. if [ -n "$2" ]; then
  65. echo "$2"
  66. fi
  67. echo "${1} has no build depends.
  68. Reading package lists...
  69. Building dependency tree...
  70. The following NEW packages will be installed:
  71. build-essential
  72. 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  73. Inst build-essential (1.0 wheezy [all])
  74. Conf build-essential (1.0 wheezy [all])"
  75. }
  76. testsuccessequal "$(getbuilddep 'foo')" apt build-dep foo -s
  77. # select by release: suite
  78. testsuccessequal "$HEADER
  79. Selected version '1.0' (stable) for foo
  80. $DOWNLOAD1" apt source -q --print-uris foo/stable
  81. testsuccessequal "$(getbuilddep 'foo' "Selected version '1.0' (stable) for foo")" apt build-dep foo/stable -s
  82. testsuccessequal "$HEADER
  83. Selected version '2.0' (unstable) for foo
  84. $DOWNLOAD2" apt source -q --print-uris foo/unstable
  85. testsuccessequal "$(getbuilddep 'foo' "Selected version '2.0' (unstable) for foo")" apt build-dep foo/unstable -s
  86. testsuccessequal "$HEADER
  87. Selected version '1.0' (stable) for foo
  88. $DOWNLOAD1" apt source -q --print-uris foo -t stable
  89. testsuccessequal "$(getbuilddep 'foo' "Selected version '1.0' (stable) for foo")" apt build-dep foo -t stable -s
  90. testsuccessequal "$HEADER
  91. Selected version '2.0' (unstable) for foo
  92. $DOWNLOAD2" apt source -q --print-uris foo -t unstable
  93. testsuccessequal "$(getbuilddep 'foo' "Selected version '2.0' (unstable) for foo")" apt build-dep foo -t unstable -s
  94. testsuccessequal "$HEADER
  95. Selected version '1.0' (stable) for baz
  96. $DOWNLOAD3" apt source -q --print-uris baz -t stable
  97. testsuccessequal "$(getbuilddep 'baz' "Selected version '1.0' (stable) for baz")" apt build-dep baz -t stable -s
  98. # select by release: codename
  99. testsuccessequal "$HEADER
  100. Selected version '2.0' (sid) for foo
  101. $DOWNLOAD2" apt source -q --print-uris foo/sid
  102. testsuccessequal "$(getbuilddep 'foo' "Selected version '2.0' (sid) for foo")" apt build-dep foo/sid -s
  103. testsuccessequal "$HEADER
  104. Selected version '2.0' (sid) for foo
  105. $DOWNLOAD2" apt source -q --print-uris foo -t sid
  106. testsuccessequal "$(getbuilddep 'foo' "Selected version '2.0' (sid) for foo")" apt build-dep foo -t sid -s
  107. testsuccessequal "$HEADER
  108. Selected version '2.0' (sid) for baz
  109. $DOWNLOAD4" apt source -q --print-uris baz -t sid
  110. testsuccessequal "$(getbuilddep 'baz' "Selected version '2.0' (sid) for baz")" apt build-dep baz -t sid -s
  111. # select by version
  112. testsuccessequal "$HEADER
  113. $DOWNLOAD1" apt source -q --print-uris foo=1.0
  114. testsuccessequal "$(getbuilddep 'foo')" apt build-dep foo=1.0 -s
  115. # select by release with no binary package (Bug#731102) but ensure to get
  116. # highest version
  117. DOWNLOAD01="Need to get 0 B/25 B of source archives.
  118. 'file://${APTARCHIVE}/foo_0.1.dsc' foo_0.1.dsc 11 SHA256:72af24b0290fe1d13a3e25fddd2633e43c87ff79d249bc850009e47bcce73565
  119. 'file://${APTARCHIVE}/foo_0.1.tar.gz' foo_0.1.tar.gz 14 SHA256:ec748ad88a71f98bfdc012e1a7632377d05fe3ebbf9c0922e0691fe4d79c0585"
  120. testsuccessequal "$HEADER
  121. Selected version '0.1' (wheezy) for foo
  122. $DOWNLOAD01" apt source -q --print-uris foo/wheezy
  123. testsuccessequal "$(getbuilddep 'foo' "Selected version '0.1' (wheezy) for foo")" apt build-dep foo/wheezy -s
  124. # unavailable one
  125. testfailureequal "$HEADER
  126. E: Can not find version '9.9-not-there' of package 'foo'
  127. E: Unable to find a source package for foo" apt source -q --print-uris foo=9.9-not-there
  128. testfailureequal "Reading package lists...
  129. E: Can not find version '9.9-not-there' of package 'foo'
  130. E: Unable to find a source package for foo=9.9-not-there" apt build-dep -s foo=9.9-not-there
  131. # version and release
  132. DOWNLOAD001="Need to get 0 B/29 B of source archives.
  133. 'file://${APTARCHIVE}/foo_0.0.1.dsc' foo_0.0.1.dsc 13 SHA256:649dfe03bbb70cebdfe7c6bf9036f9f2472510b8f52e823bdf5ade362ebaa76f
  134. 'file://${APTARCHIVE}/foo_0.0.1.tar.gz' foo_0.0.1.tar.gz 16 SHA256:ab7ba789d178362ecc808e49705e2338988a7f5b9410ec11a6c9555c017de907"
  135. testsuccessequal "$HEADER
  136. $DOWNLOAD001" apt source -q --print-uris -t unstable foo=0.0.1
  137. testsuccessequal "$(getbuilddep 'foo')" apt build-dep foo=0.0.1 -s
  138. testsuccessequal "$HEADER
  139. Need to get 0 B/25 B of source archives.
  140. Fetch source foo" apt source -q -s foo
  141. testsuccessequal "$(getbuilddep 'foo')" apt build-dep foo -s
  142. testfailureequal 'E: Must specify at least one package to fetch source for' apt source
  143. testfailureequal 'E: Must specify at least one package to check builddeps for' apt build-dep
  144. testsuccessequal "Reading package lists...
  145. NOTICE: 'bar' packaging is maintained in the 'Git' version control system at:
  146. git://anonscm.debian.org/bar/bar.git -b debian/experimental
  147. Please use:
  148. git clone git://anonscm.debian.org/bar/bar.git -b debian/experimental
  149. to retrieve the latest (possibly unreleased) updates to the package.
  150. Need to get 0 B/25 B of source archives.
  151. Fetch source bar" apt source bar -s
  152. testsuccessequal "$(getbuilddep 'bar')" apt build-dep bar -s
  153. testsuccessequal "$HEADER
  154. Need to get 0 B/25 B of source archives.
  155. Fetch source bin" apt source bin -s -q
  156. testsuccessequal "$(getbuilddep 'bin')" apt build-dep bin -s
  157. testsuccessequal "$HEADER
  158. Selected version '3-2' (unstable) for bin
  159. Need to get 0 B/25 B of source archives.
  160. Fetch source bin" apt source bin/unstable -s -q
  161. testsuccessequal "$(getbuilddep 'bin' "Selected version '3-2' (unstable) for bin")" apt build-dep bin/unstable -s
  162. testsuccessequal "$HEADER
  163. Picking 'bin-backport' as source package instead of 'bin'
  164. Selected version '2-2' (stable) for bin-backport
  165. Need to get 0 B/43 B of source archives.
  166. Fetch source bin-backport" apt source bin/stable -s -q
  167. testsuccessequal "$(getbuilddep 'bin-backport' "Picking 'bin-backport' as source package instead of 'bin'
  168. Selected version '2-2' (stable) for bin-backport")" apt build-dep bin/stable -s