]> granicus.if.org Git - docbook-dsssl/commitdiff
in install.sh, replaced use of non-portable "readlink -f" with
authorMichael Smith <xmldoc@users.sourceforge.net>
Fri, 21 Mar 2008 05:12:40 +0000 (05:12 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Fri, 21 Mar 2008 05:12:40 +0000 (05:12 +0000)
combination of cd/dirname/pwd that has the same effect. This is a
partial fix for #1735710. Thanks to Ivan Vilata i Balaguer.

releasetools/install.sh

index d195ea32eb3cd9beb2a1132d72dffa263fa4a5bb..48652a322dbbfba16a9108ed65bf0356daf2180c 100755 (executable)
 # of the thisBinDir to a colon-separated list of the pathnames of
 # the directories that contain those executables.
 
-mydir=$(readlink -f $(dirname $0))
+# mydir is the "canonical" absolute pathname for install.sh
+mydir=$(cd -P $(dirname $0) && pwd -P) || exit 1
+
 thisLocatingRules=$mydir/locatingrules.xml
 thisXmlCatalog=$mydir/catalog.xml
 thisSgmlCatalog=$mydir/catalog
+
 # .urilist file contains a list of pairs of local pathnames and
 # URIs to test for catalog resolution
 thisUriList=$mydir/.urilist
@@ -791,21 +794,21 @@ EOF
 
 writeUninstallFile() {
   uninstallFile=$mydir/uninstall.sh
-  echo "#!/bin/bash"                               > $uninstallFile || exit 1
-  echo "mydir=\$(readlink -f \$(dirname \$0))"    >> $uninstallFile || exit 1
+  echo '#!/bin/bash'                               > $uninstallFile || exit 1
+  echo 'mydir=$(cd -P $(dirname $0) && pwd -P)'   >> $uninstallFile || exit 1
   echo "\$mydir/install.sh \\"                    >> $uninstallFile || exit 1
   echo "  --uninstall \\"                         >> $uninstallFile || exit 1
   echo "  --catalogManager=$myCatalogManager \\"  >> $uninstallFile || exit 1
-  echo "  --dotEmacs=$myEmacsFile \\"             >> $uninstallFile || exit 1
-  echo "  \$@"                                    >> $uninstallFile || exit 1
+  echo "  --dotEmacs='$myEmacsFile' \\"           >> $uninstallFile || exit 1
+  echo '  $@'                                     >> $uninstallFile || exit 1
   chmod 755 $uninstallFile || exit 1
 }
 
 writeTestFile() {
   testFile=$mydir/test.sh
   echo "#!/bin/bash"                                > $testFile || exit 1
-  echo "mydir=\$(readlink -f \$(dirname \$0))"     >> $testFile || exit 1
-  echo "\$mydir/install.sh --test"                 >> $testFile || exit 1
+  echo 'mydir=$(cd -P $(dirname $0) && pwd -P)'    >> $testFile || exit 1
+  echo '$mydir/install.sh --test'                  >> $testFile || exit 1
   chmod 755 $testFile || exit 1
 }
 
@@ -848,15 +851,6 @@ EOF
 }
 
 testCatalogs() {
-  readlinkResponse="$(readlink -f . 2>/dev/null)"
-  if [ -z "$readlinkResponse" ]; then
-    cat 1>&2 <<EOF
-
-FATAL: Cannot locate the "readlink" command. Stopping.
-EOF
-  exit
-  fi
-
   if [ ! -f "$thisXmlCatalog" ]; then
     cat 1>&2 <<EOF
 
@@ -881,13 +875,18 @@ WARNING: Cannot locate the "xmlcatalog" command. Make sure that
 EOF
     else
       emit_message "Testing with xmlcatalog..."
+      # read in pathname-uri pairs from .urilist file
       while read pair; do
-        path=$(readlink -f "$mydir/${pair%* *}")
+        if [ ! "${pair%* *}" = "." ]; then
+          path=$mydir/${pair%* *}
+        else
+          path=$mydir/
+        fi
         uri=${pair#* *}
         emit_message
         emit_message "  Tested: $uri"
         for catalog in $XML_CATALOG_FILES; do
-          response="$(readlink -f "$(xmlcatalog $catalog $uri| grep -v "No entry")")"
+          response="$(xmlcatalog $catalog $uri| grep -v "No entry")"
           if [ -n "$response" ]; then
             if [ "$response" = "$path" ]; then
               emit_message "  Result: $path"
@@ -910,8 +909,13 @@ EOF
     else
       emit_message
       emit_message "Testing with Apache XML Commons Resolver..."
+      # read in pathname-uri pairs from .urilist file
       while read pair; do
-        path=$(readlink -f "$mydir/${pair%* *}")
+        if [ ! "${pair%* *}" = "." ]; then
+          path=$mydir/${pair%* *}
+        else
+          path=$mydir/
+        fi
         uri=${pair#* *}
         emit_message
         emit_message "  Tested: $uri"