diff --git a/NEWS b/NEWS index 7253a228..10c764e6 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +xbps-0.35 (???): + + * Make sure that required root symlinks in void are never removed or detected + as obsoletes; added new test cases to stress the code works as expected. + xbps-0.34 (2014-03-26): * xbps-query(8): search mode now accepts -p/--property argument to match patterns diff --git a/lib/package_find_obsoletes.c b/lib/package_find_obsoletes.c index 4d318e1e..3bc9b4af 100644 --- a/lib/package_find_obsoletes.c +++ b/lib/package_find_obsoletes.c @@ -78,6 +78,17 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp, xbps_array_t instfiles, newfiles, obsoletes; xbps_object_t obj, obj2; xbps_string_t oldstr, newstr; + /* These are symlinks in Void and must not be removed */ + const char *basesymlinks[] = { + "./bin", + "./sbin", + "./lib", + "./lib32", + "./lib64", + "./usr/lib32", + "./usr/lib64", + "./var/run", + }; const char *oldhash; char *file; int rv = 0; @@ -148,17 +159,18 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp, continue; } /* - * Do not add required symlinks for the - * system transition to /usr. + * Make sure to not remove any symlink of root directory. */ - if ((strcmp(file, "./bin") == 0) || - (strcmp(file, "./bin/") == 0) || - (strcmp(file, "./sbin") == 0) || - (strcmp(file, "./sbin/") == 0) || - (strcmp(file, "./lib") == 0) || - (strcmp(file, "./lib/") == 0) || - (strcmp(file, "./lib64/") == 0) || - (strcmp(file, "./lib64") == 0)) { + found = false; + for (uint8_t x = 0; x < __arraycount(basesymlinks); x++) { + if (strcmp(file, basesymlinks[x]) == 0) { + found = true; + xbps_dbg_printf(xhp, "[obsoletes] ignoring " + "%s removal\n", file); + break; + } + } + if (found) { free(file); continue; } diff --git a/lib/package_remove.c b/lib/package_remove.c index 1dcf750b..70e4b311 100644 --- a/lib/package_remove.c +++ b/lib/package_remove.c @@ -98,6 +98,7 @@ remove_pkg_files(struct xbps_handle *xhp, "/lib", "/lib32", "/lib64", + "/usr/lib32", "/usr/lib64", "/var/run", }; diff --git a/tests/xbps/libxbps/shell/obsoletefiles_test.sh b/tests/xbps/libxbps/shell/obsoletefiles_test.sh index 09523392..74b8573f 100644 --- a/tests/xbps/libxbps/shell/obsoletefiles_test.sh +++ b/tests/xbps/libxbps/shell/obsoletefiles_test.sh @@ -50,6 +50,58 @@ reinstall_obsoletes_body() { atf_check_equal $rv 0 } +# 2- make sure that root symlinks aren't detected as obsoletes on upgrades. +atf_test_case root_symlinks_update + +root_symlinks_update_head() { + atf_set "descr" "Test that root symlinks aren't obsoletes on update" +} + +root_symlinks_update_body() { + mkdir repo + mkdir -p pkg_A/usr/bin pkg_A/usr/sbin pkg_A/usr/lib pkg_A/var pkg_A/run + touch -f pkg_A/usr/bin/foo + ln -sfr pkg_A/usr/bin pkg_A/bin + ln -sfr pkg_A/usr/sbin pkg_A/sbin + ln -sfr pkg_A/usr/lib pkg_A/usr/lib32 + ln -sfr pkg_A/usr/lib pkg_A/usr/lib64 + ln -sfr pkg_A/run pkg_A/var/run + + cd repo + xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A + atf_check_equal $? 0 + rm -rf ../pkg_A + xbps-rindex -a *.xbps + atf_check_equal $? 0 + + xbps-install -r root -C null.conf --repository=$PWD -yd foo + atf_check_equal $? 0 + + cd .. + mkdir -p pkg_A/usr/bin + touch -f pkg_A/usr/bin/blah + + cd repo + xbps-create -A noarch -n foo-1.1_1 -s "foo pkg" ../pkg_A + atf_check_equal $? 0 + rm -rf ../pkg_A + xbps-rindex -a *.xbps + atf_check_equal $? 0 + + xbps-install -r root -C null.conf --repository=$PWD -yuvd foo + atf_check_equal $? 0 + + rv=1 + if [ -h root/bin -a -h root/sbin -a -h root/usr/lib32 -a -h root/usr/lib64 -a -h root/var/run ]; then + rv=0 + fi + ls -l root + ls -l root/usr + ls -l root/var + atf_check_equal $rv 0 +} + atf_init_test_cases() { atf_add_test_case reinstall_obsoletes + atf_add_test_case root_symlinks_update } diff --git a/tests/xbps/libxbps/shell/remove_test.sh b/tests/xbps/libxbps/shell/remove_test.sh index 1c793e71..2212ecd3 100644 --- a/tests/xbps/libxbps/shell/remove_test.sh +++ b/tests/xbps/libxbps/shell/remove_test.sh @@ -8,12 +8,20 @@ keep_base_symlinks_head() { } keep_base_symlinks_body() { - mkdir -p root/usr/bin + mkdir -p root/usr/bin root/usr/lib root/run root/var ln -sfr root/usr/bin root/bin + ln -sfr root/usr/lib root/lib + ln -sfr root/usr/lib root/usr/lib32 + ln -sfr root/usr/lib root/usr/lib64 + ln -sfr root/run root/var/run mkdir some_repo - mkdir -p pkg_A/usr/bin pkg_A/bin + mkdir -p pkg_A/usr/bin pkg_A/bin pkg_A/usr/lib pkg_A/var touch -f pkg_A/usr/bin/foo + ln -sfr pkg_A/usr/lib pkg_A/usr/lib32 + ln -sfr pkg_A/usr/lib pkg_A/usr/lib64 + ln -sfr /run pkg_A/var/run + cd some_repo xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A atf_check_equal $? 0 @@ -24,7 +32,7 @@ keep_base_symlinks_body() { atf_check_equal $? 0 xbps-remove -r root -y foo atf_check_equal $? 0 - if [ -h root/bin ]; then + if [ -h root/bin -a -h root/lib -a -h root/usr/lib32 -a -h root/usr/lib64 -a -h root/var/run ]; then rv=0 else rv=1