test-apt-get-install-deb 8.0 KB

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