test-essential-force-loopbreak 4.95 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh
set -e

TESTDIR="$(readlink -f "$(dirname "$0")")"
. "$TESTDIR/framework"

setupenvironment
configarchitecture 'native'

insertinstalledpackage 'sysvinit' 'native' '1' 'Essential: yes'

buildsimplenativepackage 'sysvinit' 'native' '2' 'sid' 'Pre-Depends: sysvinit-core | systemd-sysv
Essential: yes'
buildsimplenativepackage 'sysvinit-core' 'native' '2' 'sid'

buildsimplenativepackage 'systemd-sysv' 'native' '2~conflict' 'sid-conflict' 'Conflicts: sysvinit (<< 2)
Breaks: sysvinit-core'

buildsimplenativepackage 'systemd-sysv' 'native' '2~break' 'sid-break' 'Breaks: sysvinit (<< 2), sysvinit-core'

21
22
23
24
25
26
27
28
29
30
31
32
33
# one more time, with Protected
insertinstalledpackage 'protected-sysvinit' 'native' '1' 'Protected: yes'

buildsimplenativepackage 'protected-sysvinit' 'native' '2' 'sid' 'Pre-Depends: protected-sysvinit-core | protected-systemd-sysv
Protected: yes'
buildsimplenativepackage 'protected-sysvinit-core' 'native' '2' 'sid'

buildsimplenativepackage 'protected-systemd-sysv' 'native' '2~conflict' 'sid-conflict' 'Conflicts: protected-sysvinit (<< 2)
Breaks: protected-sysvinit-core'

buildsimplenativepackage 'protected-systemd-sysv' 'native' '2~break' 'sid-break' 'Breaks: protected-sysvinit (<< 2), protected-sysvinit-core'


34
35
36
37
38
setupaptarchive

cp -a rootdir/var/lib/dpkg/status dpkg.status.backup

testforcebreak() {
39
40
	package="sid-$1"
	prefix="$2"
41
42
43
44
45
	cp -a dpkg.status.backup rootdir/var/lib/dpkg/status
	rm -f rootdir/var/lib/apt/extended_states
	testfailureequal "Reading package lists...
Building dependency tree...
The following additional packages will be installed:
46
  ${prefix}sysvinit
47
The following NEW packages will be installed:
48
  ${prefix}systemd-sysv
49
The following packages will be upgraded:
50
51
52
53
  ${prefix}sysvinit
1 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
E: This installation run will require temporarily removing the essential package ${prefix}sysvinit:$(getarchitecture 'native') due to a Conflicts/Pre-Depends loop. This is often bad, but if you really want to do it, activate the APT::Force-LoopBreak option.
E: Internal Error, Could not early remove ${prefix}sysvinit:$(dpkg --print-architecture) (2)" aptget install ${prefix}systemd-sysv -t "$package" -s
54
	# ensure that really nothing happens
55
56
57
	testfailure aptget install ${prefix}systemd-sysv -y -t "$package"
	testdpkginstalled "${prefix}sysvinit"
	testdpkgnotinstalled "${prefix}systemd-sysv"
58
59
60

	# with enough force however …
	cp -a dpkg.status.backup rootdir/var/lib/dpkg/status
61
	testsuccess aptget install ${prefix}systemd-sysv -y -t "$package" -o APT::Force-LoopBreak=1 -o Debug::pkgDpkgPm=1
62
	cp rootdir/tmp/testsuccess.output apt.output
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
	if [ "$prefix" = "protected-" ]; then
		testsuccess grep -- "--force-remove-protected --remove ${prefix}sysvinit" apt.output
    else
		testsuccess grep -- "--force-remove-essential --remove ${prefix}sysvinit" apt.output
	fi
	testsuccess aptget install ${prefix}systemd-sysv -y -t "$package" -o APT::Force-LoopBreak=1
	testdpkginstalled "${prefix}sysvinit" "${prefix}systemd-sysv"
}

testforcebreak 'conflict'
testforcebreak 'break'

testnoforcebreak() {
	cp -a dpkg.status.backup rootdir/var/lib/dpkg/status
	rm -f rootdir/var/lib/apt/extended_states
	testequalor2 "Reading package lists...
Building dependency tree...
The following additional packages will be installed:
  protected-sysvinit
The following NEW packages will be installed:
  protected-systemd-sysv
The following packages will be upgraded:
  protected-sysvinit
1 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Inst protected-systemd-sysv (2~$1 sid-$1 [$(getarchitecture 'native')]) [protected-systemd-sysv:$(getarchitecture 'native') on protected-sysvinit:$(getarchitecture 'native')] []
Conf protected-systemd-sysv:$(getarchitecture 'native') broken
 Breaks:protected-sysvinit:$(getarchitecture 'native')
 []
Inst protected-sysvinit [1] (2 sid [$(getarchitecture 'native')])
Conf protected-sysvinit (2 sid [$(getarchitecture 'native')])
E: Conf Broken protected-systemd-sysv:$(getarchitecture 'native')" "Reading package lists...
Building dependency tree...
The following additional packages will be installed:
  protected-sysvinit
The following NEW packages will be installed:
  protected-systemd-sysv
The following packages will be upgraded:
  protected-sysvinit
1 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Remv protected-sysvinit [1]
Inst protected-systemd-sysv (2~conflict sid-conflict [$(getarchitecture 'native')])
Conf protected-systemd-sysv (2~conflict sid-conflict [$(getarchitecture 'native')])
Inst protected-sysvinit [1] (2 sid [$(getarchitecture 'native')])
Conf protected-sysvinit (2 sid [$(getarchitecture 'native')])" aptget install protected-systemd-sysv -t "sid-$1" -s

    # we check with 'real' packages here as the simulation reports a 'Conf broken'
	cp -a dpkg.status.backup rootdir/var/lib/dpkg/status
	testsuccess aptget install protected-systemd-sysv -y -t "sid-$1"
	testdpkginstalled 'protected-sysvinit' 'protected-systemd-sysv'
112
113
}

114
115
testforcebreak 'conflict' 'protected-'
testnoforcebreak 'break'