test-apt-get-install-deb 3.5 KB

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