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