Install gettext-0.18.1.1.tar.gz
[msysgit.git] / mingw / bin / autopoint
blob616e44500a0f663e98db81121b2cfb1097d0644e
1 #! /bin/sh
3 # Copyright (C) 2002-2010 Free Software Foundation, Inc.
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.
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.
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/>.
19 # This file is meant for authors, maintainers, co-maintainers or installers
20 # of packages which are internationalized with the help of GNU gettext. For
21 # further information how to use it consult the GNU gettext manual.
23 progname=$0
24 package=gettext-tools
25 version=0.18.1
27 # Set variables
28 # - gettext_dir directory where the sources are stored.
29 prefix="/mingw"
30 datarootdir="${prefix}/share"
31 gettext_dir="${datarootdir}/gettext"
33 # func_tmpdir
34 # creates a temporary directory.
35 # Sets variable
36 # - tmp pathname of freshly created temporary directory
37 func_tmpdir ()
39 # Use the environment variable TMPDIR, falling back to /tmp. This allows
40 # users to specify a different temporary directory, for example, if their
41 # /tmp is filled up or too small.
42 : ${TMPDIR=/tmp}
44 # Use the mktemp program if available. If not available, hide the error
45 # message.
46 tmp=`(umask 077 && mktemp -d "$TMPDIR/gtXXXXXX") 2>/dev/null` &&
47 test -n "$tmp" && test -d "$tmp"
48 } ||
50 # Use a simple mkdir command. It is guaranteed to fail if the directory
51 # already exists. $RANDOM is bash specific and expands to empty in shells
52 # other than bash, ksh and zsh. Its use does not increase security;
53 # rather, it minimizes the probability of failure in a very cluttered /tmp
54 # directory.
55 tmp=$TMPDIR/gt$$-$RANDOM
56 (umask 077 && mkdir "$tmp")
57 } ||
59 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
60 { (exit 1); exit 1; }
64 # Support for relocatability.
65 func_find_curr_installdir ()
67 # Determine curr_installdir, even taking into account symlinks.
68 curr_executable="$0"
69 case "$curr_executable" in
70 */* | *\\*) ;;
71 *) # Need to look in the PATH.
72 if test "${PATH_SEPARATOR+set}" != set; then
73 func_tmpdir
74 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
75 chmod +x "$tmp"/conf.sh
76 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
77 PATH_SEPARATOR=';'
78 else
79 PATH_SEPARATOR=:
81 rm -rf "$tmp"
83 save_IFS="$IFS"; IFS="$PATH_SEPARATOR"
84 for dir in $PATH; do
85 IFS="$save_IFS"
86 test -z "$dir" && dir=.
87 for exec_ext in ''; do
88 if test -f "$dir/$curr_executable$exec_ext"; then
89 curr_executable="$dir/$curr_executable$exec_ext"
90 break 2
92 done
93 done
94 IFS="$save_IFS"
96 esac
97 # Make absolute.
98 case "$curr_executable" in
99 /* | ?:/* | ?:\\*) ;;
100 *) curr_executable=`pwd`/"$curr_executable" ;;
101 esac
102 # Resolve symlinks.
103 sed_dirname='s,/[^/]*$,,'
104 sed_linkdest='s,^.* -> \(.*\),\1,p'
105 while : ; do
106 lsline=`LC_ALL=C ls -l "$curr_executable"`
107 case "$lsline" in
108 *" -> "*)
109 linkdest=`echo "$lsline" | sed -n -e "$sed_linkdest"`
110 case "$linkdest" in
111 /* | ?:/* | ?:\\*) curr_executable="$linkdest" ;;
112 *) curr_executable=`echo "$curr_executable" | sed -e "$sed_dirname"`/"$linkdest" ;;
113 esac ;;
114 *) break ;;
115 esac
116 done
117 curr_installdir=`echo "$curr_executable" | sed -e 's,/[^/]*$,,'`
118 # Canonicalize.
119 curr_installdir=`cd "$curr_installdir" && pwd`
121 func_find_prefixes ()
123 # Compute the original/current installation prefixes by stripping the
124 # trailing directories off the original/current installation directories.
125 orig_installprefix="$orig_installdir"
126 curr_installprefix="$curr_installdir"
127 while true; do
128 orig_last=`echo "$orig_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'`
129 curr_last=`echo "$curr_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'`
130 if test -z "$orig_last" || test -z "$curr_last"; then
131 break
133 if test "$orig_last" != "$curr_last"; then
134 break
136 orig_installprefix=`echo "$orig_installprefix" | sed -e 's,/[^/]*$,,'`
137 curr_installprefix=`echo "$curr_installprefix" | sed -e 's,/[^/]*$,,'`
138 done
140 if test "yes" = yes; then
141 exec_prefix="${prefix}"
142 bindir="${exec_prefix}/bin"
143 orig_installdir="$bindir" # see Makefile.am's *_SCRIPTS variables
144 func_find_curr_installdir # determine curr_installdir
145 func_find_prefixes
146 # Relocate the directory variables that we use.
147 gettext_dir=`echo "$gettext_dir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'`
150 # func_usage
151 # outputs to stdout the --help usage message.
152 func_usage ()
154 echo "\
155 Usage: autopoint [OPTION]...
157 Copies standard gettext infrastructure files into a source package.
159 Options:
160 --help print this help and exit
161 --version print version information and exit
162 -f, --force force overwriting of files that already exist
163 -n, --dry-run print modifications but don't perform them"
164 # echo "\
165 # -V version copy the infrastructure of the specified gettext version
166 # (dangerous)"
167 echo "
168 Report bugs to <bug-gnu-gettext@gnu.org>."
171 # func_version
172 # outputs to stdout the --version message.
173 func_version ()
175 echo "$progname (GNU $package) $version"
176 echo "Uses a versions archive in git format."
177 echo "Copyright (C) 2002-2010 Free Software Foundation, Inc.
178 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
179 This is free software: you are free to change and redistribute it.
180 There is NO WARRANTY, to the extent permitted by law."
181 echo "Written by" "Bruno Haible"
184 # func_fatal_error message
185 # outputs to stderr a fatal error message, and terminates the program.
186 func_fatal_error ()
188 echo "autopoint: *** $1" 1>&2
189 echo "autopoint: *** Stop." 1>&2
190 exit 1
193 # Command-line option processing.
194 # Removes the OPTIONS from the arguments. Sets the variables:
195 # - force yes if --force was given, empty otherwise
196 # - ver gettext version if -V was given, empty otherwise
197 # - doit false if --dry-run was given, : otherwise
199 force=
200 ver=
201 doit=:
203 while test $# -gt 0; do
204 case "$1" in
205 -n | --dry-run | --dry-ru | --dry-r | --dry- | --dry | --dr | --d )
206 shift
207 doit=false ;;
208 -f | --force | --forc | --for | --fo | --f )
209 shift
210 force=yes ;;
211 --help | --hel | --he | --h )
212 func_usage; exit 0 ;;
213 # -V ) # Some people put a space between -V and the version number.
214 # shift
215 # if test $# = 0; then
216 # func_usage 1>&2
217 # exit 1
218 # fi
219 # ver=$1;
220 # shift ;;
221 # -V*) # Some people omit the space between -V and the version number.
222 # ver=`echo "X$1" | sed -e 's/^X-V//'`
223 # shift ;;
224 --version | --versio | --versi | --vers | --ver | --ve | --v )
225 func_version
226 exit 0 ;;
227 -- ) # Stop option prcessing
228 shift; break ;;
229 -* )
230 echo "autopoint: unknown option $1" 1>&2
231 echo "Try 'autopoint --help' for more information." 1>&2
232 exit 1 ;;
234 break ;;
235 esac
236 done
239 # Command-line argument processing.
240 # Analyzes the remaining arguments.
242 if test $# -gt 0; then
243 func_usage 1>&2
244 exit 1
248 srcdir=`pwd`
249 # The current directory is now $srcdir.
251 # Check integrity of package: A configure.in/ac must be present. Sets variable
252 # - configure_in name of configure.in/ac file.
253 if test -f configure.in; then
254 configure_in=configure.in
255 else
256 if test -f configure.ac; then
257 configure_in=configure.ac
258 else
259 # KDE specific convention: configure.in.in
260 if test -f configure.in.in; then
261 configure_in=configure.in.in
262 else
263 func_fatal_error "Missing configure.in or configure.ac, please cd to your package first."
268 # Check whether the -V option and the version number in configure.in match.
269 # At least one of the two must be given. If both are given, they must agree.
270 sed_extract_AM_GNU_GETTEXT_VERSION_argument='s/^AM_GNU_GETTEXT_VERSION(\([^()]*\)).*$/\1/'
271 sed_remove_outer_brackets='s/^\[\(.*\)\]$/\1/'
272 xver=`cat "$configure_in" | grep '^AM_GNU_GETTEXT_VERSION(' | sed -n -e "$sed_extract_AM_GNU_GETTEXT_VERSION_argument"p | sed -e "$sed_remove_outer_brackets" | sed -e 1q`
273 if test -z "$xver" && test -f intl/VERSION; then
274 xver=`cat intl/VERSION | LC_ALL=C sed -n -e 's/^.*gettext-\([-+_.0-9A-Za-z]*\).*$/\1/p'`
276 if test -n "$xver"; then
277 if test -n "$ver"; then
278 if test "X$ver" != "X$xver"; then
279 func_fatal_error "Version mismatch: specified -V $ver but the package uses gettext version $xver"
281 else
282 ver="$xver"
284 else
285 if test -z "$ver"; then
286 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"
290 # Check whether the version number is supported.
291 case "$ver" in
292 0.10.35 | 0.10.36 | 0.10.37 | 0.10.38 | 0.10.39 | 0.10.40 | \
293 0.11 | 0.11.1 | 0.11.2 | 0.11.3 | 0.11.4 | 0.11.5 | \
294 0.12 | 0.12.1 | \
295 0.13 | 0.13.1 | \
296 0.14 | 0.14.1 | 0.14.2 | 0.14.3 | 0.14.4 | 0.14.5 | 0.14.6 | \
297 0.15 | \
298 0.16 | 0.16.1 | \
299 0.17 | \
300 0.18 | 0.18.1 )
303 func_fatal_error "The AM_GNU_GETTEXT_VERSION declaration in your $configure_in
304 file requires the infrastructure from gettext-$ver but this version
305 is older. Please upgrade to gettext-$ver or newer."
307 esac
309 # Check in which directory config.rpath, mkinstalldirs etc. belong.
310 auxdir=`cat "$configure_in" | grep '^AC_CONFIG_AUX_DIR' | sed -n -e 's/AC_CONFIG_AUX_DIR(\([^()]*\))/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q`
311 if test -n "$auxdir"; then
312 auxdir="$auxdir/"
315 # Check in which directory the *.m4 macros belong.
316 m4dir=m4
317 if test -f Makefile.am; then
318 # A package using automake.
319 # Extract the macro directory name from Makefile.am.
320 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
321 m4dir_is_next=
322 for arg in $aclocal_amflags; do
323 if test -n "$m4dir_is_next"; then
324 m4dir="$arg"
325 break
326 else
327 if test "X$arg" = "X-I"; then
328 m4dir_is_next=yes
329 else
330 m4dir_is_next=
333 done
336 # Check whether to omit the intl/ directory.
337 omitintl=`cat "$configure_in" | grep '^AM_GNU_GETTEXT' | sed -n -e 's/^AM_GNU_GETTEXT(\([^(),]*\).*$/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q`
338 omitintl=`if test 'external' = "$omitintl"; then echo yes; fi`
340 # Check in which directory or directories the po/* infrastructure belongs.
341 sed_extract_config_files='s,#.*$,,
342 s,^dnl .*$,,
343 s, dnl .*$,,
344 /AC_CONFIG_FILES(/ {
347 s/)/)/
349 s/\\$//
353 s,^.*AC_CONFIG_FILES([[ ]*\([^]"$`\\)]*\).*$,\1,p
355 configfiles=`cat "$configure_in" | sed -n -e "$sed_extract_config_files"`
356 # PO directories have a Makefile.in generated from Makefile.in.in.
357 # Treat a directory as a PO directory if and only if it has a
358 # POTFILES.in file. This allows packages to have multiple PO
359 # directories under different names or in different locations.
360 sed_remove_Makefile_in='s,/Makefile\.in$,,'
361 podirs=`for f in $configfiles; do case "$f" in */Makefile.in) echo $f;; esac; done | sed -e "$sed_remove_Makefile_in"`
362 if test -z "$podirs"; then
363 # If we cannot get the list of PO directories from configure.ac, assume the
364 # common default.
365 podirs="po"
368 # Set up a temporary checkout directory.
369 # Set variables
370 # - work_dir directory containing the temporary checkout
371 work_dir=tmpwrk$$
372 mkdir "$work_dir" || {
373 if test -d "$work_dir"; then
374 func_fatal_error "directory $work_dir already exists"
375 else
376 func_fatal_error "cannot create directory $work_dir"
380 # We support three archive formats.
382 # Format | Size (KiB) for gettext-0.17 | Extra tools needed |
383 # -------+-----------------------------+--------------------+
384 # dir | 3000 | -- |
385 # cvs | 356 | cvs |
386 # git | 484 | git |
387 # -------+-----------------------------+--------------------+
389 case "git" in
390 dir)
391 # The archive of different versions is very large, but using it does not
392 # require special tools.
393 gzip -d -c < "$gettext_dir/archive.dir.tar.gz" | (cd "$work_dir" && tar xf - "gettext-$ver")
394 if test `find "$work_dir" -type f -print | wc -l` = 0; then
395 rm -rf "$work_dir"
396 func_fatal_error "infrastructure files for version $ver not found; this is autopoint from GNU $package $version"
398 mv "$work_dir/gettext-$ver" "$work_dir/archive"
401 cvs)
402 # We distributed the many different versions of the files in a CVS
403 # repository. This guaranteed a good compression rate:
405 # Including version size in KB of
406 # "du autopoint-files/archive"
407 # 0.10.35 240
408 # 0.10.36 428
409 # 0.10.37 436
410 # 0.10.38 488
411 # 0.10.39 500
412 # 0.10.40 528
413 # 0.11 720
414 # 0.11.1 740
415 # 0.11.2 748
416 # 0.11.3 804
417 # 0.11.4 864
418 # 0.11.5 880
419 # 0.12 1032
420 # 0.12.1 1032
421 # 0.13 1220
422 # 0.13.1 1236
423 # 0.14 1296
424 # 0.14.1 1300
425 # 0.14.2 1420
426 # 0.14.3 1428
427 # 0.14.4 1464
428 # 0.14.5 1508
429 # 0.14.6 1580
430 # 0.15 1760
431 # 0.16 1808
432 # 0.16.1 1812
433 # 0.17 2128
434 # 0.18 2656
436 # The requirement that the user must have the CVS program available is not
437 # a severe restrictions, because most of the people who use autopoint are
438 # users of CVS.
440 # But the CVS format is now deprecated, because "cvs init" does not work in
441 # all circumstances
442 # (see <http://lists.gnu.org/archive/html/bug-cvs/2010-05/msg00003.html>)
443 # and we are not allowed to distribute the cvs infrastructure files
444 # ourselves
445 # (see <http://lists.gnu.org/archive/html/bug-cvs/2010-06/msg00011.html>).
447 # Check availability of the CVS program.
448 (cvs -v) >/dev/null 2>/dev/null || func_fatal_error "cvs program not found"
450 # Set up a temporary CVS repository.
451 # We need the temporary CVS repository because any checkout needs write
452 # access to the CVSROOT/history file, so it cannot be under $gettext_dir.
453 # We need the temporary checkout directory because when --force was not
454 # given, we need to compare the existing files with the checked out ones.
455 # Set variables
456 # - cvs_dir directory containing the temporary repository
457 cvs_dir=tmpcvs$$
458 # Use an umask of 077, to avoid attacks that work by overwriting files in
459 # the "$CVSROOT"/CVSROOT directory.
460 (umask 077 && mkdir "$cvs_dir") || {
461 if test -d "$cvs_dir"; then
462 func_fatal_error "directory $cvs_dir already exists"
463 else
464 func_fatal_error "cannot create directory $cvs_dir"
467 CVSROOT="$srcdir/$cvs_dir"
468 unset CVS_CLIENT_LOG
469 unset CVS_CLIENT_PORT
470 unset CVS_IGNORE_REMOTE_ROOT
471 unset CVS_LOCAL_BRANCH_NUM
472 unset CVS_NOBASES
473 unset CVS_PASSFILE
474 unset CVS_PASSWORD
475 unset CVS_PROXY_PORT
476 unset CVS_RCMD_PORT
477 unset CVS_RSH
478 unset CVS_SERVER
479 unset CVS_SERVER_SLEEP
480 CVS_SIGN_COMMITS=
481 export CVS_SIGN_COMMITS
482 unset CVS_SSH
483 unset CVS_VERIFY_CHECKOUTS
484 unset CVS_VERIFY_TEMPLATE
485 unset CVSIGNORE
486 unset CVSREAD
487 unset CVSREADONLYFS
488 unset CVSUMASK
489 unset CVSWRAPPERS
491 # Need to pass -d "$CVSROOT", because there may be a CVS directory in the
492 # current directory.
493 cvs -d "$CVSROOT" init
494 gzip -d -c < "$gettext_dir/archive.cvs.tar.gz" | (cd "$cvs_dir" && tar xf -)
496 cd "$work_dir"
497 cvsver=gettext-`echo "$ver" | sed -e 's/\./_/g'`
498 (cvs -d "$CVSROOT" checkout -r"$cvsver" archive > /dev/null) 2>&1 | grep -v '^cvs checkout: Updating'
499 find archive -name CVS -type d -print | xargs rm -rf
500 cd ..
501 rm -rf "$cvs_dir"
502 # Check that really all CVS directories are gone, otherwise we would overwrite
503 # the contents of the user's CVS directories.
504 if test `find $work_dir/archive -name CVS -type d -print | wc -l` != 0; then
505 rm -rf "$work_dir"
506 func_fatal_error "failed to remove all CVS subdirectories"
508 if test `find $work_dir/archive -type f -print | wc -l` = 0; then
509 rm -rf "$work_dir"
510 func_fatal_error "infrastructure files for version $ver not found; this is autopoint from GNU $package $version"
514 git)
515 # Check availability of the git program.
516 (git --version) >/dev/null 2>/dev/null || func_fatal_error "git program not found"
517 mkdir "$work_dir/archive"
518 gzip -d -c < "$gettext_dir/archive.git.tar.gz" | (cd "$work_dir/archive" && tar xf -)
519 (cd "$work_dir/archive" && git checkout -q "gettext-$ver") || {
520 rm -rf "$work_dir"
521 func_fatal_error "infrastructure files for version $ver not found; this is autopoint from GNU $package $version"
523 (cd "$work_dir/archive" && rm -rf .git .gitignore)
525 esac
527 # func_destfile file
528 # determines the destination file, relative to the package's top level
529 # directory, for a given file name, relative to archive.
530 # Sets variables
531 # - destfile relative destination file name, or
532 # empty if the file shall be omitted
533 # - sharedowner yes if the file is not only owned by GNU gettext but may
534 # be installed by automake or other tools, otherwise empty
535 # - allpodirs yes if the file is to be installed in every dir in $podirs
536 func_destfile ()
538 # There are five categories of files:
539 # ABOUT_NLS -> top level directory
540 # config.rpath mkinstalldirs -> $auxdir
541 # m4/* -> $m4dir/
542 # intl/* -> intl/
543 # po/* ->
544 sharedowner=
545 allpodirs=
546 case `echo "$1" | sed -e 's,[^/]*$,,'` in
547 "" )
548 case "$1" in
549 config.rpath ) destfile="$auxdir$1" ;;
550 mkinstalldirs ) destfile="$auxdir$1" sharedowner=yes ;;
551 * ) destfile="$1" ;;
552 esac
554 m4/ ) destfile=`echo "$1" | sed -e "s,^m4/,$m4dir/,"` ;;
555 intl/ ) if test -n "$omitintl"; then destfile=""; else destfile="$1"; fi ;;
556 po/ ) destfile=`echo "$1" | sed -e "s,^po/,,"` allpodirs=yes ;;
557 * ) destfile="$1" ;;
558 esac
561 # func_compare existingfile gettextfile
562 # compares the existing file and the file from gettext, and decides whether the
563 # existing file should be overwritten with the file from gettext. Returns 0 if
564 # it should be overwritten, or 1 if it should be skipped.
565 sed_extract_serial='s/^#.* serial \([^ ]*\).*/\1/p
567 func_compare ()
569 if cmp -s "$1" "$2"; then
570 false
571 else
572 case "$2" in
573 *.m4)
574 # For interoperability with gnulib. gnulib often has newer versions of
575 # the *.m4 files than the latest gettext release. Don't overwrite a
576 # newer version from gnulib with an older version from the gettext
577 # release. The version can be retrieved from the first line, which
578 # looks like this: # file.m4 serial NN ...
579 existing_serial=`sed -n -e "$sed_extract_serial" < "$1"`
580 gettext_serial=`sed -n -e "$sed_extract_serial" < "$2"`
581 if test -n "$existing_serial" && test -n "$gettext_serial" \
582 && test "$existing_serial" -ge "$gettext_serial" 2> /dev/null; then
583 false
584 else
585 true
589 true
591 esac
595 # If some files have been locally modified and we have not been requested
596 # to overwrite them, then bail out. This is better than leaving a source
597 # package around where half of the files are locally modified and half are
598 # original - too great risk of version mismatch.
599 if test -z "$force"; then
600 mismatch=
601 func_tmpdir
602 mismatchfile="$tmp"/autopoint.diff
603 for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir/archive/,," | LC_ALL=C sort`; do
604 func_destfile "$file"
605 if test -n "$destfile"; then
606 func_compare_to_destfile ()
608 finaldestfile="$1"
609 if test -f "$finaldestfile"; then
610 if func_compare "$finaldestfile" "$work_dir/archive/$file"; then
611 if test -n "$sharedowner"; then
612 echo "autopoint: warning: File $finaldestfile has been locally modified." 1>&2
613 else
614 echo "autopoint: File $finaldestfile has been locally modified." 1>&2
615 mismatch=yes
616 diff -c "$work_dir/archive/$file" "$finaldestfile" | sed -e "1s,$work_dir/archive/,," >> "$mismatchfile"
621 if test -n "$allpodirs"; then
622 for dir in $podirs; do
623 func_compare_to_destfile "$dir/$destfile"
624 done
625 else
626 func_compare_to_destfile "$destfile"
629 done
630 if test -n "$mismatch"; then
631 rm -rf "$work_dir"
632 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'."
634 rm -rf "$tmp"
637 # func_mkdir_for to
638 # ensures the directory that would the given file exists.
639 # 'to' is a relative pathname, relative to the current directory.
640 func_mkdir_for ()
642 base=`echo "$1" | sed -e 's,/[^/]*$,,'`
643 if test "X$base" != "X$1" && test -n "$base"; then
644 func_mkdir_for "$base"
645 # Recompute base. It was clobbered by the recursive call.
646 base=`echo "$1" | sed -e 's,/[^/]*$,,'`
647 test -d "$base" || { echo "Creating directory $base"; mkdir "$base"; }
651 # func_copy from to
652 # copies a file.
653 # 'from' is a relative pathname, relative to the current directory.
654 # 'to' is a relative pathname, relative to the current directory.
655 func_copy ()
657 if $doit; then
658 func_mkdir_for "$2"
659 rm -f "$2"
660 echo "Copying file $2"
661 cp "$1" "$2"
662 else
663 echo "Copy file $2"
667 # func_backup to
668 # makes a backup of a file that is about to be overwritten or replaced.
669 # 'to' is a relative pathname, relative to the current directory.
670 func_backup ()
672 if $doit; then
673 if test -f "$1"; then
674 rm -f "$1~"
675 cp -p "$1" "$1~"
680 # Now copy the files.
681 for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir/archive/,," | LC_ALL=C sort`; do
682 func_destfile "$file"
683 if test -n "$destfile"; then
684 func_copy_to_destfile ()
686 finaldestfile="$1"
687 mustcopy=
688 if test -f "$finaldestfile"; then
689 if func_compare "$finaldestfile" "$work_dir/archive/$file"; then
690 if test -n "$force"; then
691 # Overwrite locally modified file.
692 mustcopy=yes
694 # If --force is not specified, don't overwrite locally modified files
695 # for which GNU gettext is a shared owner.
697 else
698 mustcopy=yes
700 if test -n "$mustcopy"; then
701 func_backup "$finaldestfile"
702 func_copy "$work_dir/archive/$file" "$finaldestfile"
705 if test -n "$allpodirs"; then
706 for dir in $podirs; do
707 func_copy_to_destfile "$dir/$destfile"
708 done
709 else
710 func_copy_to_destfile "$destfile"
713 done
715 # That's it.
716 rm -rf "$work_dir"
717 exit 0