annotate src/libmad-0.15.1b/install-sh @ 79:91c729825bca pa_catalina

Update build for AUDIO_COMPONENT_FIX
author Chris Cannam
date Wed, 30 Oct 2019 12:40:34 +0000
parents c7265573341e
children
rev   line source
Chris@0 1 #!/bin/sh
Chris@0 2 #
Chris@0 3 # install - install a program, script, or datafile
Chris@0 4 # This comes from X11R5 (mit/util/scripts/install.sh).
Chris@0 5 #
Chris@0 6 # Copyright 1991 by the Massachusetts Institute of Technology
Chris@0 7 #
Chris@0 8 # Permission to use, copy, modify, distribute, and sell this software and its
Chris@0 9 # documentation for any purpose is hereby granted without fee, provided that
Chris@0 10 # the above copyright notice appear in all copies and that both that
Chris@0 11 # copyright notice and this permission notice appear in supporting
Chris@0 12 # documentation, and that the name of M.I.T. not be used in advertising or
Chris@0 13 # publicity pertaining to distribution of the software without specific,
Chris@0 14 # written prior permission. M.I.T. makes no representations about the
Chris@0 15 # suitability of this software for any purpose. It is provided "as is"
Chris@0 16 # without express or implied warranty.
Chris@0 17 #
Chris@0 18 # Calling this script install-sh is preferred over install.sh, to prevent
Chris@0 19 # `make' implicit rules from creating a file called install from it
Chris@0 20 # when there is no Makefile.
Chris@0 21 #
Chris@0 22 # This script is compatible with the BSD install script, but was written
Chris@0 23 # from scratch. It can only install one file at a time, a restriction
Chris@0 24 # shared with many OS's install programs.
Chris@0 25
Chris@0 26
Chris@0 27 # set DOITPROG to echo to test this script
Chris@0 28
Chris@0 29 # Don't use :- since 4.3BSD and earlier shells don't like it.
Chris@0 30 doit="${DOITPROG-}"
Chris@0 31
Chris@0 32
Chris@0 33 # put in absolute paths if you don't have them in your path; or use env. vars.
Chris@0 34
Chris@0 35 mvprog="${MVPROG-mv}"
Chris@0 36 cpprog="${CPPROG-cp}"
Chris@0 37 chmodprog="${CHMODPROG-chmod}"
Chris@0 38 chownprog="${CHOWNPROG-chown}"
Chris@0 39 chgrpprog="${CHGRPPROG-chgrp}"
Chris@0 40 stripprog="${STRIPPROG-strip}"
Chris@0 41 rmprog="${RMPROG-rm}"
Chris@0 42 mkdirprog="${MKDIRPROG-mkdir}"
Chris@0 43
Chris@0 44 transformbasename=""
Chris@0 45 transform_arg=""
Chris@0 46 instcmd="$mvprog"
Chris@0 47 chmodcmd="$chmodprog 0755"
Chris@0 48 chowncmd=""
Chris@0 49 chgrpcmd=""
Chris@0 50 stripcmd=""
Chris@0 51 rmcmd="$rmprog -f"
Chris@0 52 mvcmd="$mvprog"
Chris@0 53 src=""
Chris@0 54 dst=""
Chris@0 55 dir_arg=""
Chris@0 56
Chris@0 57 while [ x"$1" != x ]; do
Chris@0 58 case $1 in
Chris@0 59 -c) instcmd=$cpprog
Chris@0 60 shift
Chris@0 61 continue;;
Chris@0 62
Chris@0 63 -d) dir_arg=true
Chris@0 64 shift
Chris@0 65 continue;;
Chris@0 66
Chris@0 67 -m) chmodcmd="$chmodprog $2"
Chris@0 68 shift
Chris@0 69 shift
Chris@0 70 continue;;
Chris@0 71
Chris@0 72 -o) chowncmd="$chownprog $2"
Chris@0 73 shift
Chris@0 74 shift
Chris@0 75 continue;;
Chris@0 76
Chris@0 77 -g) chgrpcmd="$chgrpprog $2"
Chris@0 78 shift
Chris@0 79 shift
Chris@0 80 continue;;
Chris@0 81
Chris@0 82 -s) stripcmd=$stripprog
Chris@0 83 shift
Chris@0 84 continue;;
Chris@0 85
Chris@0 86 -t=*) transformarg=`echo $1 | sed 's/-t=//'`
Chris@0 87 shift
Chris@0 88 continue;;
Chris@0 89
Chris@0 90 -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
Chris@0 91 shift
Chris@0 92 continue;;
Chris@0 93
Chris@0 94 *) if [ x"$src" = x ]
Chris@0 95 then
Chris@0 96 src=$1
Chris@0 97 else
Chris@0 98 # this colon is to work around a 386BSD /bin/sh bug
Chris@0 99 :
Chris@0 100 dst=$1
Chris@0 101 fi
Chris@0 102 shift
Chris@0 103 continue;;
Chris@0 104 esac
Chris@0 105 done
Chris@0 106
Chris@0 107 if [ x"$src" = x ]
Chris@0 108 then
Chris@0 109 echo "$0: no input file specified" >&2
Chris@0 110 exit 1
Chris@0 111 else
Chris@0 112 :
Chris@0 113 fi
Chris@0 114
Chris@0 115 if [ x"$dir_arg" != x ]; then
Chris@0 116 dst=$src
Chris@0 117 src=""
Chris@0 118
Chris@0 119 if [ -d "$dst" ]; then
Chris@0 120 instcmd=:
Chris@0 121 chmodcmd=""
Chris@0 122 else
Chris@0 123 instcmd=$mkdirprog
Chris@0 124 fi
Chris@0 125 else
Chris@0 126
Chris@0 127 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
Chris@0 128 # might cause directories to be created, which would be especially bad
Chris@0 129 # if $src (and thus $dsttmp) contains '*'.
Chris@0 130
Chris@0 131 if [ -f "$src" ] || [ -d "$src" ]
Chris@0 132 then
Chris@0 133 :
Chris@0 134 else
Chris@0 135 echo "$0: $src does not exist" >&2
Chris@0 136 exit 1
Chris@0 137 fi
Chris@0 138
Chris@0 139 if [ x"$dst" = x ]
Chris@0 140 then
Chris@0 141 echo "$0: no destination specified" >&2
Chris@0 142 exit 1
Chris@0 143 else
Chris@0 144 :
Chris@0 145 fi
Chris@0 146
Chris@0 147 # If destination is a directory, append the input filename; if your system
Chris@0 148 # does not like double slashes in filenames, you may need to add some logic
Chris@0 149
Chris@0 150 if [ -d "$dst" ]
Chris@0 151 then
Chris@0 152 dst=$dst/`basename "$src"`
Chris@0 153 else
Chris@0 154 :
Chris@0 155 fi
Chris@0 156 fi
Chris@0 157
Chris@0 158 ## this sed command emulates the dirname command
Chris@0 159 dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
Chris@0 160
Chris@0 161 # Make sure that the destination directory exists.
Chris@0 162 # this part is taken from Noah Friedman's mkinstalldirs script
Chris@0 163
Chris@0 164 # Skip lots of stat calls in the usual case.
Chris@0 165 if [ ! -d "$dstdir" ]; then
Chris@0 166 defaultIFS='
Chris@0 167 '
Chris@0 168 IFS="${IFS-$defaultIFS}"
Chris@0 169
Chris@0 170 oIFS=$IFS
Chris@0 171 # Some sh's can't handle IFS=/ for some reason.
Chris@0 172 IFS='%'
Chris@0 173 set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
Chris@0 174 IFS=$oIFS
Chris@0 175
Chris@0 176 pathcomp=''
Chris@0 177
Chris@0 178 while [ $# -ne 0 ] ; do
Chris@0 179 pathcomp=$pathcomp$1
Chris@0 180 shift
Chris@0 181
Chris@0 182 if [ ! -d "$pathcomp" ] ;
Chris@0 183 then
Chris@0 184 $mkdirprog "$pathcomp"
Chris@0 185 else
Chris@0 186 :
Chris@0 187 fi
Chris@0 188
Chris@0 189 pathcomp=$pathcomp/
Chris@0 190 done
Chris@0 191 fi
Chris@0 192
Chris@0 193 if [ x"$dir_arg" != x ]
Chris@0 194 then
Chris@0 195 $doit $instcmd "$dst" &&
Chris@0 196
Chris@0 197 if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
Chris@0 198 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
Chris@0 199 if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
Chris@0 200 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
Chris@0 201 else
Chris@0 202
Chris@0 203 # If we're going to rename the final executable, determine the name now.
Chris@0 204
Chris@0 205 if [ x"$transformarg" = x ]
Chris@0 206 then
Chris@0 207 dstfile=`basename "$dst"`
Chris@0 208 else
Chris@0 209 dstfile=`basename "$dst" $transformbasename |
Chris@0 210 sed $transformarg`$transformbasename
Chris@0 211 fi
Chris@0 212
Chris@0 213 # don't allow the sed command to completely eliminate the filename
Chris@0 214
Chris@0 215 if [ x"$dstfile" = x ]
Chris@0 216 then
Chris@0 217 dstfile=`basename "$dst"`
Chris@0 218 else
Chris@0 219 :
Chris@0 220 fi
Chris@0 221
Chris@0 222 # Make a couple of temp file names in the proper directory.
Chris@0 223
Chris@0 224 dsttmp=$dstdir/#inst.$$#
Chris@0 225 rmtmp=$dstdir/#rm.$$#
Chris@0 226
Chris@0 227 # Trap to clean up temp files at exit.
Chris@0 228
Chris@0 229 trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
Chris@0 230 trap '(exit $?); exit' 1 2 13 15
Chris@0 231
Chris@0 232 # Move or copy the file name to the temp name
Chris@0 233
Chris@0 234 $doit $instcmd "$src" "$dsttmp" &&
Chris@0 235
Chris@0 236 # and set any options; do chmod last to preserve setuid bits
Chris@0 237
Chris@0 238 # If any of these fail, we abort the whole thing. If we want to
Chris@0 239 # ignore errors from any of these, just make sure not to ignore
Chris@0 240 # errors from the above "$doit $instcmd $src $dsttmp" command.
Chris@0 241
Chris@0 242 if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
Chris@0 243 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
Chris@0 244 if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
Chris@0 245 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
Chris@0 246
Chris@0 247 # Now remove or move aside any old file at destination location. We try this
Chris@0 248 # two ways since rm can't unlink itself on some systems and the destination
Chris@0 249 # file might be busy for other reasons. In this case, the final cleanup
Chris@0 250 # might fail but the new file should still install successfully.
Chris@0 251
Chris@0 252 {
Chris@0 253 if [ -f "$dstdir/$dstfile" ]
Chris@0 254 then
Chris@0 255 $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
Chris@0 256 $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
Chris@0 257 {
Chris@0 258 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
Chris@0 259 (exit 1); exit
Chris@0 260 }
Chris@0 261 else
Chris@0 262 :
Chris@0 263 fi
Chris@0 264 } &&
Chris@0 265
Chris@0 266 # Now rename the file to the real destination.
Chris@0 267
Chris@0 268 $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
Chris@0 269
Chris@0 270 fi &&
Chris@0 271
Chris@0 272 # The final little trick to "correctly" pass the exit status to the exit trap.
Chris@0 273
Chris@0 274 {
Chris@0 275 (exit 0); exit
Chris@0 276 }