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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. FD=0
  24. echo -n > ${hook}-v${1}.list
  25. if [ -n \"${2}\" ]; then
  26. FD=\$APT_HOOK_INFO_FD
  27. if [ "\$FD" != \"${2}\" ]; then echo \"ERROR: Information is not on requested FD: \$FD != ${2}\" >> ${hook}-v${1}.list; fi
  28. fi
  29. while read </proc/\$\$/fd/\$FD line; do
  30. if echo \"\$line\" | grep -Fq '**'; then
  31. echo \"\$line\"
  32. fi
  33. done >> ${hook}-v${1}.list" > ${hook}-v${1}.sh
  34. chmod +x ${hook}-v${1}.sh
  35. echo "dpkg::${hook}:: \"./${hook}-v${1}.sh --foo -bar\";
  36. DPkg::Tools::options::\"./${hook}-v${1}.sh\"::Version \"$1\";" > rootdir/etc/apt/apt.conf.d/hook-v$1
  37. if [ -n "$2" ]; then
  38. echo "DPkg::Tools::options::\"./${hook}-v${1}.sh\"::InfoFD \"${2}\";" >> rootdir/etc/apt/apt.conf.d/hook-v$1
  39. fi
  40. }
  41. observehook() {
  42. rm -f ${hook}-v2.list ${hook}-v3.list
  43. msgtest 'Observe hooks while' "$*"
  44. testsuccess --nomsg aptget "$@" -y --force-yes
  45. }
  46. testrun() {
  47. observehook install stuff -t stable
  48. testfileequal "${hook}-v2.list" 'libsame - < 1 **CONFIGURE**
  49. toolkit - < 1 **CONFIGURE**
  50. stuff - < 1 **CONFIGURE**'
  51. testfileequal "${hook}-v3.list" 'libsame - - none < 1 amd64 same **CONFIGURE**
  52. toolkit - - none < 1 all foreign **CONFIGURE**
  53. stuff - - none < 1 amd64 none **CONFIGURE**'
  54. observehook install stuff -t unstable
  55. testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE**
  56. toolkit 1 < 2 **CONFIGURE**
  57. stuff 1 < 2 **CONFIGURE**'
  58. testfileequal "${hook}-v3.list" 'libsame 1 amd64 same < 2 amd64 same **CONFIGURE**
  59. toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE**
  60. stuff 1 amd64 none < 2 amd64 none **CONFIGURE**'
  61. observehook install stuff:i386 -t unstable
  62. testfileequal "${hook}-v2.list" 'stuff 2 > - **REMOVE**
  63. libsame - < 2 **CONFIGURE**
  64. stuff - < 2 **CONFIGURE**'
  65. testfileequal "${hook}-v3.list" 'stuff 2 amd64 none > - - none **REMOVE**
  66. libsame - - none < 2 i386 same **CONFIGURE**
  67. stuff - - none < 2 i386 none **CONFIGURE**'
  68. observehook remove libsame
  69. testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**'
  70. testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**'
  71. observehook install stuff:i386/stable libsame:i386/stable toolkit/stable
  72. testfileequal "${hook}-v2.list" 'libsame 2 > 1 **CONFIGURE**
  73. toolkit 2 > 1 **CONFIGURE**
  74. stuff 2 > 1 **CONFIGURE**'
  75. testfileequal "${hook}-v3.list" 'libsame 2 i386 same > 1 i386 same **CONFIGURE**
  76. toolkit 2 amd64 foreign > 1 all foreign **CONFIGURE**
  77. stuff 2 i386 none > 1 i386 none **CONFIGURE**'
  78. observehook install 'libsame:*'
  79. testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE**
  80. libsame - < 2 **CONFIGURE**
  81. toolkit 1 < 2 **CONFIGURE**
  82. stuff 1 < 2 **CONFIGURE**'
  83. testfileequal "${hook}-v3.list" 'libsame 1 i386 same < 2 i386 same **CONFIGURE**
  84. libsame - - none < 2 amd64 same **CONFIGURE**
  85. toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE**
  86. stuff 1 i386 none < 2 i386 none **CONFIGURE**'
  87. observehook purge stuff:i386 'libsame:*' toolkit
  88. testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**
  89. stuff 2 > - **REMOVE**
  90. libsame 2 > - **REMOVE**
  91. toolkit 2 > - **REMOVE**'
  92. testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**
  93. stuff 2 i386 none > - - none **REMOVE**
  94. libsame 2 i386 same > - - none **REMOVE**
  95. toolkit 2 amd64 foreign > - - none **REMOVE**'
  96. observehook install confpkg
  97. testfileequal "${hook}-v2.list" 'confpkg - < 1 **CONFIGURE**'
  98. testfileequal "${hook}-v3.list" 'confpkg - - none < 1 amd64 none **CONFIGURE**'
  99. observehook remove confpkg
  100. testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
  101. testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
  102. msgtest 'Conffiles of package remained after remove' 'confpkg'
  103. dpkg -l confpkg | grep -q '^rc' && msgpass || msgfail
  104. observehook purge confpkg
  105. testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
  106. testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
  107. msgtest 'Conffiles are gone after purge' 'confpkg'
  108. dpkg -l confpkg 2>/dev/null | grep -q '^rc' && msgfail || msgpass
  109. }
  110. enablehookversion 2
  111. enablehookversion 3
  112. testrun
  113. enablehookversion 2 13
  114. enablehookversion 3 13
  115. testrun