]> granicus.if.org Git - docbook-dsssl/commitdiff
intial add; hack to find trang in a "portable" way, and run it
authorMichael Smith <xmldoc@users.sourceforge.net>
Wed, 30 Mar 2005 07:35:29 +0000 (07:35 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Wed, 30 Mar 2005 07:35:29 +0000 (07:35 +0000)
cvstools/runtrang [new file with mode: 0755]

diff --git a/cvstools/runtrang b/cvstools/runtrang
new file mode 100755 (executable)
index 0000000..2aaf260
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+# $Id$
+
+# This script attempts to find and run trang with "simple"
+# conversions (one input file and output file specified, with no
+# other arguments).
+#
+# Usage: trang <inputFileOrUri> <outputFile>
+
+# if trang is found in CLASSPATH, then call trang "manually"
+if [[ $CLASSPATH == *trang* ]]; then
+  TRANG="java com.thaiopensource.relaxng.translate.Driver";
+else
+  # otherwise, try to find trang.jar using the "locate" command
+  if [ "$(locate tng.jar)" ]; then
+    for jar in `locate trang.jar`; do
+      TRANG="java -jar $jar";
+      break;
+    done
+  else
+    # otherwise, look in a few likely places
+    if \
+      [ -f  "/usr/share/java/trang.jar" ] || \
+      [ -f "/usr/local/java/trang.jar" ] || \
+      [ -f "/usr/local/share/java/trang.jar" ]; then
+      for jar in \
+        "/usr/share/java/trang.jar" \
+        "/usr/local/java/trang.jar" \
+        "/usr/local/share/java/trang.jar"; do
+        if [ -f "$jar" ]; then
+          TRANG="java -jar $jar"
+          break
+        fi
+      done
+    else 
+      # otherwise, look for a non-jar "trang" executable (as in Debian)
+      if [ "$(which trang)" ]; then
+        TRANG=`which trang`;
+      fi
+    fi
+  fi
+fi
+
+# if trang was found, run it
+if [ -n "$TRANG" ]; then
+    echo $TRANG $1 $2
+else
+  # otherwise, exit with an error
+  echo "error: cannot locate trang" 1>&2
+  exit 1
+fi