void-packages/srcpkgs/xbps/patches/0007-xbps-create-8-record-target-file-or-relative-symlink.patch

78 lines
2.3 KiB
Diff

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