Revert "Stop converting relative symlinks to absolute."
This reverts commit 9ae3638429.
This change is ok, but cannot be used right now because all existing
binpkgs were created with an old xbps-create(8).
This commit is contained in:
@@ -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(path);
|
||||
lnk = xbps_symlink_target(xhp, path, target);
|
||||
if (lnk == NULL) {
|
||||
xbps_dbg_printf(xhp, "[remove] %s "
|
||||
"symlink_target: %s\n", path, strerror(errno));
|
||||
|
||||
48
lib/util.c
48
lib/util.c
@@ -454,10 +454,10 @@ xbps_sanitize_path(const char *src)
|
||||
}
|
||||
|
||||
char *
|
||||
xbps_symlink_target(const char *path)
|
||||
xbps_symlink_target(struct xbps_handle *xhp, const char *path, const char *tgt)
|
||||
{
|
||||
struct stat sb;
|
||||
char *lnk = NULL;
|
||||
char *p, *p1, *dname, *res = NULL, *lnk = NULL;
|
||||
ssize_t r;
|
||||
|
||||
if (lstat(path, &sb) == -1)
|
||||
@@ -472,5 +472,47 @@ xbps_symlink_target(const char *path)
|
||||
return NULL;
|
||||
}
|
||||
lnk[sb.st_size] = '\0';
|
||||
return lnk;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user