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