]> Dogcows Code - chaz/tar/blob - bootstrap
Fix typo: remove po/tar.html.
[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 (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`) &&
113
114 $WGET_COMMAND -O "$subdir/$domain.html" "$TP_URL$domain" &&
115
116 sed -n 's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p' <"$subdir/$domain.html" |
117 sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 |
118 awk -F. '
119 { if (lang && $1 != lang) print lang, ver }
120 { lang = $1; ver = substr($0, index($0, ".") + 1) }
121 END { if (lang) print lang, ver }
122 ' |
123 awk -v domain="$domain" -v po_file="$po_file" -v subdir="$subdir" '
124 {
125 lang = $1
126 if (po_file == (lang ".po")) next
127
128 # Work around bugs in translations uncovered by gettext 0.15.
129 # This workaround can be removed once the translations are fixed.
130 if (lang == "hu" || lang == "ja" || lang == "ky" || lang == "zh_TW") next
131
132 ver = $2
133 urlfmt = ""
134 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
135 }
136 END { print ":" }
137 ' |
138 sh &&
139 ls "$subdir"/*.po | sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" &&
140 rm "$subdir/$domain.html"
141 }
142
143 update_po() {
144 if [ $# = 1 ]; then
145 case $1 in
146 *.po) POFILE=$1;;
147 *) POFILE=${1}.po;;
148 esac
149 get_translations po $package "$POFILE" &&
150 LANG=`expr $POFILE : '\(.*\)\.po'` &&
151 { grep -q $LANG po/LINGUAS ||
152 (echo $LANG; cat po/LINGUAS) | sort -o po/LINGUAS; }
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([tar_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([tar_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/libtar_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/inttypes-h.m4
373 m4/inttypes-pri.m4
374 m4/lcmessage.m4
375 m4/lock.m4
376 m4/printf-posix.m4
377 m4/visibility.m4
378 '
379 echo $0: rm -fr $intl_files_to_remove ...
380 rm -fr $intl_files_to_remove || exit
381
382
383 # Undo changes to gnulib files that autoreconf made.
384 for gnulib_file in $gnulib_files; do
385 test ! -f $gnulib_file || cmp -s $gnulib_file $GNULIB_SRCDIR/$gnulib_file || {
386 rm -f $gnulib_file &&
387 echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file again" &&
388 cp -p $GNULIB_SRCDIR/$gnulib_file $gnulib_file || exit
389 }
390 done
391
392 # Make sure aclocal.m4 is not older than input files.
393 sleep 1
394
395 for command in \
396 'aclocal --force -I m4' \
397 'autoconf --force' \
398 'autoheader --force' \
399 'automake --add-missing --copy --force-missing';
400 do
401 echo "$0: $command ..."
402 $command || exit
403 done
404
405
406 # Put bug-reporting address into po/Makevars.
407 echo "$0: sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-$package@gnu.org/' po/Makevars.template >po/Makevars ..."
408 sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/' po/Makevars.template >po/Makevars
409
410
411
412 echo "$0: done. Now you can run './configure'."
This page took 0.052323 seconds and 5 git commands to generate.