patch-install-sh 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. $Id: update-patches 24 2008-08-31 14:56:13Z wbx $
  2. --- cgilib-0.7.orig/install-sh 2009-02-08 19:47:04.000000000 +0100
  3. +++ cgilib-0.7/install-sh 2009-05-09 03:58:09.000000000 +0200
  4. @@ -1,7 +1,7 @@
  5. #!/bin/sh
  6. # install - install a program, script, or datafile
  7. -scriptversion=2006-12-25.00
  8. +scriptversion=2005-05-14.22
  9. # This originates from X11R5 (mit/util/scripts/install.sh), which was
  10. # later released in X11R6 (xc/config/util/install.sh) with the
  11. @@ -39,68 +39,38 @@ scriptversion=2006-12-25.00
  12. # when there is no Makefile.
  13. #
  14. # This script is compatible with the BSD install script, but was written
  15. -# from scratch.
  16. -
  17. -nl='
  18. -'
  19. -IFS=" "" $nl"
  20. +# from scratch. It can only install one file at a time, a restriction
  21. +# shared with many OS's install programs.
  22. # set DOITPROG to echo to test this script
  23. # Don't use :- since 4.3BSD and earlier shells don't like it.
  24. -doit=${DOITPROG-}
  25. -if test -z "$doit"; then
  26. - doit_exec=exec
  27. -else
  28. - doit_exec=$doit
  29. -fi
  30. -
  31. -# Put in absolute file names if you don't have them in your path;
  32. -# or use environment vars.
  33. -
  34. -chgrpprog=${CHGRPPROG-chgrp}
  35. -chmodprog=${CHMODPROG-chmod}
  36. -chownprog=${CHOWNPROG-chown}
  37. -cmpprog=${CMPPROG-cmp}
  38. -cpprog=${CPPROG-cp}
  39. -mkdirprog=${MKDIRPROG-mkdir}
  40. -mvprog=${MVPROG-mv}
  41. -rmprog=${RMPROG-rm}
  42. -stripprog=${STRIPPROG-strip}
  43. -
  44. -posix_glob='?'
  45. -initialize_posix_glob='
  46. - test "$posix_glob" != "?" || {
  47. - if (set -f) 2>/dev/null; then
  48. - posix_glob=
  49. - else
  50. - posix_glob=:
  51. - fi
  52. - }
  53. -'
  54. +doit="${DOITPROG-}"
  55. -posix_mkdir=
  56. +# put in absolute paths if you don't have them in your path; or use env. vars.
  57. -# Desired mode of installed file.
  58. -mode=0755
  59. +mvprog="${MVPROG-mv}"
  60. +cpprog="${CPPROG-cp}"
  61. +chmodprog="${CHMODPROG-chmod}"
  62. +chownprog="${CHOWNPROG-chown}"
  63. +chgrpprog="${CHGRPPROG-chgrp}"
  64. +stripprog="${STRIPPROG-strip}"
  65. +rmprog="${RMPROG-rm}"
  66. +mkdirprog="${MKDIRPROG-mkdir}"
  67. -chgrpcmd=
  68. -chmodcmd=$chmodprog
  69. +chmodcmd="$chmodprog 0755"
  70. chowncmd=
  71. -mvcmd=$mvprog
  72. -rmcmd="$rmprog -f"
  73. +chgrpcmd=
  74. stripcmd=
  75. -
  76. +rmcmd="$rmprog -f"
  77. +mvcmd="$mvprog"
  78. src=
  79. dst=
  80. dir_arg=
  81. -dst_arg=
  82. -
  83. -copy_on_change=false
  84. +dstarg=
  85. no_target_directory=
  86. -usage="\
  87. -Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
  88. +usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
  89. or: $0 [OPTION]... SRCFILES... DIRECTORY
  90. or: $0 [OPTION]... -t DIRECTORY SRCFILES...
  91. or: $0 [OPTION]... -d DIRECTORIES...
  92. @@ -110,86 +80,81 @@ In the 2nd and 3rd, copy all SRCFILES to
  93. In the 4th, create DIRECTORIES.
  94. Options:
  95. - --help display this help and exit.
  96. - --version display version info and exit.
  97. -
  98. - -c (ignored)
  99. - -C install only if different (preserve the last data modification time)
  100. - -d create directories instead of installing files.
  101. - -g GROUP $chgrpprog installed files to GROUP.
  102. - -m MODE $chmodprog installed files to MODE.
  103. - -o USER $chownprog installed files to USER.
  104. - -s $stripprog installed files.
  105. - -t DIRECTORY install into DIRECTORY.
  106. - -T report an error if DSTFILE is a directory.
  107. +-c (ignored)
  108. +-d create directories instead of installing files.
  109. +-g GROUP $chgrpprog installed files to GROUP.
  110. +-m MODE $chmodprog installed files to MODE.
  111. +-o USER $chownprog installed files to USER.
  112. +-s $stripprog installed files.
  113. +-t DIRECTORY install into DIRECTORY.
  114. +-T report an error if DSTFILE is a directory.
  115. +--help display this help and exit.
  116. +--version display version info and exit.
  117. Environment variables override the default commands:
  118. - CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
  119. - RMPROG STRIPPROG
  120. + CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
  121. "
  122. -while test $# -ne 0; do
  123. +while test -n "$1"; do
  124. case $1 in
  125. - -c) ;;
  126. -
  127. - -C) copy_on_change=true;;
  128. + -c) shift
  129. + continue;;
  130. - -d) dir_arg=true;;
  131. + -d) dir_arg=true
  132. + shift
  133. + continue;;
  134. -g) chgrpcmd="$chgrpprog $2"
  135. - shift;;
  136. + shift
  137. + shift
  138. + continue;;
  139. --help) echo "$usage"; exit $?;;
  140. - -m) mode=$2
  141. - case $mode in
  142. - *' '* | *' '* | *'
  143. -'* | *'*'* | *'?'* | *'['*)
  144. - echo "$0: invalid mode: $mode" >&2
  145. - exit 1;;
  146. - esac
  147. - shift;;
  148. + -m) chmodcmd="$chmodprog $2"
  149. + shift
  150. + shift
  151. + continue;;
  152. -o) chowncmd="$chownprog $2"
  153. - shift;;
  154. + shift
  155. + shift
  156. + continue;;
  157. - -s) stripcmd=$stripprog;;
  158. + -s) stripcmd=$stripprog
  159. + shift
  160. + continue;;
  161. - -t) dst_arg=$2
  162. - shift;;
  163. + -t) dstarg=$2
  164. + shift
  165. + shift
  166. + continue;;
  167. - -T) no_target_directory=true;;
  168. + -T) no_target_directory=true
  169. + shift
  170. + continue;;
  171. --version) echo "$0 $scriptversion"; exit $?;;
  172. - --) shift
  173. + *) # When -d is used, all remaining arguments are directories to create.
  174. + # When -t is used, the destination is already specified.
  175. + test -n "$dir_arg$dstarg" && break
  176. + # Otherwise, the last argument is the destination. Remove it from $@.
  177. + for arg
  178. + do
  179. + if test -n "$dstarg"; then
  180. + # $@ is not empty: it contains at least $arg.
  181. + set fnord "$@" "$dstarg"
  182. + shift # fnord
  183. + fi
  184. + shift # arg
  185. + dstarg=$arg
  186. + done
  187. break;;
  188. -
  189. - -*) echo "$0: invalid option: $1" >&2
  190. - exit 1;;
  191. -
  192. - *) break;;
  193. esac
  194. - shift
  195. done
  196. -if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
  197. - # When -d is used, all remaining arguments are directories to create.
  198. - # When -t is used, the destination is already specified.
  199. - # Otherwise, the last argument is the destination. Remove it from $@.
  200. - for arg
  201. - do
  202. - if test -n "$dst_arg"; then
  203. - # $@ is not empty: it contains at least $arg.
  204. - set fnord "$@" "$dst_arg"
  205. - shift # fnord
  206. - fi
  207. - shift # arg
  208. - dst_arg=$arg
  209. - done
  210. -fi
  211. -
  212. -if test $# -eq 0; then
  213. +if test -z "$1"; then
  214. if test -z "$dir_arg"; then
  215. echo "$0: no input file specified." >&2
  216. exit 1
  217. @@ -199,47 +164,24 @@ if test $# -eq 0; then
  218. exit 0
  219. fi
  220. -if test -z "$dir_arg"; then
  221. - trap '(exit $?); exit' 1 2 13 15
  222. -
  223. - # Set umask so as not to create temps with too-generous modes.
  224. - # However, 'strip' requires both read and write access to temps.
  225. - case $mode in
  226. - # Optimize common cases.
  227. - *644) cp_umask=133;;
  228. - *755) cp_umask=22;;
  229. -
  230. - *[0-7])
  231. - if test -z "$stripcmd"; then
  232. - u_plus_rw=
  233. - else
  234. - u_plus_rw='% 200'
  235. - fi
  236. - cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
  237. - *)
  238. - if test -z "$stripcmd"; then
  239. - u_plus_rw=
  240. - else
  241. - u_plus_rw=,u+rw
  242. - fi
  243. - cp_umask=$mode$u_plus_rw;;
  244. - esac
  245. -fi
  246. -
  247. for src
  248. do
  249. # Protect names starting with `-'.
  250. case $src in
  251. - -*) src=./$src;;
  252. + -*) src=./$src ;;
  253. esac
  254. if test -n "$dir_arg"; then
  255. dst=$src
  256. - dstdir=$dst
  257. - test -d "$dstdir"
  258. - dstdir_status=$?
  259. - else
  260. + src=
  261. + if test -d "$dst"; then
  262. + mkdircmd=:
  263. + chmodcmd=
  264. + else
  265. + mkdircmd=$mkdirprog
  266. + fi
  267. + else
  268. # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
  269. # might cause directories to be created, which would be especially bad
  270. # if $src (and thus $dsttmp) contains '*'.
  271. @@ -248,199 +190,71 @@ do
  272. exit 1
  273. fi
  274. - if test -z "$dst_arg"; then
  275. + if test -z "$dstarg"; then
  276. echo "$0: no destination specified." >&2
  277. exit 1
  278. fi
  279. - dst=$dst_arg
  280. + dst=$dstarg
  281. # Protect names starting with `-'.
  282. case $dst in
  283. - -*) dst=./$dst;;
  284. + -*) dst=./$dst ;;
  285. esac
  286. # If destination is a directory, append the input filename; won't work
  287. # if double slashes aren't ignored.
  288. if test -d "$dst"; then
  289. if test -n "$no_target_directory"; then
  290. - echo "$0: $dst_arg: Is a directory" >&2
  291. + echo "$0: $dstarg: Is a directory" >&2
  292. exit 1
  293. fi
  294. - dstdir=$dst
  295. - dst=$dstdir/`basename "$src"`
  296. - dstdir_status=0
  297. - else
  298. - # Prefer dirname, but fall back on a substitute if dirname fails.
  299. - dstdir=`
  300. - (dirname "$dst") 2>/dev/null ||
  301. - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
  302. - X"$dst" : 'X\(//\)[^/]' \| \
  303. - X"$dst" : 'X\(//\)$' \| \
  304. - X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
  305. - echo X"$dst" |
  306. - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
  307. - s//\1/
  308. - q
  309. - }
  310. - /^X\(\/\/\)[^/].*/{
  311. - s//\1/
  312. - q
  313. - }
  314. - /^X\(\/\/\)$/{
  315. - s//\1/
  316. - q
  317. - }
  318. - /^X\(\/\).*/{
  319. - s//\1/
  320. - q
  321. - }
  322. - s/.*/./; q'
  323. - `
  324. -
  325. - test -d "$dstdir"
  326. - dstdir_status=$?
  327. + dst=$dst/`basename "$src"`
  328. fi
  329. fi
  330. - obsolete_mkdir_used=false
  331. -
  332. - if test $dstdir_status != 0; then
  333. - case $posix_mkdir in
  334. - '')
  335. - # Create intermediate dirs using mode 755 as modified by the umask.
  336. - # This is like FreeBSD 'install' as of 1997-10-28.
  337. - umask=`umask`
  338. - case $stripcmd.$umask in
  339. - # Optimize common cases.
  340. - *[2367][2367]) mkdir_umask=$umask;;
  341. - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
  342. -
  343. - *[0-7])
  344. - mkdir_umask=`expr $umask + 22 \
  345. - - $umask % 100 % 40 + $umask % 20 \
  346. - - $umask % 10 % 4 + $umask % 2
  347. - `;;
  348. - *) mkdir_umask=$umask,go-w;;
  349. - esac
  350. -
  351. - # With -d, create the new directory with the user-specified mode.
  352. - # Otherwise, rely on $mkdir_umask.
  353. - if test -n "$dir_arg"; then
  354. - mkdir_mode=-m$mode
  355. - else
  356. - mkdir_mode=
  357. - fi
  358. -
  359. - posix_mkdir=false
  360. - case $umask in
  361. - *[123567][0-7][0-7])
  362. - # POSIX mkdir -p sets u+wx bits regardless of umask, which
  363. - # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
  364. - ;;
  365. - *)
  366. - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
  367. - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
  368. -
  369. - if (umask $mkdir_umask &&
  370. - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
  371. - then
  372. - if test -z "$dir_arg" || {
  373. - # Check for POSIX incompatibilities with -m.
  374. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
  375. - # other-writeable bit of parent directory when it shouldn't.
  376. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
  377. - ls_ld_tmpdir=`ls -ld "$tmpdir"`
  378. - case $ls_ld_tmpdir in
  379. - d????-?r-*) different_mode=700;;
  380. - d????-?--*) different_mode=755;;
  381. - *) false;;
  382. - esac &&
  383. - $mkdirprog -m$different_mode -p -- "$tmpdir" && {
  384. - ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
  385. - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
  386. - }
  387. - }
  388. - then posix_mkdir=:
  389. - fi
  390. - rmdir "$tmpdir/d" "$tmpdir"
  391. - else
  392. - # Remove any dirs left behind by ancient mkdir implementations.
  393. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
  394. - fi
  395. - trap '' 0;;
  396. - esac;;
  397. - esac
  398. + # This sed command emulates the dirname command.
  399. + dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
  400. - if
  401. - $posix_mkdir && (
  402. - umask $mkdir_umask &&
  403. - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
  404. - )
  405. - then :
  406. - else
  407. + # Make sure that the destination directory exists.
  408. - # The umask is ridiculous, or mkdir does not conform to POSIX,
  409. - # or it failed possibly due to a race condition. Create the
  410. - # directory the slow way, step by step, checking for races as we go.
  411. + # Skip lots of stat calls in the usual case.
  412. + if test ! -d "$dstdir"; then
  413. + defaultIFS='
  414. + '
  415. + IFS="${IFS-$defaultIFS}"
  416. - case $dstdir in
  417. - /*) prefix='/';;
  418. - -*) prefix='./';;
  419. - *) prefix='';;
  420. - esac
  421. + oIFS=$IFS
  422. + # Some sh's can't handle IFS=/ for some reason.
  423. + IFS='%'
  424. + set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
  425. + shift
  426. + IFS=$oIFS
  427. - eval "$initialize_posix_glob"
  428. + pathcomp=
  429. - oIFS=$IFS
  430. - IFS=/
  431. - $posix_glob set -f
  432. - set fnord $dstdir
  433. + while test $# -ne 0 ; do
  434. + pathcomp=$pathcomp$1
  435. shift
  436. - $posix_glob set +f
  437. - IFS=$oIFS
  438. -
  439. - prefixes=
  440. -
  441. - for d
  442. - do
  443. - test -z "$d" && continue
  444. -
  445. - prefix=$prefix$d
  446. - if test -d "$prefix"; then
  447. - prefixes=
  448. - else
  449. - if $posix_mkdir; then
  450. - (umask=$mkdir_umask &&
  451. - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
  452. - # Don't fail if two instances are running concurrently.
  453. - test -d "$prefix" || exit 1
  454. - else
  455. - case $prefix in
  456. - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
  457. - *) qprefix=$prefix;;
  458. - esac
  459. - prefixes="$prefixes '$qprefix'"
  460. - fi
  461. - fi
  462. - prefix=$prefix/
  463. - done
  464. -
  465. - if test -n "$prefixes"; then
  466. - # Don't fail if two instances are running concurrently.
  467. - (umask $mkdir_umask &&
  468. - eval "\$doit_exec \$mkdirprog $prefixes") ||
  469. - test -d "$dstdir" || exit 1
  470. - obsolete_mkdir_used=true
  471. + if test ! -d "$pathcomp"; then
  472. + $mkdirprog "$pathcomp"
  473. + # mkdir can fail with a `File exist' error in case several
  474. + # install-sh are creating the directory concurrently. This
  475. + # is OK.
  476. + test -d "$pathcomp" || exit
  477. fi
  478. - fi
  479. + pathcomp=$pathcomp/
  480. + done
  481. fi
  482. if test -n "$dir_arg"; then
  483. - { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
  484. - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
  485. - { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
  486. - test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
  487. + $doit $mkdircmd "$dst" \
  488. + && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
  489. + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
  490. + && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
  491. + && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
  492. +
  493. else
  494. + dstfile=`basename "$dst"`
  495. # Make a couple of temp file names in the proper directory.
  496. dsttmp=$dstdir/_inst.$$_
  497. @@ -448,9 +262,10 @@ do
  498. # Trap to clean up those temp files at exit.
  499. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
  500. + trap '(exit $?); exit' 1 2 13 15
  501. # Copy the file name to the temp name.
  502. - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
  503. + $doit $cpprog "$src" "$dsttmp" &&
  504. # and set any options; do chmod last to preserve setuid bits.
  505. #
  506. @@ -458,59 +273,48 @@ do
  507. # ignore errors from any of these, just make sure not to ignore
  508. # errors from the above "$doit $cpprog $src $dsttmp" command.
  509. #
  510. - { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
  511. - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
  512. - { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
  513. - { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
  514. -
  515. - # If -C, don't bother to copy if it wouldn't change the file.
  516. - if $copy_on_change &&
  517. - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
  518. - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
  519. -
  520. - eval "$initialize_posix_glob" &&
  521. - $posix_glob set -f &&
  522. - set X $old && old=:$2:$4:$5:$6 &&
  523. - set X $new && new=:$2:$4:$5:$6 &&
  524. - $posix_glob set +f &&
  525. -
  526. - test "$old" = "$new" &&
  527. - $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
  528. - then
  529. - rm -f "$dsttmp"
  530. - else
  531. - # Rename the file to the real destination.
  532. - $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
  533. + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
  534. + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
  535. + && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
  536. + && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
  537. - # The rename failed, perhaps because mv can't rename something else
  538. - # to itself, or perhaps because mv is so ancient that it does not
  539. - # support -f.
  540. - {
  541. - # Now remove or move aside any old file at destination location.
  542. - # We try this two ways since rm can't unlink itself on some
  543. - # systems and the destination file might be busy for other
  544. - # reasons. In this case, the final cleanup might fail but the new
  545. - # file should still install successfully.
  546. - {
  547. - test ! -f "$dst" ||
  548. - $doit $rmcmd -f "$dst" 2>/dev/null ||
  549. - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
  550. - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
  551. - } ||
  552. - { echo "$0: cannot unlink or rename $dst" >&2
  553. - (exit 1); exit 1
  554. - }
  555. - } &&
  556. + # Now rename the file to the real destination.
  557. + { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
  558. + || {
  559. + # The rename failed, perhaps because mv can't rename something else
  560. + # to itself, or perhaps because mv is so ancient that it does not
  561. + # support -f.
  562. - # Now rename the file to the real destination.
  563. - $doit $mvcmd "$dsttmp" "$dst"
  564. - }
  565. - fi || exit 1
  566. + # Now remove or move aside any old file at destination location.
  567. + # We try this two ways since rm can't unlink itself on some
  568. + # systems and the destination file might be busy for other
  569. + # reasons. In this case, the final cleanup might fail but the new
  570. + # file should still install successfully.
  571. + {
  572. + if test -f "$dstdir/$dstfile"; then
  573. + $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
  574. + || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
  575. + || {
  576. + echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
  577. + (exit 1); exit 1
  578. + }
  579. + else
  580. + :
  581. + fi
  582. + } &&
  583. - trap '' 0
  584. - fi
  585. + # Now rename the file to the real destination.
  586. + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
  587. + }
  588. + }
  589. + fi || { (exit 1); exit 1; }
  590. done
  591. +# The final little trick to "correctly" pass the exit status to the exit trap.
  592. +{
  593. + (exit 0); exit 0
  594. +}
  595. +
  596. # Local variables:
  597. # eval: (add-hook 'write-file-hooks 'time-stamp)
  598. # time-stamp-start: "scriptversion="