]> Dogcows Code - chaz/tar/blob - bootstrap
(copy_files): Accept optional third argument: a prefix
[chaz/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 Running without arguments will suffice in most cases. It is equivalent
56 to
57
58 ./bootstrap --cvs-auth=ext --cvs-user=anoncvs
59
60 EOF
61 }
62
63 update_po() {
64 if [ $# = 1 ]; then
65 case $1 in
66 *.po) POFILE=$1;;
67 *) POFILE=${1}.po;;
68 esac
69 echo "$0: getting translation for $1..."
70 wget -r -C off $TP_URL/$POFILE
71 else
72 echo "$0: getting translations into po..."
73 (cd po &&
74 rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'` &&
75 wget -nv -nd -r -l 1 -A .po -C off $TP_URL &&
76 rm -f index.html index.html.[0-9]*
77 ls *.po | sed 's/\.po$//' >LINGUAS
78 ) || exit
79 fi
80 }
81
82 # Parse options.
83
84 DOWNLOAD_PO=yes
85 for option
86 do
87 case $option in
88 --help)
89 usage
90 exit;;
91 --gnulib-srcdir=*)
92 GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
93 --paxutils-srcdir=*)
94 PAXUTILS_SRCDIR=`expr "$option" : '--paxutils-srcdir=\(.*\)'`;;
95 --cvs-auth=*)
96 CVS_AUTH=`expr "$option" : '--cvs-auth=\(.*\)'`;;
97 --cvs-user=*)
98 CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
99 --no-po)
100 DOWNLOAD_PO=no;;
101 --update-po=*)
102 DOWNLOAD_PO=`expr "$option" : '--update-po=\(.*\)'`;;
103 --update-po)
104 DOWNLOAD_PO=only;;
105 *)
106 echo >&2 "$0: $option: unknown option"
107 exit 1;;
108 esac
109 done
110
111 case $DOWNLOAD_PO in
112 only) update_po
113 exit 0
114 ;;
115 no|yes) ;;
116 *) update_po $DOWNLOAD_PO
117 exit 0
118 esac
119
120 echo "$0: Bootstrapping CVS tar..."
121
122 build_cvs_prefix() {
123 CVS_PREFIX=:${1}:
124 if [ "${2}" != - ]; then
125 CVS_PREFIX=${CVS_PREFIX}${2}@
126 fi
127 if [ "$1" = "ext" ]; then
128 if [ -z "${CVS_RSH}" ]; then
129 CVS_RSH=ssh
130 export CVS_RSH
131 fi
132 fi
133 }
134
135 # checkout package
136 checkout() {
137 if [ ! -d $1 ]; then
138 echo "$0: getting $1 files..."
139
140 trap exit 1 2 13 15
141 trap 'rm -fr $1; exit 1' 0
142
143 case "${CVS_AUTH--}" in
144 -) build_cvs_prefix ext anoncvs
145 ;;
146 pserver) build_cvs_prefix $CVS_AUTH ${CVS_USER:-anoncvs}
147 ;;
148 gserver|server)
149 build_cvs_prefix $CVS_AUTH ${CVS_USER--}
150 ;;
151 ext) build_cvs_prefix $CVS_AUTH ${CVS_USER--}
152 ;;
153 *) echo "$0: Unknown CVS access method" >&2
154 exit 1;;
155 esac
156 if [ "${CVS_AUTH--}" = "pserver" ]; then
157 cvs -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/$1 login || exit
158 fi
159 cvs -q -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/$1 co $1 || exit
160
161 trap - 0
162 fi
163 }
164
165 gnulib_modules=
166 newline='
167 '
168
169 get_modules() {
170 new_gnulib_modules=`sed '/^[ ]*#/d; /^[ ]*$/d' $*`
171 case $gnulib_modules,$new_gnulib_modules in
172 ?*,?*) new_gnulib_modules=$newline$new_gnulib_modules;;
173 esac
174 gnulib_modules=$gnulib_modules$new_gnulib_modules
175 }
176
177 # Get paxutils files
178 case ${PAXUTILS_SRCDIR--} in
179 -) checkout paxutils
180 PAXUTILS_SRCDIR=paxutils
181 esac
182
183 if [ -r $PAXUTILS_SRCDIR/gnulib.modules ]; then
184 get_modules $PAXUTILS_SRCDIR/gnulib.modules
185 fi
186
187 # copy_files srcdir dstdir
188 copy_files() {
189 for file in `cat $1/DISTFILES`
190 do
191 case $file in
192 "#*") continue;;
193 esac
194 dst=`echo $file | sed 's^.*/^^'`
195 if [ $# -eq 3 ]; then
196 case $dst in
197 ${3}*) ;;
198 *) dst=${3}$dst;;
199 esac
200 fi
201 echo "$0: Copying file $1/$file to $2/$dst"
202 cp -p $1/$file $2/$dst
203 done
204 }
205
206 copy_files ${PAXUTILS_SRCDIR}/m4 m4
207 echo "$0: Creating m4/paxutils.m4"
208 (echo "# This file is generated automatically. Please, do not edit."
209 echo "#"
210 echo "AC_DEFUN([tar_PAXUTILS],["
211 cat ${PAXUTILS_SRCDIR}/m4/DISTFILES | sed '/^#/d;s/\(.*\)\.m4/pu_\1/' | tr a-z A-Z
212 echo "])") > ./m4/paxutils.m4
213
214 if [ -d rmt ]; then
215 :
216 else
217 mkdir rmt
218 fi
219
220 for dir in doc rmt lib tests
221 do
222 copy_files ${PAXUTILS_SRCDIR}/$dir $dir
223 done
224
225 copy_files ${PAXUTILS_SRCDIR}/paxlib lib pax
226
227 # Get gnulib files.
228
229 case ${GNULIB_SRCDIR--} in
230 -) checkout gnulib
231 GNULIB_SRCDIR=gnulib
232 esac
233
234 <$GNULIB_SRCDIR/gnulib-tool || exit
235
236 get_modules gnulib.modules
237
238 gnulib_modules=`echo "$gnulib_modules" | sort -u`
239 previous_gnulib_modules=
240 while [ "$gnulib_modules" != "$previous_gnulib_modules" ]; do
241 previous_gnulib_modules=$gnulib_modules
242 gnulib_modules=`
243 (echo "$gnulib_modules"
244 for gnulib_module in $gnulib_modules; do
245 $GNULIB_SRCDIR/gnulib-tool --extract-dependencies $gnulib_module
246 done) | sort -u
247 `
248 done
249
250 gnulib_files=`
251 (for gnulib_module in $gnulib_modules; do
252 $GNULIB_SRCDIR/gnulib-tool --extract-filelist $gnulib_module
253 done) | sort -u
254 `
255
256 gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u`
257 mkdir -p $gnulib_dirs || exit
258
259 for gnulib_file in $gnulib_files; do
260 dest=$gnulib_file
261
262 case $gnulib_file in
263 m4/codeset.m4) continue;;
264 m4/intdiv0.m4) continue;;
265 m4/inttypes-pri.m4) continue;;
266 m4/isc-posix.m4) continue;;
267 m4/lcmessage.m4) continue;;
268 m4/onceonly_2_57.m4) dest=m4/onceonly.m4;;
269 # These will be overwritten by autopoint, which still uses
270 # old jm_.* macro names, so we have to keep both copies.
271 m4/gettext.m4 | m4/glibc21.m4 | m4/inttypes_h.m4 | m4/lib-ld.m4 | \
272 m4/lib-prefix.m4 | m4/po.m4 | m4/stdint_h.m4 | m4/uintmax_t.m4 | \
273 m4/ulonglong.m4)
274 dest=`expr $gnulib_file : '\(.*\).m4'`_gl.m4;;
275 esac
276
277 rm -f $dest &&
278 echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file" &&
279 cp -p $GNULIB_SRCDIR/$gnulib_file $dest || exit
280 done
281
282 echo "$0: Creating m4/gnulib.m4"
283 (echo "# This file is generated automatically. Please, do not edit."
284 echo "#"
285 echo "AC_DEFUN([tar_GNULIB],["
286 for gnulib_module in $gnulib_modules; do
287 echo "# $gnulib_module"
288 $GNULIB_SRCDIR/gnulib-tool --extract-autoconf-snippet $gnulib_module
289 done | sed '/AM_GNU_GETTEXT/d'
290 echo "])") > ./m4/gnulib.m4
291
292 echo "$0: Creating lib/Makefile.am"
293 (echo "# This file is generated automatically from lib/Makefile.am. Do not edit!"
294 cat lib/Makefile.tmpl
295
296 for gnulib_module in $gnulib_modules; do
297 echo "# $gnulib_module"
298 $GNULIB_SRCDIR/gnulib-tool --extract-automake-snippet $gnulib_module
299 done | sed 's/lib_SOURCES/libtar_a_SOURCES/g' ) > lib/Makefile.am
300
301 # Get translations.
302 if test "$DOWNLOAD_PO" = "yes"; then
303 update_po
304 fi
305
306 # Reconfigure, getting other files.
307
308 echo "$0: autoreconf --verbose --install --force ..."
309 autoreconf --verbose --install --force || exit 1
310
311
312 echo "$0: done. Now you can run './configure'."
This page took 0.053518 seconds and 5 git commands to generate.