You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2015/07/07 14:53:14 UTC

[15/18] jena git commit: Update template.bin to improve JENA_HOME resolution (JENA-977)

Update template.bin to improve JENA_HOME resolution (JENA-977)

Applies the JENA_HOME resolution fixes from the tdbloader2 script
changes to the template.bin template that is used to generate the
various Jena command scripts


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/40fe2cd9
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/40fe2cd9
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/40fe2cd9

Branch: refs/heads/master
Commit: 40fe2cd93861e99e53184f76383323565407e372
Parents: 9b07039
Author: Rob Vesse <rv...@apache.org>
Authored: Wed Jul 1 10:32:45 2015 +0100
Committer: Rob Vesse <rv...@apache.org>
Committed: Wed Jul 1 10:32:45 2015 +0100

----------------------------------------------------------------------
 apache-jena/README       |  9 +++--
 apache-jena/cmd-maker    | 12 ++-----
 apache-jena/template.bin | 77 ++++++++++++++++++++++++++++++++++---------
 3 files changed, 69 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/40fe2cd9/apache-jena/README
----------------------------------------------------------------------
diff --git a/apache-jena/README b/apache-jena/README
index 5f80997..e283a8c 100644
--- a/apache-jena/README
+++ b/apache-jena/README
@@ -27,20 +27,23 @@
   line tools.  The scripts can be copied to a convenient place on the
   command path.
 
-  To use the Jena tools from the command line you need to set the JENAROOT
+  To use the Jena tools from the command line you need to set the JENA_HOME
   environment variable to point to the location where you have 
   unzipped the Jena distribution:
 
   Windows:
-    set JENA_HOME=\path\to\apache-jena-2.7.5
+    set JENA_HOME=\path\to\apache-jena-x.y.z
     bat\sparql.bat --version    
 
   Linux:
     The command scripts automatically set JENA_HOME but if you want
     to switch to a different version fro the same scripts:
 
-    export JENA_HOME=/path/to/apache-jena-2.7.5
+    export JENA_HOME=/path/to/apache-jena-x.y.z
     bin/sparql --version    
+
+  Where x.y.z is the version of the Jena command line tools you have 
+  downloaded
     
   If you receive a class not found exception when trying to run one of the 
   scripts then you may have set JENA_HOME incorrectly. A quick and easy way

http://git-wip-us.apache.org/repos/asf/jena/blob/40fe2cd9/apache-jena/cmd-maker
----------------------------------------------------------------------
diff --git a/apache-jena/cmd-maker b/apache-jena/cmd-maker
index eb2a4e4..71e297c 100755
--- a/apache-jena/cmd-maker
+++ b/apache-jena/cmd-maker
@@ -19,14 +19,8 @@
 # Not tdbloader2.
 ## tdbloader2 is slightly different.
 ##   The main program is not a java program
-##   It is split into tdbloader2 and tdbloader2worker
-##   tdbloader2worker (the mainporgram) is the same in 
-##   developement and here. tdbloader2 is like the script 
-##   wrappers except it execs tdbloader2worker, not
-##   java.  It needs manually updating.
-##   Replace the java exec with:
-##     export JENA_CP
-##     exec tdbloader2worker "$@"
+##   It is split into several scripts that leverage a mixture of 
+##   POSIX and java tools and should be maintained separately
 
 CMDS=$(cat <<EOF
 jena.rdfcat
@@ -86,5 +80,3 @@ do
     make_bat $cmd
 done
 
-## Specials
-cp ../jena-tdb/bin/tdbloader2worker bin/tdbloader2worker

http://git-wip-us.apache.org/repos/asf/jena/blob/40fe2cd9/apache-jena/template.bin
----------------------------------------------------------------------
diff --git a/apache-jena/template.bin b/apache-jena/template.bin
index aad767a..bbc91fb 100644
--- a/apache-jena/template.bin
+++ b/apache-jena/template.bin
@@ -1,23 +1,68 @@
 #!/bin/sh
 ## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
 
+function resolveLink() {
+  local NAME=$1
+
+  if [ -L "$NAME" ]; then
+    case "$OSTYPE" in
+      darwin*|bsd*)
+        # BSD style readlink behaves differently to GNU readlink
+        # Have to manually follow links
+        while [ -L "$NAME" ]; do
+          NAME=$(readlink "$NAME")
+        done
+        ;;
+      *)
+        # Assuming standard GNU readlink with -f for
+        # canonicalize and follow
+        NAME=$(readlink -f "$NAME")
+        ;;
+    esac
+  fi
+
+  echo "$NAME"
+}
+
 # If JENA_HOME is empty
-if [ -z "$JENA_HOME" ]
-	then
-    SCRIPT="$0"
-    # Catch common issue: script has been symlinked
-	if [ -L "$SCRIPT" ]
-		then
-		SCRIPT="$(readlink "$0")"
-		# If link is relative
-		case "$SCRIPT" in
-   			/*) ;; # fine
-			*) SCRIPT=$( dirname "$0" )/$SCRIPT;; # fix
-		esac
-	fi
-
-    # Work out root from script location
-    JENA_HOME="$( cd "$( dirname "$SCRIPT" )/.." && pwd )"
+if [ -z "$JENA_HOME" ]; then
+  echo "JENA_HOME not set, attempting to locate JENA_HOME automatically"
+  SCRIPT="$0"
+  # Catch common issue: script has been symlinked
+  if [ -L "$SCRIPT" ]; then
+    SCRIPT=$(resolveLink "$0")
+    # If link is relative
+    case "$SCRIPT" in
+      /*)
+        # Already absolute
+        ;;
+      *)
+        # Relative, make absolute
+        SCRIPT=$( dirname "$0" )/$SCRIPT
+        ;;
+    esac
+  fi
+
+  # Work out root from script location
+  JENA_HOME="$( cd "$( dirname "$SCRIPT" )/.." && pwd )"
+  export JENA_HOME
+  echo "Located JENA_HOME at ${JENA_HOME}"
+fi
+# If JENA_HOME is a symbolic link need to resolve
+if [ -L "${JENA_HOME}" ]; then
+  JENA_HOME=$(resolveLink "$JENA_HOME")
+  # If link is relative
+  case "$JENA_HOME" in
+    /*)
+      # Already absolute
+      ;;
+    *)
+      # Relative, make absolute
+      JENA_HOME=$(dirname "$JENA_HOME")
+      ;;
+  esac
+  export JENA_HOME
+  echo "Resolved symbolic links for JENA_HOME to $JENA_HOME"
 fi
 
 # ---- Setup