annotate src/libvorbis-1.3.3/install-sh @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 98c1576536ae
children
rev   line source
cannam@86 1 #!/bin/sh
cannam@86 2 # install - install a program, script, or datafile
cannam@86 3
cannam@86 4 scriptversion=2005-05-14.22
cannam@86 5
cannam@86 6 # This originates from X11R5 (mit/util/scripts/install.sh), which was
cannam@86 7 # later released in X11R6 (xc/config/util/install.sh) with the
cannam@86 8 # following copyright and license.
cannam@86 9 #
cannam@86 10 # Copyright (C) 1994 X Consortium
cannam@86 11 #
cannam@86 12 # Permission is hereby granted, free of charge, to any person obtaining a copy
cannam@86 13 # of this software and associated documentation files (the "Software"), to
cannam@86 14 # deal in the Software without restriction, including without limitation the
cannam@86 15 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
cannam@86 16 # sell copies of the Software, and to permit persons to whom the Software is
cannam@86 17 # furnished to do so, subject to the following conditions:
cannam@86 18 #
cannam@86 19 # The above copyright notice and this permission notice shall be included in
cannam@86 20 # all copies or substantial portions of the Software.
cannam@86 21 #
cannam@86 22 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
cannam@86 23 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
cannam@86 24 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
cannam@86 25 # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
cannam@86 26 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
cannam@86 27 # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
cannam@86 28 #
cannam@86 29 # Except as contained in this notice, the name of the X Consortium shall not
cannam@86 30 # be used in advertising or otherwise to promote the sale, use or other deal-
cannam@86 31 # ings in this Software without prior written authorization from the X Consor-
cannam@86 32 # tium.
cannam@86 33 #
cannam@86 34 #
cannam@86 35 # FSF changes to this file are in the public domain.
cannam@86 36 #
cannam@86 37 # Calling this script install-sh is preferred over install.sh, to prevent
cannam@86 38 # `make' implicit rules from creating a file called install from it
cannam@86 39 # when there is no Makefile.
cannam@86 40 #
cannam@86 41 # This script is compatible with the BSD install script, but was written
cannam@86 42 # from scratch. It can only install one file at a time, a restriction
cannam@86 43 # shared with many OS's install programs.
cannam@86 44
cannam@86 45 # set DOITPROG to echo to test this script
cannam@86 46
cannam@86 47 # Don't use :- since 4.3BSD and earlier shells don't like it.
cannam@86 48 doit="${DOITPROG-}"
cannam@86 49
cannam@86 50 # put in absolute paths if you don't have them in your path; or use env. vars.
cannam@86 51
cannam@86 52 mvprog="${MVPROG-mv}"
cannam@86 53 cpprog="${CPPROG-cp}"
cannam@86 54 chmodprog="${CHMODPROG-chmod}"
cannam@86 55 chownprog="${CHOWNPROG-chown}"
cannam@86 56 chgrpprog="${CHGRPPROG-chgrp}"
cannam@86 57 stripprog="${STRIPPROG-strip}"
cannam@86 58 rmprog="${RMPROG-rm}"
cannam@86 59 mkdirprog="${MKDIRPROG-mkdir}"
cannam@86 60
cannam@86 61 chmodcmd="$chmodprog 0755"
cannam@86 62 chowncmd=
cannam@86 63 chgrpcmd=
cannam@86 64 stripcmd=
cannam@86 65 rmcmd="$rmprog -f"
cannam@86 66 mvcmd="$mvprog"
cannam@86 67 src=
cannam@86 68 dst=
cannam@86 69 dir_arg=
cannam@86 70 dstarg=
cannam@86 71 no_target_directory=
cannam@86 72
cannam@86 73 usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
cannam@86 74 or: $0 [OPTION]... SRCFILES... DIRECTORY
cannam@86 75 or: $0 [OPTION]... -t DIRECTORY SRCFILES...
cannam@86 76 or: $0 [OPTION]... -d DIRECTORIES...
cannam@86 77
cannam@86 78 In the 1st form, copy SRCFILE to DSTFILE.
cannam@86 79 In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
cannam@86 80 In the 4th, create DIRECTORIES.
cannam@86 81
cannam@86 82 Options:
cannam@86 83 -c (ignored)
cannam@86 84 -d create directories instead of installing files.
cannam@86 85 -g GROUP $chgrpprog installed files to GROUP.
cannam@86 86 -m MODE $chmodprog installed files to MODE.
cannam@86 87 -o USER $chownprog installed files to USER.
cannam@86 88 -s $stripprog installed files.
cannam@86 89 -t DIRECTORY install into DIRECTORY.
cannam@86 90 -T report an error if DSTFILE is a directory.
cannam@86 91 --help display this help and exit.
cannam@86 92 --version display version info and exit.
cannam@86 93
cannam@86 94 Environment variables override the default commands:
cannam@86 95 CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
cannam@86 96 "
cannam@86 97
cannam@86 98 while test -n "$1"; do
cannam@86 99 case $1 in
cannam@86 100 -c) shift
cannam@86 101 continue;;
cannam@86 102
cannam@86 103 -d) dir_arg=true
cannam@86 104 shift
cannam@86 105 continue;;
cannam@86 106
cannam@86 107 -g) chgrpcmd="$chgrpprog $2"
cannam@86 108 shift
cannam@86 109 shift
cannam@86 110 continue;;
cannam@86 111
cannam@86 112 --help) echo "$usage"; exit $?;;
cannam@86 113
cannam@86 114 -m) chmodcmd="$chmodprog $2"
cannam@86 115 shift
cannam@86 116 shift
cannam@86 117 continue;;
cannam@86 118
cannam@86 119 -o) chowncmd="$chownprog $2"
cannam@86 120 shift
cannam@86 121 shift
cannam@86 122 continue;;
cannam@86 123
cannam@86 124 -s) stripcmd=$stripprog
cannam@86 125 shift
cannam@86 126 continue;;
cannam@86 127
cannam@86 128 -t) dstarg=$2
cannam@86 129 shift
cannam@86 130 shift
cannam@86 131 continue;;
cannam@86 132
cannam@86 133 -T) no_target_directory=true
cannam@86 134 shift
cannam@86 135 continue;;
cannam@86 136
cannam@86 137 --version) echo "$0 $scriptversion"; exit $?;;
cannam@86 138
cannam@86 139 *) # When -d is used, all remaining arguments are directories to create.
cannam@86 140 # When -t is used, the destination is already specified.
cannam@86 141 test -n "$dir_arg$dstarg" && break
cannam@86 142 # Otherwise, the last argument is the destination. Remove it from $@.
cannam@86 143 for arg
cannam@86 144 do
cannam@86 145 if test -n "$dstarg"; then
cannam@86 146 # $@ is not empty: it contains at least $arg.
cannam@86 147 set fnord "$@" "$dstarg"
cannam@86 148 shift # fnord
cannam@86 149 fi
cannam@86 150 shift # arg
cannam@86 151 dstarg=$arg
cannam@86 152 done
cannam@86 153 break;;
cannam@86 154 esac
cannam@86 155 done
cannam@86 156
cannam@86 157 if test -z "$1"; then
cannam@86 158 if test -z "$dir_arg"; then
cannam@86 159 echo "$0: no input file specified." >&2
cannam@86 160 exit 1
cannam@86 161 fi
cannam@86 162 # It's OK to call `install-sh -d' without argument.
cannam@86 163 # This can happen when creating conditional directories.
cannam@86 164 exit 0
cannam@86 165 fi
cannam@86 166
cannam@86 167 for src
cannam@86 168 do
cannam@86 169 # Protect names starting with `-'.
cannam@86 170 case $src in
cannam@86 171 -*) src=./$src ;;
cannam@86 172 esac
cannam@86 173
cannam@86 174 if test -n "$dir_arg"; then
cannam@86 175 dst=$src
cannam@86 176 src=
cannam@86 177
cannam@86 178 if test -d "$dst"; then
cannam@86 179 mkdircmd=:
cannam@86 180 chmodcmd=
cannam@86 181 else
cannam@86 182 mkdircmd=$mkdirprog
cannam@86 183 fi
cannam@86 184 else
cannam@86 185 # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
cannam@86 186 # might cause directories to be created, which would be especially bad
cannam@86 187 # if $src (and thus $dsttmp) contains '*'.
cannam@86 188 if test ! -f "$src" && test ! -d "$src"; then
cannam@86 189 echo "$0: $src does not exist." >&2
cannam@86 190 exit 1
cannam@86 191 fi
cannam@86 192
cannam@86 193 if test -z "$dstarg"; then
cannam@86 194 echo "$0: no destination specified." >&2
cannam@86 195 exit 1
cannam@86 196 fi
cannam@86 197
cannam@86 198 dst=$dstarg
cannam@86 199 # Protect names starting with `-'.
cannam@86 200 case $dst in
cannam@86 201 -*) dst=./$dst ;;
cannam@86 202 esac
cannam@86 203
cannam@86 204 # If destination is a directory, append the input filename; won't work
cannam@86 205 # if double slashes aren't ignored.
cannam@86 206 if test -d "$dst"; then
cannam@86 207 if test -n "$no_target_directory"; then
cannam@86 208 echo "$0: $dstarg: Is a directory" >&2
cannam@86 209 exit 1
cannam@86 210 fi
cannam@86 211 dst=$dst/`basename "$src"`
cannam@86 212 fi
cannam@86 213 fi
cannam@86 214
cannam@86 215 # This sed command emulates the dirname command.
cannam@86 216 dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
cannam@86 217
cannam@86 218 # Make sure that the destination directory exists.
cannam@86 219
cannam@86 220 # Skip lots of stat calls in the usual case.
cannam@86 221 if test ! -d "$dstdir"; then
cannam@86 222 defaultIFS='
cannam@86 223 '
cannam@86 224 IFS="${IFS-$defaultIFS}"
cannam@86 225
cannam@86 226 oIFS=$IFS
cannam@86 227 # Some sh's can't handle IFS=/ for some reason.
cannam@86 228 IFS='%'
cannam@86 229 set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
cannam@86 230 shift
cannam@86 231 IFS=$oIFS
cannam@86 232
cannam@86 233 pathcomp=
cannam@86 234
cannam@86 235 while test $# -ne 0 ; do
cannam@86 236 pathcomp=$pathcomp$1
cannam@86 237 shift
cannam@86 238 if test ! -d "$pathcomp"; then
cannam@86 239 $mkdirprog "$pathcomp"
cannam@86 240 # mkdir can fail with a `File exist' error in case several
cannam@86 241 # install-sh are creating the directory concurrently. This
cannam@86 242 # is OK.
cannam@86 243 test -d "$pathcomp" || exit
cannam@86 244 fi
cannam@86 245 pathcomp=$pathcomp/
cannam@86 246 done
cannam@86 247 fi
cannam@86 248
cannam@86 249 if test -n "$dir_arg"; then
cannam@86 250 $doit $mkdircmd "$dst" \
cannam@86 251 && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
cannam@86 252 && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
cannam@86 253 && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
cannam@86 254 && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
cannam@86 255
cannam@86 256 else
cannam@86 257 dstfile=`basename "$dst"`
cannam@86 258
cannam@86 259 # Make a couple of temp file names in the proper directory.
cannam@86 260 dsttmp=$dstdir/_inst.$$_
cannam@86 261 rmtmp=$dstdir/_rm.$$_
cannam@86 262
cannam@86 263 # Trap to clean up those temp files at exit.
cannam@86 264 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
cannam@86 265 trap '(exit $?); exit' 1 2 13 15
cannam@86 266
cannam@86 267 # Copy the file name to the temp name.
cannam@86 268 $doit $cpprog "$src" "$dsttmp" &&
cannam@86 269
cannam@86 270 # and set any options; do chmod last to preserve setuid bits.
cannam@86 271 #
cannam@86 272 # If any of these fail, we abort the whole thing. If we want to
cannam@86 273 # ignore errors from any of these, just make sure not to ignore
cannam@86 274 # errors from the above "$doit $cpprog $src $dsttmp" command.
cannam@86 275 #
cannam@86 276 { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
cannam@86 277 && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
cannam@86 278 && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
cannam@86 279 && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
cannam@86 280
cannam@86 281 # Now rename the file to the real destination.
cannam@86 282 { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
cannam@86 283 || {
cannam@86 284 # The rename failed, perhaps because mv can't rename something else
cannam@86 285 # to itself, or perhaps because mv is so ancient that it does not
cannam@86 286 # support -f.
cannam@86 287
cannam@86 288 # Now remove or move aside any old file at destination location.
cannam@86 289 # We try this two ways since rm can't unlink itself on some
cannam@86 290 # systems and the destination file might be busy for other
cannam@86 291 # reasons. In this case, the final cleanup might fail but the new
cannam@86 292 # file should still install successfully.
cannam@86 293 {
cannam@86 294 if test -f "$dstdir/$dstfile"; then
cannam@86 295 $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
cannam@86 296 || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
cannam@86 297 || {
cannam@86 298 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
cannam@86 299 (exit 1); exit 1
cannam@86 300 }
cannam@86 301 else
cannam@86 302 :
cannam@86 303 fi
cannam@86 304 } &&
cannam@86 305
cannam@86 306 # Now rename the file to the real destination.
cannam@86 307 $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
cannam@86 308 }
cannam@86 309 }
cannam@86 310 fi || { (exit 1); exit 1; }
cannam@86 311 done
cannam@86 312
cannam@86 313 # The final little trick to "correctly" pass the exit status to the exit trap.
cannam@86 314 {
cannam@86 315 (exit 0); exit 0
cannam@86 316 }
cannam@86 317
cannam@86 318 # Local variables:
cannam@86 319 # eval: (add-hook 'write-file-hooks 'time-stamp)
cannam@86 320 # time-stamp-start: "scriptversion="
cannam@86 321 # time-stamp-format: "%:y-%02m-%02d.%02H"
cannam@86 322 # time-stamp-end: "$"
cannam@86 323 # End: