libxbps: make sure to remove pkg metadata file on upgrades with skip-obsoletes.

This fixes the following case:

 - A-1.0_1 is installed and owns bin/foo.
 - A-1.1_1 is in the transaction and depends on B-1.0_1 that owns bin/foo.
 - B-1.0_1 is in the transaction and replaces A<1.1_1.
 - A-1.1_1 in the transaction now has "skip-obsoletes".
 - A is updated to 1.1_1, its metadata file (<pkgname>-files.plist) wasn't removed.

Added two new test cases to verify moving files from/to a dependency.
This commit is contained in:
Juan RP 2015-01-27 17:53:37 +01:00
parent f324ea5352
commit 571d96fa92
3 changed files with 53 additions and 6 deletions

4
NEWS
View File

@ -1,5 +1,9 @@
xbps-0.44 (???): xbps-0.44 (???):
* libxbps: make sure to remove the pkg metadata file if a pkg upgrade does not
own any file and a dependency replaces it due to moving files between them.
Added two new test cases to verify its correctness.
* xbps-query(8): --regex option now matches EREs in case insensitive mode. * xbps-query(8): --regex option now matches EREs in case insensitive mode.
* libxbps: globally check for unresolved shared libraries before accepting * libxbps: globally check for unresolved shared libraries before accepting

View File

@ -478,6 +478,7 @@ unpack_archive(struct xbps_handle *xhp,
xbps_object_release(obj); xbps_object_release(obj);
} }
xbps_object_release(pkg_filesd); xbps_object_release(pkg_filesd);
out:
/* /*
* If unpacked pkg has no files, remove its files metadata plist. * If unpacked pkg has no files, remove its files metadata plist.
*/ */
@ -486,7 +487,6 @@ unpack_archive(struct xbps_handle *xhp,
unlink(buf); unlink(buf);
free(buf); free(buf);
} }
out:
if (xbps_object_type(binpkg_filesd) == XBPS_TYPE_DICTIONARY) if (xbps_object_type(binpkg_filesd) == XBPS_TYPE_DICTIONARY)
xbps_object_release(binpkg_filesd); xbps_object_release(binpkg_filesd);
if (pkgname != NULL) if (pkgname != NULL)

View File

@ -101,13 +101,13 @@ root_symlinks_update_body() {
atf_check_equal $rv 0 atf_check_equal $rv 0
} }
atf_test_case files_move atf_test_case files_move_from_dependency
files_move_head() { files_move_from_dependency_head() {
atf_set "descr" "Test that moving files between pkgs work" atf_set "descr" "Test that moving files between a dependency to the main pkg works"
} }
files_move_body() { files_move_from_dependency_body() {
mkdir repo mkdir repo
mkdir -p pkg_A/usr/bin pkg_A/usr/sbin pkg_B/usr/sbin mkdir -p pkg_A/usr/bin pkg_A/usr/sbin pkg_B/usr/sbin
echo "0123456789" > pkg_A/usr/bin/foo echo "0123456789" > pkg_A/usr/bin/foo
@ -146,8 +146,51 @@ files_move_body() {
atf_check_equal $? 0 atf_check_equal $? 0
} }
atf_test_case files_move_to_dependency
files_move_to_dependency_head() {
atf_set "descr" "Test that moving files to a dependency works"
}
files_move_to_dependency_body() {
mkdir repo
mkdir -p pkg_libressl/usr/lib pkg_libcrypto/usr/lib
echo "0123456789" > pkg_libressl/usr/lib/libcrypto.so.30
echo "0123456789" > pkg_libcrypto/usr/lib/libcrypto.so.30
cd repo
xbps-create -A noarch -n libressl-1.0_1 -s "libressl pkg" ../pkg_libressl
atf_check_equal $? 0
xbps-create -A noarch -n libcrypto-1.0_1 -s "libcrypto pkg" --replaces "libressl<1.1_1" ../pkg_libcrypto
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
xbps-install -r root --repository=$PWD -yvd libressl
atf_check_equal $? 0
rm -rf ../pkg_libressl/*
xbps-create -A noarch -n libressl-1.1_1 -s "libressl pkg" --dependencies "libcrypto>=1.0" ../pkg_libressl
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
xbps-install -r root --repository=$PWD -yuvd
atf_check_equal $? 0
foofile=$(xbps-query -r root -f libressl|grep crypto)
atf_check_equal $foofile ""
foofile=$(xbps-query -r root -f libcrypto|grep crypto)
atf_check_equal $foofile /usr/lib/libcrypto.so.30
xbps-pkgdb -r root -av
atf_check_equal $? 0
}
atf_init_test_cases() { atf_init_test_cases() {
atf_add_test_case reinstall_obsoletes atf_add_test_case reinstall_obsoletes
atf_add_test_case root_symlinks_update atf_add_test_case root_symlinks_update
atf_add_test_case files_move atf_add_test_case files_move_from_dependency
atf_add_test_case files_move_to_dependency
} }