test-apt-get-install-deb 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. # Check that installing the local deb works if it is not the candidate
  57. echo "Package: foo
  58. Pin: version 1.0
  59. Pin-Priority: -1" > rootdir/etc/apt/preferences
  60. testsuccessequal "Reading package lists...
  61. Building dependency tree...
  62. Reading state information...
  63. Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
  64. The following packages will be REMOVED:
  65. foo:i386
  66. The following NEW packages will be installed:
  67. foo
  68. 0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
  69. Remv foo:i386 [1.0]
  70. Inst foo (1.0 local-deb [amd64])
  71. Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s
  72. createpkg() {
  73. local PKG="pkg-$1"
  74. mkdir -p ./incoming/$PKG/DEBIAN
  75. if [ -n "$2" ]; then
  76. echo -n "$2" >> ./incoming/$PKG/DEBIAN/control
  77. fi
  78. echo "Package: $PKG
  79. Version: 0
  80. Priority: extra
  81. Maintainer: No Body <no@example.org>
  82. Architecture: all
  83. Depends: foo:i386
  84. Description: test package" >> ./incoming/$PKG/DEBIAN/control
  85. if [ -n "$3" ]; then
  86. echo -n "$3" >> ./incoming/$PKG/DEBIAN/control
  87. fi
  88. testsuccess dpkg-deb --build ./incoming/$PKG/ ./incoming
  89. #dpkg-deb -I ./incoming/${PKG}_0_all.deb control
  90. }
  91. createpkg 'as-it-should-be'
  92. createpkg 'leading-newline' '
  93. '
  94. createpkg 'trailing-newline' '' '
  95. '
  96. testsuccess aptget install ./incoming/pkg-as-it-should-be_0_all.deb
  97. testsuccess aptget install ./incoming/pkg-leading-newline_0_all.deb
  98. testsuccess aptget install ./incoming/pkg-trailing-newline_0_all.deb
  99. testempty apt clean
  100. if [ "$(id -u)" = '0' ]; then
  101. # see if permission dropping is checked before usage
  102. chmod 711 ./incoming
  103. testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
  104. testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
  105. chmod 710 ./incoming
  106. testsuccesswithnotice aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
  107. testfailure grep 'is already the newest version' rootdir/tmp/testsuccesswithnotice.output
  108. chmod 700 ./incoming
  109. testsuccesswithnotice aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
  110. testfailure grep 'is already the newest version' rootdir/tmp/testsuccesswithnotice.output
  111. chmod 711 ./incoming
  112. else
  113. testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
  114. testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
  115. fi
  116. sed -i -e '/^Depends: foo/ d' rootdir/var/lib/dpkg/status
  117. testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb
  118. testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output