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.
This commit is contained in:
parent
739f4187eb
commit
fb7afa4269
|
@ -46,47 +46,45 @@ case $dirmode in
|
||||||
exec mkdir -p -- "$@"
|
exec mkdir -p -- "$@"
|
||||||
fi ;;
|
fi ;;
|
||||||
*)
|
*)
|
||||||
if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
|
# We cannot trust mkdir to set the proper permissions on
|
||||||
echo "mkdir -m $dirmode -p -- $*"
|
# parent directories. So create them manually.
|
||||||
exec mkdir -m "$dirmode" -p -- "$@"
|
;;
|
||||||
fi ;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
for file
|
for file
|
||||||
do
|
do
|
||||||
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
|
case "$file" in
|
||||||
shift
|
/* ) pathcomp="/" ;;
|
||||||
|
-* ) pathcomp="./" ;;
|
||||||
pathcomp=
|
* ) pathcomp="" ;;
|
||||||
for d
|
|
||||||
do
|
|
||||||
pathcomp="$pathcomp$d"
|
|
||||||
case "$pathcomp" in
|
|
||||||
-* ) pathcomp=./$pathcomp ;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
saved_IFS="$IFS"
|
||||||
|
IFS="/"
|
||||||
|
for d in $file
|
||||||
|
do
|
||||||
|
IFS="$saved_IFS"
|
||||||
|
if test -n "$d"; then
|
||||||
|
pathcomp="$pathcomp$d"
|
||||||
if test ! -d "$pathcomp"; then
|
if test ! -d "$pathcomp"; then
|
||||||
echo "mkdir $pathcomp"
|
echo "mkdir $pathcomp"
|
||||||
|
|
||||||
mkdir "$pathcomp" || lasterr=$?
|
mkdir "$pathcomp" || lasterr=$?
|
||||||
|
|
||||||
if test ! -d "$pathcomp"; then
|
if test ! -d "$pathcomp"; then
|
||||||
errstatus=$lasterr
|
errstatus=$lasterr
|
||||||
else
|
break
|
||||||
if test ! -z "$dirmode"; then
|
elif test -n "$dirmode"; then
|
||||||
echo "chmod $dirmode $pathcomp"
|
echo "chmod $dirmode $pathcomp"
|
||||||
|
|
||||||
lasterr=""
|
lasterr=""
|
||||||
chmod "$dirmode" "$pathcomp" || lasterr=$?
|
chmod "$dirmode" "$pathcomp" || lasterr=$?
|
||||||
|
if test -n "$lasterr"; then
|
||||||
if test ! -z "$lasterr"; then
|
|
||||||
errstatus=$lasterr
|
errstatus=$lasterr
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
pathcomp="$pathcomp/"
|
pathcomp="$pathcomp/"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue