summaryrefslogtreecommitdiff
path: root/test/integration/test-apt-get-autoremove
blob: 8630815ab6bfc62cda38d64003f5b15007f16eda (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
set -e

TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework
setupenvironment
configarchitecture 'i386'

buildsimplenativepackage 'unrelated' 'all' '1' 'unstable'
buildsimplenativepackage 'po-debconf' 'all' '1.0.16' 'unstable'
buildsimplenativepackage 'debhelper' 'all' '8.0.0' 'unstable' 'Depends: po-debconf'
setupaptarchive

testsuccess aptget install unrelated debhelper -y
testdpkginstalled 'unrelated' 'debhelper' 'po-debconf'

testmarkedauto 'po-debconf'
testsuccess aptget remove debhelper -y
testdpkgnotinstalled 'debhelper'
testdpkginstalled 'po-debconf' 'unrelated'

AUTOREMOVE='apt autoremove'
if [ -n "$SUDO_USER" ]; then
	AUTOREMOVE="sudo $AUTOREMOVE"
fi
echo 'APT::NeverAutoRemove { "^debc.*nf$"; };' > rootdir/etc/apt/apt.conf.d/00autoremove
testsuccessequal 'Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
  po-debconf
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Remv po-debconf [1.0.16]' aptget autoremove -s
testequal "Reading package lists...
Building dependency tree...
Reading state information...
The following package was automatically installed and is no longer required:
  po-debconf
Use '$AUTOREMOVE' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s
testequal "Reading package lists...
Building dependency tree...
Reading state information...
1 package was automatically installed and is no longer required.
Use '$AUTOREMOVE' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small
testdpkginstalled 'po-debconf'

echo 'APT::NeverAutoRemove { "^po-debconf$"; };' > rootdir/etc/apt/apt.conf.d/00autoremove
testsuccess aptget autoremove -y
testdpkginstalled 'po-debconf'

echo 'APT::NeverAutoRemove { "^po-.*$"; };' > rootdir/etc/apt/apt.conf.d/00autoremove
testsuccess aptget autoremove -y
testdpkginstalled "po-debconf"

rm rootdir/etc/apt/apt.conf.d/00autoremove
testsuccess aptget autoremove -y
testdpkgnotinstalled 'po-debconf'
testmarkedauto

sed rootdir/var/log/apt/history.log -e '/^Commandline: / d' -e '/^Start-Date: / d' -e '/^End-Date: / d' -e 's#), #)\nInstall: #g' | sort -u > apt-history.log
testfileequal 'apt-history.log' '
Install: debhelper:i386 (8.0.0)
Install: po-debconf:i386 (1.0.16, automatic)
Install: unrelated:i386 (1)
Remove: debhelper:i386 (8.0.0)
Remove: po-debconf:i386 (1.0.16)'

testsuccess aptget install debhelper -y
testdpkginstalled 'unrelated' 'debhelper' 'po-debconf'
testsuccess aptmark auto debhelper

testmarkedauto 'debhelper' 'po-debconf'
testsuccessequal 'Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
  debhelper po-debconf
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
Remv debhelper [8.0.0]
Remv po-debconf [1.0.16]' aptget autoremove -s
testequal "Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
  debhelper po-debconf
Use '$AUTOREMOVE' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s
testequal "Reading package lists...
Building dependency tree...
Reading state information...
2 packages were automatically installed and are no longer required.
Use '$AUTOREMOVE' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small

testsuccess aptmark hold debhelper
testsuccessequal 'Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' aptget autoremove -s

testsuccess aptget autoremove debhelper -y --allow-change-held-packages
testdpkgnotinstalled 'po-debconf' 'debhelper'
testmarkedauto
testsuccess aptget install debhelper --solver apt -y -o Debug::pkgDepCache::Marker=1
testmarkedauto 'po-debconf'