test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture 'amd64' 'i386'
  7. buildsimplenativepackage 'toolkit' 'all' '1' 'stable' 'Multi-Arch: foreign'
  8. buildsimplenativepackage 'toolkit' 'amd64' '2' 'unstable' 'Multi-Arch: foreign'
  9. buildsimplenativepackage 'libsame' 'i386,amd64' '1' 'stable' 'Multi-Arch: same'
  10. buildsimplenativepackage 'libsame' 'i386,amd64' '2' 'unstable' 'Multi-Arch: same'
  11. buildsimplenativepackage 'stuff' 'i386,amd64' '1' 'stable' 'Depends: libsame (= 1), toolkit (= 1)'
  12. buildsimplenativepackage 'stuff' 'i386,amd64' '2' 'unstable' 'Depends: libsame (= 2), toolkit (= 2)'
  13. setupsimplenativepackage 'confpkg' 'amd64' '1' 'unstable'
  14. BUILDDIR='incoming/confpkg-1'
  15. echo 'foo "bar";' > ${BUILDDIR}/pkg.conf
  16. echo 'pkg.conf /etc/pkg.conf' >> ${BUILDDIR}/debian/install
  17. buildpackage "$BUILDDIR" 'unstable' 'main' 'amd64'
  18. rm -rf "$BUILDDIR"
  19. setupaptarchive
  20. hook='pre-install-pkgs'
  21. enablehookversion() {
  22. echo "#!/bin/sh
  23. while read line; do
  24. if echo \"\$line\" | grep -Fq '**'; then
  25. echo \"\$line\"
  26. fi
  27. done > ${hook}-v${1}.list" > ${hook}-v${1}.sh
  28. chmod +x ${hook}-v${1}.sh
  29. echo "dpkg::${hook}:: \"./${hook}-v${1}.sh --foo -bar\";
  30. DPkg::Tools::options::\"./${hook}-v${1}.sh\"::Version \"$1\";" > rootdir/etc/apt/apt.conf.d/hook-v$1
  31. }
  32. enablehookversion 2
  33. enablehookversion 3
  34. observehook() {
  35. rm -f ${hook}-v2.list ${hook}-v3.list
  36. msgtest 'Observe hooks while' "$*"
  37. testsuccess --nomsg aptget "$@" -y --force-yes
  38. }
  39. observehook install stuff -t stable
  40. testfileequal "${hook}-v2.list" 'libsame - < 1 **CONFIGURE**
  41. toolkit - < 1 **CONFIGURE**
  42. stuff - < 1 **CONFIGURE**'
  43. testfileequal "${hook}-v3.list" 'libsame - - none < 1 amd64 same **CONFIGURE**
  44. toolkit - - none < 1 all foreign **CONFIGURE**
  45. stuff - - none < 1 amd64 none **CONFIGURE**'
  46. observehook install stuff -t unstable
  47. testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE**
  48. toolkit 1 < 2 **CONFIGURE**
  49. stuff 1 < 2 **CONFIGURE**'
  50. testfileequal "${hook}-v3.list" 'libsame 1 amd64 same < 2 amd64 same **CONFIGURE**
  51. toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE**
  52. stuff 1 amd64 none < 2 amd64 none **CONFIGURE**'
  53. observehook install stuff:i386 -t unstable
  54. testfileequal "${hook}-v2.list" 'stuff 2 > - **REMOVE**
  55. libsame - < 2 **CONFIGURE**
  56. stuff - < 2 **CONFIGURE**'
  57. testfileequal "${hook}-v3.list" 'stuff 2 amd64 none > - - none **REMOVE**
  58. libsame - - none < 2 i386 same **CONFIGURE**
  59. stuff - - none < 2 i386 none **CONFIGURE**'
  60. observehook remove libsame
  61. testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**'
  62. testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**'
  63. observehook install stuff:i386/stable libsame:i386/stable toolkit/stable
  64. testfileequal "${hook}-v2.list" 'libsame 2 > 1 **CONFIGURE**
  65. toolkit 2 > 1 **CONFIGURE**
  66. stuff 2 > 1 **CONFIGURE**'
  67. testfileequal "${hook}-v3.list" 'libsame 2 i386 same > 1 i386 same **CONFIGURE**
  68. toolkit 2 amd64 foreign > 1 all foreign **CONFIGURE**
  69. stuff 2 i386 none > 1 i386 none **CONFIGURE**'
  70. observehook install 'libsame:*'
  71. testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE**
  72. libsame - < 2 **CONFIGURE**
  73. toolkit 1 < 2 **CONFIGURE**
  74. stuff 1 < 2 **CONFIGURE**'
  75. testfileequal "${hook}-v3.list" 'libsame 1 i386 same < 2 i386 same **CONFIGURE**
  76. libsame - - none < 2 amd64 same **CONFIGURE**
  77. toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE**
  78. stuff 1 i386 none < 2 i386 none **CONFIGURE**'
  79. observehook purge stuff:i386 'libsame:*' toolkit
  80. testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**
  81. stuff 2 > - **REMOVE**
  82. libsame 2 > - **REMOVE**
  83. toolkit 2 > - **REMOVE**'
  84. testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**
  85. stuff 2 i386 none > - - none **REMOVE**
  86. libsame 2 i386 same > - - none **REMOVE**
  87. toolkit 2 amd64 foreign > - - none **REMOVE**'
  88. observehook install confpkg
  89. testfileequal "${hook}-v2.list" 'confpkg - < 1 **CONFIGURE**'
  90. testfileequal "${hook}-v3.list" 'confpkg - - none < 1 amd64 none **CONFIGURE**'
  91. observehook remove confpkg
  92. testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
  93. testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
  94. msgtest 'Conffiles of package remained after remove' 'confpkg'
  95. dpkg -l confpkg | grep -q '^rc' && msgpass || msgfail
  96. observehook purge confpkg
  97. testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
  98. testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
  99. msgtest 'Conffiles are gone after purge' 'confpkg'
  100. dpkg -l confpkg 2>/dev/null | grep -q '^rc' && msgfail || msgpass