xbps-alternatives: dangling symlinks are now supported.
This commit is contained in:
parent
8c5878bff6
commit
9b0cde3267
3
NEWS
3
NEWS
@ -1,5 +1,8 @@
|
|||||||
xbps-0.50 (???):
|
xbps-0.50 (???):
|
||||||
|
|
||||||
|
* xbps-alternatives(1): dangling symlinks are now supported, because the
|
||||||
|
target directory is always created.
|
||||||
|
|
||||||
* Updated zsh completions, by Steve Prybylski.
|
* Updated zsh completions, by Steve Prybylski.
|
||||||
|
|
||||||
* xbps-checkvers(1): Joey Gouly fixed bug #120
|
* xbps-checkvers(1): Joey Gouly fixed bug #120
|
||||||
|
@ -102,6 +102,7 @@ create_symlinks(struct xbps_handle *xhp, xbps_array_t a, const char *grname)
|
|||||||
cnt = xbps_array_count(a);
|
cnt = xbps_array_count(a);
|
||||||
for (i = 0; i < cnt; i++) {
|
for (i = 0; i < cnt; i++) {
|
||||||
xbps_string_t str;
|
xbps_string_t str;
|
||||||
|
char *tgt_dup, *tgt_dir;
|
||||||
char *l, *lnk, *tgt = NULL;
|
char *l, *lnk, *tgt = NULL;
|
||||||
const char *tgt0;
|
const char *tgt0;
|
||||||
int rv;
|
int rv;
|
||||||
@ -111,11 +112,15 @@ create_symlinks(struct xbps_handle *xhp, xbps_array_t a, const char *grname)
|
|||||||
assert(l);
|
assert(l);
|
||||||
tgt0 = right(xbps_string_cstring_nocopy(str));
|
tgt0 = right(xbps_string_cstring_nocopy(str));
|
||||||
assert(tgt0);
|
assert(tgt0);
|
||||||
|
/* always create target dir, for dangling symlinks */
|
||||||
|
tgt_dup = strdup(tgt0);
|
||||||
|
assert(tgt_dup);
|
||||||
|
tgt_dir = dirname(tgt_dup);
|
||||||
|
tgt = xbps_xasprintf("%s%s", xhp->rootdir, tgt_dir);
|
||||||
|
xbps_mkpath(tgt, 0755);
|
||||||
|
free(tgt);
|
||||||
|
|
||||||
if (l[0] != '/') {
|
if (l[0] != '/') {
|
||||||
char *tgt_dup, *tgt_dir;
|
|
||||||
tgt_dup = strdup(tgt0);
|
|
||||||
assert(tgt_dup);
|
|
||||||
tgt_dir = dirname(tgt_dup);
|
|
||||||
lnk = xbps_xasprintf("%s%s/%s", xhp->rootdir, tgt_dir, l);
|
lnk = xbps_xasprintf("%s%s/%s", xhp->rootdir, tgt_dir, l);
|
||||||
free(tgt_dup);
|
free(tgt_dup);
|
||||||
tgt_dup = strdup(tgt0);
|
tgt_dup = strdup(tgt0);
|
||||||
@ -123,6 +128,7 @@ create_symlinks(struct xbps_handle *xhp, xbps_array_t a, const char *grname)
|
|||||||
tgt = strdup(basename(tgt_dup));
|
tgt = strdup(basename(tgt_dup));
|
||||||
free(tgt_dup);
|
free(tgt_dup);
|
||||||
} else {
|
} else {
|
||||||
|
free(tgt_dup);
|
||||||
tgt = strdup(tgt0);
|
tgt = strdup(tgt0);
|
||||||
lnk = xbps_xasprintf("%s%s", xhp->rootdir, l);
|
lnk = xbps_xasprintf("%s%s", xhp->rootdir, l);
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,42 @@ register_one_body() {
|
|||||||
atf_check_equal $rv 0
|
atf_check_equal $rv 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atf_test_case register_one_dangling
|
||||||
|
|
||||||
|
register_one_dangling_head() {
|
||||||
|
atf_set "descr" "xbps-alternatives: register one pkg with an alternative dangling symlink"
|
||||||
|
}
|
||||||
|
register_one_dangling_body() {
|
||||||
|
mkdir -p repo pkg_A/usr/bin
|
||||||
|
cd repo
|
||||||
|
xbps-create -A noarch -n A-1.1_1 -s "A pkg" --alternatives "file:/usr/bin/file:/usr/bin/fileA file2:file2:/usr/include/fileB" ../pkg_A
|
||||||
|
atf_check_equal $? 0
|
||||||
|
xbps-rindex -d -a $PWD/*.xbps
|
||||||
|
atf_check_equal $? 0
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
xbps-install -r root --repository=repo -ydv A
|
||||||
|
atf_check_equal $? 0
|
||||||
|
rv=1
|
||||||
|
if [ -h root/usr/bin/file ]; then
|
||||||
|
lnk=$(readlink root/usr/bin/file)
|
||||||
|
if [ "$lnk" = "/usr/bin/fileA" ]; then
|
||||||
|
rv=0
|
||||||
|
fi
|
||||||
|
echo "A lnk: $lnk"
|
||||||
|
fi
|
||||||
|
atf_check_equal $rv 0
|
||||||
|
rv=1
|
||||||
|
if [ -h root/usr/include/file2 ]; then
|
||||||
|
lnk=$(readlink root/usr/include/file2)
|
||||||
|
if [ "$lnk" = "fileB" ]; then
|
||||||
|
rv=0
|
||||||
|
fi
|
||||||
|
echo "A lnk: $lnk"
|
||||||
|
fi
|
||||||
|
atf_check_equal $rv 0
|
||||||
|
}
|
||||||
|
|
||||||
atf_test_case register_one_relative
|
atf_test_case register_one_relative
|
||||||
|
|
||||||
register_one_relative_head() {
|
register_one_relative_head() {
|
||||||
@ -339,6 +375,7 @@ set_pkg_group_body() {
|
|||||||
|
|
||||||
atf_init_test_cases() {
|
atf_init_test_cases() {
|
||||||
atf_add_test_case register_one
|
atf_add_test_case register_one
|
||||||
|
atf_add_test_case register_one_dangling
|
||||||
atf_add_test_case register_one_relative
|
atf_add_test_case register_one_relative
|
||||||
atf_add_test_case register_dups
|
atf_add_test_case register_dups
|
||||||
atf_add_test_case register_multi
|
atf_add_test_case register_multi
|
||||||
|
Loading…
Reference in New Issue
Block a user