Stop converting relative symlinks to absolute.
There's no reason to make them absolute, simply store in the metadata the target file as is. This vastly simplifies the code and makes all test pass correctly.
This commit is contained in:
1 parent
2f9dd7237b
commit
9ae3638429
7 files changed
+20
-105
No files matched your search
@@ -213,7 +213,7 @@ remove_pkg_files(struct xbps_handle *xhp,
|
||||
|
||||
xbps_dictionary_get_cstring_nocopy(obj, "target", &target);
|
||||
assert(target);
|
||||
lnk = xbps_symlink_target(xhp, path, target);
|
||||
lnk = xbps_symlink_target(path);
|
||||
if (lnk == NULL) {
|
||||
xbps_dbg_printf(xhp, "[remove] %s "
|
||||
"symlink_target: %s\n", path, strerror(errno));
|
||||
|
||||
+3
-45
@@ -454,10 +454,10 @@ xbps_sanitize_path(const char *src)
|
||||
}
|
||||
|
||||
char *
|
||||
xbps_symlink_target(struct xbps_handle *xhp, const char *path, const char *tgt)
|
||||
xbps_symlink_target(const char *path)
|
||||
{
|
||||
struct stat sb;
|
||||
char *p, *p1, *dname, *res = NULL, *lnk = NULL;
|
||||
char *lnk = NULL;
|
||||
ssize_t r;
|
||||
|
||||
if (lstat(path, &sb) == -1)
|
||||
@@ -472,47 +472,5 @@ xbps_symlink_target(struct xbps_handle *xhp, const char *path, const char *tgt)
|
||||
return NULL;
|
||||
}
|
||||
lnk[sb.st_size] = '\0';
|
||||
|
||||
if (tgt[0] != '/') {
|
||||
/*
|
||||
* target file is relative and wasn't converted to absolute by
|
||||
* xbps-create(8), just compare it as is.
|
||||
*/
|
||||
return lnk;
|
||||
}
|
||||
|
||||
if (strstr(lnk, "./") || lnk[0] != '/') {
|
||||
/* relative */
|
||||
p = strdup(path);
|
||||
assert(p);
|
||||
dname = dirname(p);
|
||||
assert(dname);
|
||||
p = xbps_xasprintf("%s/%s", dname, lnk);
|
||||
assert(p);
|
||||
p1 = xbps_sanitize_path(p);
|
||||
assert(p1);
|
||||
free(p);
|
||||
if ((strstr(p1, "./")) && (p = realpath(p1, NULL))) {
|
||||
if (strcmp(xhp->rootdir, "/") == 0)
|
||||
res = strdup(p);
|
||||
else
|
||||
res = strdup(p + strlen(xhp->rootdir));
|
||||
|
||||
free(p);
|
||||
}
|
||||
if (res == NULL) {
|
||||
if (strcmp(xhp->rootdir, "/") == 0)
|
||||
res = strdup(p1);
|
||||
else
|
||||
res = strdup(p1 + strlen(xhp->rootdir));
|
||||
}
|
||||
assert(res);
|
||||
free(lnk);
|
||||
free(p1);
|
||||
} else {
|
||||
/* absolute */
|
||||
res = lnk;
|
||||
}
|
||||
|
||||
return res;
|
||||
return lnk;
|
||||
}
|
||||
Reference in new issue
Block a user