You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

81 lines
3.4 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'i386'
  7. insertinstalledpackage 'package1' 'i386' '1.0'
  8. insertinstalledpackage 'package2' 'i386' '1.0'
  9. insertinstalledpackage 'package3' 'i386' '1.0'
  10. insertinstalledpackage 'package4' 'i386' '1.0'
  11. insertinstalledpackage 'package5' 'i386' '1.0'
  12. insertinstalledpackage 'package6' 'i386' '1.0'
  13. buildsimplenativepackage 'foo' 'all' '1'
  14. setupaptarchive
  15. buildsimplenativepackage 'bar' 'all' '1'
  16. # Checks that the correct variable is set
  17. msgmsg 'Post-Invoke script has DPKG_FRONTEND_LOCKED set'
  18. testsuccess aptget -q -y -o Dpkg::Post-Invoke::="echo DPKG_FRONTEND_LOCKED=\$DPKG_FRONTEND_LOCKED" remove package1
  19. cp rootdir/tmp/testsuccess.output install.output
  20. testsuccess grep DPKG_FRONTEND_LOCKED=true install.output
  21. msgmsg 'Pre-Invoke script has DPKG_FRONTEND_LOCKED set'
  22. testsuccess aptget -q -y -o Dpkg::Pre-Invoke::="echo DPKG_FRONTEND_LOCKED=\$DPKG_FRONTEND_LOCKED" remove package2
  23. cp rootdir/tmp/testsuccess.output install.output
  24. testsuccess grep DPKG_FRONTEND_LOCKED=true install.output
  25. msgmsg 'Pre-Install-Pkgs script has DPKG_FRONTEND_LOCKED set'
  26. testsuccess aptget -q -y -o DPkg::Pre-Install-Pkgs::="echo DPKG_FRONTEND_LOCKED=\$DPKG_FRONTEND_LOCKED" remove package3
  27. cp rootdir/tmp/testsuccess.output install.output
  28. testsuccess grep DPKG_FRONTEND_LOCKED=true install.output
  29. # Check that the frontend lock is hold by apt-get
  30. msgmsg 'Post-Invoke script runs while frontend is locked'
  31. testfailure aptget -q -y -o Dpkg::Post-Invoke::="apt-get remove" remove package4
  32. cp rootdir/tmp/testfailure.output install.output
  33. testsuccess grep "E: Unable to acquire the dpkg frontend lock (${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/lock-frontend), is another process using it?" install.output
  34. testsuccess grep "E: Problem executing scripts DPkg::Post-Invoke 'apt-get remove'" install.output
  35. msgmsg 'Pre-Invoke script runs while frontend is locked'
  36. testfailure aptget -q -y -o Dpkg::Pre-Invoke::="apt-get remove" remove package5
  37. cp rootdir/tmp/testfailure.output install.output
  38. testsuccess grep "E: Unable to acquire the dpkg frontend lock (${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/lock-frontend), is another process using it?" install.output
  39. testsuccess grep "E: Problem executing scripts DPkg::Pre-Invoke 'apt-get remove'" install.output
  40. msgmsg 'Pre-Install-Pkgs runs while frontend is locked'
  41. testfailure aptget -q -y -o DPkg::Pre-Install-Pkgs::="apt-get remove" remove package6
  42. cp rootdir/tmp/testfailure.output install.output
  43. testsuccess grep "E: Unable to acquire the dpkg frontend lock (${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/lock-frontend), is another process using it?" install.output
  44. testsuccess grep "E: Sub-process apt-get remove returned an error code (100)" install.output
  45. testsuccess grep "Failure running script apt-get remove" install.output
  46. # Applied test case from DonKult
  47. msgmsg 'Applied case of frontend locking'
  48. cat > ./post-invoke <<EOF
  49. #!/bin/sh
  50. set -e
  51. #export DPKG_FRONTEND_LOCKED=true
  52. ${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg -i ${TMPWORKINGDIRECTORY}/incoming/bar_1_all.deb
  53. EOF
  54. chmod +x ./post-invoke
  55. echo "dpkg::post-invoke:: \"${TMPWORKINGDIRECTORY}/post-invoke\";" > rootdir/etc/apt/apt.conf.d/01dpkgpostinvoke
  56. testdpkgnotinstalled 'foo' 'bar'
  57. testsuccess apt show foo
  58. testfailure apt show bar
  59. testsuccess apt install foo -s
  60. testdpkgnotinstalled 'foo' 'bar'
  61. testsuccess apt install foo
  62. testdpkginstalled 'foo' 'bar'