void-packages/srcpkgs/xbps/patches/0009-xbps-create-handle-correctly-another-case-of-relativ.patch

68 lines
2.1 KiB
Diff

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