From dea85887622458583cd6628bda280d90f81ec71f Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 4 Oct 2012 14:29:36 +0200 Subject: [PATCH] xbps: merge another patch for 'xbps-bin(8) check' from git. --- ...-symlink-points-to-an-unexistent-fil.patch | 45 ++++++++++ ...heck-target-now-handles-symlinks-cor.patch | 86 +++++++++++++++++++ ...ate-unexistent-target-symlink-assert.patch | 39 --------- srcpkgs/xbps/template | 3 +- 4 files changed, 133 insertions(+), 40 deletions(-) create mode 100644 srcpkgs/xbps/patches/0001-xbps-create-if-a-symlink-points-to-an-unexistent-fil.patch create mode 100644 srcpkgs/xbps/patches/0003-xbps-bin-8-the-check-target-now-handles-symlinks-cor.patch delete mode 100644 srcpkgs/xbps/patches/xbps-create-unexistent-target-symlink-assert.patch diff --git a/srcpkgs/xbps/patches/0001-xbps-create-if-a-symlink-points-to-an-unexistent-fil.patch b/srcpkgs/xbps/patches/0001-xbps-create-if-a-symlink-points-to-an-unexistent-fil.patch new file mode 100644 index 0000000000..ee7640130d --- /dev/null +++ b/srcpkgs/xbps/patches/0001-xbps-create-if-a-symlink-points-to-an-unexistent-fil.patch @@ -0,0 +1,45 @@ +From 42c21e1c3c0fbc98b56bedbc63022c5e086feb40 Mon Sep 17 00:00:00 2001 +From: Juan RP +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 + diff --git a/srcpkgs/xbps/patches/0003-xbps-bin-8-the-check-target-now-handles-symlinks-cor.patch b/srcpkgs/xbps/patches/0003-xbps-bin-8-the-check-target-now-handles-symlinks-cor.patch new file mode 100644 index 0000000000..8df99b0fd9 --- /dev/null +++ b/srcpkgs/xbps/patches/0003-xbps-bin-8-the-check-target-now-handles-symlinks-cor.patch @@ -0,0 +1,86 @@ +From d59ad72ee4f05ea46b35984e8346158634041e38 Mon Sep 17 00:00:00 2001 +From: Juan RP +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 + #include + #include ++#include + #include + + #include +@@ -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 + diff --git a/srcpkgs/xbps/patches/xbps-create-unexistent-target-symlink-assert.patch b/srcpkgs/xbps/patches/xbps-create-unexistent-target-symlink-assert.patch deleted file mode 100644 index 8daba35162..0000000000 --- a/srcpkgs/xbps/patches/xbps-create-unexistent-target-symlink-assert.patch +++ /dev/null @@ -1,39 +0,0 @@ -commit 42c21e1c3c0fbc98b56bedbc63022c5e086feb40 -Author: Juan RP -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); diff --git a/srcpkgs/xbps/template b/srcpkgs/xbps/template index 61323ca781..cdf33aab66 100644 --- a/srcpkgs/xbps/template +++ b/srcpkgs/xbps/template @@ -1,7 +1,8 @@ # Template file for 'xbps' pkgname=xbps version=0.17 -revision=2 +revision=3 +patch_args="-Np1" build_style=configure configure_args="--prefix=/ --exec-prefix=/usr --sbindir=/usr/sbin --with-tests --with-static" depends="xbps-triggers"