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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 </dev/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 --allow-downgrades --planner $planner -o Debug::pkgDPkgProgressReporting=1
  45. # different planners have different orders – we don't care in this test here
  46. if [ -e ${hook}-v2.list ]; then
  47. sort < ${hook}-v2.list > ${hook}-v2.list.new
  48. mv ${hook}-v2.list.new ${hook}-v2.list
  49. fi
  50. if [ -e ${hook}-v3.list ]; then
  51. sort < ${hook}-v3.list > ${hook}-v3.list.new
  52. mv ${hook}-v3.list.new ${hook}-v3.list
  53. fi
  54. }
  55. testrun() {
  56. observehook install stuff -t stable
  57. testfileequal "${hook}-v2.list" 'libsame - < 1 **CONFIGURE**
  58. stuff - < 1 **CONFIGURE**
  59. toolkit - < 1 **CONFIGURE**'
  60. testfileequal "${hook}-v3.list" 'libsame - - none < 1 amd64 same **CONFIGURE**
  61. stuff - - none < 1 amd64 none **CONFIGURE**
  62. toolkit - - none < 1 all foreign **CONFIGURE**'
  63. observehook install stuff -t unstable
  64. testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE**
  65. stuff 1 < 2 **CONFIGURE**
  66. toolkit 1 < 2 **CONFIGURE**'
  67. testfileequal "${hook}-v3.list" 'libsame 1 amd64 same < 2 amd64 same **CONFIGURE**
  68. stuff 1 amd64 none < 2 amd64 none **CONFIGURE**
  69. toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE**'
  70. observehook install stuff:i386 -t unstable
  71. testfileequal "${hook}-v2.list" 'libsame - < 2 **CONFIGURE**
  72. stuff - < 2 **CONFIGURE**
  73. stuff 2 > - **REMOVE**'
  74. testfileequal "${hook}-v3.list" 'libsame - - none < 2 i386 same **CONFIGURE**
  75. stuff - - none < 2 i386 none **CONFIGURE**
  76. stuff 2 amd64 none > - - none **REMOVE**'
  77. observehook remove libsame
  78. testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**'
  79. testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**'
  80. observehook install stuff:i386/stable libsame:i386/stable toolkit/stable
  81. testfileequal "${hook}-v2.list" 'libsame 2 > 1 **CONFIGURE**
  82. stuff 2 > 1 **CONFIGURE**
  83. toolkit 2 > 1 **CONFIGURE**'
  84. testfileequal "${hook}-v3.list" 'libsame 2 i386 same > 1 i386 same **CONFIGURE**
  85. stuff 2 i386 none > 1 i386 none **CONFIGURE**
  86. toolkit 2 amd64 foreign > 1 all foreign **CONFIGURE**'
  87. observehook install 'libsame:*'
  88. testfileequal "${hook}-v2.list" 'libsame - < 2 **CONFIGURE**
  89. libsame 1 < 2 **CONFIGURE**
  90. stuff 1 < 2 **CONFIGURE**
  91. toolkit 1 < 2 **CONFIGURE**'
  92. testfileequal "${hook}-v3.list" 'libsame - - none < 2 amd64 same **CONFIGURE**
  93. libsame 1 i386 same < 2 i386 same **CONFIGURE**
  94. stuff 1 i386 none < 2 i386 none **CONFIGURE**
  95. toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE**'
  96. observehook purge stuff:i386 'libsame:*' toolkit
  97. testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**
  98. libsame 2 > - **REMOVE**
  99. stuff 2 > - **REMOVE**
  100. toolkit 2 > - **REMOVE**'
  101. testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**
  102. libsame 2 i386 same > - - none **REMOVE**
  103. stuff 2 i386 none > - - none **REMOVE**
  104. toolkit 2 amd64 foreign > - - none **REMOVE**'
  105. observehook install confpkg
  106. testfileequal "${hook}-v2.list" 'confpkg - < 1 **CONFIGURE**'
  107. testfileequal "${hook}-v3.list" 'confpkg - - none < 1 amd64 none **CONFIGURE**'
  108. observehook remove confpkg
  109. testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
  110. testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
  111. msgtest 'Conffiles of package remained after remove' 'confpkg'
  112. dpkg -l confpkg | grep -q '^rc' && msgpass || msgfail
  113. observehook purge confpkg
  114. testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
  115. testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
  116. msgtest 'Conffiles are gone after purge' 'confpkg'
  117. dpkg -l confpkg 2>/dev/null | grep -q '^rc' && msgfail || msgpass
  118. }
  119. runwithplanner()
  120. {
  121. msgmsg 'Running with planner' "$1"
  122. planner="$1"
  123. enablehookversion 2
  124. enablehookversion 3
  125. testrun
  126. enablehookversion 2 13
  127. enablehookversion 3 13
  128. testrun
  129. }
  130. runwithplanner 'apt'