]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-get-autoremove
fix testcase expecting incorrect remove log from dpkg
[apt.git] / test / integration / test-apt-get-autoremove
1 #!/bin/sh
2 set -e
3
4 TESTDIR="$(readlink -f "$(dirname "$0")")"
5 . "$TESTDIR/framework"
6 setupenvironment
7 configarchitecture 'i386'
8
9 buildsimplenativepackage 'unrelated' 'all' '1' 'unstable'
10 buildsimplenativepackage 'po-debconf' 'all' '1.0.16' 'unstable'
11 buildsimplenativepackage 'debhelper' 'all' '8.0.0' 'unstable' 'Depends: po-debconf'
12 setupaptarchive
13
14 testsuccess aptget install unrelated debhelper -y
15 testdpkginstalled 'unrelated' 'debhelper' 'po-debconf'
16
17 testmarkedauto 'po-debconf'
18 testsuccess aptget remove debhelper -y
19 testdpkgnotinstalled 'debhelper'
20 testdpkginstalled 'po-debconf' 'unrelated'
21 echo 'unrelated purge' | dpkg --set-selections
22 testdpkgstatus 'pi' '1' 'unrelated'
23
24 AUTOREMOVE='apt autoremove'
25 if [ -n "$SUDO_USER" ]; then
26 AUTOREMOVE="sudo $AUTOREMOVE"
27 fi
28 echo 'APT::NeverAutoRemove { "^debc.*nf$"; };' > rootdir/etc/apt/apt.conf.d/00autoremove
29 testsuccessequal 'Reading package lists...
30 Building dependency tree...
31 Reading state information...
32 The following packages will be REMOVED:
33 po-debconf
34 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
35 Remv po-debconf [1.0.16]' aptget autoremove -s
36 testequal "Reading package lists...
37 Building dependency tree...
38 Reading state information...
39 The following package was automatically installed and is no longer required:
40 po-debconf
41 Use '$AUTOREMOVE' to remove it.
42 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s
43 testequal "Reading package lists...
44 Building dependency tree...
45 Reading state information...
46 1 package was automatically installed and is no longer required.
47 Use '$AUTOREMOVE' to remove it.
48 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small
49 testdpkginstalled 'po-debconf'
50
51 echo 'APT::NeverAutoRemove { "^po-debconf$"; };' > rootdir/etc/apt/apt.conf.d/00autoremove
52 testsuccess aptget autoremove -y
53 testdpkginstalled 'po-debconf'
54 testdpkgstatus 'pi' '1' 'unrelated'
55
56 echo 'APT::NeverAutoRemove { "^po-.*$"; };' > rootdir/etc/apt/apt.conf.d/00autoremove
57 testsuccess aptget autoremove -y
58 testdpkginstalled "po-debconf"
59 testdpkgstatus 'pi' '1' 'unrelated'
60
61 rm rootdir/etc/apt/apt.conf.d/00autoremove
62 testsuccess aptget autoremove -y
63 testdpkgnotinstalled 'po-debconf'
64 testdpkgstatus 'pi' '1' 'unrelated'
65 testmarkedauto
66
67 sed rootdir/var/log/apt/history.log -e '/^Commandline: / d' \
68 -e '/^Start-Date: / d' -e '/^End-Date: / d' \
69 -e '/^Requested-By: / d' \
70 -e 's#), #)\nInstall: #g' | sort -u > apt-history.log
71 testfileequal 'apt-history.log' '
72 Install: debhelper:i386 (8.0.0)
73 Install: po-debconf:i386 (1.0.16, automatic)
74 Install: unrelated:i386 (1)
75 Remove: debhelper:i386 (8.0.0)
76 Remove: po-debconf:i386 (1.0.16)'
77
78 testsuccess aptget install debhelper -y
79 testdpkgstatus 'pi' '1' 'unrelated'
80 testdpkginstalled 'debhelper' 'po-debconf'
81 testsuccess aptmark auto debhelper
82
83 testmarkedauto 'debhelper' 'po-debconf'
84 testsuccessequal 'Reading package lists...
85 Building dependency tree...
86 Reading state information...
87 The following packages will be REMOVED:
88 debhelper po-debconf
89 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
90 Remv debhelper [8.0.0]
91 Remv po-debconf [1.0.16]' aptget autoremove -s
92 testequal "Reading package lists...
93 Building dependency tree...
94 Reading state information...
95 The following packages were automatically installed and are no longer required:
96 debhelper po-debconf
97 Use '$AUTOREMOVE' to remove them.
98 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s
99 testequal "Reading package lists...
100 Building dependency tree...
101 Reading state information...
102 2 packages were automatically installed and are no longer required.
103 Use '$AUTOREMOVE' to remove them.
104 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small
105
106 testsuccess aptmark hold debhelper
107 testsuccessequal 'Reading package lists...
108 Building dependency tree...
109 Reading state information...
110 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' aptget autoremove -s
111
112 testsuccess aptget autoremove debhelper -y --allow-change-held-packages
113 testdpkgnotinstalled 'po-debconf' 'debhelper'
114 testdpkgstatus 'pi' '1' 'unrelated'
115 testmarkedauto
116 testsuccess aptget install debhelper --solver apt -y -o Debug::pkgDepCache::Marker=1
117 testmarkedauto 'po-debconf'
118 testdpkgstatus 'pi' '1' 'unrelated'
119
120 insertinstalledpackage 'bar' 'all' '1' 'Depends: foo-provider'
121 insertinstalledpackage 'foo-multi1-1' 'all' '1' 'Provides: foo-provider
122 Source: foo-multi (1)'
123 insertinstalledpackage 'foo-multi1-2' 'all' '1' 'Provides: foo-provider
124 Source: foo-multi (2)'
125 insertinstalledpackage 'foo-multi1-3' 'all' '1' 'Provides: foo-provider
126 Source: foo-multi (3)'
127 insertinstalledpackage 'foo-multi2-1' 'all' '1' 'Provides: foo-provider
128 Source: foo-multi (1)'
129 insertinstalledpackage 'foo-multi2-2' 'all' '1' 'Provides: foo-provider
130 Source: foo-multi (2)'
131 insertinstalledpackage 'foo-multi2-3' 'all' '1' 'Provides: foo-provider
132 Source: foo-multi (3)'
133 insertinstalledpackage 'foo-plus-1' 'all' '1' 'Provides: foo-provider
134 Source: foo-plus (1)'
135 insertinstalledpackage 'foo-plus-2' 'all' '1' 'Provides: foo-provider
136 Source: foo-plus (2)'
137 insertinstalledpackage 'foo-plus-3' 'all' '1' 'Provides: foo-provider
138 Source: foo-plus (3)'
139 insertinstalledpackage 'foo-single-1' 'all' '1' 'Provides: foo-provider'
140 insertinstalledpackage 'foo-single-2' 'all' '1' 'Provides: foo-provider'
141
142 testsuccess aptmark auto 'foo-*'
143 testsuccessequal 'Reading package lists...
144 Building dependency tree...
145 Reading state information...
146 The following packages will be REMOVED:
147 foo-multi1-1 foo-multi1-2 foo-multi2-1 foo-multi2-2 foo-plus-1 foo-plus-2
148 0 upgraded, 0 newly installed, 6 to remove and 0 not upgraded.
149 Remv foo-multi1-1 [1]
150 Remv foo-multi1-2 [1]
151 Remv foo-multi2-1 [1]
152 Remv foo-multi2-2 [1]
153 Remv foo-plus-1 [1]
154 Remv foo-plus-2 [1]' apt autoremove -s
155
156 testdpkgstatus 'pi' '1' 'unrelated'
157 testsuccess apt purge unrelated -y