Mercurial > hg > early-roguelike
comparison install-sh @ 312:029c1f5c5588
Update the Autoconf files.
These are mostly automatic updates for obsolete macros.
author | John "Elwin" Edwards |
---|---|
date | Tue, 11 May 2021 22:30:03 -0400 |
parents | d9badb9c0179 |
children |
comparison
equal
deleted
inserted
replaced
311:28e22fb35989 | 312:029c1f5c5588 |
---|---|
1 #!/bin/sh | 1 #!/bin/sh |
2 # install - install a program, script, or datafile | 2 # install - install a program, script, or datafile |
3 | 3 |
4 scriptversion=2013-12-25.23; # UTC | 4 scriptversion=2018-03-11.20; # UTC |
5 | 5 |
6 # This originates from X11R5 (mit/util/scripts/install.sh), which was | 6 # This originates from X11R5 (mit/util/scripts/install.sh), which was |
7 # later released in X11R6 (xc/config/util/install.sh) with the | 7 # later released in X11R6 (xc/config/util/install.sh) with the |
8 # following copyright and license. | 8 # following copyright and license. |
9 # | 9 # |
269 echo "$0: no destination specified." >&2 | 269 echo "$0: no destination specified." >&2 |
270 exit 1 | 270 exit 1 |
271 fi | 271 fi |
272 dst=$dst_arg | 272 dst=$dst_arg |
273 | 273 |
274 # If destination is a directory, append the input filename; won't work | 274 # If destination is a directory, append the input filename. |
275 # if double slashes aren't ignored. | |
276 if test -d "$dst"; then | 275 if test -d "$dst"; then |
277 if test "$is_target_a_directory" = never; then | 276 if test "$is_target_a_directory" = never; then |
278 echo "$0: $dst_arg: Is a directory" >&2 | 277 echo "$0: $dst_arg: Is a directory" >&2 |
279 exit 1 | 278 exit 1 |
280 fi | 279 fi |
281 dstdir=$dst | 280 dstdir=$dst |
282 dst=$dstdir/`basename "$src"` | 281 dstbase=`basename "$src"` |
282 case $dst in | |
283 */) dst=$dst$dstbase;; | |
284 *) dst=$dst/$dstbase;; | |
285 esac | |
283 dstdir_status=0 | 286 dstdir_status=0 |
284 else | 287 else |
285 dstdir=`dirname "$dst"` | 288 dstdir=`dirname "$dst"` |
286 test -d "$dstdir" | 289 test -d "$dstdir" |
287 dstdir_status=$? | 290 dstdir_status=$? |
288 fi | 291 fi |
289 fi | 292 fi |
293 | |
294 case $dstdir in | |
295 */) dstdirslash=$dstdir;; | |
296 *) dstdirslash=$dstdir/;; | |
297 esac | |
290 | 298 |
291 obsolete_mkdir_used=false | 299 obsolete_mkdir_used=false |
292 | 300 |
293 if test $dstdir_status != 0; then | 301 if test $dstdir_status != 0; then |
294 case $posix_mkdir in | 302 case $posix_mkdir in |
322 *[123567][0-7][0-7]) | 330 *[123567][0-7][0-7]) |
323 # POSIX mkdir -p sets u+wx bits regardless of umask, which | 331 # POSIX mkdir -p sets u+wx bits regardless of umask, which |
324 # is incompatible with FreeBSD 'install' when (umask & 300) != 0. | 332 # is incompatible with FreeBSD 'install' when (umask & 300) != 0. |
325 ;; | 333 ;; |
326 *) | 334 *) |
335 # Note that $RANDOM variable is not portable (e.g. dash); Use it | |
336 # here however when possible just to lower collision chance. | |
327 tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ | 337 tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ |
328 trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 | 338 |
329 | 339 trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 |
340 | |
341 # Because "mkdir -p" follows existing symlinks and we likely work | |
342 # directly in world-writeable /tmp, make sure that the '$tmpdir' | |
343 # directory is successfully created first before we actually test | |
344 # 'mkdir -p' feature. | |
330 if (umask $mkdir_umask && | 345 if (umask $mkdir_umask && |
331 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 | 346 $mkdirprog $mkdir_mode "$tmpdir" && |
347 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 | |
332 then | 348 then |
333 if test -z "$dir_arg" || { | 349 if test -z "$dir_arg" || { |
334 # Check for POSIX incompatibilities with -m. | 350 # Check for POSIX incompatibilities with -m. |
335 # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or | 351 # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or |
336 # other-writable bit of parent directory when it shouldn't. | 352 # other-writable bit of parent directory when it shouldn't. |
337 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. | 353 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. |
338 ls_ld_tmpdir=`ls -ld "$tmpdir"` | 354 test_tmpdir="$tmpdir/a" |
355 ls_ld_tmpdir=`ls -ld "$test_tmpdir"` | |
339 case $ls_ld_tmpdir in | 356 case $ls_ld_tmpdir in |
340 d????-?r-*) different_mode=700;; | 357 d????-?r-*) different_mode=700;; |
341 d????-?--*) different_mode=755;; | 358 d????-?--*) different_mode=755;; |
342 *) false;; | 359 *) false;; |
343 esac && | 360 esac && |
344 $mkdirprog -m$different_mode -p -- "$tmpdir" && { | 361 $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { |
345 ls_ld_tmpdir_1=`ls -ld "$tmpdir"` | 362 ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` |
346 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" | 363 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" |
347 } | 364 } |
348 } | 365 } |
349 then posix_mkdir=: | 366 then posix_mkdir=: |
350 fi | 367 fi |
351 rmdir "$tmpdir/d" "$tmpdir" | 368 rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" |
352 else | 369 else |
353 # Remove any dirs left behind by ancient mkdir implementations. | 370 # Remove any dirs left behind by ancient mkdir implementations. |
354 rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null | 371 rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null |
355 fi | 372 fi |
356 trap '' 0;; | 373 trap '' 0;; |
357 esac;; | 374 esac;; |
358 esac | 375 esac |
359 | 376 |
425 { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || | 442 { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || |
426 test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 | 443 test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 |
427 else | 444 else |
428 | 445 |
429 # Make a couple of temp file names in the proper directory. | 446 # Make a couple of temp file names in the proper directory. |
430 dsttmp=$dstdir/_inst.$$_ | 447 dsttmp=${dstdirslash}_inst.$$_ |
431 rmtmp=$dstdir/_rm.$$_ | 448 rmtmp=${dstdirslash}_rm.$$_ |
432 | 449 |
433 # Trap to clean up those temp files at exit. | 450 # Trap to clean up those temp files at exit. |
434 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 | 451 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 |
435 | 452 |
436 # Copy the file name to the temp name. | 453 # Copy the file name to the temp name. |
437 (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && | 454 (umask $cp_umask && |
455 { test -z "$stripcmd" || { | |
456 # Create $dsttmp read-write so that cp doesn't create it read-only, | |
457 # which would cause strip to fail. | |
458 if test -z "$doit"; then | |
459 : >"$dsttmp" # No need to fork-exec 'touch'. | |
460 else | |
461 $doit touch "$dsttmp" | |
462 fi | |
463 } | |
464 } && | |
465 $doit_exec $cpprog "$src" "$dsttmp") && | |
438 | 466 |
439 # and set any options; do chmod last to preserve setuid bits. | 467 # and set any options; do chmod last to preserve setuid bits. |
440 # | 468 # |
441 # If any of these fail, we abort the whole thing. If we want to | 469 # If any of these fail, we abort the whole thing. If we want to |
442 # ignore errors from any of these, just make sure not to ignore | 470 # ignore errors from any of these, just make sure not to ignore |
491 trap '' 0 | 519 trap '' 0 |
492 fi | 520 fi |
493 done | 521 done |
494 | 522 |
495 # Local variables: | 523 # Local variables: |
496 # eval: (add-hook 'write-file-hooks 'time-stamp) | 524 # eval: (add-hook 'before-save-hook 'time-stamp) |
497 # time-stamp-start: "scriptversion=" | 525 # time-stamp-start: "scriptversion=" |
498 # time-stamp-format: "%:y-%02m-%02d.%02H" | 526 # time-stamp-format: "%:y-%02m-%02d.%02H" |
499 # time-stamp-time-zone: "UTC" | 527 # time-stamp-time-zone: "UTC0" |
500 # time-stamp-end: "; # UTC" | 528 # time-stamp-end: "; # UTC" |
501 # End: | 529 # End: |