Skip to content

Commit 58363aa

Browse files
committed
Fixing github tests on macos.
Using 'readlink -f' instead of 'realpath'. Added pure shell function to get relative path between two dirs. Set LC_ALL only for Linux. Echo 'uname' on 'make test'
1 parent 75002c3 commit 58363aa

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ INSTALL_BIN ?= $(PREFIX)/bin
2222
INSTALL_LIB ?= $(PREFIX)/share/$(NAME)
2323
INSTALL_EXT ?= $(INSTALL_LIB)/$(NAME).d
2424
INSTALL_MAN1 ?= $(PREFIX)/share/man/man1
25-
LINK_REL_DIR := $(shell realpath --relative-to=$(INSTALL_BIN) $(INSTALL_LIB))
25+
LINK_REL_DIR := $(shell bash share/pnrelpath.sh $(INSTALL_BIN) $(INSTALL_LIB))
2626

2727
# Docker variables:
2828
DOCKER_TAG ?= 0.0.6
@@ -49,6 +49,7 @@ help:
4949

5050
.PHONY: test
5151
test:
52+
@echo uname: '$(shell uname)'
5253
prove $(prove) $(test)
5354

5455
test-all: test docker-tests

lib/git-subrepo

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ set -e
1212
export FILTER_BRANCH_SQUELCH_WARNING=1
1313

1414
# Import Bash+ helper functions:
15-
SUBREPO_EXT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")/git-subrepo.d" # replaced by `make install`
15+
SUBREPO_EXT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/git-subrepo.d" # replaced by `make install`
1616
source "${SUBREPO_EXT_DIR}/bash+.bash"
1717
bash+:import :std can version-check
1818

share/pnrelpath.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
#
3+
# from: https://unix.stackexchange.com/questions/573047/how-to-get-the-relative-path-between-two-directories
4+
#
5+
# Expects two parameters, source-dir and target-dir, both absolute canonicalized
6+
# non-empty pathnames, either may be /-ended, neither need exist.
7+
# Returns result in shell variable $REPLY as a relative path from source-dir
8+
# to target-dir without trailing /, . if void.
9+
#
10+
# Algorithm is from a 2005 comp.unix.shell posting which has now ascended to
11+
# archive.org.
12+
13+
pnrelpath() {
14+
set -- "${1%/}/" "${2%/}/" '' ## '/'-end to avoid mismatch
15+
while [ "$1" ] && [ "$2" = "${2#"$1"}" ] ## reduce $1 to shared path
16+
do set -- "${1%/?*/}/" "$2" "../$3" ## source/.. target ../relpath
17+
done
18+
REPLY="${3}${2#"$1"}" ## build result
19+
# unless root chomp trailing '/', replace '' with '.'
20+
[ "${REPLY#/}" ] && REPLY="${REPLY%/}" || REPLY="${REPLY:-.}"
21+
}
22+
23+
pnrelpath "$1" "$2"
24+
25+
echo $REPLY

test/setup

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
set -e
44

5-
export LC_ALL=C.UTF-8
5+
if [ "$(uname)" == "Linux" ]; then
6+
export LC_ALL=C.UTF-8
7+
fi
68

79
# Get the location of this script
810
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

0 commit comments

Comments
 (0)