diff --git a/tools/ext-sync.sh b/tools/ext-sync.sh index bc3d00d334..5bf500d314 100755 --- a/tools/ext-sync.sh +++ b/tools/ext-sync.sh @@ -62,8 +62,22 @@ mirror_one() # every file of the recipe, by name; a directory ($FILESDIR, patches/) # is mirrored file by file the same way (cd "$recipe" && find . -type f | sed 's|^\./||') | while read -r f; do - mkdir -p "$dst/$(dirname "$f")" - rel=$(cd "$dst/$(dirname "$f")" && realpath -m --relative-to=. "$recipe/$f") + dd=$dst + case $f in */*) dd=$dst/${f%/*} ;; esac + mkdir -p "$dd" + # relative link target in plain sh: one ../ per component of the + # link's directory below TOP, then the file's path below TOP. + # NetBSD's realpath(1) has no -m / --relative-to (GNU only). + case $dd:$recipe in + "$TOP"/*:"$TOP"/*) + up= + oldifs=$IFS; IFS=/ + for c in ${dd#$TOP/}; do up=$up../; done + IFS=$oldifs + rel=$up${recipe#$TOP/}/$f + ;; + *) rel=$(cd "$dd" && realpath -m --relative-to=. "$recipe/$f") ;; + esac ln -s "$rel" "$dst/$f" done echo "ext-sync: $cat/$pkg from ${recipe#$TOP/}"