Francois Gouget : tools: Fix mkinstalldirs.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jun 21 08:02:21 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: fb7afa42693f5304d8f827ceebeba2d6359d4e5e
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=fb7afa42693f5304d8f827ceebeba2d6359d4e5e

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Thu Jun 15 18:05:07 2006 +0200

tools: Fix mkinstalldirs.

We cannot trust 'mkdir -p' to set the proper permissions on parent
directories. So create them manually.
Fix handling of paths containing spaces.
Properly prefix the path with './' if it starts with a '-'.
Stop trying to create a path after the first error.

---

 tools/mkinstalldirs |   68 +++++++++++++++++++++++++--------------------------
 1 files changed, 33 insertions(+), 35 deletions(-)

diff --git a/tools/mkinstalldirs b/tools/mkinstalldirs
index 8ab885e..ec700bd 100755
--- a/tools/mkinstalldirs
+++ b/tools/mkinstalldirs
@@ -46,47 +46,45 @@ case $dirmode in
     exec mkdir -p -- "$@"
   fi ;;
 *)
-  if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
-    echo "mkdir -m $dirmode -p -- $*"
-    exec mkdir -m "$dirmode" -p -- "$@"
-  fi ;;
+  # We cannot trust mkdir to set the proper permissions on
+  # parent directories. So create them manually.
+  ;;
 esac
 
 for file
 do
-   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
-   shift
+   case "$file" in
+     /* ) pathcomp="/" ;;
+     -* ) pathcomp="./" ;;
+      * ) pathcomp="" ;;
+   esac
 
-   pathcomp=
-   for d
+   saved_IFS="$IFS"
+   IFS="/"
+   for d in $file
    do
-     pathcomp="$pathcomp$d"
-     case "$pathcomp" in
-       -* ) pathcomp=./$pathcomp ;;
-     esac
-
-     if test ! -d "$pathcomp"; then
-	echo "mkdir $pathcomp"
-
-	mkdir "$pathcomp" || lasterr=$?
-
-	if test ! -d "$pathcomp"; then
-	  errstatus=$lasterr
-	else
-	  if test ! -z "$dirmode"; then
-	     echo "chmod $dirmode $pathcomp"
-
-	     lasterr=""
-	     chmod "$dirmode" "$pathcomp" || lasterr=$?
-
-	     if test ! -z "$lasterr"; then
-	       errstatus=$lasterr
-	     fi
-	  fi
-	fi
-     fi
-
-     pathcomp="$pathcomp/"
+      IFS="$saved_IFS"
+      if test -n "$d"; then
+         pathcomp="$pathcomp$d"
+         if test ! -d "$pathcomp"; then
+            echo "mkdir $pathcomp"
+            mkdir "$pathcomp" || lasterr=$?
+
+            if test ! -d "$pathcomp"; then
+               errstatus=$lasterr
+               break
+            elif test -n "$dirmode"; then
+               echo "chmod $dirmode $pathcomp"
+               lasterr=""
+               chmod "$dirmode" "$pathcomp" || lasterr=$?
+               if test -n "$lasterr"; then
+                  errstatus=$lasterr
+                  break
+               fi
+            fi
+         fi
+         pathcomp="$pathcomp/"
+      fi
    done
 done
 




More information about the wine-cvs mailing list