ext-sync: relative links in plain sh, NetBSD's realpath has no -m/--relative-to

On the MacBook every recipe mirror came out empty (realpath: unknown option
-- m), so userland.sh found 'don't know how to make install' for mcde,
splinter, tasksd.  Checked with a scratch tree: misc/tasksd links resolve,
no dangling link.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
lotherkandClaude Sonnet 5.5 committed 2026-11-24 06:34:07 +00:00
1 parent 6199effa3c
commit 551bfcdcd6
1 file changed
+16 -2
+16 -2
View File
@@ -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/}"