Skip to content

Commit c11dba0

Browse files
committed
lib: preserve: don't delete file's on package removal
The old behaviour was to only respect `preserve` on package updates. This leads to issues where `vkpurge` would not be able to remove other files not part of a kernel package when an obsolete kernel package was removed using `xbps-remove -o`. So for consistency `preserve` in a packages properties always means `preserve`.
1 parent c4e54ec commit c11dba0

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

lib/transaction_files.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ collect_obsoletes(struct xbps_handle *xhp)
247247
* new package.
248248
* Probably obsolete.
249249
*/
250-
if (item->old.preserve && item->old.update) {
250+
if (item->old.preserve) {
251251
xbps_dbg_printf("[files] %s: skipping `preserve` %s: %s\n",
252252
item->old.pkgver, typestr(item->old.type), item->file);
253253
continue;

tests/xbps/libxbps/shell/preserve_test.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,60 @@ preserve_update_conflict_body() {
8585
atf_check_equal $? 0
8686
}
8787

88+
atf_test_case preserve_remove
89+
90+
preserve_remove_head() {
91+
atf_set "descr" "Tests for pkg removal with preserve"
92+
}
93+
94+
preserve_remove_body() {
95+
mkdir some_repo
96+
mkdir -p pkg_A/1.0
97+
echo "blahblah" > pkg_A/1.0/blah
98+
echo "foofoo" > pkg_A/1.0/foo
99+
100+
cd some_repo
101+
xbps-create -A noarch -n A-1.0_1 -s "A pkg" --preserve ../pkg_A
102+
atf_check_equal $? 0
103+
xbps-rindex -d -a $PWD/*.xbps
104+
atf_check_equal $? 0
105+
cd ..
106+
107+
xbps-install -r root --repository=$PWD/some_repo -yd A
108+
atf_check_equal $? 0
109+
110+
cd some_repo
111+
mv ../pkg_A/1.0 ../pkg_A/1.1
112+
rm -f *.xbps
113+
xbps-create -A noarch -n A-1.1_1 -s "A pkg" --preserve ../pkg_A
114+
atf_check_equal $? 0
115+
xbps-rindex -d -a $PWD/*.xbps
116+
atf_check_equal $? 0
117+
cd ..
118+
119+
xbps-install -r root --repository=$PWD/some_repo -yd A
120+
atf_check_equal $? 0
121+
122+
rv=0
123+
[ -e root/1.0/blah -a -e root/1.0/blah ] || rv=1
124+
[ -e root/1.1/blah -a -e root/1.1/blah ] || rv=2
125+
atf_check_equal $rv 0
126+
127+
xbps-remove -r root -yd A
128+
atf_check_equal $? 0
129+
130+
rv=0
131+
[ -e root/1.0/blah -a -e root/1.0/blah ] || rv=1
132+
[ -e root/1.1/blah -a -e root/1.1/blah ] || rv=2
133+
atf_check_equal $rv 0
134+
135+
xbps-pkgdb -r root -av
136+
atf_check_equal $? 0
137+
}
138+
139+
88140
atf_init_test_cases() {
89141
atf_add_test_case preserve_update
90142
atf_add_test_case preserve_update_conflict
143+
atf_add_test_case preserve_remove
91144
}

0 commit comments

Comments
 (0)