test-apt-get-install-deb 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. cd downloaded
  38. testsuccess aptget install "$(readlink -f ../incoming/foo_1.0_i386.deb)" -o Debug::pkgCacheGen=1 -y --allow-downgrades
  39. testsuccess aptget install ../incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1 -y --allow-downgrades
  40. cd ..
  41. testsuccessequal "Reading package lists...
  42. Building dependency tree...
  43. Reading state information...
  44. Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
  45. The following packages will be REMOVED:
  46. foo:i386
  47. The following NEW packages will be installed:
  48. foo
  49. 0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
  50. Remv foo:i386 [1.0]
  51. Inst foo (1.0 local-deb [amd64])
  52. Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s
  53. # Check that installing the local deb works if it is not the candidate
  54. echo "Package: foo
  55. Pin: version 1.0
  56. Pin-Priority: -1" > rootdir/etc/apt/preferences
  57. testsuccessequal "Reading package lists...
  58. Building dependency tree...
  59. Reading state information...
  60. Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
  61. The following packages will be REMOVED:
  62. foo:i386
  63. The following NEW packages will be installed:
  64. foo
  65. 0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
  66. Remv foo:i386 [1.0]
  67. Inst foo (1.0 local-deb [amd64])
  68. Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s
  69. createpkg() {
  70. local PKG="pkg-$1"
  71. mkdir -p ./incoming/$PKG/DEBIAN
  72. if [ -n "$2" ]; then
  73. echo -n "$2" >> ./incoming/$PKG/DEBIAN/control
  74. fi
  75. echo "Package: $PKG
  76. Version: 0
  77. Priority: extra
  78. Maintainer: No Body <no@example.org>
  79. Architecture: all
  80. Description: test package" >> ./incoming/$PKG/DEBIAN/control
  81. if [ -n "$3" ]; then
  82. echo -n "$3" >> ./incoming/$PKG/DEBIAN/control
  83. fi
  84. testsuccess dpkg-deb --build ./incoming/$PKG/ ./incoming
  85. #dpkg-deb -I ./incoming/${PKG}_0_all.deb control
  86. }
  87. createpkg 'as-it-should-be'
  88. createpkg 'leading-newline' '
  89. '
  90. createpkg 'trailing-newline' '' '
  91. '
  92. testsuccess aptget install ./incoming/pkg-as-it-should-be_0_all.deb
  93. testsuccess aptget install ./incoming/pkg-leading-newline_0_all.deb
  94. testsuccess aptget install ./incoming/pkg-trailing-newline_0_all.deb
  95. # see if permission dropping is checked before usage
  96. if [ "$(id -u)" = '0' ]; then
  97. apt clean
  98. chmod 711 ./incoming
  99. testsuccess aptget install -y --allow-downgrades ./incoming/pkg-as-it-should-be_0_all.deb
  100. chmod 710 ./incoming
  101. testsuccesswithnotice aptget install -y --allow-downgrades ./incoming/pkg-as-it-should-be_0_all.deb
  102. chmod 700 ./incoming
  103. testsuccesswithnotice aptget install -y --allow-downgrades ./incoming/pkg-as-it-should-be_0_all.deb
  104. fi