summaryrefslogtreecommitdiff
path: root/test/integration/test-kernel-helper-autoremove
blob: 4c0571b13c9a013e563402ff7c04e1fb9fe3076c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh

set -e

# setup testdir
TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework

TMPDIR=$(mktemp -d)
cd $TMPDIR
addtrap "cd /; rm -rf $TMPDIR"

# create mock environment
mkdir apt.conf.d
cat > aptconfig.conf <<EOF
Dir::Etc::parts "$TMPDIR/apt.conf.d";
Dir::bin::dpkg "$TMPDIR/fake-dpkg";
EOF
APT_CONFIG=aptconfig.conf
export APT_CONFIG

# install fake-dpkg into it
install -m755 $TESTDIR/test-kernel-helper-autoremove.fake-dpkg $TMPDIR/fake-dpkg

# run the helper
sh  ${TESTDIR}/../../debian/apt.auto-removal.sh

# and ensure its there, valid and version 10.0.0-1 is there too
test -e $TMPDIR/apt.conf.d/01autoremove-kernels
apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-10.0.0-1-generic\.\*" 
# ... and also that the running kernel is exlucded
apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-$(uname -r)\.\*" 

# done
msgpass