[
https://issues.apache.org/jira/browse/JENA-1735?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16897281#comment-16897281
]
Colin Gross edited comment on JENA-1735 at 7/31/19 5:16 PM:
------------------------------------------------------------
h3. Origin
It appears that free bsd's
[readlink|https://www.freebsd.org/cgi/man.cgi?query=readlink] still has
mismatched options as does OSX. Open bsd's
[readlink|https://man.openbsd.org/readlink.1] does appear to have the {{-f}}
option that corresponds to the gnu
[readlink|https://www.gnu.org/software/coreutils/manual/html_node/readlink-invocation.html].
Basically, readlink still can't be depended on to have a {{-f}} option that
does what we want.
As for where this comes from, I shamelessly copied this approach from [Chris
Beer|https://github.com/cbeer]. I can't recall which project I originally
encountered it on, but it did get used in [solr
here|https://github.com/apache/lucene-solr/blob/1d85cd783863f75cea133fb9c452302214165a4d/solr/bin/post#L19-L31].
h3. Other solutions
h4. loop on readlink
The other options to ameliorate this without trying to detect the OS, has been
to loop on {{readlink}} *without* the {{-f}} option. That approach has the
downside of getting stuck in symlink cycles if they exist.
h4. cd and pwd -P
The method used in the arq project will follow links to directories. Doing
{{"$( cd $LINK; pwd -P)"}} will work when the link target is a directory. If
the target of the link is a file, you'll still have to work out the directory
of the path the link points to, and follow that. Looping on working out the
path of the link target gets you back to the issue with looping on readlink.
h3. My current use
I'm currently using ansible to dist the version of this script with symlink
resolution. It avoids a few issues for me:
* Can put symlink to fuseki-server in the appropriate bin directory.
* Avoid having to mess with PATH for any/all users
* Avoids having to discover or keep track of absolute path to fuseki in
provisioning tool (e.g. ansible or puppet)
I thought I'd contribute the solution I'm using so it's not a problem for
others. I won't be offended nor put off if it's not the right solution for
this project.
was (Author: grosscol):
h3. Origin
It appears that free bsd's
[readlink|https://www.freebsd.org/cgi/man.cgi?query=readlink] still has
mismatched options as does OSX. Open bsd's
[readlink|https://man.openbsd.org/readlink.1] does appear to have the {{-f}}
option that corresponds to the gnu
[readlink|https://www.gnu.org/software/coreutils/manual/html_node/readlink-invocation.html].
Basically, readlink still can't be depended on to have a {{-f}} option that
does what we want.
As for where this comes from, I shameless copied this approach from [Chris
Beer|https://github.com/cbeer]. I can't recall which project I originally
encountered it on, but it did get used in [solr
here|https://github.com/apache/lucene-solr/blob/1d85cd783863f75cea133fb9c452302214165a4d/solr/bin/post#L19-L31].
h3. Other solutions
h4. loop on readlink
The other options to ameliorate this without trying to detect the OS, has been
to loop on {{readlink}} *without* the {{-f}} option. That approach has the
downside of getting stuck in symlink cycles if they exist.
h4. cd and pwd -P
The method used in the arq project will follow links to directories. Doing
{{"$( cd $LINK; pwd -P)"}} will work when the link target is a directory. If
the target of the link is a file, you'll still have to work out the directory
of the path the link points to, and follow that. Looping on working out the
path of the link target gets you back to the issue with looping on readlink.
h3. My current use
I'm currently using ansible to dist the version of this script with symlink
resolution. It avoids a few issues for me:
* Can put symlink to fuseki-server in the appropriate bin directory.
* Avoid having to mess with PATH for any/all users
* Avoids having to discover or keep track of absolute path to fuseki in
provisioning tool (e.g. ansible or puppet)
I thought I'd contribute the solution I'm using so it's not a problem for
others. I won't be offended nor put off if it's not the right solution for
this project.
> Allow symlinking to fuseki-server script
> ----------------------------------------
>
> Key: JENA-1735
> URL: https://issues.apache.org/jira/browse/JENA-1735
> Project: Apache Jena
> Issue Type: Improvement
> Components: Fuseki
> Affects Versions: Fuseki 2.5.0
> Environment: Ubuntu 18.04 (bionic)
> Debian 9 (stretch)
> Reporter: Colin Gross
> Priority: Minor
> Labels: easyfix
> Original Estimate: 1h
> Time Spent: 10m
> Remaining Estimate: 50m
>
> Symlinking to executables or scripts from a PATH directory is a common
> practice. This is some sysadmins perfered method as it makes updating the
> fuseki version just redirecting a symlink.
> This needs to run on both GNU and BSD based systems (e.g. OSX), so using
> readlink is a tricky wicket. It it doesn't behave the same on both, nor are
> the meaning of the flags consistent between systems.
> Similar to issue JENA-1297
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)