xbps: update to 0.44.
This commit is contained in:
parent
9dfa697e99
commit
fe1848e619
12 changed files with 6 additions and 796 deletions
|
@ -1,28 +0,0 @@
|
|||
From 5d7a5a646d2f6629135b3d3ada1be00c55457151 Mon Sep 17 00:00:00 2001
|
||||
From: Juan RP <xtraeme@gmail.com>
|
||||
Date: Tue, 6 Jan 2015 07:58:45 +0100
|
||||
Subject: [PATCH 1/3] xbps_repo_get_pkg_revdeps: find pkg via repo_get_xxx not
|
||||
rpool_get_xxx.
|
||||
|
||||
---
|
||||
lib/repo.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/lib/repo.c b/lib/repo.c
|
||||
index aeca621..67e556b 100644
|
||||
--- lib/repo.c
|
||||
+++ lib/repo.c
|
||||
@@ -434,8 +434,8 @@ xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg)
|
||||
if (repo->idx == NULL)
|
||||
return NULL;
|
||||
|
||||
- if (((pkgd = xbps_rpool_get_pkg(repo->xhp, pkg)) == NULL) &&
|
||||
- ((pkgd = xbps_rpool_get_virtualpkg(repo->xhp, pkg)) == NULL)) {
|
||||
+ if (((pkgd = xbps_repo_get_pkg(repo, pkg)) == NULL) &&
|
||||
+ ((pkgd = xbps_repo_get_virtualpkg(repo, pkg)) == NULL)) {
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
--
|
||||
2.2.1
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
From cdf7fc81af26414c8729721771d948677194ecef Mon Sep 17 00:00:00 2001
|
||||
From: Juan RP <xtraeme@gmail.com>
|
||||
Date: Thu, 8 Jan 2015 10:32:08 +0100
|
||||
Subject: [PATCH 2/3] xbps-query(8): performance improvement to the ownedby
|
||||
mode with --regex.
|
||||
|
||||
Only compile the ERE once, rather than on any file. Found and suggested
|
||||
by Christian Neukirchen (@chneukirchen).
|
||||
---
|
||||
NEWS | 3 +++
|
||||
bin/xbps-query/ownedby.c | 23 ++++++++++++++---------
|
||||
2 files changed, 17 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/bin/xbps-query/ownedby.c b/bin/xbps-query/ownedby.c
|
||||
index 0def81a..4e3e175 100644
|
||||
--- bin/xbps-query/ownedby.c
|
||||
+++ bin/xbps-query/ownedby.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
- * Copyright (c) 2010-2014 Juan Romero Pardines.
|
||||
+ * Copyright (c) 2010-2015 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -37,8 +37,9 @@
|
||||
#include "defs.h"
|
||||
|
||||
struct ffdata {
|
||||
- bool regex;
|
||||
+ bool rematch;
|
||||
const char *pat, *repouri;
|
||||
+ regex_t regex;
|
||||
xbps_array_t allkeys;
|
||||
xbps_dictionary_t filesd;
|
||||
};
|
||||
@@ -52,7 +53,6 @@ match_files_by_pattern(xbps_dictionary_t pkg_filesd,
|
||||
xbps_array_t array;
|
||||
xbps_object_t obj;
|
||||
const char *keyname, *filestr, *typestr;
|
||||
- regex_t regex;
|
||||
|
||||
keyname = xbps_dictionary_keysym_cstring_nocopy(key);
|
||||
|
||||
@@ -72,13 +72,10 @@ match_files_by_pattern(xbps_dictionary_t pkg_filesd,
|
||||
xbps_dictionary_get_cstring_nocopy(obj, "file", &filestr);
|
||||
if (filestr == NULL)
|
||||
continue;
|
||||
- if (ffd->regex) {
|
||||
- if (regcomp(®ex, ffd->pat, REG_EXTENDED|REG_NOSUB) != 0)
|
||||
- return;
|
||||
- if (regexec(®ex, filestr, 0, 0, 0) == 0) {
|
||||
+ if (ffd->rematch) {
|
||||
+ if (regexec(&ffd->regex, filestr, 0, 0, 0) == 0) {
|
||||
printf("%s: %s (%s)\n", pkgver, filestr, typestr);
|
||||
}
|
||||
- regfree(®ex);
|
||||
} else {
|
||||
if ((fnmatch(ffd->pat, filestr, FNM_PERIOD)) == 0)
|
||||
printf("%s: %s (%s)\n", pkgver, filestr, typestr);
|
||||
@@ -176,16 +173,24 @@ ownedby(struct xbps_handle *xhp, const char *pat, bool repo, bool regex)
|
||||
char *rfile;
|
||||
int rv;
|
||||
|
||||
- ffd.regex = regex;
|
||||
+ ffd.rematch = false;
|
||||
ffd.pat = pat;
|
||||
|
||||
if ((rfile = realpath(pat, NULL)) != NULL)
|
||||
ffd.pat = rfile;
|
||||
|
||||
+ if (regex) {
|
||||
+ ffd.rematch = true;
|
||||
+ if (regcomp(&ffd.regex, ffd.pat, REG_EXTENDED|REG_NOSUB) != 0)
|
||||
+ return EINVAL;
|
||||
+ }
|
||||
if (repo)
|
||||
rv = xbps_rpool_foreach(xhp, repo_ownedby_cb, &ffd);
|
||||
else
|
||||
rv = xbps_pkgdb_foreach_cb(xhp, ownedby_pkgdb_cb, &ffd);
|
||||
|
||||
+ if (regex)
|
||||
+ regfree(&ffd.regex);
|
||||
+
|
||||
return rv;
|
||||
}
|
||||
--
|
||||
2.2.1
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
From 91b7b2fd5ac354e1f4fa2e1f04247242aeebbf23 Mon Sep 17 00:00:00 2001
|
||||
From: Juan RP <xtraeme@gmail.com>
|
||||
Date: Sun, 11 Jan 2015 11:01:09 +0100
|
||||
Subject: [PATCH] Use a sane umask(2) before unpacking package files.
|
||||
|
||||
See https://github.com/voidlinux/void-packages/issues/835
|
||||
for more information.
|
||||
---
|
||||
NEWS | 3 +++
|
||||
lib/package_unpack.c | 8 +++++++-
|
||||
2 files changed, 10 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/package_unpack.c b/lib/package_unpack.c
|
||||
index 237883f..d655cee 100644
|
||||
--- lib/package_unpack.c
|
||||
+++ lib/package_unpack.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
|
||||
@@ -502,6 +502,7 @@ xbps_unpack_binary_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkg_repod)
|
||||
const char *pkgver;
|
||||
char *bpkg = NULL;
|
||||
int pkg_fd = -1, rv = 0;
|
||||
+ mode_t myumask;
|
||||
|
||||
assert(xbps_object_type(pkg_repod) == XBPS_TYPE_DICTIONARY);
|
||||
|
||||
@@ -529,6 +530,8 @@ xbps_unpack_binary_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkg_repod)
|
||||
archive_read_support_compression_xz(ar);
|
||||
archive_read_support_format_tar(ar);
|
||||
|
||||
+ myumask = umask(022);
|
||||
+
|
||||
pkg_fd = open(bpkg, O_RDONLY|O_CLOEXEC);
|
||||
if (pkg_fd == -1) {
|
||||
rv = errno;
|
||||
@@ -594,5 +597,8 @@ out:
|
||||
if (bpkg)
|
||||
free(bpkg);
|
||||
|
||||
+ /* restore */
|
||||
+ umask(myumask);
|
||||
+
|
||||
return rv;
|
||||
}
|
||||
--
|
||||
2.2.1
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
From d11230a29de77ff5ab121134b5b7f083b10dca52 Mon Sep 17 00:00:00 2001
|
||||
From: Juan RP <xtraeme@gmail.com>
|
||||
Date: Sun, 18 Jan 2015 10:22:05 +0100
|
||||
Subject: [PATCH 1/2] libxbps: abort pkg unpacking as soon as a file cannot be
|
||||
written.
|
||||
|
||||
Close #74
|
||||
---
|
||||
NEWS | 4 ++++
|
||||
lib/package_unpack.c | 17 +++++++++++------
|
||||
2 files changed, 15 insertions(+), 6 deletions(-)
|
||||
|
||||
--- lib/package_unpack.c
|
||||
+++ lib/package_unpack.c
|
||||
@@ -86,7 +86,7 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
ssize_t entry_size;
|
||||
const char *file, *entry_pname, *transact;
|
||||
char *pkgname, *buf;
|
||||
- int ar_rv, rv, entry_type, flags;
|
||||
+ int ar_rv, rv, error, entry_type, flags;
|
||||
bool preserve, update, file_exists, skip_obsoletes;
|
||||
bool skip_extract, force, xucd_stats;
|
||||
uid_t euid;
|
||||
@@ -94,7 +94,7 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
binpkg_filesd = pkg_filesd = NULL;
|
||||
force = preserve = update = file_exists = false;
|
||||
skip_obsoletes = xucd_stats = false;
|
||||
- ar_rv = rv = entry_type = flags = 0;
|
||||
+ ar_rv = rv = error = entry_type = flags = 0;
|
||||
|
||||
xbps_dictionary_get_bool(pkg_repod, "preserve", &preserve);
|
||||
xbps_dictionary_get_bool(pkg_repod, "skip-obsoletes", &skip_obsoletes);
|
||||
@@ -403,10 +403,12 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
* Extract entry from archive.
|
||||
*/
|
||||
if (archive_read_extract(ar, entry, flags) != 0) {
|
||||
+ error = archive_errno(ar);
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
- archive_errno(ar), pkgver,
|
||||
+ error, pkgver,
|
||||
"%s: [unpack] failed to extract file `%s': %s",
|
||||
- pkgver, entry_pname, archive_error_string(ar));
|
||||
+ pkgver, entry_pname, strerror(error));
|
||||
+ break;
|
||||
} else {
|
||||
if (xhp->unpack_cb != NULL) {
|
||||
xucd.entry_extract_count++;
|
||||
@@ -417,10 +419,13 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
/*
|
||||
* If there was any error extracting files from archive, error out.
|
||||
*/
|
||||
- if (ar_rv == ARCHIVE_FATAL) {
|
||||
+ if (error || ar_rv == ARCHIVE_FATAL) {
|
||||
+ rv = error;
|
||||
+ if (!rv)
|
||||
+ rv = ar_rv;
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL, rv, pkgver,
|
||||
"%s: [unpack] failed to extract files: %s",
|
||||
- pkgver, archive_error_string(ar));
|
||||
+ pkgver, strerror(rv));
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
--
|
||||
2.2.2
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
From 1403826fa6509c570ae167bc1344cc7acf605138 Mon Sep 17 00:00:00 2001
|
||||
From: Juan RP <xtraeme@gmail.com>
|
||||
Date: Tue, 17 Feb 2015 11:59:05 +0100
|
||||
Subject: [PATCH] libxbps: detect and remove properly symlinks with relative
|
||||
targets.
|
||||
|
||||
Close #78
|
||||
---
|
||||
NEWS | 3 +++
|
||||
lib/package_remove.c | 23 +++++++++++++++--------
|
||||
tests/xbps/libxbps/shell/remove_test.sh | 32 +++++++++++++++++++++++++++++++-
|
||||
3 files changed, 49 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/lib/package_remove.c b/lib/package_remove.c
|
||||
index 57ea49b..04d6e00 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;
|
||||
+ char *lnk, *res = NULL;
|
||||
ssize_t r;
|
||||
|
||||
if (lstat(path, &sb) == -1)
|
||||
@@ -111,16 +111,23 @@ symlink_target(struct xbps_handle *xhp, const char *path)
|
||||
return NULL;
|
||||
}
|
||||
lnk[sb.st_size] = '\0';
|
||||
- if (lnk[0] != '/') {
|
||||
- char *p, *dname;
|
||||
+ if (strstr(lnk, "./") || lnk[0] != '/') {
|
||||
+ char *p, *p1, *dname;
|
||||
|
||||
/* relative */
|
||||
p = strdup(path);
|
||||
assert(p);
|
||||
dname = dirname(p);
|
||||
assert(dname);
|
||||
- dname += strlen(xhp->rootdir) + 1;
|
||||
- res = xbps_xasprintf("%s/%s", dname, lnk);
|
||||
+ p = xbps_xasprintf("%s/%s", dname, lnk);
|
||||
+ assert(p);
|
||||
+ if (strstr(p, "./") && ((p1 = realpath(p, NULL)))) {
|
||||
+ res = strdup(p1 + strlen(xhp->rootdir));
|
||||
+ }
|
||||
+ if (res == NULL) {
|
||||
+ res = strdup(p + strlen(xhp->rootdir)+1);
|
||||
+ }
|
||||
+ assert(res);
|
||||
free(lnk);
|
||||
free(p);
|
||||
} else {
|
||||
@@ -375,15 +382,15 @@ xbps_remove_pkg(struct xbps_handle *xhp, const char *pkgver, bool update)
|
||||
rv = EPERM;
|
||||
goto out;
|
||||
}
|
||||
+ /* Remove links */
|
||||
+ if ((rv = remove_pkg_files(xhp, pkgfilesd, "links", pkgver)) != 0)
|
||||
+ goto out;
|
||||
/* Remove regular files */
|
||||
if ((rv = remove_pkg_files(xhp, pkgfilesd, "files", pkgver)) != 0)
|
||||
goto out;
|
||||
/* Remove configuration files */
|
||||
if ((rv = remove_pkg_files(xhp, pkgfilesd, "conf_files", pkgver)) != 0)
|
||||
goto out;
|
||||
- /* Remove links */
|
||||
- if ((rv = remove_pkg_files(xhp, pkgfilesd, "links", pkgver)) != 0)
|
||||
- goto out;
|
||||
/* Remove dirs */
|
||||
if ((rv = remove_pkg_files(xhp, pkgfilesd, "dirs", pkgver)) != 0)
|
||||
goto out;
|
||||
diff --git a/tests/xbps/libxbps/shell/remove_test.sh b/tests/xbps/libxbps/shell/remove_test.sh
|
||||
index a160a67..1566903 100644
|
||||
--- tests/xbps/libxbps/shell/remove_test.sh
|
||||
+++ tests/xbps/libxbps/shell/remove_test.sh
|
||||
@@ -62,7 +62,7 @@ remove_symlinks_body() {
|
||||
xbps-rindex -d -a $PWD/*.xbps
|
||||
atf_check_equal $? 0
|
||||
cd ..
|
||||
- xbps-install -r root -C null.conf --repository=$PWD/some_repo -y B
|
||||
+ xbps-install -r root --repository=$PWD/some_repo -y B
|
||||
atf_check_equal $? 0
|
||||
xbps-pkgdb -r root -m manual A
|
||||
atf_check_equal $? 0
|
||||
@@ -75,6 +75,35 @@ remove_symlinks_body() {
|
||||
atf_check_equal $rv 0
|
||||
}
|
||||
|
||||
+atf_test_case remove_symlinks_relative
|
||||
+
|
||||
+remove_symlinks_relative_head() {
|
||||
+ atf_set "descr" "Tests for package removal: relative symlink cleanup test"
|
||||
+}
|
||||
+
|
||||
+remove_symlinks_relative_body() {
|
||||
+ mkdir some_repo
|
||||
+ mkdir -p pkg_A/usr/lib pkg_A/usr/share/lib
|
||||
+ touch -f pkg_A/usr/lib/libfoo.so.1.2.0
|
||||
+ ln -sfr pkg_A/usr/lib/libfoo.so.1.2.0 pkg_A/usr/share/lib/libfoo.so.1
|
||||
+
|
||||
+ cd some_repo
|
||||
+ xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
|
||||
+ atf_check_equal $? 0
|
||||
+ xbps-rindex -d -a $PWD/*.xbps
|
||||
+ atf_check_equal $? 0
|
||||
+ cd ..
|
||||
+ xbps-install -r root --repository=$PWD/some_repo -y A
|
||||
+ atf_check_equal $? 0
|
||||
+ xbps-remove -r root -Ryvd A
|
||||
+ atf_check_equal $? 0
|
||||
+ rv=0
|
||||
+ if [ -h root/usr/share/lib/libfoo.so.1 -o -h root/usr/lib/libfoo.so.1.2.0 -o -d root/usr/share/lib -o -d root/usr/lib ]; then
|
||||
+ rv=1
|
||||
+ fi
|
||||
+ atf_check_equal $rv 0
|
||||
+}
|
||||
+
|
||||
# 3rd test: make sure that symlinks to the rootfs are also removed.
|
||||
atf_test_case remove_symlinks_from_root
|
||||
|
||||
@@ -353,6 +382,7 @@ atf_init_test_cases() {
|
||||
atf_add_test_case keep_modified_symlinks
|
||||
atf_add_test_case remove_readonly_files
|
||||
atf_add_test_case remove_symlinks
|
||||
+ atf_add_test_case remove_symlinks_relative
|
||||
atf_add_test_case remove_symlinks_from_root
|
||||
atf_add_test_case remove_symlinks_modified
|
||||
atf_add_test_case remove_dups
|
||||
--
|
||||
2.3.0
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
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
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
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
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
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,68 +0,0 @@
|
|||
From 69e3a50e75de5a555504a0fc733fd9f484e33a79 Mon Sep 17 00:00:00 2001
|
||||
From: Juan RP <xtraeme@gmail.com>
|
||||
Date: Thu, 19 Feb 2015 09:44:09 +0100
|
||||
Subject: [PATCH 1/2] xbps-create: handle correctly another case of relative
|
||||
symlinks.
|
||||
|
||||
---
|
||||
bin/xbps-create/main.c | 2 +-
|
||||
tests/xbps/xbps-create/basic_test.sh | 29 +++++++++++++++++++++++++++++
|
||||
2 files changed, 30 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/bin/xbps-create/main.c b/bin/xbps-create/main.c
|
||||
index f09a114..e089700 100644
|
||||
--- bin/xbps-create/main.c
|
||||
+++ bin/xbps-create/main.c
|
||||
@@ -283,7 +283,7 @@ ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf _u
|
||||
* Check if symlink is absolute or relative; on the former
|
||||
* make it absolute for the target object.
|
||||
*/
|
||||
- if (strncmp(buf, "../", 3) == 0) {
|
||||
+ if (strstr(buf, "./")) {
|
||||
p = realpath(fpath, NULL);
|
||||
if (p == NULL) {
|
||||
/*
|
||||
diff --git a/tests/xbps/xbps-create/basic_test.sh b/tests/xbps/xbps-create/basic_test.sh
|
||||
index d712403..3460088 100644
|
||||
--- tests/xbps/xbps-create/basic_test.sh
|
||||
+++ tests/xbps/xbps-create/basic_test.sh
|
||||
@@ -58,7 +58,36 @@ symlink_relative_target_body() {
|
||||
atf_check_equal $rv 0
|
||||
}
|
||||
|
||||
+atf_test_case symlink_relative_target_cwd
|
||||
+
|
||||
+symlink_relative_target_cwd_head() {
|
||||
+ atf_set "descr" "xbps-create(8): relative symlinks to cwd in destdir must be absolute"
|
||||
+}
|
||||
+
|
||||
+symlink_relative_target_cwd_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
|
||||
+ atf_add_test_case symlink_relative_target_cwd
|
||||
}
|
||||
--
|
||||
2.3.0
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
From ae8ce645421962402b046cd2a34c27aa3c38609a Mon Sep 17 00:00:00 2001
|
||||
From: Juan RP <xtraeme@gmail.com>
|
||||
Date: Sat, 21 Feb 2015 16:52:27 +0100
|
||||
Subject: [PATCH] Restore pkg file timestamps while unpacking as regular user.
|
||||
|
||||
Requested by @dominikh.
|
||||
---
|
||||
NEWS | 3 +++
|
||||
include/xbps_api_impl.h | 10 +++++-----
|
||||
tests/xbps/xbps-create/basic_test.sh | 25 +++++++++++++++++++++++++
|
||||
3 files changed, 33 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/include/xbps_api_impl.h b/include/xbps_api_impl.h
|
||||
index b177bf8..a9fb07c 100644
|
||||
--- include/xbps_api_impl.h
|
||||
+++ include/xbps_api_impl.h
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
- * Copyright (c) 2010-2014 Juan Romero Pardines.
|
||||
+ * Copyright (c) 2010-2015 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -46,10 +46,10 @@
|
||||
#include "compat.h"
|
||||
|
||||
#define EXTRACT_FLAGS ARCHIVE_EXTRACT_SECURE_NODOTDOT | \
|
||||
- ARCHIVE_EXTRACT_SECURE_SYMLINKS
|
||||
-#define FEXTRACT_FLAGS ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | \
|
||||
- ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_UNLINK | \
|
||||
- EXTRACT_FLAGS
|
||||
+ ARCHIVE_EXTRACT_SECURE_SYMLINKS | \
|
||||
+ ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_PERM | \
|
||||
+ ARCHIVE_EXTRACT_UNLINK
|
||||
+#define FEXTRACT_FLAGS ARCHIVE_EXTRACT_OWNER | EXTRACT_FLAGS
|
||||
|
||||
#ifndef __UNCONST
|
||||
#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
|
||||
--
|
||||
2.3.0
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
From 2cae0cba01fc4baab98073006187d6edb94eedf0 Mon Sep 17 00:00:00 2001
|
||||
From: Juan RP <xtraeme@gmail.com>
|
||||
Date: Sun, 22 Feb 2015 18:20:32 +0100
|
||||
Subject: [PATCH] xbps-create(8): store file mtime in metadata for upcoming
|
||||
changes.
|
||||
|
||||
---
|
||||
NEWS | 3 +++
|
||||
bin/xbps-create/main.c | 12 ++++++++++--
|
||||
2 files changed, 13 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/bin/xbps-create/main.c b/bin/xbps-create/main.c
|
||||
index e089700..5f2e101 100644
|
||||
--- bin/xbps-create/main.c
|
||||
+++ bin/xbps-create/main.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
- * Copyright (c) 2012-2014 Juan Romero Pardines.
|
||||
+ * Copyright (c) 2012-2015 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -57,6 +57,7 @@
|
||||
|
||||
struct xentry {
|
||||
TAILQ_ENTRY(xentry) entries;
|
||||
+ uint64_t mtime;
|
||||
char *file, *type, *target, *hash;
|
||||
ino_t inode;
|
||||
};
|
||||
@@ -272,6 +273,8 @@ ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf _u
|
||||
*/
|
||||
xe->type = strdup("links");
|
||||
assert(xe->type);
|
||||
+ /* store modification time for regular files and links */
|
||||
+ xe->mtime = (uint64_t)sb->st_mtime;
|
||||
buf = malloc(sb->st_size+1);
|
||||
assert(buf);
|
||||
r = readlink(fpath, buf, sb->st_size+1);
|
||||
@@ -348,6 +351,8 @@ ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf _u
|
||||
die("failed to process hash for %s:", fpath);
|
||||
|
||||
xe->inode = sb->st_ino;
|
||||
+ /* store modification time for regular files and links */
|
||||
+ xe->mtime = (uint64_t)sb->st_mtime;
|
||||
|
||||
} else if (type == FTW_D || type == FTW_DP) {
|
||||
/* directory */
|
||||
@@ -409,8 +414,11 @@ process_xentry(const char *key, const char *mutable_files)
|
||||
xbps_dictionary_set_cstring(d, "file", p);
|
||||
if (xe->target)
|
||||
xbps_dictionary_set_cstring(d, "target", xe->target);
|
||||
- else if (xe->hash)
|
||||
+ if (xe->hash)
|
||||
xbps_dictionary_set_cstring(d, "sha256", xe->hash);
|
||||
+ if (xe->mtime)
|
||||
+ xbps_dictionary_set_uint64(d, "mtime", xe->mtime);
|
||||
+
|
||||
xbps_array_add(a, d);
|
||||
xbps_object_release(d);
|
||||
}
|
||||
--
|
||||
2.3.0
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
# Template file for 'xbps'
|
||||
pkgname=xbps
|
||||
version=0.43.1
|
||||
revision=11
|
||||
version=0.44
|
||||
revision=1
|
||||
bootstrap=yes
|
||||
build_style=configure
|
||||
short_desc="The XBPS package system utilities"
|
||||
|
@ -9,10 +9,10 @@ maintainer="Juan RP <xtraeme@gmail.com>"
|
|||
homepage="https://github.com/voidlinux/xbps"
|
||||
license="2-clause-BSD"
|
||||
distfiles="https://github.com/voidlinux/xbps/archive/${version}.tar.gz"
|
||||
checksum=d8a2511dbeb7bccad0bf0bfd4fa9e46c5483c523db1f30bdd179c24ddf244e26
|
||||
checksum=159199564c6b6203dc2ce517fbe8c377e470813ffa7f51121df2589cb8259e4c
|
||||
|
||||
makedepends="zlib-devel libressl-devel>=2.1.4 libarchive-devel>=3.1.2"
|
||||
depends="xbps-triggers>=0.75"
|
||||
depends="xbps-triggers"
|
||||
|
||||
if [ -z "$CHROOT_READY" ]; then
|
||||
CFLAGS+=" -idirafter ${XBPS_MASTERDIR}/usr/include"
|
||||
|
@ -30,16 +30,9 @@ else
|
|||
|
||||
fi
|
||||
|
||||
if [ "$XBPS_TARGET_MACHINE" = "i686-musl" ]; then
|
||||
# XXX disable SSP until the issue is found.
|
||||
CFLAGS+=" -fno-stack-protector"
|
||||
fi
|
||||
|
||||
do_configure() {
|
||||
if [ "$CHROOT_READY" ]; then
|
||||
_args="--enable-tests"
|
||||
fi
|
||||
HAVE_VASPRINTF=1 ./configure --prefix=/usr --sysconfdir=/etc --enable-debug ${_args}
|
||||
HAVE_VASPRINTF=1 ./configure --prefix=/usr --sysconfdir=/etc --enable-debug \
|
||||
${CHROOT_READY:+--enable-tests}
|
||||
}
|
||||
|
||||
libxbps_package() {
|
||||
|
|
Loading…
Reference in a new issue