Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/pkg
Path: blob/main/tests/frontend/force_reinstall_shlib.sh
4743 views
1
#! /usr/bin/env atf-sh
2
3
. $(atf_get_srcdir)/test_environment.sh
4
5
tests_init \
6
force_install_no_unrelated_reinstall \
7
force_install_no_rdep_removal
8
9
force_install_no_unrelated_reinstall_body() {
10
atf_skip_on Darwin The macOS linker uses different flags
11
12
# Regression test: pkg install -f should not propose to reinstall
13
# unrelated packages whose only connection to the target is via
14
# shlib provides/requires.
15
#
16
# Without the fix in handle_provide, the remote provider would be
17
# added to the universe even when its digest matches the local one,
18
# giving the SAT solver the opportunity to pick the remote and
19
# schedule a spurious reinstall.
20
21
touch empty.c
22
cc -shared -Wl,-soname=libtest.so.1 empty.c -o libtest.so.1
23
ln -s libtest.so.1 libtest.so
24
cc -shared -Wl,-soname=libconsumer.so.1 empty.c -o libconsumer.so.1 -ltest -L.
25
26
# provider: provides libtest.so.1
27
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg provider provider 1 /usr/local
28
cat << EOF >> provider.ucl
29
files: {
30
${TMPDIR}/libtest.so.1: "",
31
}
32
EOF
33
34
# target: links against libtest.so.1 but has NO explicit dep on
35
# provider. The only connection is via shlib require/provide.
36
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg target target 1 /usr/local
37
cat << EOF >> target.ucl
38
files: {
39
${TMPDIR}/libconsumer.so.1: "",
40
}
41
EOF
42
43
# Create packages and repo
44
for p in provider target; do
45
atf_check \
46
-o ignore \
47
-e empty \
48
-s exit:0 \
49
pkg create -M ${p}.ucl
50
done
51
52
atf_check \
53
-o ignore \
54
-e empty \
55
-s exit:0 \
56
pkg repo .
57
58
mkdir reposconf
59
cat << EOF > reposconf/repo.conf
60
local: {
61
url: file:///$TMPDIR,
62
enabled: true
63
}
64
EOF
65
66
# Install both from the repo (digests will match local vs remote)
67
atf_check \
68
-o ignore \
69
-s exit:0 \
70
pkg -o REPOS_DIR="${TMPDIR}/reposconf" -o PKG_CACHEDIR="${TMPDIR}" \
71
install -y provider target
72
73
# Force reinstall target: only target should be reinstalled,
74
# provider must NOT be pulled in.
75
atf_check \
76
-o match:"target-1" \
77
-o not-match:"provider" \
78
-s exit:1 \
79
pkg -o REPOS_DIR="${TMPDIR}/reposconf" -o PKG_CACHEDIR="${TMPDIR}" \
80
install -fn target
81
}
82
83
force_install_no_rdep_removal_body() {
84
# Regression test for issue #2566: pkg install -f of a package
85
# that many other packages depend on should NOT propose to remove
86
# those reverse dependencies.
87
88
# base: the package we will force-reinstall
89
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg base base 1 /usr/local
90
91
# rdep1, rdep2: packages that depend on base
92
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg rdep1 rdep1 1 /usr/local
93
cat << EOF >> rdep1.ucl
94
deps: {
95
base: {
96
origin: "base",
97
version: "1"
98
}
99
}
100
EOF
101
102
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg rdep2 rdep2 1 /usr/local
103
cat << EOF >> rdep2.ucl
104
deps: {
105
base: {
106
origin: "base",
107
version: "1"
108
}
109
}
110
EOF
111
112
# Create packages and repo
113
for p in base rdep1 rdep2; do
114
atf_check \
115
-o ignore \
116
-e empty \
117
-s exit:0 \
118
pkg create -M ${p}.ucl
119
done
120
121
atf_check \
122
-o ignore \
123
-e empty \
124
-s exit:0 \
125
pkg repo .
126
127
mkdir reposconf
128
cat << EOF > reposconf/repo.conf
129
local: {
130
url: file:///$TMPDIR,
131
enabled: true
132
}
133
EOF
134
135
# Install all three packages
136
atf_check \
137
-o ignore \
138
-s exit:0 \
139
pkg -o REPOS_DIR="${TMPDIR}/reposconf" -o PKG_CACHEDIR="${TMPDIR}" \
140
install -y base rdep1 rdep2
141
142
# Force reinstall base: rdep1 and rdep2 must NOT be removed
143
atf_check \
144
-o match:"base" \
145
-o not-match:"REMOVED" \
146
-o not-match:"rdep1" \
147
-o not-match:"rdep2" \
148
-s exit:1 \
149
pkg -o REPOS_DIR="${TMPDIR}/reposconf" -o PKG_CACHEDIR="${TMPDIR}" \
150
install -fn base
151
}
152
153