summaryrefslogtreecommitdiffstats
path: root/test/integration/test-apt-mark
blob: d1c65ad7c40e85d35ab75375630edb04e0efcb52 (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/sh
set -e

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

insertpackage 'unstable' 'bar' 'amd64,i386' '1'
insertpackage 'unstable' 'uninstalled' 'all' '1'
insertpackage 'unstable' 'uninstalled-native' 'amd64' '1'

insertinstalledpackage 'foo' 'all' '1'
insertinstalledpackage 'bar' 'amd64' '1'

setupaptarchive

testnoautopkg() {
	testempty aptmark showauto
	testempty aptcache -q=1 showauto
	testsuccessequal 'bar
foo' aptmark showmanual
	testsuccessequal 'bar
foo' aptmark showmanual bar foo uninstalled
}
testfooisauto() {
	testsuccessequal 'foo' aptmark showauto
	testsuccessequal 'foo' aptcache -q=1 showauto
	testsuccessequal 'foo' aptmark showauto foo
	testsuccessequal 'foo' aptcache -q=1 showauto foo
	testsuccessequal 'bar' aptmark showmanual
	testsuccessequal 'bar' aptmark showmanual bar
}
testmarkonpkgasauto() {
	testsuccess $1 -q=1 $2 foo
	testfooisauto
	testsuccess $1 -q=1 $2 foo
	testfooisauto

	testsuccess $1 -q=1 $3 foo
	testnoautopkg
	testsuccess $1 -q=1 $3 foo
	testnoautopkg
}

testfailureequal 'E: No packages found' aptmark auto
testfailureequal 'E: No packages found' aptmark manual

testnoautopkg
testmarkonpkgasauto 'aptmark' 'auto' 'manual'
testmarkonpkgasauto 'aptmark' 'markauto' 'unmarkauto'
testmarkonpkgasauto 'aptget' 'markauto' 'unmarkauto'

testnoholdpkg() {
	testempty aptmark showhold
	testempty aptmark showholds  # typical "typo"
}
testpkgonhold() {
	testsuccessequal "$1" aptmark showhold
	testsuccessequal "$1" aptmark showholds
	testsuccessequal "$1" aptmark showhold $1
	testsuccessequal "$1" aptmark showholds $1
}
testmarkonepkgashold() {
	testsuccess aptmark hold $1
	testpkgonhold $1
	testsuccess aptmark hold $1
	testpkgonhold $1
	testsuccess aptmark unhold $1
	testnoholdpkg
	testsuccess aptmark unhold $1
	testnoholdpkg
}

testfailureequal 'E: No packages found' aptmark hold
testfailureequal 'E: No packages found' aptmark unhold

testnoholdpkg
testmarkonepkgashold 'foo'
testmarkonepkgashold 'bar'

msgtest 'dpkg supports --merge-avail via' 'stdin'
if dpkg --merge-avail - < /dev/null >/dev/null 2>&1; then
	msgpass
else
	msgskip 'dpkg version too old'
	exit 0
fi

testmarkonepkgashold 'uninstalled'
testmarkonepkgashold 'uninstalled-native'

testsuccessequal 'uninstalled set on hold.' aptmark hold uninstalled
testsuccessequal 'uninstalled-native set on hold.' aptmark hold uninstalled-native
# FIXME: Remove old alternative answer for dpkg < 1.20.7 post bullseye release
testequalor2 'Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  uninstalled uninstalled-native
The following held packages will be changed:
  uninstalled uninstalled-native
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Inst uninstalled (1 unstable [all])
Inst uninstalled-native (1 unstable [amd64])
Conf uninstalled (1 unstable [all])
Conf uninstalled-native (1 unstable [amd64])' 'Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  uninstalled uninstalled-native
The following held packages will be changed:
  uninstalled-native
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Inst uninstalled (1 unstable [all])
Inst uninstalled-native (1 unstable [amd64])
Conf uninstalled (1 unstable [all])
Conf uninstalled-native (1 unstable [amd64])' aptget install uninstalled uninstalled-native -s
testsuccess aptmark unhold uninstalled uninstalled-native

testselections() {
	testsuccess aptmark hold "$1"
	testsuccessequal "$1" aptmark showholds "$1"
	testsuccess aptmark unhold "$1"
	testsuccessequal "$1" aptmark showinstalls "$1"
	testsuccess aptmark hold "$1"
	testsuccessequal "$1" aptmark showholds "$1"
	testsuccess aptmark install "$1"
	testsuccessequal "$1" aptmark showinstalls "$1"
	testsuccess aptmark remove "$1"
	testsuccessequal "$1" aptmark showremoves "$1"
	testsuccess aptmark purge "$1"
	testsuccessequal "$1" aptmark showpurges "$1"
}
testselections 'foo'
testselections 'bar'

testsuccessequal 'Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
  bar* foo*
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
Purg bar [1]
Purg foo [1]' aptget dselect-upgrade -s

testuninstalledselections() {
	testsuccess aptmark hold "$1"
	testsuccessequal "$1" aptmark showholds "$1"
	testsuccess aptmark unhold "$1"
	testsuccessequal "$1" aptmark showremoves "$1"
	testsuccess aptmark hold "$1"
	testsuccessequal "$1" aptmark showholds "$1"
	testsuccess aptmark install "$1"
	testsuccessequal "$1" aptmark showinstalls "$1"
}
testuninstalledselections 'uninstalled'
testuninstalledselections 'uninstalled-native'