You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fop 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. #! /bin/sh
  2. #
  3. # Licensed to the Apache Software Foundation (ASF) under one or more
  4. # contributor license agreements. See the NOTICE file distributed with
  5. # this work for additional information regarding copyright ownership.
  6. # The ASF licenses this file to You under the Apache License, Version 2.0
  7. # (the "License"); you may not use this file except in compliance with
  8. # the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. # Shell script to run FOP, adapted from the Jakarta-Ant project.
  18. rpm_mode=true
  19. java_exec_args="-Djava.awt.headless=true"
  20. fop_exec_args=
  21. no_config=false
  22. fop_exec_debug=false
  23. show_help=false
  24. for arg in "$@" ; do
  25. if [ "$arg" = "--noconfig" ] ; then
  26. no_config=true
  27. elif [ "$arg" = "--execdebug" ] ; then
  28. fop_exec_debug=true
  29. elif [ my"$arg" = my"--h" -o my"$arg" = my"--help" ] ; then
  30. show_help=true
  31. fop_exec_args="$fop_exec_args -h"
  32. else
  33. if [ my"$arg" = my"-h" -o my"$arg" = my"-help" ] ; then
  34. show_help=true
  35. fi
  36. fop_exec_args="$fop_exec_args \"$arg\""
  37. fi
  38. done
  39. # Source/default fop configuration
  40. if $no_config ; then
  41. rpm_mode=false
  42. else
  43. # load system-wide fop configuration
  44. if [ -f "/etc/fop.conf" ] ; then
  45. . /etc/fop.conf
  46. fi
  47. # load user fop configuration
  48. if [ -f "$HOME/.fop/fop.conf" ] ; then
  49. . $HOME/.fop/fop.conf
  50. fi
  51. if [ -f "$HOME/.foprc" ] ; then
  52. . "$HOME/.foprc"
  53. fi
  54. # provide default configuration values
  55. if [ -z "$rpm_mode" ] ; then
  56. rpm_mode=false
  57. fi
  58. if [ -z "$usejikes" ] ; then
  59. usejikes=$use_jikes_default
  60. fi
  61. fi
  62. # Setup Java environment in rpm mode
  63. if $rpm_mode ; then
  64. if [ -f /usr/share/java-utils/java-functions ] ; then
  65. . /usr/share/java-utils/java-functions
  66. set_jvm
  67. set_javacmd
  68. fi
  69. fi
  70. # OS specific support. $var _must_ be set to either true or false.
  71. cygwin=false;
  72. darwin=false;
  73. case "`uname`" in
  74. CYGWIN*) cygwin=true ;;
  75. Darwin*) darwin=true
  76. if [ -z "$JAVA_HOME" ] ; then
  77. JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
  78. fi
  79. ;;
  80. esac
  81. if [ -z "$FOP_HOME" -o ! -d "$FOP_HOME" ] ; then
  82. ## resolve links - $0 may be a link to fop's home
  83. PRG="$0"
  84. progname=`basename "$0"`
  85. # need this for relative symlinks
  86. while [ -h "$PRG" ] ; do
  87. ls=`ls -ld "$PRG"`
  88. link=`expr "$ls" : '.*-> \(.*\)$'`
  89. if expr "$link" : '/.*' > /dev/null; then
  90. PRG="$link"
  91. else
  92. PRG=`dirname "$PRG"`"/$link"
  93. fi
  94. done
  95. FOP_HOME=`dirname "$PRG"`
  96. # make it fully qualified
  97. FOP_HOME=`cd "$FOP_HOME" && pwd`
  98. fi
  99. # For Cygwin, ensure paths are in UNIX format before anything is touched
  100. if $cygwin ; then
  101. [ -n "$FOP_HOME" ] &&
  102. FOP_HOME=`cygpath --unix "$FOP_HOME"`
  103. [ -n "$JAVA_HOME" ] &&
  104. JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
  105. fi
  106. if [ "$OS" = "Windows_NT" ] ; then
  107. pathSepChar=";"
  108. else
  109. pathSepChar=":"
  110. fi
  111. if [ -z "$JAVACMD" ] ; then
  112. if [ -n "$JAVA_HOME" ] ; then
  113. if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
  114. # IBM's JDK on AIX uses strange locations for the executables
  115. JAVACMD="$JAVA_HOME/jre/sh/java"
  116. else
  117. JAVACMD="$JAVA_HOME/bin/java"
  118. fi
  119. else
  120. JAVACMD=`which java 2> /dev/null `
  121. if [ -z "$JAVACMD" ] ; then
  122. JAVACMD=java
  123. fi
  124. fi
  125. fi
  126. if [ ! -x "$JAVACMD" ] ; then
  127. echo "Error: JAVA_HOME is not defined correctly."
  128. echo " We cannot execute $JAVACMD"
  129. exit 1
  130. fi
  131. if [ -n "$CLASSPATH" ] ; then
  132. LOCALCLASSPATH=$CLASSPATH
  133. fi
  134. # add fop.jar, fop-sandbox and fop-hyph.jar, which reside in $FOP_HOME/build
  135. LOCALCLASSPATH=${FOP_HOME}/build/fop.jar${pathSepChar}${FOP_HOME}/build/fop-sandbox.jar${pathSepChar}${FOP_HOME}/build/fop-hyph.jar${pathSepChar}$LOCALCLASSPATH
  136. # add in the dependency .jar files, which reside in $FOP_HOME/lib
  137. OLD_IFS=$IFS
  138. IFS="
  139. "
  140. DIRLIBS=${FOP_HOME}/lib/*.jar
  141. for i in ${DIRLIBS}
  142. do
  143. # if the directory is empty, then it will return the input string
  144. # this is stupid, so case for it
  145. if [ "$i" != "${DIRLIBS}" ] ; then
  146. if [ -z "$LOCALCLASSPATH" ] ; then
  147. LOCALCLASSPATH=$i
  148. else
  149. LOCALCLASSPATH="$i"${pathSepChar}$LOCALCLASSPATH
  150. fi
  151. fi
  152. done
  153. IFS=$OLD_IFS
  154. # add in user-defined hyphenation JARs
  155. if [ -n "$FOP_HYPHENATION_PATH" ] ; then
  156. LOCALCLASSPATH=$LOCALCLASSPATH${pathSepChar}$FOP_HYPHENATION_PATH
  157. fi
  158. # For Cygwin, switch paths to appropriate format before running java
  159. # For PATHs convert to unix format first, then to windows format to ensure
  160. # both formats are supported. Probably this will fail on directories with ;
  161. # in the name in the path. Let's assume that paths containing ; are more
  162. # rare than windows style paths on cygwin.
  163. if $cygwin; then
  164. if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
  165. format=mixed
  166. else
  167. format=windows
  168. fi
  169. FOP_HOME=`cygpath --$format "$FOP_HOME"`
  170. LCP_TEMP=`cygpath --path --unix "$LOCALCLASSPATH"`
  171. LOCALCLASSPATH=`cygpath --path --$format "$LCP_TEMP"`
  172. if [ -n "$CLASSPATH" ] ; then
  173. CP_TEMP=`cygpath --path --unix "$CLASSPATH"`
  174. CLASSPATH=`cygpath --path --$format "$CP_TEMP"`
  175. fi
  176. CYGHOME=`cygpath --$format "$HOME"`
  177. fi
  178. # Show script help if requested
  179. if $show_help ; then
  180. fop_exec_args=""
  181. echo $0 '[script options] [FOP options]'
  182. echo 'Script Options:'
  183. echo ' --help, -h print this message and FOP help'
  184. echo ' --noconfig suppress sourcing of /etc/fop.conf,'
  185. echo ' $HOME/.fop/fop.conf, and $HOME/.foprc'
  186. echo ' configuration files'
  187. echo ' --execdebug print FOP exec line generated by this'
  188. echo ' launch script'
  189. fi
  190. # add a second backslash to variables terminated by a backslash under cygwin
  191. if $cygwin; then
  192. case "$FOP_HOME" in
  193. *\\ )
  194. FOP_HOME="$FOP_HOME\\"
  195. ;;
  196. esac
  197. case "$CYGHOME" in
  198. *\\ )
  199. CYGHOME="$CYGHOME\\"
  200. ;;
  201. esac
  202. case "$LOCALCLASSPATH" in
  203. *\\ )
  204. LOCALCLASSPATH="$LOCALCLASSPATH\\"
  205. ;;
  206. esac
  207. case "$CLASSPATH" in
  208. *\\ )
  209. CLASSPATH="$CLASSPATH\\"
  210. ;;
  211. esac
  212. fi
  213. # The default commons logger for JDK1.4 is JDK1.4Logger.
  214. # To use a different logger, uncomment the one desired below
  215. # LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog
  216. # LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
  217. # LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
  218. # Logging levels
  219. # Below option is only if you are using SimpleLog instead of the default JDK1.4 Logger.
  220. # To set logging levels for JDK 1.4 Logger, edit the %JAVA_HOME%/JRE/LIB/logging.properties
  221. # file instead.
  222. # Possible SimpleLog values: "trace", "debug", "info" (default), "warn", "error", or "fatal".
  223. # LOGLEVEL=-Dorg.apache.commons.logging.simplelog.defaultlog=INFO
  224. # Execute FOP using eval/exec to preserve spaces in paths,
  225. # java options, and FOP args
  226. fop_exec_command="exec \"$JAVACMD\" $java_exec_args $LOGCHOICE $LOGLEVEL -classpath \"$LOCALCLASSPATH\" $FOP_OPTS org.apache.fop.cli.Main $fop_exec_args"
  227. if $fop_exec_debug ; then
  228. echo $fop_exec_command
  229. fi
  230. eval $fop_exec_command