]> Dogcows Code - chaz/tar/blob - bootstrap
(AT_KEYWORDS): Keyword `filechange'
[chaz/tar] / bootstrap
1 #! /bin/sh
2
3 # Bootstrap this package from CVS.
4
5 # Copyright (C) 2003, 2004, 2005, 2006 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 2, 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 package=tar
25
26 # Translation Project URL, for the registry of all projects.
27 TP_URL='http://www.iro.umontreal.ca/translation/registry.cgi?domain='
28
29 # Ensure file names are sorted consistently across platforms.
30 # Also, ensure diagnostics are in English, e.g., "wget --help" below.
31 LC_ALL=C
32 export LC_ALL
33
34 usage() {
35 cat <<EOF
36 usage: $0 [--gnulib-srcdir=DIR][--paxutils-srcdir=DIR][--cvs-auth=AUTH-METHOD][--cvs-user=USERNAME][--no-po]
37 Options are:
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 --cvs-auth=METHOD Set the CVS access method used for downloading
49 gnulib files. METHOD is one of the keywords
50 accepted by cvs -d option (see info cvs
51 repository).
52 --cvs-user=USERNAME Set the CVS username to be used when accessing
53 the gnulib repository.
54 --no-po Do not download po files.
55 --update-po[=LANG] Update po file(s) and exit.
56
57 If the file \`.bootstrap' exists in the current working directory, its
58 contents is read, comments and empty lines removed, shell variables expanded
59 and the result is prepended to the command line options.
60
61 Running without arguments will suffice in most cases. It is equivalent
62 to
63
64 ./bootstrap --cvs-auth=pserver
65
66 EOF
67 }
68
69 # Read configuration file
70 if [ -r .bootstrap ]; then
71 echo "$0: Reading configuration file .bootstrap"
72 eval set -- "`sed 's/#.*$//;/^$/d' .bootstrap | tr '\n' ' '` $*"
73 fi
74
75 # Parse options.
76
77 DOWNLOAD_PO=yes
78 for option
79 do
80 case $option in
81 --help)
82 usage
83 exit;;
84 --gnulib-srcdir=*)
85 GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
86 --paxutils-srcdir=*)
87 PAXUTILS_SRCDIR=`expr "$option" : '--paxutils-srcdir=\(.*\)'`;;
88 --cvs-auth=*)
89 CVS_AUTH=`expr "$option" : '--cvs-auth=\(.*\)'`;;
90 --cvs-user=*)
91 CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
92 --no-po)
93 DOWNLOAD_PO=no;;
94 --update-po=*)
95 DOWNLOAD_PO=`expr "$option" : '--update-po=\(.*\)'`;;
96 --update-po)
97 DOWNLOAD_PO=only;;
98 *)
99 echo >&2 "$0: $option: unknown option"
100 exit 1;;
101 esac
102 done
103
104 # Get translations.
105
106 get_translations() {
107 subdir=$1
108 domain=$2
109 po_file=$3
110
111 echo "$0: getting translations into $subdir for $domain..."
112
113 case $po_file in
114 '') (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`);;
115 esac &&
116
117 $WGET_COMMAND -O "$subdir/$domain.html" "$TP_URL$domain" &&
118
119 sed -n 's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p' <"$subdir/$domain.html" |
120 sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 |
121 awk -F. '
122 { if (lang && $1 != lang) print lang, ver }
123 { lang = $1; ver = substr($0, index($0, ".") + 1) }
124 END { if (lang) print lang, ver }
125 ' |
126 awk -v domain="$domain" -v po_file="$po_file" -v subdir="$subdir" '
127 {
128 lang = $1
129 if (po_file && po_file != (lang ".po")) next
130
131 # Work around bugs in translations uncovered by gettext 0.15.
132 # This workaround can be removed once the translations are fixed.
133 if (lang == "hu" || lang == "zh_TW") next
134
135 ver = $2
136 urlfmt = ""
137 printf "$WGET_COMMAND -O %s/%s.po 'http://www.iro.umontreal.ca/translation/teams/PO/%s/%s-%s.%s.po' &&\n", subdir, lang, lang, domain, ver, lang
138 }
139 END { print ":" }
140 ' |
141 sh &&
142 ls "$subdir"/*.po | sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" &&
143 rm "$subdir/$domain.html"
144 }
145
146 update_po() {
147 if [ $# = 1 ]; then
148 case $1 in
149 *.po) POFILE=$1;;
150 *) POFILE=${1}.po;;
151 esac
152 get_translations po $package "$POFILE"
153 else
154 get_translations po $package
155 fi
156 }
157
158 case $DOWNLOAD_PO in
159 no) ;;
160 *)
161 case `wget --help` in
162 *'--no-cache'*)
163 no_cache='--no-cache';;
164 *'--cache=on/off'*)
165 no_cache='--cache=off';;
166 *)
167 no_cache='';;
168 esac
169
170 WGET_COMMAND="wget -nv $no_cache"
171 export WGET_COMMAND
172 esac
173
174 case $DOWNLOAD_PO in
175 only) update_po
176 exit
177 ;;
178 no|yes) ;;
179 *) update_po $DOWNLOAD_PO
180 exit
181 esac
182
183
184 echo "$0: Bootstrapping CVS $package..."
185
186 build_cvs_prefix() {
187 CVS_PREFIX=:${1}:
188 if [ "${2}" != - ]; then
189 CVS_PREFIX=${CVS_PREFIX}${2}@
190 fi
191 if [ "$1" = "ext" ]; then
192 if [ -z "${CVS_RSH}" ]; then
193 CVS_RSH=ssh
194 export CVS_RSH
195 fi
196 fi
197 }
198
199 # checkout package
200 checkout() {
201 if [ ! -d $1 ]; then
202 echo "$0: getting $1 files..."
203
204 trap exit 1 2 13 15
205 trap 'rm -fr $1; exit 1' 0
206
207 case "${CVS_AUTH-pserver}" in
208 pserver) build_cvs_prefix pserver ${CVS_USER:-anonymous}
209 ;;
210 gserver|server)
211 build_cvs_prefix $CVS_AUTH ${CVS_USER--}
212 ;;
213 ext) build_cvs_prefix $CVS_AUTH ${CVS_USER--}
214 ;;
215 *) echo "$0: Unknown CVS access method" >&2
216 exit 1;;
217 esac
218 cvs -q -d ${CVS_PREFIX}cvs.sv.gnu.org:/cvsroot/$1 co $1 || exit
219
220 trap - 0
221 fi
222 }
223
224 gnulib_modules=
225 newline='
226 '
227
228 get_modules() {
229 new_gnulib_modules=`sed '/^[ ]*#/d; /^[ ]*$/d' $*`
230 case $gnulib_modules,$new_gnulib_modules in
231 ?*,?*) new_gnulib_modules=$newline$new_gnulib_modules;;
232 esac
233 gnulib_modules=$gnulib_modules$new_gnulib_modules
234 }
235
236 # Get paxutils files
237 case ${PAXUTILS_SRCDIR--} in
238 -) checkout paxutils
239 PAXUTILS_SRCDIR=paxutils
240 esac
241
242 if [ -r $PAXUTILS_SRCDIR/gnulib.modules ]; then
243 get_modules $PAXUTILS_SRCDIR/gnulib.modules
244 fi
245
246 # copy_files srcdir dstdir
247 copy_files() {
248 for file in `cat $1/DISTFILES`
249 do
250 case $file in
251 "#*") continue;;
252 esac
253 dst=`echo $file | sed 's^.*/^^'`
254 if [ $# -eq 3 ]; then
255 case $dst in
256 ${3}*) ;;
257 *) dst=${3}$dst;;
258 esac
259 fi
260 echo "$0: Copying file $1/$file to $2/$dst"
261 cp -p $1/$file $2/$dst
262 done
263 }
264
265 copy_files ${PAXUTILS_SRCDIR}/m4 m4
266 echo "$0: Creating m4/paxutils.m4"
267 (echo "# This file is generated automatically. Please, do not edit."
268 echo "#"
269 echo "AC_DEFUN([${package}_PAXUTILS],["
270 cat ${PAXUTILS_SRCDIR}/m4/DISTFILES | sed '/^#/d;s/\(.*\)\.m4/pu_\1/' | tr a-z A-Z
271 echo "])") > ./m4/paxutils.m4
272
273 if [ -d rmt ]; then
274 :
275 else
276 mkdir rmt
277 fi
278
279 for dir in doc rmt lib tests
280 do
281 copy_files ${PAXUTILS_SRCDIR}/$dir $dir
282 done
283
284 copy_files ${PAXUTILS_SRCDIR}/paxlib lib pax
285
286 # Get gnulib files.
287
288 case ${GNULIB_SRCDIR--} in
289 -) checkout gnulib
290 GNULIB_SRCDIR=gnulib
291 esac
292
293 gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
294 <$gnulib_tool || exit
295
296 get_modules gnulib.modules
297
298 gnulib_modules=`echo "$gnulib_modules" | sort -u`
299 previous_gnulib_modules=
300 while [ "$gnulib_modules" != "$previous_gnulib_modules" ]; do
301 previous_gnulib_modules=$gnulib_modules
302 gnulib_modules=`
303 (echo "$gnulib_modules"
304 for gnulib_module in $gnulib_modules; do
305 $gnulib_tool --extract-dependencies $gnulib_module
306 done) | sort -u
307 `
308 done
309
310 gnulib_files=`
311 (for gnulib_module in $gnulib_modules; do
312 $gnulib_tool --extract-filelist $gnulib_module
313 done) | sort -u
314 `
315
316 gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u`
317 mkdir -p $gnulib_dirs || exit
318
319 for gnulib_file in $gnulib_files; do
320 dest=$gnulib_file
321 rm -f $dest &&
322 echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file" &&
323 cp -p $GNULIB_SRCDIR/$gnulib_file $dest || exit
324 done
325
326 # This suppresses a bogus diagnostic
327 # "warning: macro `AM_LANGINFO_CODESET' not found in library".
328 echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
329 sed '
330 /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
331 AC_DEFUN([AM_INTL_SUBDIR], [])
332 /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
333 AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
334 ' m4/gettext.m4 >m4/gettext_gl.m4 || exit
335
336 echo "$0: Creating m4/gnulib.m4"
337 (echo "# This file is generated automatically. Please, do not edit."
338 echo "#"
339 echo "AC_DEFUN([${package}_GNULIB],["
340 for gnulib_module in $gnulib_modules; do
341 echo "# $gnulib_module"
342 $gnulib_tool --extract-autoconf-snippet $gnulib_module
343 done | sed '/AM_GNU_GETTEXT/d'
344 echo "])") > ./m4/gnulib.m4
345
346 echo "$0: Creating lib/Makefile.am"
347 (echo "# This file is generated automatically. Do not edit!"
348 cat lib/Makefile.tmpl
349
350 for gnulib_module in $gnulib_modules; do
351 echo "# $gnulib_module"
352 $gnulib_tool --extract-automake-snippet $gnulib_module
353 done | sed "s/lib_SOURCES/lib${package}_a_SOURCES/g" ) > lib/Makefile.am
354
355 # Get translations.
356 if test "$DOWNLOAD_PO" = "yes"; then
357 update_po
358 fi
359
360 # Reconfigure, getting other files.
361
362 echo "$0: autopoint --force ..."
363 autopoint --force || exit
364
365 # We don't need intl, so remove it.
366 intl_files_to_remove='
367 intl
368 m4/gettext.m4
369 m4/glibc2.m4
370 m4/intdiv0.m4
371 m4/intmax.m4
372 m4/lcmessage.m4
373 m4/lock.m4
374 m4/printf-posix.m4
375 m4/visibility.m4
376 '
377 echo $0: rm -fr $intl_files_to_remove ...
378 rm -fr $intl_files_to_remove || exit
379
380
381 # Undo changes to gnulib files that autoreconf made.
382
383 for gnulib_file in $gnulib_files; do
384 test ! -f $gnulib_file || cmp -s $gnulib_file $GNULIB_SRCDIR/$gnulib_file || {
385 rm -f $gnulib_file &&
386 echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file again" &&
387 cp -p $GNULIB_SRCDIR/$gnulib_file $gnulib_file || exit
388 }
389 done
390
391 # Make sure aclocal.m4 is not older than input files.
392 sleep 1
393
394 for command in \
395 'aclocal --force -I m4' \
396 'autoconf --force' \
397 'autoheader --force' \
398 'automake --add-missing --copy --force-missing';
399 do
400 echo "$0: $command ..."
401 $command || exit
402 done
403
404
405 # Create gettext configuration.
406 echo "$0: Creating po/Makevars from po/Makevars.template ..."
407 sed '
408 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
409 /^XGETTEXT_OPTIONS *=/{
410 s/$/ \\/
411 a\
412 --flag=_:1:pass-c-format \\\
413 --flag=N_:1:pass-c-format \\\
414 --flag=error:3:c-format --flag=error_at_line:5:c-format \\\
415 --flag=asnprintf:3:c-format --flag=vasnprintf:3:c-format \\\
416 --flag=argp_error:2:c-format \\\
417 --flag=__argp_error:2:c-format \\\
418 --flag=argp_failure:4:c-format \\\
419 --flag=__argp_failure:4:c-format \\\
420 --flag=argp_fmtstream_printf:2:c-format \\\
421 --flag=__argp_fmtstream_printf:2:c-format
422 }
423 ' po/Makevars.template >po/Makevars
424
425
426 echo "$0: done. Now you can run './configure'."
This page took 0.055447 seconds and 4 git commands to generate.