test-apt-get-install-deb 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. testsuccess aptget install ./incoming/pkg-as-it-should-be_0_all.deb
  112. testsuccess aptget install ./incoming/pkg-leading-newline_0_all.deb
  113. testsuccess aptget install ./incoming/pkg-trailing-newline_0_all.deb
  114. testempty apt clean
  115. if [ "$(id -u)" = '0' ]; then
  116. # see if permission dropping is checked before usage
  117. chmod 711 ./incoming
  118. testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
  119. testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
  120. chmod 710 ./incoming
  121. testsuccesswithnotice aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
  122. testfailure grep 'is already the newest version' rootdir/tmp/testsuccesswithnotice.output
  123. chmod 700 ./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 711 ./incoming
  127. else
  128. testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
  129. testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
  130. fi
  131. sed -i -e '/^Depends: foo/ d' rootdir/var/lib/dpkg/status
  132. testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb
  133. testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
  134. testsuccess apt purge -y pkg-as-it-should-be
  135. echo "Package: pkg-as-it-should-be
  136. Architecture: all
  137. Version: 0
  138. Installed-Size: 2903
  139. Filename: incoming/pkg-as-it-should-be_0_all.deb
  140. Size: $(stat -c %s incoming/pkg-as-it-should-be_0_all.deb)
  141. SHA256: $(sha256sum incoming/pkg-as-it-should-be_0_all.deb | cut -d' ' -f 1)
  142. " > Packages
  143. testdpkgnotinstalled 'pkg-as-it-should-be'
  144. testnopackage pkg-as-it-should-be
  145. testsuccess apt install --with-source ./Packages pkg-as-it-should-be -s
  146. testsuccess apt install --with-source ./Packages pkg-as-it-should-be --print-uris
  147. testsuccess apt show --with-source ./Packages pkg-as-it-should-be
  148. testequal 'Package: pkg-as-it-should-be' head -n1 rootdir/tmp/testsuccess.output
  149. testsuccess apt install -y --with-source ./Packages pkg-as-it-should-be
  150. testdpkginstalled 'pkg-as-it-should-be'
  151. rm -f ./Packages
  152. echo 'dpkg::install::recursive "true";
  153. dpkg::install::recursive::force "true";
  154. dpkg::install::recursive::minimum "0";' > rootdir/etc/apt/apt.conf.d/lowerminimum.conf
  155. mv ./incoming/pkg-as-it-should-be_0_all.deb ./incoming/pkg-as-it-should-be_0_all.ddeb
  156. testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.ddeb --reinstall
  157. testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
  158. testsuccess apt purge -y pkg-as-it-should-be
  159. testdpkgnotinstalled 'pkg-as-it-should-be'
  160. mv ./incoming/pkg-as-it-should-be_0_all.ddeb ./incoming/pkg-as-it-should-be_0_all.foobar
  161. echo "Package: pkg-as-it-should-be
  162. Architecture: all
  163. Version: 0
  164. Installed-Size: 2903
  165. Filename: incoming/pkg-as-it-should-be_0_all.foobar
  166. Size: $(stat -c %s incoming/pkg-as-it-should-be_0_all.foobar)
  167. SHA256: $(sha256sum incoming/pkg-as-it-should-be_0_all.foobar | cut -d' ' -f 1)
  168. " | gzip > Packages.gz
  169. testsuccess apt install --with-source ./Packages.gz pkg-as-it-should-be -s
  170. testsuccess apt install --with-source ./Packages.gz pkg-as-it-should-be --print-uris
  171. testsuccess apt show --with-source ./Packages.gz pkg-as-it-should-be
  172. testequal 'Package: pkg-as-it-should-be' head -n1 rootdir/tmp/testsuccess.output
  173. testsuccess apt install -y --with-source ./Packages.gz pkg-as-it-should-be
  174. testdpkginstalled 'pkg-as-it-should-be'