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