toolkit/crashreporter/google-breakpad/src/third_party/glog/mkinstalldirs

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 #! /bin/sh
michael@0 2 # mkinstalldirs --- make directory hierarchy
michael@0 3
michael@0 4 scriptversion=2006-05-11.19
michael@0 5
michael@0 6 # Original author: Noah Friedman <friedman@prep.ai.mit.edu>
michael@0 7 # Created: 1993-05-16
michael@0 8 # Public domain.
michael@0 9 #
michael@0 10 # This file is maintained in Automake, please report
michael@0 11 # bugs to <bug-automake@gnu.org> or send patches to
michael@0 12 # <automake-patches@gnu.org>.
michael@0 13
michael@0 14 nl='
michael@0 15 '
michael@0 16 IFS=" "" $nl"
michael@0 17 errstatus=0
michael@0 18 dirmode=
michael@0 19
michael@0 20 usage="\
michael@0 21 Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
michael@0 22
michael@0 23 Create each directory DIR (with mode MODE, if specified), including all
michael@0 24 leading file name components.
michael@0 25
michael@0 26 Report bugs to <bug-automake@gnu.org>."
michael@0 27
michael@0 28 # process command line arguments
michael@0 29 while test $# -gt 0 ; do
michael@0 30 case $1 in
michael@0 31 -h | --help | --h*) # -h for help
michael@0 32 echo "$usage"
michael@0 33 exit $?
michael@0 34 ;;
michael@0 35 -m) # -m PERM arg
michael@0 36 shift
michael@0 37 test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
michael@0 38 dirmode=$1
michael@0 39 shift
michael@0 40 ;;
michael@0 41 --version)
michael@0 42 echo "$0 $scriptversion"
michael@0 43 exit $?
michael@0 44 ;;
michael@0 45 --) # stop option processing
michael@0 46 shift
michael@0 47 break
michael@0 48 ;;
michael@0 49 -*) # unknown option
michael@0 50 echo "$usage" 1>&2
michael@0 51 exit 1
michael@0 52 ;;
michael@0 53 *) # first non-opt arg
michael@0 54 break
michael@0 55 ;;
michael@0 56 esac
michael@0 57 done
michael@0 58
michael@0 59 for file
michael@0 60 do
michael@0 61 if test -d "$file"; then
michael@0 62 shift
michael@0 63 else
michael@0 64 break
michael@0 65 fi
michael@0 66 done
michael@0 67
michael@0 68 case $# in
michael@0 69 0) exit 0 ;;
michael@0 70 esac
michael@0 71
michael@0 72 # Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
michael@0 73 # mkdir -p a/c at the same time, both will detect that a is missing,
michael@0 74 # one will create a, then the other will try to create a and die with
michael@0 75 # a "File exists" error. This is a problem when calling mkinstalldirs
michael@0 76 # from a parallel make. We use --version in the probe to restrict
michael@0 77 # ourselves to GNU mkdir, which is thread-safe.
michael@0 78 case $dirmode in
michael@0 79 '')
michael@0 80 if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
michael@0 81 echo "mkdir -p -- $*"
michael@0 82 exec mkdir -p -- "$@"
michael@0 83 else
michael@0 84 # On NextStep and OpenStep, the `mkdir' command does not
michael@0 85 # recognize any option. It will interpret all options as
michael@0 86 # directories to create, and then abort because `.' already
michael@0 87 # exists.
michael@0 88 test -d ./-p && rmdir ./-p
michael@0 89 test -d ./--version && rmdir ./--version
michael@0 90 fi
michael@0 91 ;;
michael@0 92 *)
michael@0 93 if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
michael@0 94 test ! -d ./--version; then
michael@0 95 echo "mkdir -m $dirmode -p -- $*"
michael@0 96 exec mkdir -m "$dirmode" -p -- "$@"
michael@0 97 else
michael@0 98 # Clean up after NextStep and OpenStep mkdir.
michael@0 99 for d in ./-m ./-p ./--version "./$dirmode";
michael@0 100 do
michael@0 101 test -d $d && rmdir $d
michael@0 102 done
michael@0 103 fi
michael@0 104 ;;
michael@0 105 esac
michael@0 106
michael@0 107 for file
michael@0 108 do
michael@0 109 case $file in
michael@0 110 /*) pathcomp=/ ;;
michael@0 111 *) pathcomp= ;;
michael@0 112 esac
michael@0 113 oIFS=$IFS
michael@0 114 IFS=/
michael@0 115 set fnord $file
michael@0 116 shift
michael@0 117 IFS=$oIFS
michael@0 118
michael@0 119 for d
michael@0 120 do
michael@0 121 test "x$d" = x && continue
michael@0 122
michael@0 123 pathcomp=$pathcomp$d
michael@0 124 case $pathcomp in
michael@0 125 -*) pathcomp=./$pathcomp ;;
michael@0 126 esac
michael@0 127
michael@0 128 if test ! -d "$pathcomp"; then
michael@0 129 echo "mkdir $pathcomp"
michael@0 130
michael@0 131 mkdir "$pathcomp" || lasterr=$?
michael@0 132
michael@0 133 if test ! -d "$pathcomp"; then
michael@0 134 errstatus=$lasterr
michael@0 135 else
michael@0 136 if test ! -z "$dirmode"; then
michael@0 137 echo "chmod $dirmode $pathcomp"
michael@0 138 lasterr=
michael@0 139 chmod "$dirmode" "$pathcomp" || lasterr=$?
michael@0 140
michael@0 141 if test ! -z "$lasterr"; then
michael@0 142 errstatus=$lasterr
michael@0 143 fi
michael@0 144 fi
michael@0 145 fi
michael@0 146 fi
michael@0 147
michael@0 148 pathcomp=$pathcomp/
michael@0 149 done
michael@0 150 done
michael@0 151
michael@0 152 exit $errstatus
michael@0 153
michael@0 154 # Local Variables:
michael@0 155 # mode: shell-script
michael@0 156 # sh-indentation: 2
michael@0 157 # eval: (add-hook 'write-file-hooks 'time-stamp)
michael@0 158 # time-stamp-start: "scriptversion="
michael@0 159 # time-stamp-format: "%:y-%02m-%02d.%02H"
michael@0 160 # time-stamp-end: "$"
michael@0 161 # End:

mercurial