2 # $Id: install.sh 7942 2008-03-26 06:08:08Z xmldoc $
\r
5 # install.sh - Set up user environment for a XML/XSLT distribution
\r
7 # This is as an interactive installer for updating your
\r
8 # environment to use an XML/XSLT distribution such as the DocBook
\r
9 # XSL Stylesheets. Its main purpose is to configure your
\r
10 # environment with XML catalog data and schema "locating rules"
\r
11 # data provided in the XML/XSLT distribution.
\r
13 # Although this installer was created for the DocBook project, it
\r
14 # is a general-purpose tool that can be used with any XML/XSLT
\r
15 # distribution that provides XML/SGML catalogs and locating rules.
\r
17 # This script is mainly intended to make things easier for you if
\r
18 # you want to install a particular XML/XSLT distribution that has
\r
19 # not (yet) been packaged for your OS distro (Debian, Fedora,
\r
20 # whatever), or to use "snapshot" or development releases
\r
22 # It works by updating your shell startup file (e.g., .bashrc and
\r
23 # .cshrc) and .emacs file and by finding or creating a writable
\r
24 # CatalogManager.properties file to update.
\r
26 # It makes backup copies of any files it touches, and also
\r
27 # generates a uninstall.sh script for reverting its changes.
\r
29 # In the same directory where it is located, it expects to find
\r
30 # the following four files:
\r
31 # - locatingrules.xml
\r
35 # And if it's unable to locate a CatalogManager.properties file in
\r
36 # your environment, it expects to find an "example" one in the
\r
37 # same directory as itself, which it copies over to your
\r
38 # ~/.resolver directory.
\r
40 # If the distribution contains any executables, change the value
\r
41 # of the thisBinDir to a colon-separated list of the pathnames of
\r
42 # the directories that contain those executables.
\r
44 # mydir is the "canonical" absolute pathname for install.sh
\r
45 mydir=$(cd -P $(dirname $0) && pwd -P) || exit 1
\r
47 thisLocatingRules=$mydir/locatingrules.xml
\r
48 thisXmlCatalog=$mydir/catalog.xml
\r
49 thisSgmlCatalog=$mydir/catalog
\r
51 # .urilist file contains a list of pairs of local pathnames and
\r
52 # URIs to test for catalog resolution
\r
53 thisUriList=$mydir/.urilist
\r
54 exampleCatalogManager=$mydir/.CatalogManager.properties.example
\r
55 thisCatalogManager=$HOME/.resolver/CatalogManager.properties
\r
57 # thisBinDir directory is a colon-separated list of the pathnames
\r
58 # to all directories that contain executables provided with the
\r
59 # distribution (for example, the DocBook XSL Stylesheets
\r
60 # distribution contains a "docbook-xsl-update" convenience script
\r
61 # for rsync'ing up to the latest docbook-xsl snapshot). The
\r
62 # install.sh script adds the value of thisBinDir to your PATH
\r
63 # environment variable
\r
64 thisBinDir=$mydir/tools/bin
\r
70 if [ ! "${*#--batch}" = "$*" ]; then
\r
75 if [ ! "$1" = "--test" ]; then
\r
76 emit_message "NOTE: For non-interactive installs/uninstalls, use --batch"
\r
77 if [ ! "$1" = "--uninstall" ]; then
\r
83 osName="Unidentified"
\r
84 if uname -s | grep -qi "cygwin"; then
\r
88 classPathSeparator=":"
\r
89 if [ "$osName" = "Cygwin" ]; then
\r
90 thisJavaXmlCatalog=$(cygpath -m $thisXmlCatalog)
\r
91 classPathSeparator=";"
\r
93 thisJavaXmlCatalog=$thisXmlCatalog
\r
99 updateCatalogManager
\r
102 updateUserStartupFiles
\r
110 rm -f $mydir/.profile.incl
\r
111 rm -f $mydir/.cshrc.incl
\r
112 rm -f $mydir/.emacs.el
\r
116 if [ $(id -u) == "0" ]; then
\r
119 WARNING: This install script is meant to be run as a non-root
\r
120 user, but you are running it as root.
\r
123 read -s -n1 -p "Are you sure you want to continue? [No] "
\r
124 emit_message "$REPLY"
\r
129 *) emit_message "OK, exiting without making changes."
\r
137 updateCatalogManager() {
\r
139 # - finds or creates a writable CatalogManager.properties file
\r
141 # - adds the catalog.xml file for this distribution to the
\r
142 # CatalogManager.properties file found
\r
144 if [ -z "$CLASSPATH" ]; then
\r
147 NOTE: There is no CLASSPATH variable set in your environment.
\r
148 No attempt was made to find a CatalogManager.properties
\r
149 file. Using $thisCatalogManager instead
\r
152 # split CLASSPATH in a list of pathnames by replacing all separator
\r
153 # characters with spaces
\r
154 if [ "$osName" = "Cygwin" ]; then
\r
155 pathnames=$(echo $CLASSPATH | tr ";" " ")
\r
157 pathnames=$(echo $CLASSPATH | tr ":" " ")
\r
159 for path in $pathnames; do
\r
160 if [ "$osName" = "Cygwin" ]; then
\r
161 path=$(cygpath -u $path)
\r
163 # strip out trailing slash from pathname
\r
164 path=$(echo $path | sed 's/\/$//')
\r
165 # find CatalogManager.properties file
\r
166 if [ -f $path/CatalogManager.properties ];
\r
168 existingCatalogManager=$path/CatalogManager.properties
\r
173 # end of CLASSPATH check
\r
175 if [ -w "$existingCatalogManager" ]; then
\r
176 # existing CatalogManager.properties was found and it is
\r
177 # writable, so use it
\r
178 myCatalogManager=$existingCatalogManager
\r
180 if [ -f "$existingCatalogManager" ]; then
\r
181 # a non-writable CatalogManager.properties exists, so emit a
\r
182 # note saying that it won't be used
\r
184 NOTE: $existingCatalogManager file found,
\r
185 but you don't have permission to write to it.
\r
187 $thisCatalogManager
\r
190 # CLASSPATH is set, but no CatalogManager.properties found
\r
191 if [ -n "$CLASSPATH" ]; then
\r
193 NOTE: No CatalogManager.properties found from CLASSPATH.
\r
195 $thisCatalogManager
\r
199 if [ "$batchmode" = "Yes" ]; then
\r
202 # end of check for existing writable CatalogManager.properties
\r
204 if [ -f $thisCatalogManager ]; then
\r
205 myCatalogManager=$thisCatalogManager
\r
208 if [ ! "$batchmode" = "Yes" ]; then
\r
210 read -s -n1 -p "Create $thisCatalogManager file? [Yes] "
\r
211 emit_message "$REPLY"
\r
219 if [ ! -d "${thisCatalogManager%/*}" ]; then
\r
220 mkdir -p ${thisCatalogManager%/*}
\r
222 cp $mydir/.CatalogManager.properties.example $thisCatalogManager || exit 1
\r
223 emit_message "NOTE: Created the following file:"
\r
224 emit_message " $thisCatalogManager"
\r
225 myCatalogManager=$thisCatalogManager
\r
228 # end of creating "private" CatalogManager.properties
\r
230 # end of check for "private" CatalogManager.properties
\r
232 # end of check finding/creating writable CatalogManager.properties
\r
234 if [ -n "$myCatalogManager" ]; then
\r
236 catalogsLine=$(grep "^catalogs=" $myCatalogManager)
\r
237 if [ -f /etc/xml/catalog ] && [ "$osName" != "Cygwin" ] \
\r
238 && [ "${catalogsLine#*/etc/xml/catalog*}" = "$catalogsLine" ]; then
\r
241 WARNING: /etc/xml/catalog exists but was not found in:
\r
243 If /etc/xml/catalog file has content, you probably
\r
244 should reference it in:
\r
246 This installer can automatically add it for you,
\r
247 but BE WARNED that once it has been added, the
\r
248 uninstaller for this distribution CANNOT REMOVE IT
\r
249 automatically during uninstall. If you no longer want
\r
250 it included, you will need to remove it manually.
\r
254 if [ ! "$batchmode" = "Yes" ]; then
\r
255 read -s -n1 -p "Add /etc/xml/catalog to $myCatalogManager? [Yes] "
\r
256 emit_message "$REPLY"
\r
263 etcXmlCatalog=/etc/xml/catalog
\r
268 catalogBackup="$myCatalogManager.$$.bak"
\r
269 if [ ! -w "${myCatalogManager%/*}" ]; then
\r
271 emit_message "WARNING: ${myCatalogManager%/*} directory is not writable."
\r
276 if [ ! "$batchmode" = "Yes" ]; then
\r
278 emit_message "Add $thisJavaXmlCatalog"
\r
279 read -s -n1 -p "to $myCatalogManager file? [Yes] "
\r
280 emit_message "$REPLY"
\r
288 if [ "$catalogsLine" ] ; then
\r
289 if [ "${catalogsLine#*$thisJavaXmlCatalog*}" != "$catalogsLine" ]; then
\r
290 emit_message "NOTE: $thisJavaXmlCatalog"
\r
291 emit_message " already in:"
\r
292 emit_message " $myCatalogManager"
\r
294 mv $myCatalogManager $catalogBackup || exit 1
\r
295 sed "s#^catalogs=\(.*\)\$#catalogs=$thisJavaXmlCatalog;\1;$etcXmlCatalog#" $catalogBackup \
\r
296 | sed 's/;\+/;/' | sed 's/;$//' > $myCatalogManager || exit 1
\r
297 emit_message "NOTE: Successfully updated the following file:"
\r
298 emit_message " $myCatalogManager"
\r
299 emit_message " Backup written to:"
\r
300 emit_message " $catalogBackup"
\r
303 mv $myCatalogManager $catalogBackup || exit 1
\r
304 cp $catalogBackup $myCatalogManager
\r
305 echo "catalogs=$thisJavaXmlCatalog;$etcXmlCatalog" \
\r
306 | sed 's/;\+/;/' | sed 's/;$//' >> $myCatalogManager || exit 1
\r
307 emit_message "NOTE: \"catalogs=\" line added to $myCatalogManager."
\r
308 emit_message " Backup written to $catalogBackup"
\r
312 # end of backing up and updating CatalogManager.properties
\r
315 # end of CatalogManager.properties updates
\r
317 if [ "$osName" = "Cygwin" ]; then
\r
318 myCatalogManager=$(cygpath -m $myCatalogManager)
\r
325 echo "$REPLY" >> $mydir/.profile.incl
\r
327 # $thisBinDir is not in PATH, so add it
\r
328 if [ "\${PATH#*$thisBinDir*}" = "\$PATH" ]; then
\r
329 PATH="$thisBinDir:\$PATH"
\r
332 if [ -z "\$XML_CATALOG_FILES" ]; then
\r
333 XML_CATALOG_FILES="$thisXmlCatalog"
\r
335 # $thisXmlCatalog is not in XML_CATALOG_FILES, so add it
\r
336 if [ "\${XML_CATALOG_FILES#*$thisXmlCatalog*}" = "\$XML_CATALOG_FILES" ]; then
\r
337 XML_CATALOG_FILES="$thisXmlCatalog \$XML_CATALOG_FILES"
\r
340 # /etc/xml/catalog exists but is not in XML_CATALOG_FILES, so add it
\r
341 if [ -f /etc/xml/catalog ] && \
\r
342 [ "\${XML_CATALOG_FILES#*/etc/xml/catalog*}" = "\$XML_CATALOG_FILES" ]; then
\r
343 XML_CATALOG_FILES="\$XML_CATALOG_FILES /etc/xml/catalog"
\r
345 export XML_CATALOG_FILES
\r
347 if [ -z "\$SGML_CATALOG_FILES" ]; then
\r
348 SGML_CATALOG_FILES="$thisSgmlCatalog"
\r
350 # $thisSgmlCatalog is not in SGML_CATALOG_FILES, so add it
\r
351 if [ "\${SGML_CATALOG_FILES#*$thisSgmlCatalog}" = "\$SGML_CATALOG_FILES" ]; then
\r
352 SGML_CATALOG_FILES="$thisSgmlCatalog:\$SGML_CATALOG_FILES"
\r
355 # /etc/sgml/catalog exists but is not in SGML_CATALOG_FILES, so add it
\r
356 if [ -f /etc/sgml/catalog ] && \
\r
357 [ "\${SGML_CATALOG_FILES#*/etc/sgml/catalog*}" = "\$SGML_CATALOG_FILES" ]; then
\r
358 SGML_CATALOG_FILES="\$SGML_CATALOG_FILES:/etc/sgml/catalog"
\r
360 export SGML_CATALOG_FILES
\r
364 echo "$REPLY" >> $mydir/.cshrc.incl
\r
366 # $thisBinDir is not in PATH, so add it
\r
367 if ( "\\\`echo \$PATH | grep -v $thisBinDir\\\`" != "" ) then
\r
368 setenv PATH "$thisBinDir:\$PATH"
\r
370 if ( ! $\?XML_CATALOG_FILES ) then
\r
371 setenv XML_CATALOG_FILES "$thisXmlCatalog"
\r
372 # $thisXmlCatalog is not in XML_CATALOG_FILES, so add it
\r
373 else if ( "\\\`echo \$XML_CATALOG_FILES | grep -v $thisXmlCatalog\\\`" != "" ) then
\r
374 setenv XML_CATALOG_FILES "$thisXmlCatalog \$XML_CATALOG_FILES"
\r
377 # /etc/xml/catalog exists but is not in XML_CATALOG_FILES, so add it
\r
378 if ( -f /etc/xml/catalog && "\\\`echo \$XML_CATALOG_FILES | grep -v /etc/xml/catalog\\\`" != "" ) then
\r
379 setenv XML_CATALOG_FILES "\$XML_CATALOG_FILES /etc/xml/catalog"
\r
383 if ( ! $\?SGML_CATALOG_FILES ) then
\r
384 setenv SGML_CATALOG_FILES "$thisSgmlCatalog"
\r
385 else if ( "\\\`echo \$SGML_CATALOG_FILES | grep -v $thisSgmlCatalog\\\`" != "" ) then
\r
386 setenv SGML_CATALOG_FILES "$thisSgmlCatalog:\$SGML_CATALOG_FILES"
\r
389 # /etc/SGML/catalog exists but is not in SGML_CATALOG_FILES, so add it
\r
390 if ( -f /etc/sgml/catalog && "\\\`echo \$SGML_CATALOG_FILES | grep -v /etc/sgml/catalog\\\`" != "" ) then
\r
391 setenv SGML_CATALOG_FILES {\$SGML_CATALOG_FILES}:/etc/sgml/catalog
\r
395 if [ -n "$myCatalogManager" ]; then
\r
396 myCatalogManagerDir=${myCatalogManager%/*}
\r
398 echo "$REPLY" >> $mydir/.profile.incl
\r
402 if [ -z "\$CLASSPATH" ]; then
\r
403 CLASSPATH="$myCatalogManagerDir"
\r
405 # $myCatalogManagerDir is not in CLASSPATH, so add it
\r
406 if [ "\${CLASSPATH#*$myCatalogManagerDir*}" = "\$CLASSPATH" ]; then
\r
407 CLASSPATH="$myCatalogManagerDir$classPathSeparator\$CLASSPATH"
\r
414 echo "$REPLY" >> $mydir/.cshrc.incl
\r
418 if ( ! $\?CLASSPATH ) then
\r
419 setenv CLASSPATH "$myCatalogManagerDir"
\r
420 # $myCatalogManagerDir is not in CLASSPATH, so add it
\r
421 else if ( "\\\`echo \$CLASSPATH | grep -v $myCatalogManagerDir\\\`" != "" ) then
\r
422 setenv CLASSPATH "$myCatalogManagerDir$classPathSeparator\$CLASSPATH"
\r
430 echo "$REPLY" >> $mydir/.emacs.el
\r
435 (setq rng-schema-locating-files-default
\r
436 (append '("$thisLocatingRules")
\r
437 rng-schema-locating-files-default ))))
\r
443 updateUserStartupFiles() {
\r
444 if [ ! "$batchmode" = "Yes" ]; then
\r
447 NOTE: To source your environment correctly for using the catalog
\r
448 files in this distribution, you need to update one or more
\r
449 of your shell startup files. This installer can
\r
450 automatically make the necessary changes. Or, if you prefer,
\r
451 you can make the changes manually.
\r
458 # if running csh or tcsh, target .cshrc and .tcshrc files for
\r
459 # update; otherwise, target .bash_* and .profiles
\r
461 parent=$(ps -p $PPID | grep "/")
\r
462 if [ "${parent#*csh}" != "$parent" ] || [ "${parent#*tcsh}" != "$parent" ]; then
\r
463 myStartupFiles=".cshrc .tcshrc"
\r
464 appendLine="source $mydir/.cshrc.incl"
\r
466 myStartupFiles=".bash_profile .bash_login .profile .bashrc"
\r
467 appendLine=". $mydir/.profile.incl"
\r
470 for file in $myStartupFiles; do
\r
471 if [ -f "$HOME/$file" ]; then
\r
472 dotFileBackup=$HOME/$file.$$.bak
\r
474 if [ ! "$batchmode" = "Yes" ]; then
\r
475 read -s -n1 -p "Update $HOME/$file? [Yes] "
\r
476 emit_message "$REPLY"
\r
482 NOTE: No change made to $HOME/$file. You either need
\r
483 to add the following line to it, or manually source
\r
484 the shell environment for this distribution each
\r
485 time you want use it.
\r
492 lineExists="$(grep "$appendLine" $HOME/$file )"
\r
493 if [ ! "$lineExists" ]; then
\r
494 mv $HOME/$file $dotFileBackup || exit 1
\r
495 cp $dotFileBackup $HOME/$file || exit 1
\r
496 echo "$appendLine" >> $HOME/$file || exit 1
\r
498 NOTE: Successfully updated the following file:
\r
506 NOTE: The following file already contains information for this
\r
507 distribution, so I did not update it.
\r
516 if [ -z "$dotFileBackup" ]; then
\r
517 if [ ! "$batchmode" = "Yes" ]; then
\r
521 NOTE: No shell startup files updated. You can source the
\r
522 environment for this distribution manually, each time you
\r
523 want to use it, by typing the following.
\r
531 updateUserDotEmacs() {
\r
532 if [ -f $thisLocatingRules ]; then
\r
535 NOTE: This distribution includes a "schema locating rules" file
\r
536 for Emacs/nXML. To use it, you should update either your
\r
537 .emacs or .emacs.el file. This installer can automatically
\r
538 make the necessary changes. Or, if you prefer, you can make
\r
539 the changes manually.
\r
543 emacsAppendLine="(load-file \"$mydir/.emacs.el\")"
\r
545 for file in .emacs .emacs.el; do
\r
546 if [ -f "$HOME/$file" ]; then
\r
547 myEmacsFile=$HOME/$file
\r
551 if [ ! -f "$myEmacsFile" ]; then
\r
553 if [ ! "$batchmode" = "Yes" ]; then
\r
554 read -s -n1 -p "No .emacs or .emacs.el file. Create one? [No] "
\r
555 emit_message "$REPLY"
\r
560 myEmacsFile=$HOME/.emacs
\r
565 NOTE: No Emacs changes made. To use this distribution with,
\r
566 Emacs/nXML, you can create a .emacs file and manually add
\r
567 the following line to it, or you can run it as a command
\r
576 if [ -n "$myEmacsFile" ]; then
\r
578 if [ ! "$batchmode" = "Yes" ]; then
\r
579 read -s -n1 -p "Update $myEmacsFile? [Yes] "
\r
580 emit_message "$REPLY"
\r
587 NOTE: No change made to $myEmacsFile. To use this distribution
\r
588 with Emacs/nXML, you can manually add the following line
\r
589 to your $myEmacsFile, or you can run it as a command
\r
597 lineExists="$(grep "$emacsAppendLine" $myEmacsFile)"
\r
598 if [ ! "$lineExists" ]; then
\r
599 dotEmacsBackup=$myEmacsFile.$$.bak
\r
600 mv $myEmacsFile $dotEmacsBackup || exit 1
\r
601 cp $dotEmacsBackup $myEmacsFile || exit 1
\r
602 echo "$emacsAppendLine" >> $myEmacsFile || exit 1
\r
604 NOTE: Successfully updated the following file:
\r
612 NOTE: The following file already contains information for this
\r
613 distribution, so I did not update it.
\r
625 if [ ! "$batchmode" = "Yes" ]; then
\r
628 NOTE: To "uninstall" this distribution, the changes made to your
\r
629 CatalogManagers.properties, startup files, and/or .emacs
\r
630 file need to be reverted. This uninstaller can automatically
\r
631 revert them. Or, if you prefer, you can revert them manually.
\r
636 if [ "$osName" = "Cygwin" ]; then
\r
637 thisXmlCatalog=$thisJavaXmlCatalog
\r
640 # make "escaped" version of PWD to use with sed and grep
\r
641 escapedPwd=$(echo $mydir | sed "s#/#\\\\\/#g")
\r
643 # check to see if a non-empty value for catalogManager was fed
\r
645 if [ -n ${1#--catalogManager=} ]; then
\r
646 myCatalogManager=${1#--catalogManager=}
\r
647 catalogBackup="$myCatalogManager.$$.bak"
\r
648 catalogsLine=$(grep "^catalogs=" $myCatalogManager)
\r
649 if [ "$catalogsLine" ] ; then
\r
650 if [ "${catalogsLine#*$thisXmlCatalog*}" != "$catalogsLine" ]; then
\r
652 if [ ! "$batchmode" = "Yes" ]; then
\r
653 read -s -n1 -p "Revert $myCatalogManager? [Yes] "
\r
654 emit_message "$REPLY"
\r
660 NOTE: No change made to $myCatalogManager. You need to manually
\r
661 remove the following path from the "catalog=" line.
\r
668 mv $myCatalogManager $catalogBackup || exit 1
\r
669 sed "s#^catalogs=\(.*\)$thisXmlCatalog\(.*\)\$#catalogs=\1\2#" $catalogBackup \
\r
670 | sed 's/;\+/;/' | sed 's/;$//' | sed 's/=;/=/' > $myCatalogManager || exit 1
\r
672 NOTE: Successfully updated the following file:
\r
681 emit_message "NOTE: No data for this distribution found in:"
\r
682 emit_message " $myCatalogManager"
\r
687 NOTE: No data for this distribution was found in the following
\r
688 file, so I did not revert it.
\r
694 if [ -n "$myEmacsFile" ]; then
\r
695 # check to see if a non-empty value for --dotEmacs file was fed
\r
697 if [ -n ${2#--dotEmacs=} ]; then
\r
698 myEmacsFile=${2#--dotEmacs=}
\r
699 revertLine="(load-file \"$escapedPwd\/\.emacs\.el\")"
\r
700 loadLine="$(grep "$revertLine" "$myEmacsFile")"
\r
701 if [ -n "$loadLine" ]; then
\r
704 if [ ! "$batchmode" = "Yes" ]; then
\r
705 read -s -n1 -p "Revert $myEmacsFile? [Yes] "
\r
706 emit_message "$REPLY"
\r
712 NOTE: No change made to $myEmacsFile. You need to manually
\r
713 remove the following line.
\r
715 (load-file \"$mydir/.emacs.el\")
\r
720 dotEmacsBackup=$myEmacsFile.$$.bak
\r
721 sed -e "/$revertLine/d" -i".$$.bak" $myEmacsFile || exit 1
\r
723 NOTE: successfully reverted the following file:
\r
732 emit_message "NOTE: No data for this distribution found in:"
\r
733 emit_message " $myEmacsFile"
\r
738 # check all startup files
\r
739 myStartupFiles=".bash_profile .bash_login .profile .bashrc .cshrc .tcshrc"
\r
740 for file in $myStartupFiles; do
\r
741 if [ -e "$HOME/$file" ]; then
\r
744 revertLine="source $mydir/.cshrc.incl"
\r
745 revertLineEsc="source $escapedPwd\/\.cshrc\.incl"
\r
748 revertLine=". $mydir/.profile.incl"
\r
749 revertLineEsc="\. $escapedPwd\/\.profile\.incl"
\r
752 lineExists="$(grep "$revertLineEsc" $HOME/$file )"
\r
753 if [ "$lineExists" ]; then
\r
755 if [ ! "$batchmode" = "Yes" ]; then
\r
756 read -s -n1 -p "Update $HOME/$file? [Yes] "
\r
757 emit_message "$REPLY"
\r
763 NOTE: No change made to $HOME/$file. You need to manually remove
\r
764 the following line from it.
\r
771 dotFileBackup=$HOME/$file.$$.bak
\r
772 sed -e "/$revertLineEsc/d" -i".$$.bak" $HOME/$file || exit 1
\r
774 NOTE: Successfully updated the following file:
\r
783 emit_message "NOTE: No data for this distribution found in:"
\r
784 emit_message " $HOME/$file"
\r
790 emit_message "Done. Deleted uninstall.sh file."
\r
791 rm -f $mydir/test.sh || exit 1
\r
792 rm -f $mydir/uninstall.sh || exit 1
\r
795 writeUninstallFile() {
\r
796 uninstallFile=$mydir/uninstall.sh
\r
797 echo '#!/bin/bash' > $uninstallFile || exit 1
\r
798 echo 'mydir=$(cd -P $(dirname $0) && pwd -P)' >> $uninstallFile || exit 1
\r
799 echo "\$mydir/install.sh \\" >> $uninstallFile || exit 1
\r
800 echo " --uninstall \\" >> $uninstallFile || exit 1
\r
801 echo " --catalogManager=$myCatalogManager \\" >> $uninstallFile || exit 1
\r
802 echo " --dotEmacs='$myEmacsFile' \\" >> $uninstallFile || exit 1
\r
803 echo ' $@' >> $uninstallFile || exit 1
\r
804 chmod 755 $uninstallFile || exit 1
\r
808 testFile=$mydir/test.sh
\r
809 echo "#!/bin/bash" > $testFile || exit 1
\r
810 echo 'mydir=$(cd -P $(dirname $0) && pwd -P)' >> $testFile || exit 1
\r
811 echo '$mydir/install.sh --test' >> $testFile || exit 1
\r
812 chmod 755 $testFile || exit 1
\r
815 printExitMessage() {
\r
817 To source your shell environment for this distribution, type the
\r
825 checkForResolver() {
\r
826 resolverResponse="$(java org.apache.xml.resolver.apps.resolver uri -u foo 2>/dev/null)"
\r
827 if [ -z "$resolverResponse" ]; then
\r
830 NOTE: Your environment does not seem to contain the Apache XML
\r
831 Commons Resolver; without that, you can't use XML catalogs
\r
832 with Java applications. For more information, see the "How
\r
833 to use a catalog file" section in Bob Stayton's "DocBook
\r
834 XSL: The Complete Guide"
\r
836 http://sagehill.net/docbookxsl/UseCatalog.html
\r
842 emitNoChangeMsg() {
\r
845 NOTE: No changes were made to CatalogManagers.properties. To
\r
846 provide your Java tools with XML catalog information for
\r
847 this distribution, you will need to make the appropriate
\r
854 if [ ! -f "$thisXmlCatalog" ]; then
\r
857 FATAL: $thisXmlCatalog file needed but not found. Stopping.
\r
862 if [ -z "$XML_CATALOG_FILES" ]; then
\r
864 emit_message "WARNING: XML_CATALOG_FILES not set. Not testing with xmlcatalog."
\r
866 xmlCatalogResponse="$(xmlcatalog 2>/dev/null)"
\r
867 if [ -z "$xmlCatalogResponse" ]; then
\r
870 WARNING: Cannot locate the "xmlcatalog" command. Make sure that
\r
871 you have libxml2 and its associated utilities installed.
\r
873 http://xmlsoft.org/
\r
877 emit_message "Testing with xmlcatalog..."
\r
878 # read in pathname-uri pairs from .urilist file
\r
879 while read pair; do
\r
880 if [ ! "${pair%* *}" = "." ]; then
\r
881 path=$mydir/${pair%* *}
\r
887 emit_message " Tested: $uri"
\r
888 for catalog in $XML_CATALOG_FILES; do
\r
889 response="$(xmlcatalog $catalog $uri| grep -v "No entry")"
\r
890 if [ -n "$response" ]; then
\r
891 if [ "$response" = "$path" ]; then
\r
892 emit_message " Result: $path"
\r
895 emit_message " Result: FAILED"
\r
899 done < $mydir/.urilist
\r
903 if [ -z "$CLASSPATH" ]; then
\r
905 emit_message "NOTE: CLASSPATH not set. Not testing with Apache XML Commons Resolver."
\r
907 if [ "$(checkForResolver)" ]; then
\r
911 emit_message "Testing with Apache XML Commons Resolver..."
\r
912 # read in pathname-uri pairs from .urilist file
\r
913 while read pair; do
\r
914 if [ ! "${pair%* *}" = "." ]; then
\r
915 path=$mydir/${pair%* *}
\r
921 emit_message " Tested: $uri"
\r
922 if [ ${uri%.dtd} != $uri ]; then
\r
923 response="$(java org.apache.xml.resolver.apps.resolver system -s $uri | grep "Result")"
\r
925 response="$(java org.apache.xml.resolver.apps.resolver uri -u $uri | grep "Result")"
\r
927 if [ "$response" ]; then
\r
928 if [ "${response#*$path}" != "$response" ]; then
\r
929 emit_message " Result: $path"
\r
931 emit_message " Result: FAILED"
\r
935 done < $mydir/.urilist
\r
940 # get opts and execute appropriate function
\r
955 # Copyright 2005-2007 Michael(tm) Smith <smith@sideshowbarker.net>
\r
957 # Permission is hereby granted, free of charge, to any person
\r
958 # obtaining a copy of this software and associated documentation
\r
959 # files (the "Software"), to deal in the Software without
\r
960 # restriction, including without limitation the rights to use, copy,
\r
961 # modify, merge, publish, distribute, sublicense, and/or sell copies
\r
962 # of the Software, and to permit persons to whom the Software is
\r
963 # furnished to do so, subject to the following conditions:
\r
965 # The above copyright notice and this permission notice shall be
\r
966 # included in all copies or substantial portions of the Software.
\r
968 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
969 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
970 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
971 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
\r
972 # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
\r
973 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
974 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
\r
975 # DEALINGS IN THE SOFTWARE.
\r