patch-install-sh 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. --- Libnet-1.0.2a.orig/install-sh 2001-02-05 18:51:48.000000000 +0100
  2. +++ Libnet-1.0.2a/install-sh 2009-08-23 00:39:58.189621602 +0200
  3. @@ -1,19 +1,38 @@
  4. -#! /bin/sh
  5. -#
  6. +#!/bin/sh
  7. # install - install a program, script, or datafile
  8. -# This comes from X11R5 (mit/util/scripts/install.sh).
  9. +
  10. +scriptversion=2004-04-01.17
  11. +
  12. +# This originates from X11R5 (mit/util/scripts/install.sh), which was
  13. +# later released in X11R6 (xc/config/util/install.sh) with the
  14. +# following copyright and license.
  15. #
  16. -# Copyright 1991 by the Massachusetts Institute of Technology
  17. +# Copyright (C) 1994 X Consortium
  18. #
  19. -# Permission to use, copy, modify, distribute, and sell this software and its
  20. -# documentation for any purpose is hereby granted without fee, provided that
  21. -# the above copyright notice appear in all copies and that both that
  22. -# copyright notice and this permission notice appear in supporting
  23. -# documentation, and that the name of M.I.T. not be used in advertising or
  24. -# publicity pertaining to distribution of the software without specific,
  25. -# written prior permission. M.I.T. makes no representations about the
  26. -# suitability of this software for any purpose. It is provided "as is"
  27. -# without express or implied warranty.
  28. +# Permission is hereby granted, free of charge, to any person obtaining a copy
  29. +# of this software and associated documentation files (the "Software"), to
  30. +# deal in the Software without restriction, including without limitation the
  31. +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  32. +# sell copies of the Software, and to permit persons to whom the Software is
  33. +# furnished to do so, subject to the following conditions:
  34. +#
  35. +# The above copyright notice and this permission notice shall be included in
  36. +# all copies or substantial portions of the Software.
  37. +#
  38. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  39. +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  40. +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  41. +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  42. +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
  43. +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  44. +#
  45. +# Except as contained in this notice, the name of the X Consortium shall not
  46. +# be used in advertising or otherwise to promote the sale, use or other deal-
  47. +# ings in this Software without prior written authorization from the X Consor-
  48. +# tium.
  49. +#
  50. +#
  51. +# FSF changes to this file are in the public domain.
  52. #
  53. # Calling this script install-sh is preferred over install.sh, to prevent
  54. # `make' implicit rules from creating a file called install from it
  55. @@ -23,13 +42,11 @@
  56. # from scratch. It can only install one file at a time, a restriction
  57. # shared with many OS's install programs.
  58. -
  59. # set DOITPROG to echo to test this script
  60. # Don't use :- since 4.3BSD and earlier shells don't like it.
  61. doit="${DOITPROG-}"
  62. -
  63. # put in absolute paths if you don't have them in your path; or use env. vars.
  64. mvprog="${MVPROG-mv}"
  65. @@ -41,210 +58,268 @@ stripprog="${STRIPPROG-strip}"
  66. rmprog="${RMPROG-rm}"
  67. mkdirprog="${MKDIRPROG-mkdir}"
  68. -transformbasename=""
  69. -transform_arg=""
  70. -instcmd="$cpprog"
  71. +transformbasename=
  72. +transform_arg=
  73. +instcmd="$mvprog"
  74. chmodcmd="$chmodprog 0755"
  75. -chowncmd=""
  76. -chgrpcmd=""
  77. -stripcmd=""
  78. +chowncmd=
  79. +chgrpcmd=
  80. +stripcmd=
  81. rmcmd="$rmprog -f"
  82. mvcmd="$mvprog"
  83. -src=""
  84. -dst=""
  85. -dir_arg=""
  86. -
  87. -while [ x"$1" != x ]; do
  88. - case $1 in
  89. - -c) instcmd="$cpprog"
  90. - shift
  91. - continue;;
  92. -
  93. - -d) dir_arg=true
  94. - shift
  95. - continue;;
  96. +src=
  97. +dst=
  98. +dir_arg=
  99. - -m) chmodcmd="$chmodprog $2"
  100. - shift
  101. - shift
  102. - continue;;
  103. +usage="Usage: $0 [OPTION]... SRCFILE DSTFILE
  104. + or: $0 [OPTION]... SRCFILES... DIRECTORY
  105. + or: $0 -d DIRECTORIES...
  106. - -o) chowncmd="$chownprog $2"
  107. - shift
  108. - shift
  109. - continue;;
  110. +In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default.
  111. +In the second, create the directory path DIR.
  112. - -g) chgrpcmd="$chgrpprog $2"
  113. - shift
  114. - shift
  115. - continue;;
  116. +Options:
  117. +-b=TRANSFORMBASENAME
  118. +-c copy source (using $cpprog) instead of moving (using $mvprog).
  119. +-d create directories instead of installing files.
  120. +-g GROUP $chgrp installed files to GROUP.
  121. +-m MODE $chmod installed files to MODE.
  122. +-o USER $chown installed files to USER.
  123. +-s strip installed files (using $stripprog).
  124. +-t=TRANSFORM
  125. +--help display this help and exit.
  126. +--version display version info and exit.
  127. - -s) stripcmd="$stripprog"
  128. - shift
  129. - continue;;
  130. +Environment variables override the default commands:
  131. + CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
  132. +"
  133. - -t=*) transformarg=`echo $1 | sed 's/-t=//'`
  134. - shift
  135. - continue;;
  136. +while test -n "$1"; do
  137. + case $1 in
  138. + -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
  139. + shift
  140. + continue;;
  141. - -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
  142. - shift
  143. - continue;;
  144. + -c) instcmd=$cpprog
  145. + shift
  146. + continue;;
  147. - *) if [ x"$src" = x ]
  148. - then
  149. - src=$1
  150. - else
  151. - # this colon is to work around a 386BSD /bin/sh bug
  152. - :
  153. - dst=$1
  154. - fi
  155. - shift
  156. - continue;;
  157. - esac
  158. -done
  159. + -d) dir_arg=true
  160. + shift
  161. + continue;;
  162. -if [ x"$src" = x ]
  163. -then
  164. - echo "install: no input file specified"
  165. - exit 1
  166. -else
  167. - true
  168. -fi
  169. + -g) chgrpcmd="$chgrpprog $2"
  170. + shift
  171. + shift
  172. + continue;;
  173. -if [ x"$dir_arg" != x ]; then
  174. - dst=$src
  175. - src=""
  176. -
  177. - if [ -d $dst ]; then
  178. - instcmd=:
  179. - else
  180. - instcmd=mkdir
  181. - fi
  182. -else
  183. + --help) echo "$usage"; exit 0;;
  184. -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
  185. -# might cause directories to be created, which would be especially bad
  186. -# if $src (and thus $dsttmp) contains '*'.
  187. + -m) chmodcmd="$chmodprog $2"
  188. + shift
  189. + shift
  190. + continue;;
  191. - if [ -f $src -o -d $src ]
  192. - then
  193. - true
  194. - else
  195. - echo "install: $src does not exist"
  196. - exit 1
  197. - fi
  198. -
  199. - if [ x"$dst" = x ]
  200. - then
  201. - echo "install: no destination specified"
  202. - exit 1
  203. - else
  204. - true
  205. - fi
  206. + -o) chowncmd="$chownprog $2"
  207. + shift
  208. + shift
  209. + continue;;
  210. -# If destination is a directory, append the input filename; if your system
  211. -# does not like double slashes in filenames, you may need to add some logic
  212. + -s) stripcmd=$stripprog
  213. + shift
  214. + continue;;
  215. - if [ -d $dst ]
  216. - then
  217. - dst="$dst"/`basename $src`
  218. - else
  219. - true
  220. - fi
  221. -fi
  222. + -t=*) transformarg=`echo $1 | sed 's/-t=//'`
  223. + shift
  224. + continue;;
  225. -## this sed command emulates the dirname command
  226. -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
  227. + --version) echo "$0 $scriptversion"; exit 0;;
  228. -# Make sure that the destination directory exists.
  229. -# this part is taken from Noah Friedman's mkinstalldirs script
  230. + *) # When -d is used, all remaining arguments are directories to create.
  231. + test -n "$dir_arg" && break
  232. + # Otherwise, the last argument is the destination. Remove it from $@.
  233. + for arg
  234. + do
  235. + if test -n "$dstarg"; then
  236. + # $@ is not empty: it contains at least $arg.
  237. + set fnord "$@" "$dstarg"
  238. + shift # fnord
  239. + fi
  240. + shift # arg
  241. + dstarg=$arg
  242. + done
  243. + break;;
  244. + esac
  245. +done
  246. -# Skip lots of stat calls in the usual case.
  247. -if [ ! -d "$dstdir" ]; then
  248. -defaultIFS='
  249. -'
  250. -IFS="${IFS-${defaultIFS}}"
  251. +if test -z "$1"; then
  252. + if test -z "$dir_arg"; then
  253. + echo "$0: no input file specified." >&2
  254. + exit 1
  255. + fi
  256. + # It's OK to call `install-sh -d' without argument.
  257. + # This can happen when creating conditional directories.
  258. + exit 0
  259. +fi
  260. -oIFS="${IFS}"
  261. -# Some sh's can't handle IFS=/ for some reason.
  262. -IFS='%'
  263. -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
  264. -IFS="${oIFS}"
  265. +for src
  266. +do
  267. + # Protect names starting with `-'.
  268. + case $src in
  269. + -*) src=./$src ;;
  270. + esac
  271. -pathcomp=''
  272. + if test -n "$dir_arg"; then
  273. + dst=$src
  274. + src=
  275. -while [ $# -ne 0 ] ; do
  276. - pathcomp="${pathcomp}${1}"
  277. - shift
  278. + if test -d "$dst"; then
  279. + instcmd=:
  280. + chmodcmd=
  281. + else
  282. + instcmd=$mkdirprog
  283. + fi
  284. + else
  285. + # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
  286. + # might cause directories to be created, which would be especially bad
  287. + # if $src (and thus $dsttmp) contains '*'.
  288. + if test ! -f "$src" && test ! -d "$src"; then
  289. + echo "$0: $src does not exist." >&2
  290. + exit 1
  291. + fi
  292. - if [ ! -d "${pathcomp}" ] ;
  293. - then
  294. - $mkdirprog "${pathcomp}"
  295. - else
  296. - true
  297. - fi
  298. + if test -z "$dstarg"; then
  299. + echo "$0: no destination specified." >&2
  300. + exit 1
  301. + fi
  302. - pathcomp="${pathcomp}/"
  303. -done
  304. -fi
  305. + dst=$dstarg
  306. + # Protect names starting with `-'.
  307. + case $dst in
  308. + -*) dst=./$dst ;;
  309. + esac
  310. -if [ x"$dir_arg" != x ]
  311. -then
  312. - $doit $instcmd $dst &&
  313. + # If destination is a directory, append the input filename; won't work
  314. + # if double slashes aren't ignored.
  315. + if test -d "$dst"; then
  316. + dst=$dst/`basename "$src"`
  317. + fi
  318. + fi
  319. - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
  320. - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
  321. - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
  322. - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
  323. -else
  324. + # This sed command emulates the dirname command.
  325. + dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
  326. -# If we're going to rename the final executable, determine the name now.
  327. + # Make sure that the destination directory exists.
  328. - if [ x"$transformarg" = x ]
  329. - then
  330. - dstfile=`basename $dst`
  331. - else
  332. - dstfile=`basename $dst $transformbasename |
  333. - sed $transformarg`$transformbasename
  334. - fi
  335. + # Skip lots of stat calls in the usual case.
  336. + if test ! -d "$dstdir"; then
  337. + defaultIFS='
  338. + '
  339. + IFS="${IFS-$defaultIFS}"
  340. -# don't allow the sed command to completely eliminate the filename
  341. + oIFS=$IFS
  342. + # Some sh's can't handle IFS=/ for some reason.
  343. + IFS='%'
  344. + set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
  345. + IFS=$oIFS
  346. - if [ x"$dstfile" = x ]
  347. - then
  348. - dstfile=`basename $dst`
  349. - else
  350. - true
  351. - fi
  352. + pathcomp=
  353. -# Make a temp file name in the proper directory.
  354. + while test $# -ne 0 ; do
  355. + pathcomp=$pathcomp$1
  356. + shift
  357. + if test ! -d "$pathcomp"; then
  358. + $mkdirprog "$pathcomp" || lasterr=$?
  359. + # mkdir can fail with a `File exist' error in case several
  360. + # install-sh are creating the directory concurrently. This
  361. + # is OK.
  362. + test ! -d "$pathcomp" && { (exit ${lasterr-1}); exit; }
  363. + fi
  364. + pathcomp=$pathcomp/
  365. + done
  366. + fi
  367. - dsttmp=$dstdir/#inst.$$#
  368. + if test -n "$dir_arg"; then
  369. + $doit $instcmd "$dst" \
  370. + && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
  371. + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
  372. + && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
  373. + && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
  374. -# Move or copy the file name to the temp name
  375. + else
  376. + # If we're going to rename the final executable, determine the name now.
  377. + if test -z "$transformarg"; then
  378. + dstfile=`basename "$dst"`
  379. + else
  380. + dstfile=`basename "$dst" $transformbasename \
  381. + | sed $transformarg`$transformbasename
  382. + fi
  383. - $doit $instcmd $src $dsttmp &&
  384. + # don't allow the sed command to completely eliminate the filename.
  385. + test -z "$dstfile" && dstfile=`basename "$dst"`
  386. - trap "rm -f ${dsttmp}" 0 &&
  387. + # Make a couple of temp file names in the proper directory.
  388. + dsttmp=$dstdir/_inst.$$_
  389. + rmtmp=$dstdir/_rm.$$_
  390. -# and set any options; do chmod last to preserve setuid bits
  391. + # Trap to clean up those temp files at exit.
  392. + trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
  393. + trap '(exit $?); exit' 1 2 13 15
  394. -# If any of these fail, we abort the whole thing. If we want to
  395. -# ignore errors from any of these, just make sure not to ignore
  396. -# errors from the above "$doit $instcmd $src $dsttmp" command.
  397. + # Move or copy the file name to the temp name
  398. + $doit $instcmd "$src" "$dsttmp" &&
  399. - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
  400. - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
  401. - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
  402. - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
  403. + # and set any options; do chmod last to preserve setuid bits.
  404. + #
  405. + # If any of these fail, we abort the whole thing. If we want to
  406. + # ignore errors from any of these, just make sure not to ignore
  407. + # errors from the above "$doit $instcmd $src $dsttmp" command.
  408. + #
  409. + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
  410. + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
  411. + && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
  412. + && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
  413. -# Now rename the file to the real destination.
  414. + # Now rename the file to the real destination.
  415. + { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
  416. + || {
  417. + # The rename failed, perhaps because mv can't rename something else
  418. + # to itself, or perhaps because mv is so ancient that it does not
  419. + # support -f.
  420. - $doit $rmcmd -f $dstdir/$dstfile &&
  421. - $doit $mvcmd $dsttmp $dstdir/$dstfile
  422. + # Now remove or move aside any old file at destination location.
  423. + # We try this two ways since rm can't unlink itself on some
  424. + # systems and the destination file might be busy for other
  425. + # reasons. In this case, the final cleanup might fail but the new
  426. + # file should still install successfully.
  427. + {
  428. + if test -f "$dstdir/$dstfile"; then
  429. + $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
  430. + || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
  431. + || {
  432. + echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
  433. + (exit 1); exit
  434. + }
  435. + else
  436. + :
  437. + fi
  438. + } &&
  439. -fi &&
  440. + # Now rename the file to the real destination.
  441. + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
  442. + }
  443. + }
  444. + fi || { (exit 1); exit; }
  445. +done
  446. +# The final little trick to "correctly" pass the exit status to the exit trap.
  447. +{
  448. + (exit 0); exit
  449. +}
  450. -exit 0
  451. +# Local variables:
  452. +# eval: (add-hook 'write-file-hooks 'time-stamp)
  453. +# time-stamp-start: "scriptversion="
  454. +# time-stamp-format: "%:y-%02m-%02d.%02H"
  455. +# time-stamp-end: "$"
  456. +# End: