Fix mkinstalldirs

Francois Gouget fgouget at codeweavers.com
Thu Jun 15 11:05:07 CDT 2006


The Wine makefiles assume that 'mkinstalldirs -m 755 $prefix/lib/wine' 
will set specified permissions on any directory that needs to be 
created, both $prefix/lib and $prefix/lib/wine in this case.

However, most of the time mkinstalldirs just calls out to 'mkdir -p -m 
755' and the Linux mkdir tool (GNU mkdir 5.94) *does* not set the 
specified permissions on non-leaf directories. So $prefix/lib/wine will 
end up with the right permissions but not $prefix/lib. This means 
mkinstalldirs must do the job by hand.

But then we run into the second issue which is that the 'by hand' 
portion of the code does not support spaces and thus needs fixing too.


Changelog:

  * tools/mkinstalldirs

    Francois Gouget <fgouget at codeweavers.com>
    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.


-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: tools/mkinstalldirs
===================================================================
RCS file: /home/wine/wine/tools/mkinstalldirs,v
retrieving revision 1.1
diff -u -p -r1.1 mkinstalldirs
--- tools/mkinstalldirs	9 May 2002 04:31:40 -0000	1.1
+++ tools/mkinstalldirs	15 Jun 2006 08:35:35 -0000
@@ -46,44 +46,44 @@ 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
-
-   pathcomp=
-   for d
+   case "$file" in
+     /* ) pathcomp="/" ;;
+      * ) pathcomp="./" ;;
+   esac
+
+   saved_IFS="$IFS"
+   IFS="/"
+   for d in $file
    do
+     IFS="$saved_IFS"
      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
+
+     if test -n "$pathcomp" -a ! -d "$pathcomp"; then
+       echo "mkdir $pathcomp"
+       mkdir "$pathcomp" || lasterr=$?
+
+       if test ! -d "$pathcomp"; then
+         errstatus=$lasterr
+         break
+       else
+         if test ! -z "$dirmode"; then
+           echo "chmod $dirmode $pathcomp"
+           lasterr=""
+           chmod "$dirmode" "$pathcomp" || lasterr=$?
+
+           if test ! -z "$lasterr"; then
+             errstatus=$lasterr
+             break
+           fi
+         fi
+       fi
      fi
 
      pathcomp="$pathcomp/"


More information about the wine-patches mailing list