Make sure that root symlinks in void are never removed or detected as obsoletes.

Added/improved test cases to detect those conditions work as expected.
This commit is contained in:
Juan RP 2014-03-31 10:16:18 +02:00
parent ab0f928cca
commit 4530c79bb2
5 changed files with 91 additions and 13 deletions

5
NEWS
View File

@ -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-0.34 (2014-03-26):
* xbps-query(8): search mode now accepts -p/--property argument to match patterns * xbps-query(8): search mode now accepts -p/--property argument to match patterns

View File

@ -78,6 +78,17 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
xbps_array_t instfiles, newfiles, obsoletes; xbps_array_t instfiles, newfiles, obsoletes;
xbps_object_t obj, obj2; xbps_object_t obj, obj2;
xbps_string_t oldstr, newstr; 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; const char *oldhash;
char *file; char *file;
int rv = 0; int rv = 0;
@ -148,17 +159,18 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
continue; continue;
} }
/* /*
* Do not add required symlinks for the * Make sure to not remove any symlink of root directory.
* system transition to /usr.
*/ */
if ((strcmp(file, "./bin") == 0) || found = false;
(strcmp(file, "./bin/") == 0) || for (uint8_t x = 0; x < __arraycount(basesymlinks); x++) {
(strcmp(file, "./sbin") == 0) || if (strcmp(file, basesymlinks[x]) == 0) {
(strcmp(file, "./sbin/") == 0) || found = true;
(strcmp(file, "./lib") == 0) || xbps_dbg_printf(xhp, "[obsoletes] ignoring "
(strcmp(file, "./lib/") == 0) || "%s removal\n", file);
(strcmp(file, "./lib64/") == 0) || break;
(strcmp(file, "./lib64") == 0)) { }
}
if (found) {
free(file); free(file);
continue; continue;
} }

View File

@ -98,6 +98,7 @@ remove_pkg_files(struct xbps_handle *xhp,
"/lib", "/lib",
"/lib32", "/lib32",
"/lib64", "/lib64",
"/usr/lib32",
"/usr/lib64", "/usr/lib64",
"/var/run", "/var/run",
}; };

View File

@ -50,6 +50,58 @@ reinstall_obsoletes_body() {
atf_check_equal $rv 0 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_init_test_cases() {
atf_add_test_case reinstall_obsoletes atf_add_test_case reinstall_obsoletes
atf_add_test_case root_symlinks_update
} }

View File

@ -8,12 +8,20 @@ keep_base_symlinks_head() {
} }
keep_base_symlinks_body() { 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/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 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 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 cd some_repo
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A
atf_check_equal $? 0 atf_check_equal $? 0
@ -24,7 +32,7 @@ keep_base_symlinks_body() {
atf_check_equal $? 0 atf_check_equal $? 0
xbps-remove -r root -y foo xbps-remove -r root -y foo
atf_check_equal $? 0 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 rv=0
else else
rv=1 rv=1