]> Dogcows Code - chaz/tar/blob - bootstrap
(checkout): Use URL of the gnulib CVS mirror.
[chaz/tar] / bootstrap
1 #! /bin/sh
2
3 # Bootstrap this package from CVS.
4
5 # Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
10 # any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 # 02110-1301, USA.
21
22 # Written by Paul Eggert and Sergey Poznyakoff.
23
24 nl='
25 '
26
27 # Ensure file names are sorted consistently across platforms.
28 # Also, ensure diagnostics are in English, e.g., "wget --help" below.
29 LC_ALL=C
30 export LC_ALL
31
32 usage() {
33 echo >&2 "\
34 Usage: $0 [OPTION]...
35 Bootstrap this package from the checked-out sources.
36
37 Options:
38 --paxutils-srcdir=DIRNAME Specify the local directory where paxutils
39 sources reside. Use this if you already
40 have paxutils sources on your machine, and
41 do not want to waste your bandwidth dowloading
42 them again.
43 --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
44 sources reside. Use this if you already
45 have gnulib sources on your machine, and
46 do not want to waste your bandwidth dowloading
47 them again.
48 --copy Copy files instead of creating symbolic links.
49 --force Attempt to bootstrap even if the sources seem
50 not to have been checked out.
51 --skip-po Do not download po files.
52 --update-po[=LANG] Update po file(s) and exit.
53 --cvs-user=USERNAME Set the CVS username to be used when accessing
54 the paxutils repository.
55
56 If the file bootstrap.conf exists in the current working directory, its
57 contents are read as shell variables to configure the bootstrap.
58
59 Local defaults can be provided by placing the file \`.bootstrap' in the
60 current working directory. The file is read after bootstrap.conf, comments
61 and empty lines are removed, shell variables expanded and the result is
62 prepended to the command line options.
63
64 Running without arguments will suffice in most cases.
65 "
66 }
67
68 checkout() {
69 if [ ! -d $1 ]; then
70 echo "$0: getting $1 files..."
71
72 case $1 in
73 paxutils)
74 case ${CVS_AUTH-pserver} in
75 pserver)
76 CVS_PREFIX=':pserver:anonymous@';;
77 ssh)
78 CVS_PREFIX="$CVS_USER${CVS_USER+@}";;
79 *)
80 echo "$0: $CVS_AUTH: Unknown CVS access method" >&2
81 exit 1;;
82 esac
83
84 case $CVS_RSH in
85 '') CVS_RSH=ssh; export CVS_RSH;;
86 esac
87
88 CVSURL=${CVS_PREFIX}cvs.savannah.gnu.org:/cvsroot/"$1"
89 ;;
90
91 gnulib)
92 CVSURL=:pserver:anonymous@pserver.git.sv.gnu.org:/gnulib.git
93 ;;
94
95 esac
96
97 trap "cleanup $1" 1 2 13 15
98
99 cvs -z3 -q -d $CVSURL co $1 || cleanup $1
100
101 trap - 1 2 13 15
102 fi
103 }
104
105 cleanup() {
106 status=$?
107 rm -fr $1
108 exit $status
109 }
110
111 # Configuration.
112
113 # List of gnulib modules needed.
114 gnulib_modules=
115
116 # Any gnulib files needed that are not in modules.
117 gnulib_files=
118
119 # Translation Project URL, for the registry of all projects
120 # and for the translation-team master directory.
121 tp_url() {
122 echo "http://translationproject.org/domain/$1.html"
123 }
124
125 extract_package_name='
126 /^AC_INIT(/{
127 /.*,.*,.*,/{
128 s///
129 s/[][]//g
130 p
131 q
132 }
133 s/AC_INIT(\[*//
134 s/]*,.*//
135 s/^GNU //
136 y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
137 s/[^A-Za-z0-9_]/-/g
138 p
139 }
140 '
141 package=`sed -n "$extract_package_name" configure.ac` || exit
142
143 # Extra files from gnulib, which override files from other sources.
144 gnulib_extra_files='
145 build-aux/announce-gen
146 build-aux/install-sh
147 build-aux/missing
148 build-aux/mdate-sh
149 build-aux/texinfo.tex
150 build-aux/depcomp
151 build-aux/config.guess
152 build-aux/config.sub
153 doc/INSTALL
154 '
155
156 # Other locale categories that need message catalogs.
157 EXTRA_LOCALE_CATEGORIES=
158
159 # Additional xgettext options to use. Use "\\\newline" to break lines.
160 XGETTEXT_OPTIONS='\\\
161 --flag=_:1:pass-c-format\\\
162 --flag=N_:1:pass-c-format\\\
163 --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
164 '
165
166 # Files we don't want to import.
167 excluded_files=
168
169 # File that should exist in the top directory of a checked out hierarchy,
170 # but not in a distribution tarball.
171 CVS_only_file=README-cvs
172
173 # Whether to use copies instead of symlinks.
174 copy=false
175
176 # Override the default configuration, if necessary.
177 test -r bootstrap.conf && . ./bootstrap.conf
178
179 # Read local configuration file
180 if [ -r .bootstrap ]; then
181 echo "$0: Reading configuration file .bootstrap"
182 eval set -- "`sed 's/#.*$//;/^$/d' .bootstrap | tr '\n' ' '` $*"
183 fi
184
185 # Translate configuration into internal form.
186
187 # Parse options.
188
189 for option
190 do
191 case $option in
192 --help)
193 usage
194 exit;;
195 --paxutils-srcdir=*)
196 PAXUTILS_SRCDIR=`expr "$option" : '--paxutils-srcdir=\(.*\)'`;;
197 --gnulib-srcdir=*)
198 GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
199 --cvs-user=*)
200 CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
201 --skip-po | --no-po) # --no-po is for compatibility with 'tar' tradition.
202 DOWNLOAD_PO=skip;;
203 --update-po=*)
204 DOWNLOAD_PO=`expr "$option" : '--update-po=\(.*\)'`;;
205 --update-po)
206 DOWNLOAD_PO=only;;
207 --force)
208 CVS_only_file=;;
209 --copy)
210 copy=true;;
211 *)
212 echo >&2 "$0: $option: unknown option"
213 exit 1;;
214 esac
215 done
216
217 if test -n "$CVS_only_file" && test ! -r "$CVS_only_file"; then
218 echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
219 exit 1
220 fi
221
222 echo "$0: Bootstrapping CVS $package..."
223
224 # Get translations.
225
226 get_translations() {
227 subdir=$1
228 domain=$2
229 po_file=$3
230
231 case $WGET_COMMAND in
232 '')
233 echo "$0: wget not available; skipping translations";;
234 ?*)
235 url=`tp_url $domain`
236 baseurl=`expr "$url" : '\(.*\)/.*'`
237 echo "$0: getting translations into $subdir for $domain..." &&
238 case $po_file in
239 '') (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`);;
240 esac &&
241
242 $WGET_COMMAND -O "$subdir/$domain.html" "$url" &&
243
244 sed -n 's|.*href="\(.*\)/\([^/][^/]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\2:\3:\1|p' <"$subdir/$domain.html" |
245 sort -t: -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 |
246 awk -F: '
247 { if (lang && $1 != lang) print lang, ver, $3 }
248 { lang = $1; ver = $2 }
249 END { if (lang) print lang, ver, $3 }
250 ' | awk -v domain="$domain" -v baseurl="$baseurl" -v subdir="$subdir" \
251 -v po_file="$po_file" '
252 {
253 lang = $1
254 if (po_file && po_file != (lang ".po")) next
255 ver = $2
256 printf "{ $WGET_COMMAND -O %s/%s.po %s/%s/%s/%s-%s.%s.po &&\n", subdir, lang, baseurl, $3, lang, domain, ver, lang
257 printf " msgfmt -c -o /dev/null %s/%s.po || {\n", subdir, lang
258 printf " echo >&2 '\'"$0"': omitting translation for %s'\''\n", lang
259 printf " rm -f %s/%s.po; }; } &&\n", subdir, lang
260 }
261 END { print ":" }
262 ' | WGET_COMMAND="$WGET_COMMAND" sh
263 ;;
264 esac &&
265 ls "$subdir"/*.po 2>/dev/null |
266 sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" &&
267 rm -f "$subdir/$domain.html"
268 }
269
270 case `wget --help` in
271 *'--no-cache'*)
272 WGET_COMMAND='wget -nv --no-cache';;
273 *'--cache=on/off'*)
274 WGET_COMMAND='wget -nv --cache=off';;
275 *'--non-verbose'*)
276 WGET_COMMAND='wget -nv';;
277 *)
278 WGET_COMMAND='';;
279 esac
280
281 case $DOWNLOAD_PO in
282 'skip')
283 ;;
284 '')
285 get_translations po $package || exit
286 ;;
287 'only')
288 get_translations po $package
289 exit
290 ;;
291 *.po)
292 get_translations po $package "$DOWNLOAD_PO"
293 exit
294 ;;
295 *)
296 get_translations po $package "${DOWNLOAD_PO}.po"
297 exit
298 esac
299
300 # Get paxutils files.
301
302 case ${PAXUTILS_SRCDIR--} in
303 -) checkout paxutils
304 PAXUTILS_SRCDIR=paxutils
305 esac
306
307 if [ -r $PAXUTILS_SRCDIR/gnulib.modules ]; then
308 gnulib_modules=`
309 (echo "$gnulib_modules"; grep '^[^#]' $PAXUTILS_SRCDIR/gnulib.modules) |
310 sort -u
311 `
312 fi
313
314 ignore_file_list=
315 cleanup_ifl() {
316 test -n "$ignore_file_list" && rm -f $ignore_file_list
317 }
318
319 trap 'cleanup_ifl' 1 2 3 15
320
321 # ignorefile DIR FILE
322 # add FILE to the temporary ignorelist in the directory DIR
323 ignorefile() {
324 file=$1/.ignore.$$
325 echo "$2" >> $file
326 if `echo $ignore_list | grep -qv $file`; then
327 ignore_file_list="$ignore_file_list
328 $file"
329 fi
330 }
331
332 # copy_files srcdir dstdir
333 copy_files() {
334 for file in `cat $1/DISTFILES`
335 do
336 case $file in
337 "#*") continue;;
338 esac
339 dst=`echo $file | sed 's^.*/^^'`
340 if [ $# -eq 3 ]; then
341 case $dst in
342 ${3}*) ;;
343 *) dst=${3}$dst;;
344 esac
345 fi
346 echo "$0: Copying file $1/$file to $2/$dst"
347 cp -p $1/$file $2/$dst
348 ignorefile $2 $dst
349 done
350 }
351
352 # Get gnulib files.
353
354 case ${GNULIB_SRCDIR--} in
355 -)
356 checkout gnulib
357 GNULIB_SRCDIR=gnulib
358 esac
359
360 gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
361 <$gnulib_tool || exit
362
363 ensure_dir_exists()
364 {
365 d=`dirname $dst`
366 test -d "$d" || mkdir -p -- "$d"
367 }
368
369 symlink_to_gnulib()
370 {
371 src=$GNULIB_SRCDIR/$1
372 dst=${2-$1}
373
374 test -f "$src" && {
375 if $copy; then
376 {
377 test ! -h "$dst" || {
378 echo "$0: rm -f $dst" &&
379 rm -f "$dst"
380 }
381 } &&
382 test -f "$dst" &&
383 cmp -s "$src" "$dst" || {
384 echo "$0: cp -fp $src $dst" &&
385 ensure_dir_exists $dst &&
386 cp -fp "$src" "$dst"
387 }
388 else
389 test -h "$dst" &&
390 src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
391 dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
392 test "$src_i" = "$dst_i" || {
393 dot_dots=
394 case $src in
395 /*) ;;
396 *)
397 case /$dst/ in
398 *//* | */../* | */./* | /*/*/*/*/*/)
399 echo >&2 "$0: invalid symlink calculation: $src -> $dst"
400 exit 1;;
401 /*/*/*/*/) dot_dots=../../../;;
402 /*/*/*/) dot_dots=../../;;
403 /*/*/) dot_dots=../;;
404 esac;;
405 esac
406
407 echo "$0: ln -fs $dot_dots$src $dst" &&
408 ensure_dir_exists $dst &&
409 ln -fs "$dot_dots$src" "$dst"
410 }
411 fi
412 }
413 }
414
415 cp_mark_as_generated()
416 {
417 cp_src=$1
418 cp_dst=$2
419
420 if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
421 symlink_to_gnulib "$cp_dst"
422 else
423 case $cp_dst in
424 *.[ch]) c1='/* '; c2=' */';;
425 *.texi) c1='@c '; c2= ;;
426 *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
427 *) c1= ; c2= ;;
428 esac
429
430 if test -z "$c1"; then
431 cmp -s "$cp_src" "$cp_dst" || {
432 echo "$0: cp -f $cp_src $cp_dst" &&
433 cp -f "$cp_src" "$cp_dst"
434 }
435 else
436 # Copy the file first to get proper permissions if it
437 # doesn't already exist. Then overwrite the copy.
438 cp "$cp_src" "$cp_dst-t" &&
439 (
440 echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
441 echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
442 cat "$cp_src"
443 ) > $cp_dst-t &&
444 if cmp -s "$cp_dst-t" "$cp_dst"; then
445 rm -f "$cp_dst-t"
446 else
447 echo "$0: cp $cp_src $cp_dst # with edits" &&
448 mv -f "$cp_dst-t" "$cp_dst"
449 fi
450 fi
451 fi
452 }
453
454 version_controlled_file() {
455 dir=$1
456 file=$2
457 found=no
458 if test -d CVS; then
459 grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
460 grep '^/[^/]*/[0-9]' > /dev/null && found=yes
461 elif test -d .git; then
462 git-rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
463 else
464 echo "$0: no version control for $dir/$file?" >&2
465 fi
466 test $found = yes
467 }
468
469 slurp() {
470 for dir in . `(cd $1 && find * -type d -print)`; do
471 copied=
472 sep=
473 for file in `ls $1/$dir`; do
474 test -d $1/$dir/$file && continue
475 for excluded_file in $excluded_files; do
476 test "$dir/$file" = "$excluded_file" && continue 2
477 done
478 if test $file = Makefile.am; then
479 copied=$copied${sep}gnulib.mk; sep=$nl
480 remove_intl='/^[^#].*\/intl/s/^/#/;'"s,/$bt,,g"
481 sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/gnulib.mk || {
482 echo "$0: Copying $1/$dir/$file to $dir/gnulib.mk ..." &&
483 rm -f $dir/gnulib.mk &&
484 sed "$remove_intl" $1/$dir/$file >$dir/gnulib.mk
485 }
486 elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
487 version_controlled_file $dir $file; then
488 echo "$0: $dir/$file overrides $1/$dir/$file"
489 else
490 copied=$copied$sep$file; sep=$nl
491 if test $file = gettext.m4; then
492 echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
493 rm -f $dir/$file
494 sed '
495 /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
496 AC_DEFUN([AM_INTL_SUBDIR], [
497 /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
498 AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
499 $a\
500 AC_DEFUN([gl_LOCK_EARLY], [])
501 ' $1/$dir/$file >$dir/$file
502 else
503 cp_mark_as_generated $1/$dir/$file $dir/$file
504 fi
505 fi || exit
506 done
507
508 if test -n "$copied"; then
509 copied="Makefile
510 Makefile.in
511 $copied"
512 if test -d CVS; then
513 dot_ig=.cvsignore
514 else
515 dor_ig=.gitignore
516 fi
517
518 ig=$dir/$dot_ig
519 if [ -f $dir/.ignore.$$ ]; then
520 tfile=$dir/.ignore.$$
521 else
522 tfile=
523 fi
524 if test -f $ig; then
525 echo "$copied" | sort -u - $ig | cmp -s - $ig ||
526 echo "$copied" | sort -u - $ig $tfile -o $ig
527 else
528 copied="$dot_ig
529 $copied"
530 if [ "$dir" = "po" ]; then
531 copied="LINGUAS
532 Makevars
533 POTFILES
534 *.mo
535 *.gmo
536 *.po
537 remove-potcdate.sed
538 stamp-po
539 $package.pot
540 $copied"
541 fi
542 echo "$copied" | sort -u - $tfile -o $ig
543 fi || exit
544 fi
545 done
546 }
547
548
549 # Create boot temporary directories to import from gnulib and gettext.
550
551 bt='.#bootmp'
552 bt2=${bt}2
553 rm -fr $bt $bt2 &&
554 mkdir $bt $bt2 || exit
555
556 # Import from gnulib.
557
558 test -d build-aux || {
559 echo "$0: mkdir build-aux ..." &&
560 mkdir build-aux
561 } || exit
562 gnulib_tool_options="\
563 --import\
564 --no-changelog\
565 --aux-dir $bt/build-aux\
566 --doc-base $bt/doc\
567 --lib lib$package\
568 --m4-base $bt/m4/\
569 --source-base $bt/lib/\
570 --tests-base $bt/tests\
571 --local-dir gl\
572 "
573 echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
574 $gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
575 slurp $bt || exit
576
577 for file in $gnulib_files; do
578 symlink_to_gnulib $file || exit
579 done
580
581
582 # Import from gettext.
583
584 echo "$0: (cd $bt2; autopoint) ..."
585 cp configure.ac $bt2 &&
586 (cd $bt2 && autopoint && rm configure.ac) &&
587 slurp $bt2 $bt || exit
588
589 rm -fr $bt $bt2 || exit
590
591 # Import from paxutils
592 copy_files ${PAXUTILS_SRCDIR}/m4 m4
593 echo "$0: Creating m4/paxutils.m4"
594 (echo "# This file is generated automatically. Please, do not edit."
595 echo "#"
596 echo "AC_DEFUN([${package}_PAXUTILS],["
597 cat ${PAXUTILS_SRCDIR}/m4/DISTFILES | sed '/^#/d;s/\(.*\)\.m4/pu_\1/' | tr a-z A-Z
598 echo "])") > ./m4/paxutils.m4
599 ignorefile m4 paxutils.m4
600
601 if [ -d rmt ]; then
602 :
603 else
604 mkdir rmt
605 fi
606
607 for dir in doc rmt lib tests
608 do
609 copy_files ${PAXUTILS_SRCDIR}/$dir $dir
610 done
611
612 copy_files ${PAXUTILS_SRCDIR}/paxlib lib pax
613
614 # Reconfigure, getting other files.
615
616 for command in \
617 'aclocal --force -I m4' \
618 'autoconf --force' \
619 'autoheader --force' \
620 'automake --add-missing --copy --force-missing';
621 do
622 echo "$0: $command ..."
623 $command || exit
624 done
625
626
627 # Get some extra files from gnulib, overriding existing files.
628
629 for file in $gnulib_extra_files; do
630 case $file in
631 */INSTALL) dst=INSTALL;;
632 *) dst=$file;;
633 esac
634 symlink_to_gnulib $file $dst || exit
635 done
636
637
638 # Create gettext configuration.
639 echo "$0: Creating po/Makevars from po/Makevars.template ..."
640 rm -f po/Makevars
641 sed '
642 /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
643 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
644 /^XGETTEXT_OPTIONS *=/{
645 s/$/ \\/
646 a\
647 '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
648 }
649 ' po/Makevars.template >po/Makevars
650
651 if test -d runtime-po; then
652 # Similarly for runtime-po/Makevars, but not quite the same.
653 rm -f runtime-po/Makevars
654 sed '
655 /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
656 /^subdir *=.*/s/=.*/= runtime-po/
657 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
658 /^XGETTEXT_OPTIONS *=/{
659 s/$/ \\/
660 a\
661 '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
662 }
663 ' <po/Makevars.template >runtime-po/Makevars
664
665 # Copy identical files from po to runtime-po.
666 (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
667 fi
668 cleanup_ifl
669 echo "$0: done. Now you can run './configure'."
This page took 0.066502 seconds and 5 git commands to generate.