xbps: merge another patch for 'xbps-bin(8) check' from git.
This commit is contained in:
parent
6647b7cf86
commit
dea8588762
4 changed files with 133 additions and 40 deletions
|
@ -0,0 +1,45 @@
|
||||||
|
From 42c21e1c3c0fbc98b56bedbc63022c5e086feb40 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Juan RP <xtraeme@gmail.com>
|
||||||
|
Date: Thu, 4 Oct 2012 09:40:52 +0200
|
||||||
|
Subject: [PATCH 1/4] xbps-create: if a symlink points to an unexistent file
|
||||||
|
store symlink target as is.
|
||||||
|
|
||||||
|
Seen in recent builds when building the systemd binpkg:
|
||||||
|
|
||||||
|
[chroot] => Building systemd-194_1.x86_64.xbps...
|
||||||
|
xbps-create.real: main.c:219: ftw_cb: Assertion `p' failed.
|
||||||
|
|
||||||
|
Which was asserting in a symlink that was pointing to a file provided by the udev
|
||||||
|
pkg, therefore realpath(3) failed.
|
||||||
|
---
|
||||||
|
bin/xbps-create/main.c | 14 +++++++++++---
|
||||||
|
1 file changed, 11 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/bin/xbps-create/main.c b/bin/xbps-create/main.c
|
||||||
|
index 2a098ca..beb79df 100644
|
||||||
|
--- a/bin/xbps-create/main.c
|
||||||
|
+++ b/bin/xbps-create/main.c
|
||||||
|
@@ -216,9 +216,17 @@ ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf)
|
||||||
|
*/
|
||||||
|
if (strncmp(buf, "../", 3) == 0) {
|
||||||
|
p = realpath(fpath, NULL);
|
||||||
|
- assert(p);
|
||||||
|
- xe->target = strdup(p + strlen(destdir));
|
||||||
|
- free(p);
|
||||||
|
+ if (p == NULL) {
|
||||||
|
+ /*
|
||||||
|
+ * This symlink points to an unexistent file,
|
||||||
|
+ * which might be provided in another package.
|
||||||
|
+ * So let's use the same target.
|
||||||
|
+ */
|
||||||
|
+ xe->target = strdup(buf);
|
||||||
|
+ } else {
|
||||||
|
+ xe->target = strdup(p + strlen(destdir));
|
||||||
|
+ free(p);
|
||||||
|
+ }
|
||||||
|
} else if (strchr(buf, '/') == NULL) {
|
||||||
|
p = strdup(filep);
|
||||||
|
assert(p);
|
||||||
|
--
|
||||||
|
1.7.12.2
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
From d59ad72ee4f05ea46b35984e8346158634041e38 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Juan RP <xtraeme@gmail.com>
|
||||||
|
Date: Thu, 4 Oct 2012 12:05:04 +0200
|
||||||
|
Subject: [PATCH 3/4] xbps-bin(8): the 'check' target now handles symlinks
|
||||||
|
correctly.
|
||||||
|
|
||||||
|
---
|
||||||
|
NEWS | 3 +++
|
||||||
|
bin/xbps-bin/check_pkg_symlinks.c | 38 ++++++++++++++++++++++++--------------
|
||||||
|
2 files changed, 27 insertions(+), 14 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/bin/xbps-bin/check_pkg_symlinks.c b/bin/xbps-bin/check_pkg_symlinks.c
|
||||||
|
index a5369f0..125c0d4 100644
|
||||||
|
--- a/bin/xbps-bin/check_pkg_symlinks.c
|
||||||
|
+++ b/bin/xbps-bin/check_pkg_symlinks.c
|
||||||
|
@@ -30,6 +30,7 @@
|
||||||
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
+#include <libgen.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
|
#include <xbps_api.h>
|
||||||
|
@@ -55,7 +56,7 @@ check_pkg_symlinks(struct xbps_handle *xhp,
|
||||||
|
prop_object_iterator_t iter;
|
||||||
|
prop_dictionary_t pkg_filesd = arg;
|
||||||
|
const char *file, *tgt = NULL;
|
||||||
|
- char *path, buf[PATH_MAX];
|
||||||
|
+ char *path, *buf, *buf2, *buf3, *dname, *path_target;
|
||||||
|
bool broken = false, test_broken = false;
|
||||||
|
|
||||||
|
(void)pkgdb_update;
|
||||||
|
@@ -80,28 +81,37 @@ check_pkg_symlinks(struct xbps_handle *xhp,
|
||||||
|
if (path == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
- memset(&buf, 0, sizeof(buf));
|
||||||
|
- if (realpath(path, buf) == NULL) {
|
||||||
|
+ if ((buf = realpath(path, NULL)) == NULL) {
|
||||||
|
xbps_error_printf("%s: broken symlink `%s': "
|
||||||
|
"%s\n", pkgname, file, strerror(errno));
|
||||||
|
test_broken = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
-
|
||||||
|
- free(path);
|
||||||
|
- if (strcmp(xhp->rootdir, "/") &&
|
||||||
|
- strstr(buf, xhp->rootdir))
|
||||||
|
- path = buf + strlen(xhp->rootdir);
|
||||||
|
- else
|
||||||
|
- path = buf;
|
||||||
|
-
|
||||||
|
- if (strcmp(path, tgt)) {
|
||||||
|
+ if (strncmp(tgt, "../", 3) == 0) {
|
||||||
|
+ /* relative symlink target */
|
||||||
|
+ dname = dirname(path);
|
||||||
|
+ buf2 = xbps_xasprintf("%s/%s", dname, tgt);
|
||||||
|
+ assert(buf2);
|
||||||
|
+ buf3 = realpath(buf2, NULL);
|
||||||
|
+ assert(buf3);
|
||||||
|
+ free(buf2);
|
||||||
|
+ path_target = buf3;
|
||||||
|
+ } else {
|
||||||
|
+ path_target = buf;
|
||||||
|
+ }
|
||||||
|
+ if (strcmp(buf, path_target)) {
|
||||||
|
xbps_error_printf("%s: modified symlink `%s' "
|
||||||
|
"points to: `%s' (shall be: `%s')\n",
|
||||||
|
- pkgname, file, path, tgt);
|
||||||
|
+ pkgname, file, buf, path_target);
|
||||||
|
test_broken = true;
|
||||||
|
}
|
||||||
|
- path = NULL;
|
||||||
|
+ free(buf);
|
||||||
|
+ free(path);
|
||||||
|
+ if (buf3)
|
||||||
|
+ free(buf3);
|
||||||
|
+
|
||||||
|
+ path = buf = buf2 = buf3 = NULL;
|
||||||
|
+
|
||||||
|
}
|
||||||
|
prop_object_iterator_release(iter);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
1.7.12.2
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
commit 42c21e1c3c0fbc98b56bedbc63022c5e086feb40
|
|
||||||
Author: Juan RP <xtraeme@gmail.com>
|
|
||||||
Date: Thu Oct 4 09:40:52 2012 +0200
|
|
||||||
|
|
||||||
xbps-create: if a symlink points to an unexistent file store symlink target as is.
|
|
||||||
|
|
||||||
Seen in recent builds when building the systemd binpkg:
|
|
||||||
|
|
||||||
[chroot] => Building systemd-194_1.x86_64.xbps...
|
|
||||||
xbps-create.real: main.c:219: ftw_cb: Assertion `p' failed.
|
|
||||||
|
|
||||||
Which was asserting in a symlink that was pointing to a file provided by the udev
|
|
||||||
pkg, therefore realpath(3) failed.
|
|
||||||
|
|
||||||
diff --git a/bin/xbps-create/main.c b/bin/xbps-create/main.c
|
|
||||||
index 2a098ca..beb79df 100644
|
|
||||||
--- bin/xbps-create/main.c
|
|
||||||
+++ bin/xbps-create/main.c
|
|
||||||
@@ -216,9 +216,17 @@ ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf)
|
|
||||||
*/
|
|
||||||
if (strncmp(buf, "../", 3) == 0) {
|
|
||||||
p = realpath(fpath, NULL);
|
|
||||||
- assert(p);
|
|
||||||
- xe->target = strdup(p + strlen(destdir));
|
|
||||||
- free(p);
|
|
||||||
+ if (p == NULL) {
|
|
||||||
+ /*
|
|
||||||
+ * This symlink points to an unexistent file,
|
|
||||||
+ * which might be provided in another package.
|
|
||||||
+ * So let's use the same target.
|
|
||||||
+ */
|
|
||||||
+ xe->target = strdup(buf);
|
|
||||||
+ } else {
|
|
||||||
+ xe->target = strdup(p + strlen(destdir));
|
|
||||||
+ free(p);
|
|
||||||
+ }
|
|
||||||
} else if (strchr(buf, '/') == NULL) {
|
|
||||||
p = strdup(filep);
|
|
||||||
assert(p);
|
|
|
@ -1,7 +1,8 @@
|
||||||
# Template file for 'xbps'
|
# Template file for 'xbps'
|
||||||
pkgname=xbps
|
pkgname=xbps
|
||||||
version=0.17
|
version=0.17
|
||||||
revision=2
|
revision=3
|
||||||
|
patch_args="-Np1"
|
||||||
build_style=configure
|
build_style=configure
|
||||||
configure_args="--prefix=/ --exec-prefix=/usr --sbindir=/usr/sbin --with-tests --with-static"
|
configure_args="--prefix=/ --exec-prefix=/usr --sbindir=/usr/sbin --with-tests --with-static"
|
||||||
depends="xbps-triggers"
|
depends="xbps-triggers"
|
||||||
|
|
Loading…
Reference in a new issue