autopoint 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  1. #! /bin/sh
  2. #
  3. # Copyright (C) 2002-2016 Free Software Foundation, Inc.
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #
  18. # This file is meant for authors, maintainers, co-maintainers or installers
  19. # of packages which are internationalized with the help of GNU gettext. For
  20. # further information how to use it consult the GNU gettext manual.
  21. progname=$0
  22. package=gettext-tools
  23. version=0.19.8
  24. archive_version=0.19.8
  25. # Set variables
  26. # - gettext_datadir directory where the data files are stored.
  27. prefix="/builds/community/qemu-stm32/sysroot-cross"
  28. datarootdir="${prefix}/share"
  29. : ${gettext_datadir="${datarootdir}/gettext"}
  30. : ${AUTOM4TE=autom4te}
  31. # func_tmpdir
  32. # creates a temporary directory.
  33. # Sets variable
  34. # - tmp pathname of freshly created temporary directory
  35. func_tmpdir ()
  36. {
  37. # Use the environment variable TMPDIR, falling back to /tmp. This allows
  38. # users to specify a different temporary directory, for example, if their
  39. # /tmp is filled up or too small.
  40. : ${TMPDIR=/tmp}
  41. {
  42. # Use the mktemp program if available. If not available, hide the error
  43. # message.
  44. tmp=`(umask 077 && mktemp -d "$TMPDIR/gtXXXXXX") 2>/dev/null` &&
  45. test -n "$tmp" && test -d "$tmp"
  46. } ||
  47. {
  48. # Use a simple mkdir command. It is guaranteed to fail if the directory
  49. # already exists. $RANDOM is bash specific and expands to empty in shells
  50. # other than bash, ksh and zsh. Its use does not increase security;
  51. # rather, it minimizes the probability of failure in a very cluttered /tmp
  52. # directory.
  53. tmp=$TMPDIR/gt$$-$RANDOM
  54. (umask 077 && mkdir "$tmp")
  55. } ||
  56. {
  57. echo "$0: cannot create a temporary directory in $TMPDIR" >&2
  58. { (exit 1); exit 1; }
  59. }
  60. }
  61. # Support for relocatability.
  62. func_find_curr_installdir ()
  63. {
  64. # Determine curr_installdir, even taking into account symlinks.
  65. curr_executable="$0"
  66. case "$curr_executable" in
  67. */* | *\\*) ;;
  68. *) # Need to look in the PATH.
  69. save_IFS="$IFS"; IFS="${PATH_SEPARATOR=':'}"
  70. for dir in $PATH; do
  71. IFS="$save_IFS"
  72. test -z "$dir" && dir=.
  73. for exec_ext in ''; do
  74. if test -f "$dir/$curr_executable$exec_ext"; then
  75. curr_executable="$dir/$curr_executable$exec_ext"
  76. break 2
  77. fi
  78. done
  79. done
  80. IFS="$save_IFS"
  81. ;;
  82. esac
  83. # Make absolute.
  84. case "$curr_executable" in
  85. /* | ?:/* | ?:\\*) ;;
  86. *) curr_executable=`pwd`/"$curr_executable" ;;
  87. esac
  88. # Resolve symlinks.
  89. sed_dirname='s,/[^/]*$,,'
  90. sed_linkdest='s,^.* -> \(.*\),\1,p'
  91. while : ; do
  92. lsline=`LC_ALL=C ls -l "$curr_executable"`
  93. case "$lsline" in
  94. *" -> "*)
  95. linkdest=`echo "$lsline" | sed -n -e "$sed_linkdest"`
  96. case "$linkdest" in
  97. /* | ?:/* | ?:\\*) curr_executable="$linkdest" ;;
  98. *) curr_executable=`echo "$curr_executable" | sed -e "$sed_dirname"`/"$linkdest" ;;
  99. esac ;;
  100. *) break ;;
  101. esac
  102. done
  103. curr_installdir=`echo "$curr_executable" | sed -e 's,/[^/]*$,,'`
  104. # Canonicalize.
  105. curr_installdir=`cd "$curr_installdir" && pwd`
  106. }
  107. func_find_prefixes ()
  108. {
  109. # Compute the original/current installation prefixes by stripping the
  110. # trailing directories off the original/current installation directories.
  111. orig_installprefix="$orig_installdir"
  112. curr_installprefix="$curr_installdir"
  113. while true; do
  114. orig_last=`echo "$orig_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'`
  115. curr_last=`echo "$curr_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'`
  116. if test -z "$orig_last" || test -z "$curr_last"; then
  117. break
  118. fi
  119. if test "$orig_last" != "$curr_last"; then
  120. break
  121. fi
  122. orig_installprefix=`echo "$orig_installprefix" | sed -e 's,/[^/]*$,,'`
  123. curr_installprefix=`echo "$curr_installprefix" | sed -e 's,/[^/]*$,,'`
  124. done
  125. }
  126. if test "no" = yes; then
  127. exec_prefix="${prefix}"
  128. bindir="${exec_prefix}/bin"
  129. orig_installdir="$bindir" # see Makefile.am's *_SCRIPTS variables
  130. func_find_curr_installdir # determine curr_installdir
  131. func_find_prefixes
  132. # Relocate the directory variables that we use.
  133. gettext_datadir=`echo "$gettext_datadir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'`
  134. fi
  135. # func_trace_autoconf macro configure.ac
  136. # traces an Autoconf macro call and outputs the arguments to stdout,
  137. # using autom4te.
  138. func_trace_autoconf ()
  139. {
  140. echo '\
  141. dnl replace macros which may abort autom4te with a no-op variant
  142. m4_pushdef([m4_assert])
  143. m4_pushdef([m4_fatal])
  144. m4_pushdef([m4_warn])
  145. m4_pushdef([m4_errprintn])
  146. m4_pushdef([m4_exit])
  147. m4_pushdef([m4_include])
  148. m4_pushdef([m4_esyscmd])
  149. ' \
  150. | "$AUTOM4TE" --no-cache --language=Autoconf-without-aclocal-m4 \
  151. --trace="$1":\$% - "$2" 2>/dev/null
  152. }
  153. # func_trace_sed macro configure.ac
  154. # traces an Autoconf macro call and outputs the arguments to stdout,
  155. # using sed.
  156. func_trace_sed ()
  157. {
  158. sed_extract_arguments='
  159. s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
  160. /'"$1"'(/ {
  161. ta
  162. :a
  163. s/)/)/
  164. tb
  165. s/\\$//
  166. N
  167. ba
  168. :b
  169. s,^.*'"$1"'([[ ]*\([^]"$`\\)]*\).*$,\1,p
  170. }
  171. d'
  172. sed -e "$sed_extract_arguments" "$2"
  173. }
  174. # func_usage
  175. # outputs to stdout the --help usage message.
  176. func_usage ()
  177. {
  178. echo "\
  179. Usage: autopoint [OPTION]...
  180. Copies standard gettext infrastructure files into a source package.
  181. Options:
  182. --help print this help and exit
  183. --version print version information and exit
  184. -f, --force force overwriting of files that already exist
  185. -n, --dry-run print modifications but don't perform them"
  186. # echo "\
  187. # -V version copy the infrastructure of the specified gettext version
  188. # (dangerous)"
  189. echo "
  190. Report bugs to <bug-gnu-gettext@gnu.org>."
  191. }
  192. # func_version
  193. # outputs to stdout the --version message.
  194. func_version ()
  195. {
  196. echo "$progname (GNU $package) $version"
  197. echo "Uses a versions archive in dirxz format."
  198. echo "Copyright (C) 2002-2013 Free Software Foundation, Inc.
  199. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  200. This is free software: you are free to change and redistribute it.
  201. There is NO WARRANTY, to the extent permitted by law."
  202. echo "Written by" "Bruno Haible"
  203. }
  204. # func_fatal_error message
  205. # outputs to stderr a fatal error message, and terminates the program.
  206. func_fatal_error ()
  207. {
  208. echo "autopoint: *** $1" 1>&2
  209. echo "autopoint: *** Stop." 1>&2
  210. exit 1
  211. }
  212. # Nuisances.
  213. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
  214. # Unset more variables known to interfere with behavior of common tools.
  215. CLICOLOR_FORCE= GREP_OPTIONS=
  216. unset CLICOLOR_FORCE GREP_OPTIONS
  217. # Command-line option processing.
  218. # Removes the OPTIONS from the arguments. Sets the variables:
  219. # - force yes if --force was given, empty otherwise
  220. # - ver gettext version if -V was given, empty otherwise
  221. # - doit false if --dry-run was given, : otherwise
  222. {
  223. force=
  224. ver=
  225. doit=:
  226. while test $# -gt 0; do
  227. case "$1" in
  228. -n | --dry-run | --dry-ru | --dry-r | --dry- | --dry | --dr | --d )
  229. shift
  230. doit=false ;;
  231. -f | --force | --forc | --for | --fo | --f )
  232. shift
  233. force=yes ;;
  234. --help | --hel | --he | --h )
  235. func_usage; exit 0 ;;
  236. # -V ) # Some people put a space between -V and the version number.
  237. # shift
  238. # if test $# = 0; then
  239. # func_usage 1>&2
  240. # exit 1
  241. # fi
  242. # ver=$1;
  243. # shift ;;
  244. # -V*) # Some people omit the space between -V and the version number.
  245. # ver=`echo "X$1" | sed -e 's/^X-V//'`
  246. # shift ;;
  247. --version | --versio | --versi | --vers | --ver | --ve | --v )
  248. func_version
  249. exit 0 ;;
  250. -- ) # Stop option prcessing
  251. shift; break ;;
  252. -* )
  253. echo "autopoint: unknown option $1" 1>&2
  254. echo "Try 'autopoint --help' for more information." 1>&2
  255. exit 1 ;;
  256. * )
  257. break ;;
  258. esac
  259. done
  260. }
  261. # Command-line argument processing.
  262. # Analyzes the remaining arguments.
  263. {
  264. if test $# -gt 0; then
  265. func_usage 1>&2
  266. exit 1
  267. fi
  268. }
  269. srcdir=`pwd`
  270. # The current directory is now $srcdir.
  271. # Check integrity of package: A configure.in/ac must be present. Sets variable
  272. # - configure_in name of configure.in/ac file.
  273. if test -f configure.in; then
  274. configure_in=configure.in
  275. else
  276. if test -f configure.ac; then
  277. configure_in=configure.ac
  278. else
  279. # KDE specific convention: configure.in.in
  280. if test -f configure.in.in; then
  281. configure_in=configure.in.in
  282. else
  283. func_fatal_error "Missing configure.in or configure.ac, please cd to your package first."
  284. fi
  285. fi
  286. fi
  287. # Select the method for Autoconf macro tracing. func_trace_autoconf
  288. # is more accurate than func_trace_sed, but it only works with
  289. # autoconf >= 2.69.
  290. if echo "AC_PREREQ([2.69])" \
  291. | "$AUTOM4TE" --no-cache --language=Autoconf-without-aclocal-m4 - 2>&1; then
  292. func_trace=func_trace_autoconf
  293. else
  294. func_trace=func_trace_sed
  295. fi
  296. # func_version_prereq required_version version
  297. # compares the required version and the latest archive version.
  298. func_version_prereq ()
  299. {
  300. req="$1"
  301. ver="$2"
  302. echo "m4_if(m4_version_compare([$ver], [$req]), [-1], [m4_exit([1])])" \
  303. | "$AUTOM4TE" --language=M4sugar 2>&1 >/dev/null
  304. }
  305. # If AM_GNU_GETTEXT_REQUIRE_VERSION is used and archive_version is newer than
  306. # that, use archive_version.
  307. xreq=`func_trace_sed AM_GNU_GETTEXT_REQUIRE_VERSION "$configure_in"`
  308. # Need to use func_trace_sed instead of $func_trace, since
  309. # AM_GNU_GETTEXT_VERSION is not a standard Autoconf trace.
  310. xver=`func_trace_sed AM_GNU_GETTEXT_VERSION "$configure_in"`
  311. # Prefer AM_GNU_GETTEXT_REQUIRE_VERSION over AM_GNU_GETTEXT_VERSION if both are
  312. # specified.
  313. if test -n "$xreq" && test -n "$xver"; then
  314. echo "autopoint: using AM_GNU_GETTEXT_REQUIRE_VERSION instead of AM_GNU_GETTEXT_VERSION"
  315. fi
  316. if test -n "$xreq"; then
  317. if func_version_prereq "$xreq" "$archive_version"; then
  318. ver="$archive_version"
  319. else
  320. func_fatal_error "gettext version $xreq or newer is required"
  321. fi
  322. else
  323. if test -z "$xver" && test -f intl/VERSION; then
  324. xver=`cat intl/VERSION | LC_ALL=C sed -n -e 's/^.*gettext-\([-+_.0-9A-Za-z]*\).*$/\1/p'`
  325. fi
  326. # Check whether the -V option and the version number in configure.in match.
  327. # At least one of the two must be given. If both are given, they must agree.
  328. if test -n "$xver"; then
  329. if test -n "$ver"; then
  330. if test "X$ver" != "X$xver"; then
  331. func_fatal_error "Version mismatch: specified -V $ver but the package uses gettext version $xver"
  332. fi
  333. else
  334. ver="$xver"
  335. fi
  336. fi
  337. fi
  338. if test -z "$ver"; then
  339. func_fatal_error "Missing version: please specify in $configure_in through a line 'AM_GNU_GETTEXT_VERSION(x.yy.zz)' the gettext version the package is using"
  340. fi
  341. # Check whether the version number is supported.
  342. case "$ver" in
  343. 0.10.35 | 0.10.36 | 0.10.37 | 0.10.38 | 0.10.39 | 0.10.40 | \
  344. 0.11 | 0.11.1 | 0.11.2 | 0.11.3 | 0.11.4 | 0.11.5 | \
  345. 0.12 | 0.12.1 | \
  346. 0.13 | 0.13.1 | \
  347. 0.14 | 0.14.1 | 0.14.2 | 0.14.3 | 0.14.4 | 0.14.5 | 0.14.6 | \
  348. 0.15 | \
  349. 0.16 | 0.16.1 | \
  350. 0.17 | \
  351. 0.18 | 0.18.1 | 0.18.2 | 0.18.3 | \
  352. 0.19 | 0.19.1 | 0.19.2 | 0.19.3 | 0.19.4 | 0.19.5 | 0.19.6 | 0.19.7 | 0.19.8 )
  353. ;;
  354. *)
  355. func_fatal_error "The AM_GNU_GETTEXT_VERSION declaration in your $configure_in
  356. file requires the infrastructure from gettext-$ver but this version
  357. is older. Please upgrade to gettext-$ver or newer."
  358. ;;
  359. esac
  360. # Check in which directory config.rpath, mkinstalldirs etc. belong.
  361. auxdir=`"$func_trace" AC_CONFIG_AUX_DIR "$configure_in"`
  362. if test -n "$auxdir"; then
  363. auxdir="$auxdir/"
  364. fi
  365. # Check in which directory the *.m4 macros belong.
  366. macrodirs=`"$func_trace" AC_CONFIG_MACRO_DIR_TRACE "$configure_in"`
  367. if test -z "$macrodirs"; then
  368. macrodirs=`"$func_trace" AC_CONFIG_MACRO_DIR "$configure_in"`
  369. fi
  370. for arg in $macrodirs; do
  371. m4dir="$arg"
  372. break
  373. done
  374. if test -z "$m4dir" && test -f Makefile.am; then
  375. # A package using automake.
  376. # Extract the macro directory name from Makefile.am.
  377. aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
  378. m4dir_is_next=
  379. for arg in $aclocal_amflags; do
  380. if test -n "$m4dir_is_next"; then
  381. m4dir="$arg"
  382. break
  383. else
  384. if test "X$arg" = "X-I"; then
  385. m4dir_is_next=yes
  386. else
  387. m4dir_is_next=
  388. fi
  389. fi
  390. done
  391. fi
  392. if test -z "$m4dir"; then
  393. m4dir=m4
  394. fi
  395. # Check whether to omit the intl/ directory.
  396. omitintl=
  397. # Need to use func_trace_sed instead of $func_trace, since
  398. # AM_GNU_GETTEXT is not a standard Autoconf trace.
  399. xargs=`func_trace_sed AM_GNU_GETTEXT "$configure_in"`
  400. save_IFS="$IFS"; IFS=:
  401. for arg in $xargs; do
  402. if test 'external' = "$arg"; then
  403. omitintl=yes
  404. break
  405. fi
  406. done
  407. IFS="$save_IFS"
  408. # Check in which directory or directories the po/* infrastructure belongs.
  409. configfiles=`"$func_trace" AC_CONFIG_FILES "$configure_in"`
  410. # PO directories have a Makefile.in generated from Makefile.in.in.
  411. # Treat a directory as a PO directory if and only if it has a
  412. # POTFILES.in file. This allows packages to have multiple PO
  413. # directories under different names or in different locations.
  414. sed_remove_Makefile_in='s,/Makefile\.in$,,'
  415. podirs=`for f in $configfiles; do case "$f" in */Makefile.in) echo $f;; esac; done | sed -e "$sed_remove_Makefile_in"`
  416. if test -z "$podirs"; then
  417. # If we cannot get the list of PO directories from configure.ac, assume the
  418. # common default.
  419. podirs="po"
  420. fi
  421. # Set up a temporary checkout directory.
  422. # Set variables
  423. # - work_dir directory containing the temporary checkout
  424. work_dir=tmpwrk$$
  425. mkdir "$work_dir" || {
  426. if test -d "$work_dir"; then
  427. func_fatal_error "directory $work_dir already exists"
  428. else
  429. func_fatal_error "cannot create directory $work_dir"
  430. fi
  431. }
  432. # We support three archive formats.
  433. #
  434. # Format | Size (KiB) for gettext-0.17 | Extra tools needed |
  435. # -------+-----------------------------+--------------------+
  436. # dir | 3000 | -- |
  437. # cvs | 356 | cvs |
  438. # git | 484 | git |
  439. # -------+-----------------------------+--------------------+
  440. case "dirxz" in
  441. dir*)
  442. # The archive of different versions is very large (unless xz compression is
  443. # used), but using it does not require special tools.
  444. case "dirxz" in
  445. dirgz) gzip -d -c < "$gettext_datadir/archive.dir.tar.gz" ;;
  446. dirbz2) bzip2 -d -c < "$gettext_datadir/archive.dir.tar.bz2" ;;
  447. dirxz) xz -d -c < "$gettext_datadir/archive.dir.tar.xz" ;;
  448. esac \
  449. | (cd "$work_dir" && tar xf - "gettext-$ver")
  450. if test `find "$work_dir" -type f -print | wc -l` = 0; then
  451. rm -rf "$work_dir"
  452. func_fatal_error "infrastructure files for version $ver not found; this is autopoint from GNU $package $version"
  453. fi
  454. mv "$work_dir/gettext-$ver" "$work_dir/archive"
  455. ;;
  456. cvs)
  457. # We distributed the many different versions of the files in a CVS
  458. # repository. This guaranteed a good compression rate:
  459. #
  460. # Including version size in KB of
  461. # "du autopoint-files/archive"
  462. # 0.10.35 240
  463. # 0.10.36 428
  464. # 0.10.37 436
  465. # 0.10.38 488
  466. # 0.10.39 500
  467. # 0.10.40 528
  468. # 0.11 720
  469. # 0.11.1 740
  470. # 0.11.2 748
  471. # 0.11.3 804
  472. # 0.11.4 864
  473. # 0.11.5 880
  474. # 0.12 1032
  475. # 0.12.1 1032
  476. # 0.13 1220
  477. # 0.13.1 1236
  478. # 0.14 1296
  479. # 0.14.1 1300
  480. # 0.14.2 1420
  481. # 0.14.3 1428
  482. # 0.14.4 1464
  483. # 0.14.5 1508
  484. # 0.14.6 1580
  485. # 0.15 1760
  486. # 0.16 1808
  487. # 0.16.1 1812
  488. # 0.17 2128
  489. # 0.18 2656
  490. #
  491. # The requirement that the user must have the CVS program available is not
  492. # a severe restrictions, because most of the people who use autopoint are
  493. # users of CVS.
  494. #
  495. # But the CVS format is now deprecated, because "cvs init" does not work in
  496. # all circumstances
  497. # (see <http://lists.gnu.org/archive/html/bug-cvs/2010-05/msg00003.html>)
  498. # and we are not allowed to distribute the cvs infrastructure files
  499. # ourselves
  500. # (see <http://lists.gnu.org/archive/html/bug-cvs/2010-06/msg00011.html>).
  501. #
  502. # Check availability of the CVS program.
  503. (cvs -v) >/dev/null 2>/dev/null || func_fatal_error "cvs program not found"
  504. # Set up a temporary CVS repository.
  505. # We need the temporary CVS repository because any checkout needs write
  506. # access to the CVSROOT/history file, so it cannot be under $gettext_datadir.
  507. # We need the temporary checkout directory because when --force was not
  508. # given, we need to compare the existing files with the checked out ones.
  509. # Set variables
  510. # - cvs_dir directory containing the temporary repository
  511. cvs_dir=tmpcvs$$
  512. # Use an umask of 077, to avoid attacks that work by overwriting files in
  513. # the "$CVSROOT"/CVSROOT directory.
  514. (umask 077 && mkdir "$cvs_dir") || {
  515. if test -d "$cvs_dir"; then
  516. func_fatal_error "directory $cvs_dir already exists"
  517. else
  518. func_fatal_error "cannot create directory $cvs_dir"
  519. fi
  520. }
  521. CVSROOT="$srcdir/$cvs_dir"
  522. unset CVS_CLIENT_LOG
  523. unset CVS_CLIENT_PORT
  524. unset CVS_IGNORE_REMOTE_ROOT
  525. unset CVS_LOCAL_BRANCH_NUM
  526. unset CVS_NOBASES
  527. unset CVS_PASSFILE
  528. unset CVS_PASSWORD
  529. unset CVS_PROXY_PORT
  530. unset CVS_RCMD_PORT
  531. unset CVS_RSH
  532. unset CVS_SERVER
  533. unset CVS_SERVER_SLEEP
  534. CVS_SIGN_COMMITS=
  535. export CVS_SIGN_COMMITS
  536. unset CVS_SSH
  537. unset CVS_VERIFY_CHECKOUTS
  538. unset CVS_VERIFY_TEMPLATE
  539. unset CVSIGNORE
  540. unset CVSREAD
  541. unset CVSREADONLYFS
  542. unset CVSUMASK
  543. unset CVSWRAPPERS
  544. # Need to pass -d "$CVSROOT", because there may be a CVS directory in the
  545. # current directory.
  546. cvs -d "$CVSROOT" init
  547. gzip -d -c < "$gettext_datadir/archive.cvs.tar.gz" | (cd "$cvs_dir" && tar xf -)
  548. cd "$work_dir"
  549. cvsver=gettext-`echo "$ver" | sed -e 's/\./_/g'`
  550. (cvs -d "$CVSROOT" checkout -r"$cvsver" archive > /dev/null) 2>&1 | grep -v '^cvs checkout: Updating'
  551. find archive -name CVS -type d -print | xargs rm -rf
  552. cd ..
  553. rm -rf "$cvs_dir"
  554. # Check that really all CVS directories are gone, otherwise we would overwrite
  555. # the contents of the user's CVS directories.
  556. if test `find $work_dir/archive -name CVS -type d -print | wc -l` != 0; then
  557. rm -rf "$work_dir"
  558. func_fatal_error "failed to remove all CVS subdirectories"
  559. fi
  560. if test `find $work_dir/archive -type f -print | wc -l` = 0; then
  561. rm -rf "$work_dir"
  562. func_fatal_error "infrastructure files for version $ver not found; this is autopoint from GNU $package $version"
  563. fi
  564. ;;
  565. git)
  566. # Check availability of the git program.
  567. (git --version) >/dev/null 2>/dev/null || func_fatal_error "git program not found"
  568. mkdir "$work_dir/archive"
  569. gzip -d -c < "$gettext_datadir/archive.git.tar.gz" | (cd "$work_dir/archive" && tar xf -)
  570. (cd "$work_dir/archive" && git checkout -q "gettext-$ver") || {
  571. rm -rf "$work_dir"
  572. func_fatal_error "infrastructure files for version $ver not found; this is autopoint from GNU $package $version"
  573. }
  574. (cd "$work_dir/archive" && rm -rf .git .gitignore)
  575. ;;
  576. esac
  577. # func_destfile file
  578. # determines the destination file, relative to the package's top level
  579. # directory, for a given file name, relative to archive.
  580. # Sets variables
  581. # - destfile relative destination file name, or
  582. # empty if the file shall be omitted
  583. # - sharedowner yes if the file is not only owned by GNU gettext but may
  584. # be installed by automake or other tools, otherwise empty
  585. # - allpodirs yes if the file is to be installed in every dir in $podirs
  586. func_destfile ()
  587. {
  588. # There are five categories of files:
  589. # ABOUT_NLS -> top level directory
  590. # config.rpath mkinstalldirs -> $auxdir
  591. # m4/* -> $m4dir/
  592. # intl/* -> intl/
  593. # po/* ->
  594. sharedowner=
  595. allpodirs=
  596. case `echo "$1" | sed -e 's,[^/]*$,,'` in
  597. "" )
  598. case "$1" in
  599. config.rpath ) destfile="$auxdir$1" ;;
  600. mkinstalldirs ) destfile="$auxdir$1" sharedowner=yes ;;
  601. * ) destfile="$1" ;;
  602. esac
  603. ;;
  604. m4/ ) destfile=`echo "$1" | sed -e "s,^m4/,$m4dir/,"` ;;
  605. intl/ ) if test -n "$omitintl"; then destfile=""; else destfile="$1"; fi ;;
  606. po/ ) destfile=`echo "$1" | sed -e "s,^po/,,"` allpodirs=yes ;;
  607. * ) destfile="$1" ;;
  608. esac
  609. }
  610. # func_compare existingfile gettextfile
  611. # compares the existing file and the file from gettext, and decides whether the
  612. # existing file should be overwritten with the file from gettext. Returns 0 if
  613. # it should be overwritten, or 1 if it should be skipped.
  614. sed_extract_serial='s/^#.* serial \([^ ]*\).*/\1/p
  615. 1q'
  616. func_compare ()
  617. {
  618. if cmp -s "$1" "$2"; then
  619. false
  620. else
  621. case "$2" in
  622. *.m4)
  623. # For interoperability with gnulib. gnulib often has newer versions of
  624. # the *.m4 files than the latest gettext release. Don't overwrite a
  625. # newer version from gnulib with an older version from the gettext
  626. # release. The version can be retrieved from the first line, which
  627. # looks like this: # file.m4 serial NN ...
  628. existing_serial=`sed -n -e "$sed_extract_serial" < "$1"`
  629. gettext_serial=`sed -n -e "$sed_extract_serial" < "$2"`
  630. if test -n "$existing_serial" && test -n "$gettext_serial" \
  631. && test "$existing_serial" -ge "$gettext_serial" 2> /dev/null; then
  632. false
  633. else
  634. true
  635. fi
  636. ;;
  637. *)
  638. true
  639. ;;
  640. esac
  641. fi
  642. }
  643. # If some files have been locally modified and we have not been requested
  644. # to overwrite them, then bail out. This is better than leaving a source
  645. # package around where half of the files are locally modified and half are
  646. # original - too great risk of version mismatch.
  647. if test -z "$force"; then
  648. mismatch=
  649. func_tmpdir
  650. mismatchfile="$tmp"/autopoint.diff
  651. for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir/archive/,," | LC_ALL=C sort`; do
  652. func_destfile "$file"
  653. if test -n "$destfile"; then
  654. func_compare_to_destfile ()
  655. {
  656. finaldestfile="$1"
  657. if test -f "$finaldestfile"; then
  658. if func_compare "$finaldestfile" "$work_dir/archive/$file"; then
  659. if test -n "$sharedowner"; then
  660. echo "autopoint: warning: File $finaldestfile has been locally modified." 1>&2
  661. else
  662. echo "autopoint: File $finaldestfile has been locally modified." 1>&2
  663. mismatch=yes
  664. diff -c "$work_dir/archive/$file" "$finaldestfile" | sed -e "1s,$work_dir/archive/,," >> "$mismatchfile"
  665. fi
  666. fi
  667. fi
  668. }
  669. if test -n "$allpodirs"; then
  670. for dir in $podirs; do
  671. func_compare_to_destfile "$dir/$destfile"
  672. done
  673. else
  674. func_compare_to_destfile "$destfile"
  675. fi
  676. fi
  677. done
  678. if test -n "$mismatch"; then
  679. rm -rf "$work_dir"
  680. func_fatal_error "Some files have been locally modified. Not overwriting them because --force has not been specified. For your convenience, you find the local modifications in the file '$mismatchfile'."
  681. fi
  682. rm -rf "$tmp"
  683. fi
  684. # func_mkdir_for to
  685. # ensures the directory that would the given file exists.
  686. # 'to' is a relative pathname, relative to the current directory.
  687. func_mkdir_for ()
  688. {
  689. base=`echo "$1" | sed -e 's,/[^/]*$,,'`
  690. if test "X$base" != "X$1" && test -n "$base"; then
  691. func_mkdir_for "$base"
  692. # Recompute base. It was clobbered by the recursive call.
  693. base=`echo "$1" | sed -e 's,/[^/]*$,,'`
  694. test -d "$base" || { echo "Creating directory $base"; mkdir "$base"; }
  695. fi
  696. }
  697. # func_copy from to
  698. # copies a file.
  699. # 'from' is a relative pathname, relative to the current directory.
  700. # 'to' is a relative pathname, relative to the current directory.
  701. func_copy ()
  702. {
  703. if $doit; then
  704. func_mkdir_for "$2"
  705. rm -f "$2"
  706. echo "Copying file $2"
  707. cp "$1" "$2"
  708. else
  709. echo "Copy file $2"
  710. fi
  711. }
  712. # func_backup to
  713. # makes a backup of a file that is about to be overwritten or replaced.
  714. # 'to' is a relative pathname, relative to the current directory.
  715. func_backup ()
  716. {
  717. if $doit; then
  718. if test -f "$1"; then
  719. rm -f "$1~"
  720. cp -p "$1" "$1~"
  721. fi
  722. fi
  723. }
  724. # Now copy the files.
  725. for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir/archive/,," | LC_ALL=C sort`; do
  726. func_destfile "$file"
  727. if test -n "$destfile"; then
  728. func_copy_to_destfile ()
  729. {
  730. finaldestfile="$1"
  731. mustcopy=
  732. if test -f "$finaldestfile"; then
  733. if func_compare "$finaldestfile" "$work_dir/archive/$file"; then
  734. if test -n "$force"; then
  735. # Overwrite locally modified file.
  736. mustcopy=yes
  737. fi
  738. # If --force is not specified, don't overwrite locally modified files
  739. # for which GNU gettext is a shared owner.
  740. fi
  741. else
  742. mustcopy=yes
  743. fi
  744. if test -n "$mustcopy"; then
  745. func_backup "$finaldestfile"
  746. func_copy "$work_dir/archive/$file" "$finaldestfile"
  747. fi
  748. }
  749. if test -n "$allpodirs"; then
  750. for dir in $podirs; do
  751. func_copy_to_destfile "$dir/$destfile"
  752. done
  753. else
  754. func_copy_to_destfile "$destfile"
  755. fi
  756. fi
  757. done
  758. # That's it.
  759. rm -rf "$work_dir"
  760. exit 0