KOffice – TDE office suite internationalization translations
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

install-sh 11KB

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