(AT_KEYWORDS): Improve to allow executionof related tests in groups.
[debian/tar] / bootstrap
1 #! /bin/sh
2
3 # Bootstrap 'tar' from CVS.
4
5 # Copyright (C) 2003, 2004, 2005 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 # URL of our text domain page in Translation Project
25 TP_URL="http://www.iro.umontreal.ca/translation/maint/tar/"
26
27 # Ensure file names are sorted consistently across platforms;
28 # e.g., m4/ulonglong_gl.m4 should follow m4/ulonglong.m4.
29 LC_ALL=C
30 export LC_ALL
31
32 usage() {
33  cat <<EOF
34  usage: $0 [--gnulib-srcdir=DIR][--paxutils-srcdir=DIR][--cvs-auth=AUTH-METHOD][--cvs-user=USERNAME][--no-po]
35  Options are:
36  --paxutils-srcdir=DIRNAME    Specify the local directory where paxutils
37                               sources reside. Use this if you already
38                               have paxutils sources on your machine, and
39                               do not want to waste your bandwidth dowloading
40                               them again.
41  --gnulib-srcdir=DIRNAME      Specify the local directory where gnulib
42                               sources reside. Use this if you already
43                               have gnulib sources on your machine, and
44                               do not want to waste your bandwidth dowloading
45                               them again.
46  --cvs-auth=METHOD            Set the CVS access method used for downloading
47                               gnulib files. METHOD is one of the keywords
48                               accepted by cvs -d option (see info cvs
49                               repository).
50  --cvs-user=USERNAME          Set the CVS username to be used when accessing
51                               the gnulib repository.
52  --no-po                      Do not download po files.
53  --update-po[=LANG]           Update po file(s) and exit.
54
55 If the file \`.bootstrap' exists in the current working directory, its
56 contents is read, comments and empty lines removed, shell variables expanded
57 and the result is prepended to the command line options.
58
59 Running without arguments will suffice in most cases. It is equivalent
60 to
61
62     ./bootstrap --cvs-auth=ext --cvs-user=anoncvs
63
64 EOF
65 }
66
67 update_po() {
68   if [ $# = 1 ]; then
69     case $1 in
70     *.po)  POFILE=$1;;
71     *)     POFILE=${1}.po;;
72     esac
73     echo "$0: getting translation for $1..."
74     wget -r --cache=off $TP_URL/$POFILE
75   else
76     echo "$0: getting translations into po..."
77     (cd po &&
78      rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'` &&
79       wget -nv -nd -r -l 1 -A .po --cache off $TP_URL &&
80       rm -f index.html index.html.[0-9]*
81       ls *.po | sed 's/\.po$//' >LINGUAS
82     ) || exit
83   fi
84 }
85
86 # Read configuration file
87 if [ -r .bootstrap ]; then
88   echo "$0: Reading configuration file .bootstrap"
89   eval set -- "`sed 's/#.*$//;/^$/d' .bootstrap | tr '\n' ' '` $*"
90 fi
91
92 # Parse options.
93
94 DOWNLOAD_PO=yes
95 for option
96 do
97   case $option in
98   --help)
99     usage
100     exit;;
101   --gnulib-srcdir=*)
102     GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
103   --paxutils-srcdir=*)
104     PAXUTILS_SRCDIR=`expr "$option" : '--paxutils-srcdir=\(.*\)'`;;
105   --cvs-auth=*)
106     CVS_AUTH=`expr "$option" : '--cvs-auth=\(.*\)'`;;
107   --cvs-user=*)
108     CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
109   --no-po)
110     DOWNLOAD_PO=no;;
111   --update-po=*)
112     DOWNLOAD_PO=`expr "$option" : '--update-po=\(.*\)'`;;
113   --update-po)
114     DOWNLOAD_PO=only;;
115   *)
116     echo >&2 "$0: $option: unknown option"
117     exit 1;;
118   esac
119 done
120
121 case $DOWNLOAD_PO in
122 only)   update_po
123         exit 0
124         ;;
125 no|yes) ;;
126 *)      update_po $DOWNLOAD_PO
127         exit 0
128 esac
129
130 echo "$0: Bootstrapping CVS tar..."
131
132 build_cvs_prefix() {
133   CVS_PREFIX=:${1}:
134   if [ "${2}" != - ]; then
135     CVS_PREFIX=${CVS_PREFIX}${2}@
136   fi
137   if [ "$1" = "ext" ]; then
138     if [ -z "${CVS_RSH}" ]; then
139        CVS_RSH=ssh
140        export CVS_RSH
141     fi
142   fi
143 }
144
145 # checkout package
146 checkout() {
147   if [ ! -d $1 ]; then
148     echo "$0: getting $1 files..."
149
150     trap exit 1 2 13 15
151     trap 'rm -fr $1; exit 1' 0
152
153     case "${CVS_AUTH--}" in
154     -)       build_cvs_prefix ext anoncvs
155              ;;
156     pserver) build_cvs_prefix $CVS_AUTH ${CVS_USER:-anoncvs}
157              ;;
158     gserver|server)
159              build_cvs_prefix $CVS_AUTH ${CVS_USER--}
160              ;;
161     ext)     build_cvs_prefix $CVS_AUTH ${CVS_USER--}
162              ;;
163     *)       echo "$0: Unknown CVS access method" >&2
164              exit 1;;
165     esac
166     if [ "${CVS_AUTH--}" = "pserver" ]; then
167       cvs -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/$1 login || exit
168     fi
169     cvs -q -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/$1 co $1 || exit
170
171     trap - 0
172   fi
173 }
174
175 gnulib_modules=
176 newline='
177 '
178
179 get_modules() {
180   new_gnulib_modules=`sed '/^[   ]*#/d; /^[      ]*$/d' $*`
181   case $gnulib_modules,$new_gnulib_modules in
182   ?*,?*) new_gnulib_modules=$newline$new_gnulib_modules;;
183   esac
184   gnulib_modules=$gnulib_modules$new_gnulib_modules
185 }
186
187 # Get paxutils files
188 case ${PAXUTILS_SRCDIR--} in
189 -) checkout paxutils
190    PAXUTILS_SRCDIR=paxutils
191 esac
192
193 if [ -r $PAXUTILS_SRCDIR/gnulib.modules ]; then
194   get_modules $PAXUTILS_SRCDIR/gnulib.modules
195 fi
196
197 # copy_files srcdir dstdir
198 copy_files() {
199   for file in `cat $1/DISTFILES`
200   do
201     case $file in
202     "#*")  continue;;
203     esac
204     dst=`echo $file | sed 's^.*/^^'`
205     if [ $# -eq 3 ]; then
206       case $dst in  
207       ${3}*) ;;
208       *) dst=${3}$dst;;
209       esac
210     fi   
211     echo "$0: Copying file $1/$file to $2/$dst"
212     cp -p $1/$file $2/$dst
213   done
214 }
215
216 copy_files ${PAXUTILS_SRCDIR}/m4 m4
217 echo "$0: Creating m4/paxutils.m4"
218 (echo "# This file is generated automatically. Please, do not edit."
219  echo "#"
220  echo "AC_DEFUN([tar_PAXUTILS],["
221  cat ${PAXUTILS_SRCDIR}/m4/DISTFILES | sed '/^#/d;s/\(.*\)\.m4/pu_\1/' | tr a-z A-Z
222  echo "])") > ./m4/paxutils.m4
223
224 if [ -d rmt ]; then
225    :
226 else
227    mkdir rmt
228 fi
229
230 for dir in doc rmt lib tests
231 do
232         copy_files ${PAXUTILS_SRCDIR}/$dir $dir
233 done
234
235 copy_files ${PAXUTILS_SRCDIR}/paxlib lib pax
236
237 # Get gnulib files.
238
239 case ${GNULIB_SRCDIR--} in
240 -) checkout gnulib
241    GNULIB_SRCDIR=gnulib
242 esac
243
244 <$GNULIB_SRCDIR/gnulib-tool || exit
245
246 get_modules gnulib.modules
247
248 gnulib_modules=`echo "$gnulib_modules" | sort -u`
249 previous_gnulib_modules=
250 while [ "$gnulib_modules" != "$previous_gnulib_modules" ]; do
251   previous_gnulib_modules=$gnulib_modules
252   gnulib_modules=`
253     (echo "$gnulib_modules"
254      for gnulib_module in $gnulib_modules; do
255        $GNULIB_SRCDIR/gnulib-tool --extract-dependencies $gnulib_module
256      done) | sort -u
257   `
258 done
259
260 gnulib_files=`
261   (for gnulib_module in $gnulib_modules; do
262      $GNULIB_SRCDIR/gnulib-tool --extract-filelist $gnulib_module
263    done) | sort -u
264 `
265
266 gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u`
267 mkdir -p $gnulib_dirs || exit
268
269 for gnulib_file in $gnulib_files; do
270   dest=$gnulib_file
271
272   case $gnulib_file in
273   m4/codeset.m4) continue;;
274   m4/intdiv0.m4) continue;;
275   m4/inttypes-pri.m4) continue;;
276   m4/isc-posix.m4) continue;;
277   m4/lcmessage.m4) continue;;
278   m4/onceonly_2_57.m4) dest=m4/onceonly.m4;;
279   # These will be overwritten by autopoint, which still uses
280   # old jm_.* macro names, so we have to keep both copies.
281   m4/gettext.m4 | m4/glibc21.m4 | m4/inttypes_h.m4 | m4/lib-ld.m4 | \
282   m4/lib-prefix.m4 | m4/po.m4 | m4/stdint_h.m4 | m4/uintmax_t.m4 | \
283   m4/ulonglong.m4)
284     dest=`expr $gnulib_file : '\(.*\).m4'`_gl.m4;;
285   esac
286
287   rm -f $dest &&
288   echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file" &&
289   cp -p $GNULIB_SRCDIR/$gnulib_file $dest || exit
290 done
291
292 echo "$0: Creating m4/gnulib.m4"
293 (echo "# This file is generated automatically. Please, do not edit."
294  echo "#"
295  echo "AC_DEFUN([tar_GNULIB],["
296  for gnulib_module in $gnulib_modules; do
297     echo "# $gnulib_module"
298     $GNULIB_SRCDIR/gnulib-tool --extract-autoconf-snippet $gnulib_module
299  done | sed '/AM_GNU_GETTEXT/d'
300  echo "])") > ./m4/gnulib.m4
301
302 echo "$0: Creating lib/Makefile.am"
303 (echo "# This file is generated automatically from lib/Makefile.am. Do not edit!"
304  cat lib/Makefile.tmpl
305
306  for gnulib_module in $gnulib_modules; do
307     echo "# $gnulib_module"
308     $GNULIB_SRCDIR/gnulib-tool --extract-automake-snippet $gnulib_module
309  done | sed 's/lib_SOURCES/libtar_a_SOURCES/g' ) > lib/Makefile.am
310
311 # Get translations.
312 if test "$DOWNLOAD_PO" = "yes"; then
313   update_po
314 fi
315
316 # Reconfigure, getting other files.
317
318 echo "$0: autoreconf --verbose --install --force ..."
319 autoreconf --verbose --install --force || exit 1
320
321
322 echo "$0: done.  Now you can run './configure'."