xbps: merge patches from master to fix voidlinux/xbps#74 correctly.
This commit is contained in:
parent
a1fbd9a929
commit
81cc26b885
5 changed files with 245 additions and 2 deletions
|
@ -3,7 +3,7 @@
|
||||||
# NOTE: keep this package synchronized with "srcpkgs/xbps".
|
# NOTE: keep this package synchronized with "srcpkgs/xbps".
|
||||||
pkgname=xbps-static
|
pkgname=xbps-static
|
||||||
version=0.43.1
|
version=0.43.1
|
||||||
revision=6
|
revision=7
|
||||||
build_style=configure
|
build_style=configure
|
||||||
short_desc="The XBPS package system utilities - static binaries"
|
short_desc="The XBPS package system utilities - static binaries"
|
||||||
maintainer="Juan RP <xtraeme@gmail.com>"
|
maintainer="Juan RP <xtraeme@gmail.com>"
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
From 628a34456036fa8c7f68768328f70fa6a383b986 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Juan RP <xtraeme@gmail.com>
|
||||||
|
Date: Tue, 17 Feb 2015 16:39:04 +0100
|
||||||
|
Subject: [PATCH 1/3] libxbps: fix a memleak introduced in 1403826fa.
|
||||||
|
|
||||||
|
---
|
||||||
|
lib/package_remove.c | 1 +
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
|
||||||
|
diff --git a/lib/package_remove.c b/lib/package_remove.c
|
||||||
|
index 04d6e00..623a805 100644
|
||||||
|
--- lib/package_remove.c
|
||||||
|
+++ lib/package_remove.c
|
||||||
|
@@ -123,6 +123,7 @@ symlink_target(struct xbps_handle *xhp, const char *path)
|
||||||
|
assert(p);
|
||||||
|
if (strstr(p, "./") && ((p1 = realpath(p, NULL)))) {
|
||||||
|
res = strdup(p1 + strlen(xhp->rootdir));
|
||||||
|
+ free(p1);
|
||||||
|
}
|
||||||
|
if (res == NULL) {
|
||||||
|
res = strdup(p + strlen(xhp->rootdir)+1);
|
||||||
|
--
|
||||||
|
2.3.0
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
From 3c34c300d1827f011803b24e9ab5058c81ec3564 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Juan RP <xtraeme@gmail.com>
|
||||||
|
Date: Wed, 18 Feb 2015 14:55:54 +0100
|
||||||
|
Subject: [PATCH 2/3] xbps-create(8): record target file or relative symlinks
|
||||||
|
correctly.
|
||||||
|
|
||||||
|
---
|
||||||
|
NEWS | 2 ++
|
||||||
|
bin/xbps-create/main.c | 3 ++-
|
||||||
|
tests/xbps/xbps-create/basic_test.sh | 31 ++++++++++++++++++++++++++++++-
|
||||||
|
3 files changed, 34 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/bin/xbps-create/main.c b/bin/xbps-create/main.c
|
||||||
|
index 9e65599..f09a114 100644
|
||||||
|
--- bin/xbps-create/main.c
|
||||||
|
+++ bin/xbps-create/main.c
|
||||||
|
@@ -303,7 +303,8 @@ ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf _u
|
||||||
|
free(p2);
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
- } else if (strchr(buf, '/') == NULL) {
|
||||||
|
+ } else if (buf[0] != '/') {
|
||||||
|
+ /* relative path */
|
||||||
|
p = strdup(filep);
|
||||||
|
assert(p);
|
||||||
|
dname = dirname(p);
|
||||||
|
diff --git a/tests/xbps/xbps-create/basic_test.sh b/tests/xbps/xbps-create/basic_test.sh
|
||||||
|
index 6769047..d712403 100644
|
||||||
|
--- tests/xbps/xbps-create/basic_test.sh
|
||||||
|
+++ tests/xbps/xbps-create/basic_test.sh
|
||||||
|
@@ -19,7 +19,7 @@ hardlinks_size_body() {
|
||||||
|
cd ..
|
||||||
|
xbps-rindex -d -a repo/*.xbps
|
||||||
|
atf_check_equal $? 0
|
||||||
|
- result="$(xbps-query -r root -C empty.conf --repository=$PWD/repo -p installed_size foo)"
|
||||||
|
+ result="$(xbps-query -r root --repository=repo -p installed_size foo)"
|
||||||
|
expected="10B"
|
||||||
|
rv=0
|
||||||
|
if [ "$result" != "$expected" ]; then
|
||||||
|
@@ -30,6 +30,35 @@ hardlinks_size_body() {
|
||||||
|
atf_check_equal $rv 0
|
||||||
|
}
|
||||||
|
|
||||||
|
+atf_test_case symlink_relative_target
|
||||||
|
+
|
||||||
|
+symlink_relative_target_head() {
|
||||||
|
+ atf_set "descr" "xbps-create(8): relative symlinks in destdir must be absolute"
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+symlink_relative_target_body() {
|
||||||
|
+ mkdir -p repo pkg_A/usr/include/gsm
|
||||||
|
+ touch -f pkg_A/usr/include/gsm/gsm.h
|
||||||
|
+ cd pkg_A/usr/include
|
||||||
|
+ ln -s gsm/gsm.h gsm.h
|
||||||
|
+ cd ../../../repo
|
||||||
|
+ xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A
|
||||||
|
+ atf_check_equal $? 0
|
||||||
|
+ cd ..
|
||||||
|
+ xbps-rindex -d -a repo/*.xbps
|
||||||
|
+ atf_check_equal $? 0
|
||||||
|
+ result="$(xbps-query -r root --repository=repo -f foo|tr -d '\n')"
|
||||||
|
+ expected="/usr/include/gsm/gsm.h/usr/include/gsm.h -> /usr/include/gsm/gsm.h"
|
||||||
|
+ rv=0
|
||||||
|
+ if [ "$result" != "$expected" ]; then
|
||||||
|
+ echo "result: $result"
|
||||||
|
+ echo "expected: $expected"
|
||||||
|
+ rv=1
|
||||||
|
+ fi
|
||||||
|
+ atf_check_equal $rv 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
atf_init_test_cases() {
|
||||||
|
atf_add_test_case hardlinks_size
|
||||||
|
+ atf_add_test_case symlink_relative_target
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.3.0
|
||||||
|
|
|
@ -0,0 +1,141 @@
|
||||||
|
From 1722635e088e385757a7ef04494b4c23456986d8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Juan RP <xtraeme@gmail.com>
|
||||||
|
Date: Wed, 18 Feb 2015 15:12:39 +0100
|
||||||
|
Subject: [PATCH 3/3] Introduce xbps_sanitize_path() to fix #78 properly.
|
||||||
|
|
||||||
|
This removes multiple slashes of a path and returns you a buffer with
|
||||||
|
the sanitized string.
|
||||||
|
---
|
||||||
|
include/xbps.h.in | 11 ++++++++++-
|
||||||
|
lib/package_remove.c | 24 ++++++++++++++++--------
|
||||||
|
lib/util.c | 29 ++++++++++++++++++++++++++++-
|
||||||
|
3 files changed, 54 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/include/xbps.h.in b/include/xbps.h.in
|
||||||
|
index aebe315..712d952 100644
|
||||||
|
--- include/xbps.h.in
|
||||||
|
+++ include/xbps.h.in
|
||||||
|
@@ -48,7 +48,7 @@
|
||||||
|
*
|
||||||
|
* This header documents the full API for the XBPS Library.
|
||||||
|
*/
|
||||||
|
-#define XBPS_API_VERSION "20141209"
|
||||||
|
+#define XBPS_API_VERSION "20150218"
|
||||||
|
|
||||||
|
#ifndef XBPS_VERSION
|
||||||
|
#define XBPS_VERSION "UNSET"
|
||||||
|
@@ -1933,6 +1933,15 @@ int xbps_cmpver(const char *pkg1, const char *pkg2);
|
||||||
|
*/
|
||||||
|
char *xbps_pubkey2fp(struct xbps_handle *xhp, xbps_data_t pubkey);
|
||||||
|
|
||||||
|
+/**
|
||||||
|
+ * Returns a buffer with a sanitized path from \a src.
|
||||||
|
+ * This removes multiple slashes.
|
||||||
|
+ *
|
||||||
|
+ * @return The sanitized path in a buffer.
|
||||||
|
+ * The returned buffer must be free(3)d when it's no longer necessary.
|
||||||
|
+ */
|
||||||
|
+char *xbps_sanitize_path(const char *src);
|
||||||
|
+
|
||||||
|
/*@}*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
diff --git a/lib/package_remove.c b/lib/package_remove.c
|
||||||
|
index 623a805..0b586e8 100644
|
||||||
|
--- lib/package_remove.c
|
||||||
|
+++ lib/package_remove.c
|
||||||
|
@@ -96,7 +96,7 @@ static char *
|
||||||
|
symlink_target(struct xbps_handle *xhp, const char *path)
|
||||||
|
{
|
||||||
|
struct stat sb;
|
||||||
|
- char *lnk, *res = NULL;
|
||||||
|
+ char *p, *p1, *dname, *lnk, *res = NULL;
|
||||||
|
ssize_t r;
|
||||||
|
|
||||||
|
if (lstat(path, &sb) == -1)
|
||||||
|
@@ -112,8 +112,6 @@ symlink_target(struct xbps_handle *xhp, const char *path)
|
||||||
|
}
|
||||||
|
lnk[sb.st_size] = '\0';
|
||||||
|
if (strstr(lnk, "./") || lnk[0] != '/') {
|
||||||
|
- char *p, *p1, *dname;
|
||||||
|
-
|
||||||
|
/* relative */
|
||||||
|
p = strdup(path);
|
||||||
|
assert(p);
|
||||||
|
@@ -121,16 +119,26 @@ symlink_target(struct xbps_handle *xhp, const char *path)
|
||||||
|
assert(dname);
|
||||||
|
p = xbps_xasprintf("%s/%s", dname, lnk);
|
||||||
|
assert(p);
|
||||||
|
- if (strstr(p, "./") && ((p1 = realpath(p, NULL)))) {
|
||||||
|
- res = strdup(p1 + strlen(xhp->rootdir));
|
||||||
|
- free(p1);
|
||||||
|
+ 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) {
|
||||||
|
- res = strdup(p + strlen(xhp->rootdir)+1);
|
||||||
|
+ if (strcmp(xhp->rootdir, "/") == 0)
|
||||||
|
+ res = strdup(p1);
|
||||||
|
+ else
|
||||||
|
+ res = strdup(p1 + strlen(xhp->rootdir));
|
||||||
|
}
|
||||||
|
assert(res);
|
||||||
|
free(lnk);
|
||||||
|
- free(p);
|
||||||
|
+ free(p1);
|
||||||
|
} else {
|
||||||
|
/* absolute */
|
||||||
|
res = lnk;
|
||||||
|
diff --git a/lib/util.c b/lib/util.c
|
||||||
|
index 0361a7c..72b8e7d 100644
|
||||||
|
--- lib/util.c
|
||||||
|
+++ lib/util.c
|
||||||
|
@@ -1,5 +1,5 @@
|
||||||
|
/*-
|
||||||
|
- * Copyright (c) 2008-2014 Juan Romero Pardines.
|
||||||
|
+ * Copyright (c) 2008-2015 Juan Romero Pardines.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@@ -425,3 +425,30 @@ xbps_pkg_reverts(xbps_dictionary_t pkg, const char *pkgver)
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+char *
|
||||||
|
+xbps_sanitize_path(const char *src)
|
||||||
|
+{
|
||||||
|
+ const char *s = src;
|
||||||
|
+ char *d, *dest;
|
||||||
|
+ size_t len;
|
||||||
|
+
|
||||||
|
+ assert(src);
|
||||||
|
+ len = strlen(src);
|
||||||
|
+ assert(len != 0);
|
||||||
|
+
|
||||||
|
+ dest = malloc(len);
|
||||||
|
+ assert(dest);
|
||||||
|
+ d = dest;
|
||||||
|
+
|
||||||
|
+ while ((*d = *s)) {
|
||||||
|
+ if (*s == '/' && *(s+1) == '/') {
|
||||||
|
+ s++;
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ d++, s++;
|
||||||
|
+ }
|
||||||
|
+ *d = '\0';
|
||||||
|
+
|
||||||
|
+ return dest;
|
||||||
|
+}
|
||||||
|
--
|
||||||
|
2.3.0
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Template file for 'xbps'
|
# Template file for 'xbps'
|
||||||
pkgname=xbps
|
pkgname=xbps
|
||||||
version=0.43.1
|
version=0.43.1
|
||||||
revision=6
|
revision=7
|
||||||
bootstrap=yes
|
bootstrap=yes
|
||||||
build_style=configure
|
build_style=configure
|
||||||
short_desc="The XBPS package system utilities"
|
short_desc="The XBPS package system utilities"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue