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.
 
 
 
 
 
 

246 lines
9.8 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64' 'i386'
  7. # regression test for #754904
  8. cat > foo.rpm <<EOF
  9. I'm not a deb, I'm a teapot.
  10. EOF
  11. for exe in apt aptget; do
  12. for cmd in install remove purge upgrade full-upgrade; do
  13. testfailureequal 'E: Unsupported file /dev/null given on commandline' $exe $cmd -qq /dev/null
  14. testfailureequal 'E: Unsupported file ./foo.rpm given on commandline' $exe $cmd -qq ./foo.rpm
  15. done
  16. done
  17. # and ensure we fail for invalid debs
  18. mv foo.rpm foo.deb
  19. for exe in apt aptget; do
  20. for cmd in install remove purge upgrade full-upgrade; do
  21. testfailuremsg "E: Sub-process Popen returned an error code (2)
  22. E: Encountered a section with no Package: header
  23. E: Problem with MergeList ${TMPWORKINGDIRECTORY}/foo.deb
  24. E: The package lists or status file could not be parsed or opened." $exe $cmd ./foo.deb
  25. done
  26. done
  27. buildsimplenativepackage 'foo' 'i386,amd64' '1.0'
  28. testfailureequal "Reading package lists...
  29. Building dependency tree...
  30. Note, selecting 'foo:i386' instead of './incoming/foo_1.0_i386.deb'
  31. Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
  32. Some packages could not be installed. This may mean that you have
  33. requested an impossible situation or if you are using the unstable
  34. distribution that some required packages have not yet been created
  35. or been moved out of Incoming.
  36. The following information may help to resolve the situation:
  37. The following packages have unmet dependencies:
  38. foo:i386 : Conflicts: foo but 1.0 is to be installed
  39. foo : Conflicts: foo:i386 but 1.0 is to be installed
  40. E: Unable to correct problems, you have held broken packages." aptget install ./incoming/foo_1.0_i386.deb ./incoming/foo_1.0_amd64.deb -s
  41. testsuccess apt show foo --with-source ./incoming/foo_1.0_amd64.deb
  42. testequal 'Package: foo
  43. Version: 1.0' grep -e '^Package:' -e '^Version:' -e '^Architecture:' rootdir/tmp/testsuccess.output
  44. testsuccess apt show ./incoming/foo_1.0_amd64.deb
  45. testequal 'Package: foo
  46. Version: 1.0' grep -e '^Package:' -e '^Version:' -e '^Architecture:' rootdir/tmp/testsuccess.output
  47. testsuccess apt show foo:i386 ./incoming/foo_1.0_amd64.deb --with-source ./incoming/foo_1.0_i386.deb
  48. testequal 'Package: foo:i386
  49. Version: 1.0
  50. Package: foo
  51. Version: 1.0' grep -e '^Package:' -e '^Version:' -e '^Architecture:' rootdir/tmp/testsuccess.output
  52. testsuccess aptcache show foo --with-source ./incoming/foo_1.0_amd64.deb
  53. testequal 'Package: foo
  54. Version: 1.0
  55. Architecture: amd64' grep -e '^Package:' -e '^Version:' -e '^Architecture:' rootdir/tmp/testsuccess.output
  56. testsuccess aptcache show ./incoming/foo_1.0_amd64.deb
  57. testequal 'Package: foo
  58. Version: 1.0
  59. Architecture: amd64' grep -e '^Package:' -e '^Version:' -e '^Architecture:' rootdir/tmp/testsuccess.output
  60. testsuccess aptcache show foo:i386 ./incoming/foo_1.0_amd64.deb --with-source ./incoming/foo_1.0_i386.deb
  61. testequal 'Package: foo
  62. Version: 1.0
  63. Architecture: i386
  64. Package: foo
  65. Version: 1.0
  66. Architecture: amd64' grep -e '^Package:' -e '^Version:' -e '^Architecture:' rootdir/tmp/testsuccess.output
  67. testsuccessequal 'Sorting...
  68. Full Text Search...
  69. foo/local-deb 1.0 amd64
  70. an autogenerated dummy foo=1.0/unstable
  71. ' apt search foo --with-source ./incoming/foo_1.0_amd64.deb
  72. testsuccessequal 'foo - an autogenerated dummy foo=1.0/unstable' aptcache search foo --with-source ./incoming/foo_1.0_amd64.deb
  73. testdpkgnotinstalled 'foo' 'foo:i386'
  74. testsuccess aptget install ./incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1
  75. testdpkginstalled 'foo:i386'
  76. testfailure aptget install incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1
  77. cd downloaded
  78. testsuccess aptget install "$(readlink -f ../incoming/foo_1.0_i386.deb)" -o Debug::pkgCacheGen=1 -y --reinstall
  79. testfailure grep 'is already the newest version' ../rootdir/tmp/testsuccess.output
  80. testsuccess aptget install ../incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1 -y --reinstall
  81. testfailure grep 'is already the newest version' ../rootdir/tmp/testsuccess.output
  82. cd ..
  83. testsuccessequal "Reading package lists...
  84. Building dependency tree...
  85. Reading state information...
  86. Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
  87. The following packages will be REMOVED:
  88. foo:i386
  89. The following NEW packages will be installed:
  90. foo
  91. 0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
  92. Remv foo:i386 [1.0]
  93. Inst foo (1.0 local-deb [amd64])
  94. Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s
  95. testsuccessequal 'Reading package lists...
  96. Building dependency tree...
  97. Reading state information...
  98. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' aptget install --with-source ./incoming/foo_1.0_amd64.deb -s
  99. testsuccessequal 'Reading package lists...
  100. Building dependency tree...
  101. Reading state information...
  102. The following packages will be REMOVED:
  103. foo:i386
  104. The following NEW packages will be installed:
  105. foo
  106. 0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
  107. Remv foo:i386 [1.0]
  108. Inst foo (1.0 local-deb [amd64])
  109. Conf foo (1.0 local-deb [amd64])' aptget install --with-source ./incoming/foo_1.0_amd64.deb foo -s
  110. # Check that installing the local deb works if it is not the candidate
  111. echo "Package: foo
  112. Pin: version 1.0
  113. Pin-Priority: -1" > rootdir/etc/apt/preferences
  114. testsuccessequal "Reading package lists...
  115. Building dependency tree...
  116. Reading state information...
  117. Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
  118. The following packages will be REMOVED:
  119. foo:i386
  120. The following NEW packages will be installed:
  121. foo
  122. 0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
  123. Remv foo:i386 [1.0]
  124. Inst foo (1.0 local-deb [amd64])
  125. Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s
  126. createpkg() {
  127. local PKG="pkg-$1"
  128. mkdir -p ./incoming/$PKG/DEBIAN
  129. if [ -n "$2" ]; then
  130. echo -n "$2" >> ./incoming/$PKG/DEBIAN/control
  131. fi
  132. echo "Package: $PKG
  133. Version: 0
  134. Priority: extra
  135. Maintainer: No Body <no@example.org>
  136. Architecture: all
  137. Depends: foo:i386
  138. Description: test package" >> ./incoming/$PKG/DEBIAN/control
  139. if [ -n "$3" ]; then
  140. echo -n "$3" >> ./incoming/$PKG/DEBIAN/control
  141. fi
  142. testsuccess dpkg-deb --build ./incoming/$PKG/ ./incoming
  143. #dpkg-deb -I ./incoming/${PKG}_0_all.deb control
  144. }
  145. createpkg 'as-it-should-be'
  146. createpkg 'leading-newline' '
  147. '
  148. createpkg 'trailing-newline' '' '
  149. '
  150. createpkg 'double-trailing-newline' '' '
  151. '
  152. echo 'Package: /pkg-/
  153. Pin: release a=experimental
  154. Pin-Priority: 501' > rootdir/etc/apt/preferences.d/pinit
  155. testsuccess aptget install ./incoming/pkg-as-it-should-be_0_all.deb
  156. testsuccess aptget install "$(readlink -f ./incoming/pkg-leading-newline_0_all.deb)"
  157. testsuccess aptget install ./incoming/pkg-trailing-newline_0_all.deb
  158. testsuccess aptget install ./incoming/pkg-double-trailing-newline_0_all.deb
  159. testempty apt clean
  160. if [ "$(id -u)" = '0' ]; then
  161. # see if permission dropping is checked before usage
  162. chmod 711 ./incoming
  163. testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
  164. testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
  165. chmod 710 ./incoming
  166. testsuccesswithnotice aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
  167. testfailure grep 'is already the newest version' rootdir/tmp/testsuccesswithnotice.output
  168. chmod 700 ./incoming
  169. testsuccesswithnotice aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
  170. testfailure grep 'is already the newest version' rootdir/tmp/testsuccesswithnotice.output
  171. chmod 711 ./incoming
  172. else
  173. testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
  174. testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
  175. fi
  176. sed -i -e '/^Depends: foo/ d' rootdir/var/lib/dpkg/status
  177. testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb
  178. testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
  179. testsuccess apt purge -y pkg-as-it-should-be
  180. echo "Package: pkg-as-it-should-be
  181. Architecture: all
  182. Version: 0
  183. Installed-Size: 2903
  184. Filename: incoming/pkg-as-it-should-be_0_all.deb
  185. Size: $(stat -c %s incoming/pkg-as-it-should-be_0_all.deb)
  186. SHA256: $(sha256sum incoming/pkg-as-it-should-be_0_all.deb | cut -d' ' -f 1)
  187. " > Packages
  188. testdpkgnotinstalled 'pkg-as-it-should-be'
  189. testnopackage pkg-as-it-should-be
  190. testsuccess apt install --with-source ./Packages pkg-as-it-should-be -s
  191. testsuccess apt install --with-source ./Packages pkg-as-it-should-be --print-uris
  192. testsuccess apt show --with-source ./Packages pkg-as-it-should-be
  193. testequal 'Package: pkg-as-it-should-be' head -n1 rootdir/tmp/testsuccess.output
  194. testsuccess apt install -y --with-source ./Packages pkg-as-it-should-be
  195. testdpkginstalled 'pkg-as-it-should-be'
  196. rm -f ./Packages
  197. echo 'dpkg::install::recursive "true";
  198. dpkg::install::recursive::force "true";
  199. dpkg::install::recursive::minimum "0";' > rootdir/etc/apt/apt.conf.d/lowerminimum.conf
  200. mv ./incoming/pkg-as-it-should-be_0_all.deb ./incoming/pkg-as-it-should-be_0_all.ddeb
  201. testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.ddeb --reinstall
  202. testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
  203. testsuccess apt purge -y pkg-as-it-should-be
  204. testdpkgnotinstalled 'pkg-as-it-should-be'
  205. mv ./incoming/pkg-as-it-should-be_0_all.ddeb ./incoming/pkg-as-it-should-be_0_all.foobar
  206. echo "Package: pkg-as-it-should-be
  207. Architecture: all
  208. Version: 0
  209. Installed-Size: 2903
  210. Filename: incoming/pkg-as-it-should-be_0_all.foobar
  211. Size: $(stat -c %s incoming/pkg-as-it-should-be_0_all.foobar)
  212. SHA256: $(sha256sum incoming/pkg-as-it-should-be_0_all.foobar | cut -d' ' -f 1)
  213. " | gzip > Packages.gz
  214. testsuccess apt install --with-source ./Packages.gz pkg-as-it-should-be -s
  215. testsuccess apt install --with-source ./Packages.gz pkg-as-it-should-be --print-uris
  216. testsuccess apt show --with-source ./Packages.gz pkg-as-it-should-be
  217. testequal 'Package: pkg-as-it-should-be' head -n1 rootdir/tmp/testsuccess.output
  218. testsuccess apt install -y --with-source ./Packages.gz pkg-as-it-should-be
  219. testdpkginstalled 'pkg-as-it-should-be'