Wed, 31 May 2017 12:20:04 +0200
adds remaining autoconf files
universe@48 | 1 | #!/bin/sh |
universe@48 | 2 | # install - install a program, script, or datafile |
universe@48 | 3 | |
universe@48 | 4 | scriptversion=2011-11-20.07; # UTC |
universe@48 | 5 | |
universe@48 | 6 | # This originates from X11R5 (mit/util/scripts/install.sh), which was |
universe@48 | 7 | # later released in X11R6 (xc/config/util/install.sh) with the |
universe@48 | 8 | # following copyright and license. |
universe@48 | 9 | # |
universe@48 | 10 | # Copyright (C) 1994 X Consortium |
universe@48 | 11 | # |
universe@48 | 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
universe@48 | 13 | # of this software and associated documentation files (the "Software"), to |
universe@48 | 14 | # deal in the Software without restriction, including without limitation the |
universe@48 | 15 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
universe@48 | 16 | # sell copies of the Software, and to permit persons to whom the Software is |
universe@48 | 17 | # furnished to do so, subject to the following conditions: |
universe@48 | 18 | # |
universe@48 | 19 | # The above copyright notice and this permission notice shall be included in |
universe@48 | 20 | # all copies or substantial portions of the Software. |
universe@48 | 21 | # |
universe@48 | 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
universe@48 | 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
universe@48 | 24 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
universe@48 | 25 | # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
universe@48 | 26 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- |
universe@48 | 27 | # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
universe@48 | 28 | # |
universe@48 | 29 | # Except as contained in this notice, the name of the X Consortium shall not |
universe@48 | 30 | # be used in advertising or otherwise to promote the sale, use or other deal- |
universe@48 | 31 | # ings in this Software without prior written authorization from the X Consor- |
universe@48 | 32 | # tium. |
universe@48 | 33 | # |
universe@48 | 34 | # |
universe@48 | 35 | # FSF changes to this file are in the public domain. |
universe@48 | 36 | # |
universe@48 | 37 | # Calling this script install-sh is preferred over install.sh, to prevent |
universe@48 | 38 | # 'make' implicit rules from creating a file called install from it |
universe@48 | 39 | # when there is no Makefile. |
universe@48 | 40 | # |
universe@48 | 41 | # This script is compatible with the BSD install script, but was written |
universe@48 | 42 | # from scratch. |
universe@48 | 43 | |
universe@48 | 44 | nl=' |
universe@48 | 45 | ' |
universe@48 | 46 | IFS=" "" $nl" |
universe@48 | 47 | |
universe@48 | 48 | # set DOITPROG to echo to test this script |
universe@48 | 49 | |
universe@48 | 50 | # Don't use :- since 4.3BSD and earlier shells don't like it. |
universe@48 | 51 | doit=${DOITPROG-} |
universe@48 | 52 | if test -z "$doit"; then |
universe@48 | 53 | doit_exec=exec |
universe@48 | 54 | else |
universe@48 | 55 | doit_exec=$doit |
universe@48 | 56 | fi |
universe@48 | 57 | |
universe@48 | 58 | # Put in absolute file names if you don't have them in your path; |
universe@48 | 59 | # or use environment vars. |
universe@48 | 60 | |
universe@48 | 61 | chgrpprog=${CHGRPPROG-chgrp} |
universe@48 | 62 | chmodprog=${CHMODPROG-chmod} |
universe@48 | 63 | chownprog=${CHOWNPROG-chown} |
universe@48 | 64 | cmpprog=${CMPPROG-cmp} |
universe@48 | 65 | cpprog=${CPPROG-cp} |
universe@48 | 66 | mkdirprog=${MKDIRPROG-mkdir} |
universe@48 | 67 | mvprog=${MVPROG-mv} |
universe@48 | 68 | rmprog=${RMPROG-rm} |
universe@48 | 69 | stripprog=${STRIPPROG-strip} |
universe@48 | 70 | |
universe@48 | 71 | posix_glob='?' |
universe@48 | 72 | initialize_posix_glob=' |
universe@48 | 73 | test "$posix_glob" != "?" || { |
universe@48 | 74 | if (set -f) 2>/dev/null; then |
universe@48 | 75 | posix_glob= |
universe@48 | 76 | else |
universe@48 | 77 | posix_glob=: |
universe@48 | 78 | fi |
universe@48 | 79 | } |
universe@48 | 80 | ' |
universe@48 | 81 | |
universe@48 | 82 | posix_mkdir= |
universe@48 | 83 | |
universe@48 | 84 | # Desired mode of installed file. |
universe@48 | 85 | mode=0755 |
universe@48 | 86 | |
universe@48 | 87 | chgrpcmd= |
universe@48 | 88 | chmodcmd=$chmodprog |
universe@48 | 89 | chowncmd= |
universe@48 | 90 | mvcmd=$mvprog |
universe@48 | 91 | rmcmd="$rmprog -f" |
universe@48 | 92 | stripcmd= |
universe@48 | 93 | |
universe@48 | 94 | src= |
universe@48 | 95 | dst= |
universe@48 | 96 | dir_arg= |
universe@48 | 97 | dst_arg= |
universe@48 | 98 | |
universe@48 | 99 | copy_on_change=false |
universe@48 | 100 | no_target_directory= |
universe@48 | 101 | |
universe@48 | 102 | usage="\ |
universe@48 | 103 | Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE |
universe@48 | 104 | or: $0 [OPTION]... SRCFILES... DIRECTORY |
universe@48 | 105 | or: $0 [OPTION]... -t DIRECTORY SRCFILES... |
universe@48 | 106 | or: $0 [OPTION]... -d DIRECTORIES... |
universe@48 | 107 | |
universe@48 | 108 | In the 1st form, copy SRCFILE to DSTFILE. |
universe@48 | 109 | In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. |
universe@48 | 110 | In the 4th, create DIRECTORIES. |
universe@48 | 111 | |
universe@48 | 112 | Options: |
universe@48 | 113 | --help display this help and exit. |
universe@48 | 114 | --version display version info and exit. |
universe@48 | 115 | |
universe@48 | 116 | -c (ignored) |
universe@48 | 117 | -C install only if different (preserve the last data modification time) |
universe@48 | 118 | -d create directories instead of installing files. |
universe@48 | 119 | -g GROUP $chgrpprog installed files to GROUP. |
universe@48 | 120 | -m MODE $chmodprog installed files to MODE. |
universe@48 | 121 | -o USER $chownprog installed files to USER. |
universe@48 | 122 | -s $stripprog installed files. |
universe@48 | 123 | -t DIRECTORY install into DIRECTORY. |
universe@48 | 124 | -T report an error if DSTFILE is a directory. |
universe@48 | 125 | |
universe@48 | 126 | Environment variables override the default commands: |
universe@48 | 127 | CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG |
universe@48 | 128 | RMPROG STRIPPROG |
universe@48 | 129 | " |
universe@48 | 130 | |
universe@48 | 131 | while test $# -ne 0; do |
universe@48 | 132 | case $1 in |
universe@48 | 133 | -c) ;; |
universe@48 | 134 | |
universe@48 | 135 | -C) copy_on_change=true;; |
universe@48 | 136 | |
universe@48 | 137 | -d) dir_arg=true;; |
universe@48 | 138 | |
universe@48 | 139 | -g) chgrpcmd="$chgrpprog $2" |
universe@48 | 140 | shift;; |
universe@48 | 141 | |
universe@48 | 142 | --help) echo "$usage"; exit $?;; |
universe@48 | 143 | |
universe@48 | 144 | -m) mode=$2 |
universe@48 | 145 | case $mode in |
universe@48 | 146 | *' '* | *' '* | *' |
universe@48 | 147 | '* | *'*'* | *'?'* | *'['*) |
universe@48 | 148 | echo "$0: invalid mode: $mode" >&2 |
universe@48 | 149 | exit 1;; |
universe@48 | 150 | esac |
universe@48 | 151 | shift;; |
universe@48 | 152 | |
universe@48 | 153 | -o) chowncmd="$chownprog $2" |
universe@48 | 154 | shift;; |
universe@48 | 155 | |
universe@48 | 156 | -s) stripcmd=$stripprog;; |
universe@48 | 157 | |
universe@48 | 158 | -t) dst_arg=$2 |
universe@48 | 159 | # Protect names problematic for 'test' and other utilities. |
universe@48 | 160 | case $dst_arg in |
universe@48 | 161 | -* | [=\(\)!]) dst_arg=./$dst_arg;; |
universe@48 | 162 | esac |
universe@48 | 163 | shift;; |
universe@48 | 164 | |
universe@48 | 165 | -T) no_target_directory=true;; |
universe@48 | 166 | |
universe@48 | 167 | --version) echo "$0 $scriptversion"; exit $?;; |
universe@48 | 168 | |
universe@48 | 169 | --) shift |
universe@48 | 170 | break;; |
universe@48 | 171 | |
universe@48 | 172 | -*) echo "$0: invalid option: $1" >&2 |
universe@48 | 173 | exit 1;; |
universe@48 | 174 | |
universe@48 | 175 | *) break;; |
universe@48 | 176 | esac |
universe@48 | 177 | shift |
universe@48 | 178 | done |
universe@48 | 179 | |
universe@48 | 180 | if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then |
universe@48 | 181 | # When -d is used, all remaining arguments are directories to create. |
universe@48 | 182 | # When -t is used, the destination is already specified. |
universe@48 | 183 | # Otherwise, the last argument is the destination. Remove it from $@. |
universe@48 | 184 | for arg |
universe@48 | 185 | do |
universe@48 | 186 | if test -n "$dst_arg"; then |
universe@48 | 187 | # $@ is not empty: it contains at least $arg. |
universe@48 | 188 | set fnord "$@" "$dst_arg" |
universe@48 | 189 | shift # fnord |
universe@48 | 190 | fi |
universe@48 | 191 | shift # arg |
universe@48 | 192 | dst_arg=$arg |
universe@48 | 193 | # Protect names problematic for 'test' and other utilities. |
universe@48 | 194 | case $dst_arg in |
universe@48 | 195 | -* | [=\(\)!]) dst_arg=./$dst_arg;; |
universe@48 | 196 | esac |
universe@48 | 197 | done |
universe@48 | 198 | fi |
universe@48 | 199 | |
universe@48 | 200 | if test $# -eq 0; then |
universe@48 | 201 | if test -z "$dir_arg"; then |
universe@48 | 202 | echo "$0: no input file specified." >&2 |
universe@48 | 203 | exit 1 |
universe@48 | 204 | fi |
universe@48 | 205 | # It's OK to call 'install-sh -d' without argument. |
universe@48 | 206 | # This can happen when creating conditional directories. |
universe@48 | 207 | exit 0 |
universe@48 | 208 | fi |
universe@48 | 209 | |
universe@48 | 210 | if test -z "$dir_arg"; then |
universe@48 | 211 | do_exit='(exit $ret); exit $ret' |
universe@48 | 212 | trap "ret=129; $do_exit" 1 |
universe@48 | 213 | trap "ret=130; $do_exit" 2 |
universe@48 | 214 | trap "ret=141; $do_exit" 13 |
universe@48 | 215 | trap "ret=143; $do_exit" 15 |
universe@48 | 216 | |
universe@48 | 217 | # Set umask so as not to create temps with too-generous modes. |
universe@48 | 218 | # However, 'strip' requires both read and write access to temps. |
universe@48 | 219 | case $mode in |
universe@48 | 220 | # Optimize common cases. |
universe@48 | 221 | *644) cp_umask=133;; |
universe@48 | 222 | *755) cp_umask=22;; |
universe@48 | 223 | |
universe@48 | 224 | *[0-7]) |
universe@48 | 225 | if test -z "$stripcmd"; then |
universe@48 | 226 | u_plus_rw= |
universe@48 | 227 | else |
universe@48 | 228 | u_plus_rw='% 200' |
universe@48 | 229 | fi |
universe@48 | 230 | cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; |
universe@48 | 231 | *) |
universe@48 | 232 | if test -z "$stripcmd"; then |
universe@48 | 233 | u_plus_rw= |
universe@48 | 234 | else |
universe@48 | 235 | u_plus_rw=,u+rw |
universe@48 | 236 | fi |
universe@48 | 237 | cp_umask=$mode$u_plus_rw;; |
universe@48 | 238 | esac |
universe@48 | 239 | fi |
universe@48 | 240 | |
universe@48 | 241 | for src |
universe@48 | 242 | do |
universe@48 | 243 | # Protect names problematic for 'test' and other utilities. |
universe@48 | 244 | case $src in |
universe@48 | 245 | -* | [=\(\)!]) src=./$src;; |
universe@48 | 246 | esac |
universe@48 | 247 | |
universe@48 | 248 | if test -n "$dir_arg"; then |
universe@48 | 249 | dst=$src |
universe@48 | 250 | dstdir=$dst |
universe@48 | 251 | test -d "$dstdir" |
universe@48 | 252 | dstdir_status=$? |
universe@48 | 253 | else |
universe@48 | 254 | |
universe@48 | 255 | # Waiting for this to be detected by the "$cpprog $src $dsttmp" command |
universe@48 | 256 | # might cause directories to be created, which would be especially bad |
universe@48 | 257 | # if $src (and thus $dsttmp) contains '*'. |
universe@48 | 258 | if test ! -f "$src" && test ! -d "$src"; then |
universe@48 | 259 | echo "$0: $src does not exist." >&2 |
universe@48 | 260 | exit 1 |
universe@48 | 261 | fi |
universe@48 | 262 | |
universe@48 | 263 | if test -z "$dst_arg"; then |
universe@48 | 264 | echo "$0: no destination specified." >&2 |
universe@48 | 265 | exit 1 |
universe@48 | 266 | fi |
universe@48 | 267 | dst=$dst_arg |
universe@48 | 268 | |
universe@48 | 269 | # If destination is a directory, append the input filename; won't work |
universe@48 | 270 | # if double slashes aren't ignored. |
universe@48 | 271 | if test -d "$dst"; then |
universe@48 | 272 | if test -n "$no_target_directory"; then |
universe@48 | 273 | echo "$0: $dst_arg: Is a directory" >&2 |
universe@48 | 274 | exit 1 |
universe@48 | 275 | fi |
universe@48 | 276 | dstdir=$dst |
universe@48 | 277 | dst=$dstdir/`basename "$src"` |
universe@48 | 278 | dstdir_status=0 |
universe@48 | 279 | else |
universe@48 | 280 | # Prefer dirname, but fall back on a substitute if dirname fails. |
universe@48 | 281 | dstdir=` |
universe@48 | 282 | (dirname "$dst") 2>/dev/null || |
universe@48 | 283 | expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ |
universe@48 | 284 | X"$dst" : 'X\(//\)[^/]' \| \ |
universe@48 | 285 | X"$dst" : 'X\(//\)$' \| \ |
universe@48 | 286 | X"$dst" : 'X\(/\)' \| . 2>/dev/null || |
universe@48 | 287 | echo X"$dst" | |
universe@48 | 288 | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ |
universe@48 | 289 | s//\1/ |
universe@48 | 290 | q |
universe@48 | 291 | } |
universe@48 | 292 | /^X\(\/\/\)[^/].*/{ |
universe@48 | 293 | s//\1/ |
universe@48 | 294 | q |
universe@48 | 295 | } |
universe@48 | 296 | /^X\(\/\/\)$/{ |
universe@48 | 297 | s//\1/ |
universe@48 | 298 | q |
universe@48 | 299 | } |
universe@48 | 300 | /^X\(\/\).*/{ |
universe@48 | 301 | s//\1/ |
universe@48 | 302 | q |
universe@48 | 303 | } |
universe@48 | 304 | s/.*/./; q' |
universe@48 | 305 | ` |
universe@48 | 306 | |
universe@48 | 307 | test -d "$dstdir" |
universe@48 | 308 | dstdir_status=$? |
universe@48 | 309 | fi |
universe@48 | 310 | fi |
universe@48 | 311 | |
universe@48 | 312 | obsolete_mkdir_used=false |
universe@48 | 313 | |
universe@48 | 314 | if test $dstdir_status != 0; then |
universe@48 | 315 | case $posix_mkdir in |
universe@48 | 316 | '') |
universe@48 | 317 | # Create intermediate dirs using mode 755 as modified by the umask. |
universe@48 | 318 | # This is like FreeBSD 'install' as of 1997-10-28. |
universe@48 | 319 | umask=`umask` |
universe@48 | 320 | case $stripcmd.$umask in |
universe@48 | 321 | # Optimize common cases. |
universe@48 | 322 | *[2367][2367]) mkdir_umask=$umask;; |
universe@48 | 323 | .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; |
universe@48 | 324 | |
universe@48 | 325 | *[0-7]) |
universe@48 | 326 | mkdir_umask=`expr $umask + 22 \ |
universe@48 | 327 | - $umask % 100 % 40 + $umask % 20 \ |
universe@48 | 328 | - $umask % 10 % 4 + $umask % 2 |
universe@48 | 329 | `;; |
universe@48 | 330 | *) mkdir_umask=$umask,go-w;; |
universe@48 | 331 | esac |
universe@48 | 332 | |
universe@48 | 333 | # With -d, create the new directory with the user-specified mode. |
universe@48 | 334 | # Otherwise, rely on $mkdir_umask. |
universe@48 | 335 | if test -n "$dir_arg"; then |
universe@48 | 336 | mkdir_mode=-m$mode |
universe@48 | 337 | else |
universe@48 | 338 | mkdir_mode= |
universe@48 | 339 | fi |
universe@48 | 340 | |
universe@48 | 341 | posix_mkdir=false |
universe@48 | 342 | case $umask in |
universe@48 | 343 | *[123567][0-7][0-7]) |
universe@48 | 344 | # POSIX mkdir -p sets u+wx bits regardless of umask, which |
universe@48 | 345 | # is incompatible with FreeBSD 'install' when (umask & 300) != 0. |
universe@48 | 346 | ;; |
universe@48 | 347 | *) |
universe@48 | 348 | tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ |
universe@48 | 349 | trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 |
universe@48 | 350 | |
universe@48 | 351 | if (umask $mkdir_umask && |
universe@48 | 352 | exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 |
universe@48 | 353 | then |
universe@48 | 354 | if test -z "$dir_arg" || { |
universe@48 | 355 | # Check for POSIX incompatibilities with -m. |
universe@48 | 356 | # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or |
universe@48 | 357 | # other-writable bit of parent directory when it shouldn't. |
universe@48 | 358 | # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. |
universe@48 | 359 | ls_ld_tmpdir=`ls -ld "$tmpdir"` |
universe@48 | 360 | case $ls_ld_tmpdir in |
universe@48 | 361 | d????-?r-*) different_mode=700;; |
universe@48 | 362 | d????-?--*) different_mode=755;; |
universe@48 | 363 | *) false;; |
universe@48 | 364 | esac && |
universe@48 | 365 | $mkdirprog -m$different_mode -p -- "$tmpdir" && { |
universe@48 | 366 | ls_ld_tmpdir_1=`ls -ld "$tmpdir"` |
universe@48 | 367 | test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" |
universe@48 | 368 | } |
universe@48 | 369 | } |
universe@48 | 370 | then posix_mkdir=: |
universe@48 | 371 | fi |
universe@48 | 372 | rmdir "$tmpdir/d" "$tmpdir" |
universe@48 | 373 | else |
universe@48 | 374 | # Remove any dirs left behind by ancient mkdir implementations. |
universe@48 | 375 | rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null |
universe@48 | 376 | fi |
universe@48 | 377 | trap '' 0;; |
universe@48 | 378 | esac;; |
universe@48 | 379 | esac |
universe@48 | 380 | |
universe@48 | 381 | if |
universe@48 | 382 | $posix_mkdir && ( |
universe@48 | 383 | umask $mkdir_umask && |
universe@48 | 384 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" |
universe@48 | 385 | ) |
universe@48 | 386 | then : |
universe@48 | 387 | else |
universe@48 | 388 | |
universe@48 | 389 | # The umask is ridiculous, or mkdir does not conform to POSIX, |
universe@48 | 390 | # or it failed possibly due to a race condition. Create the |
universe@48 | 391 | # directory the slow way, step by step, checking for races as we go. |
universe@48 | 392 | |
universe@48 | 393 | case $dstdir in |
universe@48 | 394 | /*) prefix='/';; |
universe@48 | 395 | [-=\(\)!]*) prefix='./';; |
universe@48 | 396 | *) prefix='';; |
universe@48 | 397 | esac |
universe@48 | 398 | |
universe@48 | 399 | eval "$initialize_posix_glob" |
universe@48 | 400 | |
universe@48 | 401 | oIFS=$IFS |
universe@48 | 402 | IFS=/ |
universe@48 | 403 | $posix_glob set -f |
universe@48 | 404 | set fnord $dstdir |
universe@48 | 405 | shift |
universe@48 | 406 | $posix_glob set +f |
universe@48 | 407 | IFS=$oIFS |
universe@48 | 408 | |
universe@48 | 409 | prefixes= |
universe@48 | 410 | |
universe@48 | 411 | for d |
universe@48 | 412 | do |
universe@48 | 413 | test X"$d" = X && continue |
universe@48 | 414 | |
universe@48 | 415 | prefix=$prefix$d |
universe@48 | 416 | if test -d "$prefix"; then |
universe@48 | 417 | prefixes= |
universe@48 | 418 | else |
universe@48 | 419 | if $posix_mkdir; then |
universe@48 | 420 | (umask=$mkdir_umask && |
universe@48 | 421 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break |
universe@48 | 422 | # Don't fail if two instances are running concurrently. |
universe@48 | 423 | test -d "$prefix" || exit 1 |
universe@48 | 424 | else |
universe@48 | 425 | case $prefix in |
universe@48 | 426 | *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; |
universe@48 | 427 | *) qprefix=$prefix;; |
universe@48 | 428 | esac |
universe@48 | 429 | prefixes="$prefixes '$qprefix'" |
universe@48 | 430 | fi |
universe@48 | 431 | fi |
universe@48 | 432 | prefix=$prefix/ |
universe@48 | 433 | done |
universe@48 | 434 | |
universe@48 | 435 | if test -n "$prefixes"; then |
universe@48 | 436 | # Don't fail if two instances are running concurrently. |
universe@48 | 437 | (umask $mkdir_umask && |
universe@48 | 438 | eval "\$doit_exec \$mkdirprog $prefixes") || |
universe@48 | 439 | test -d "$dstdir" || exit 1 |
universe@48 | 440 | obsolete_mkdir_used=true |
universe@48 | 441 | fi |
universe@48 | 442 | fi |
universe@48 | 443 | fi |
universe@48 | 444 | |
universe@48 | 445 | if test -n "$dir_arg"; then |
universe@48 | 446 | { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && |
universe@48 | 447 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && |
universe@48 | 448 | { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || |
universe@48 | 449 | test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 |
universe@48 | 450 | else |
universe@48 | 451 | |
universe@48 | 452 | # Make a couple of temp file names in the proper directory. |
universe@48 | 453 | dsttmp=$dstdir/_inst.$$_ |
universe@48 | 454 | rmtmp=$dstdir/_rm.$$_ |
universe@48 | 455 | |
universe@48 | 456 | # Trap to clean up those temp files at exit. |
universe@48 | 457 | trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 |
universe@48 | 458 | |
universe@48 | 459 | # Copy the file name to the temp name. |
universe@48 | 460 | (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && |
universe@48 | 461 | |
universe@48 | 462 | # and set any options; do chmod last to preserve setuid bits. |
universe@48 | 463 | # |
universe@48 | 464 | # If any of these fail, we abort the whole thing. If we want to |
universe@48 | 465 | # ignore errors from any of these, just make sure not to ignore |
universe@48 | 466 | # errors from the above "$doit $cpprog $src $dsttmp" command. |
universe@48 | 467 | # |
universe@48 | 468 | { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && |
universe@48 | 469 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && |
universe@48 | 470 | { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && |
universe@48 | 471 | { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && |
universe@48 | 472 | |
universe@48 | 473 | # If -C, don't bother to copy if it wouldn't change the file. |
universe@48 | 474 | if $copy_on_change && |
universe@48 | 475 | old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && |
universe@48 | 476 | new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && |
universe@48 | 477 | |
universe@48 | 478 | eval "$initialize_posix_glob" && |
universe@48 | 479 | $posix_glob set -f && |
universe@48 | 480 | set X $old && old=:$2:$4:$5:$6 && |
universe@48 | 481 | set X $new && new=:$2:$4:$5:$6 && |
universe@48 | 482 | $posix_glob set +f && |
universe@48 | 483 | |
universe@48 | 484 | test "$old" = "$new" && |
universe@48 | 485 | $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 |
universe@48 | 486 | then |
universe@48 | 487 | rm -f "$dsttmp" |
universe@48 | 488 | else |
universe@48 | 489 | # Rename the file to the real destination. |
universe@48 | 490 | $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || |
universe@48 | 491 | |
universe@48 | 492 | # The rename failed, perhaps because mv can't rename something else |
universe@48 | 493 | # to itself, or perhaps because mv is so ancient that it does not |
universe@48 | 494 | # support -f. |
universe@48 | 495 | { |
universe@48 | 496 | # Now remove or move aside any old file at destination location. |
universe@48 | 497 | # We try this two ways since rm can't unlink itself on some |
universe@48 | 498 | # systems and the destination file might be busy for other |
universe@48 | 499 | # reasons. In this case, the final cleanup might fail but the new |
universe@48 | 500 | # file should still install successfully. |
universe@48 | 501 | { |
universe@48 | 502 | test ! -f "$dst" || |
universe@48 | 503 | $doit $rmcmd -f "$dst" 2>/dev/null || |
universe@48 | 504 | { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && |
universe@48 | 505 | { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } |
universe@48 | 506 | } || |
universe@48 | 507 | { echo "$0: cannot unlink or rename $dst" >&2 |
universe@48 | 508 | (exit 1); exit 1 |
universe@48 | 509 | } |
universe@48 | 510 | } && |
universe@48 | 511 | |
universe@48 | 512 | # Now rename the file to the real destination. |
universe@48 | 513 | $doit $mvcmd "$dsttmp" "$dst" |
universe@48 | 514 | } |
universe@48 | 515 | fi || exit 1 |
universe@48 | 516 | |
universe@48 | 517 | trap '' 0 |
universe@48 | 518 | fi |
universe@48 | 519 | done |
universe@48 | 520 | |
universe@48 | 521 | # Local variables: |
universe@48 | 522 | # eval: (add-hook 'write-file-hooks 'time-stamp) |
universe@48 | 523 | # time-stamp-start: "scriptversion=" |
universe@48 | 524 | # time-stamp-format: "%:y-%02m-%02d.%02H" |
universe@48 | 525 | # time-stamp-time-zone: "UTC" |
universe@48 | 526 | # time-stamp-end: "; # UTC" |
universe@48 | 527 | # End: |