test-kernel-helper-autoremove 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. set -e
  3. # setup testdir
  4. TESTDIR=$(readlink -f $(dirname $0))
  5. . $TESTDIR/framework
  6. TMPDIR=$(mktemp -d)
  7. cd $TMPDIR
  8. addtrap "cd /; rm -rf $TMPDIR"
  9. # create mock environment
  10. mkdir apt.conf.d
  11. cat > aptconfig.conf <<EOF
  12. Dir::Etc::parts "$TMPDIR/apt.conf.d";
  13. Dir::bin::dpkg "$TMPDIR/fake-dpkg";
  14. EOF
  15. APT_CONFIG=aptconfig.conf
  16. export APT_CONFIG
  17. # install fake-dpkg into it
  18. install -m755 $TESTDIR/test-kernel-helper-autoremove.fake-dpkg $TMPDIR/fake-dpkg
  19. # run the helper
  20. sh ${TESTDIR}/../../debian/apt.auto-removal.sh
  21. msgtest 'Check that kernel autoremoval list is correctly created'
  22. # and ensure its there, valid and version 10.0.0-1 is there too
  23. test -e $TMPDIR/apt.conf.d/01autoremove-kernels && msgpass || msgfail
  24. msgtest 'Check that most recent kernel is saved from autoremoval'
  25. apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-10.0.0-1-generic" && msgpass || msgfail
  26. # ... and also that the running kernel is excluded
  27. msgtest 'Check that running kernel is saved from autoremoval'
  28. apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-$(uname -r)" && msgpass || msgfail
  29. # and that the old kernel is *not* excluded from autoremoval
  30. msgtest 'Check that older kernels are not excluded from autoremoval'
  31. apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-1\.0\.01-2-generic" && msgfail || msgpass
  32. msgtest "Check that the older kernel is retained when it's being installed"
  33. sh ${TESTDIR}/../../debian/apt.auto-removal.sh 1.0.01-2-generic
  34. test -e $TMPDIR/apt.conf.d/01autoremove-kernels
  35. if ! apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-10.0.0-1-generic" \
  36. || ! apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-$(uname -r)" \
  37. || ! apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-1\.0\.01-2-generic"
  38. then
  39. msgfail
  40. else
  41. msgpass
  42. fi
  43. # done