public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: "Björn Raupach" <raupach@e2n.de>
To: "kawa@sourceware.org" <kawa@sourceware.org>
Subject: Re: symlink problems with mac os
Date: Sun, 22 Oct 2017 13:05:00 -0000	[thread overview]
Message-ID: <C5A863A8-C960-44A8-8D5A-B2BB4689770F@e2n.de> (raw)
In-Reply-To: <0cfce2d5-3e68-bf23-95c6-f6fc6e717f99@bothner.com>

On 22. Oct 2017, at 14:53, Per Bothner <per@bothner.com<mailto:per@bothner.com>> wrote:

On 10/22/2017 05:00 AM, Björn Raupach wrote:
The readlink version of macOS isn’t the same as GNU/Linux one. The latter version does follow symlinks with -f. The macOS one does not support this feature.
I stumbled upon this while working on a port for MacPorts<https://www.macports.org>  Should make kawa easier to install and upgrade on macOS. (Of course it is already simple enough being a jar file and such…)

There is a Homebrew port fof Kawa which avoids the problem by patching
bin/kawa before installing it:

https://github.com/Homebrew/homebrew-core/blob/master/Formula/kawa.rb

Agreed. I would do a patch like this in MacPorts, too. Was just raising awareness of this minor issue if it was unnoticed before.


Another option is to install GNU readlink.

I considered replacing readlink -f by realpath, but as Mac OS doesn't
have readlink either, I don't see how that would help.

We could make the script more complicated, so it can work with plain readlink,
perhaps based on https://github.com/mkropat/sh-realpath/blob/master/realpath.sh .
I'm not thrilled to complicate the script that much, but it may be better
than adding a dependency.

Apache Maven does nice bash scripting to work around this issue. I am not much of a Bash programmer so I would need some time to figure this out. Here is the snippet:

## resolve links - $0 may be a link to Maven's home
PRG="$0"

# need this for relative symlinks
while [ -h "$PRG" ] ; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> \(.*\)$'`
  if expr "$link" : '/.*' > /dev/null; then
    PRG="$link"
  else
    PRG="`dirname "$PRG"`/$link"
  fi
done


The reason for the readlink to handle the case that you install kawa
as a symlink for example /usr/local/bin/kawa -> /opt/kawa-3.0/bin/kawa .
I think that is useful to support - and it doesn't work without the -f.

The maven snippet above handles that case. I can link a link and still get maven to run. Would make it portable and doesn’t need any dependency.

Looking for patches? I have time to look at that and now I am curious enough to try and solve this. ;)

--
--Per Bothner
per@bothner.com<mailto:per@bothner.com>   http://per.bothner.com/


  reply	other threads:[~2017-10-22 13:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-22 12:00 Björn Raupach
2017-10-22 12:54 ` Per Bothner
2017-10-22 13:05   ` Björn Raupach [this message]
2017-10-22 17:40     ` Per Bothner
2017-10-22 18:15       ` Björn Raupach
2017-10-22 18:31         ` Per Bothner
2017-10-22 22:10       ` Per Bothner
2017-10-23  6:47         ` Björn Raupach
2017-10-23 16:55           ` Per Bothner
2017-10-30 15:15             ` Björn Raupach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C5A863A8-C960-44A8-8D5A-B2BB4689770F@e2n.de \
    --to=raupach@e2n.de \
    --cc=kawa@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).