xbps-create(8): record target file or relative symlinks correctly.

This commit is contained in:
Juan RP 2015-02-18 14:55:54 +01:00
parent 628a344560
commit 3c34c300d1
3 changed files with 34 additions and 2 deletions

2
NEWS
View File

@ -1,5 +1,7 @@
xbps-0.44 (???):
* xbps-create(8): properly detect target of relative symlinks in some cases.
* libxbps: make sure that symlinks with relative target are detected and removed
properly. Fix #78: https://github.com/voidlinux/xbps/issues/78

View File

@ -303,7 +303,8 @@ ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf _u
free(p2);
free(p);
}
} else if (strchr(buf, '/') == NULL) {
} else if (buf[0] != '/') {
/* relative path */
p = strdup(filep);
assert(p);
dname = dirname(p);

View File

@ -19,7 +19,7 @@ hardlinks_size_body() {
cd ..
xbps-rindex -d -a repo/*.xbps
atf_check_equal $? 0
result="$(xbps-query -r root -C empty.conf --repository=$PWD/repo -p installed_size foo)"
result="$(xbps-query -r root --repository=repo -p installed_size foo)"
expected="10B"
rv=0
if [ "$result" != "$expected" ]; then
@ -30,6 +30,35 @@ hardlinks_size_body() {
atf_check_equal $rv 0
}
atf_test_case symlink_relative_target
symlink_relative_target_head() {
atf_set "descr" "xbps-create(8): relative symlinks in destdir must be absolute"
}
symlink_relative_target_body() {
mkdir -p repo pkg_A/usr/include/gsm
touch -f pkg_A/usr/include/gsm/gsm.h
cd pkg_A/usr/include
ln -s gsm/gsm.h gsm.h
cd ../../../repo
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A
atf_check_equal $? 0
cd ..
xbps-rindex -d -a repo/*.xbps
atf_check_equal $? 0
result="$(xbps-query -r root --repository=repo -f foo|tr -d '\n')"
expected="/usr/include/gsm/gsm.h/usr/include/gsm.h -> /usr/include/gsm/gsm.h"
rv=0
if [ "$result" != "$expected" ]; then
echo "result: $result"
echo "expected: $expected"
rv=1
fi
atf_check_equal $rv 0
}
atf_init_test_cases() {
atf_add_test_case hardlinks_size
atf_add_test_case symlink_relative_target
}