bootstrap 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. #! /bin/sh
  2. # Bootstrap 'tar' from CVS.
  3. # Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program; if not, write to the Free Software
  14. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  15. # 02111-1307, USA.
  16. # Written by Paul Eggert and Sergey Poznyakoff.
  17. # URL of our text domain page in Translation Project
  18. TP_URL="http://www2.iro.umontreal.ca/~gnutra/po/maint/tar/"
  19. # Ensure file names are sorted consistently across platforms;
  20. # e.g., m4/ulonglong_gl.m4 should follow m4/ulonglong.m4.
  21. LC_ALL=C
  22. export LC_ALL
  23. usage() {
  24. cat <<EOF
  25. usage: $0 [--gnulib-srcdir=DIR][--paxutils-srcdir=DIR][--cvs-auth=AUTH-METHOD][--cvs-user=USERNAME][--no-po]
  26. Options are:
  27. --paxutils-srcdir=DIRNAME Specify the local directory where paxutils
  28. sources reside. Use this if you already
  29. have paxutils sources on your machine, and
  30. do not want to waste your bandwidth dowloading
  31. them again.
  32. --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
  33. sources reside. Use this if you already
  34. have gnulib sources on your machine, and
  35. do not want to waste your bandwidth dowloading
  36. them again.
  37. --cvs-auth=METHOD Set the CVS access method used for downloading
  38. gnulib files. METHOD is one of the keywords
  39. accepted by cvs -d option (see info cvs
  40. repository).
  41. --cvs-user=USERNAME Set the CVS username to be used when accessing
  42. the gnulib repository.
  43. --no-po Do not download po files.
  44. --update-po[=LANG] Update po file(s) and exit.
  45. Running without arguments will suffice in most cases. It is equivalent
  46. to
  47. ./bootstrap --cvs-auth=ext --cvs-user=anoncvs
  48. EOF
  49. }
  50. update_po() {
  51. if [ $# = 1 ]; then
  52. case $1 in
  53. *.po) POFILE=$1;;
  54. *) POFILE=${1}.po;;
  55. esac
  56. echo "$0: getting translation for $1..."
  57. wget -r -C off $TP_URL/$POFILE
  58. else
  59. echo "$0: getting translations into po..."
  60. (cd po &&
  61. rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'` &&
  62. wget -nv -nd -r -l 1 -A .po -C off $TP_URL &&
  63. rm -f index.html index.html.[0-9]*
  64. ls *.po | sed 's/\.po$//' >LINGUAS
  65. ) || exit
  66. fi
  67. }
  68. # Parse options.
  69. DOWNLOAD_PO=yes
  70. for option
  71. do
  72. case $option in
  73. --help)
  74. usage
  75. exit;;
  76. --gnulib-srcdir=*)
  77. GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
  78. --paxutils-srcdir=*)
  79. PAXUTILS_SRCDIR=`expr "$option" : '--paxutils-srcdir=\(.*\)'`;;
  80. --cvs-auth=*)
  81. CVS_AUTH=`expr "$option" : '--cvs-auth=\(.*\)'`;;
  82. --cvs-user=*)
  83. CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
  84. --no-po)
  85. DOWNLOAD_PO=no;;
  86. --update-po=*)
  87. DOWNLOAD_PO=`expr "$option" : '--update-po=\(.*\)'`;;
  88. --update-po)
  89. DOWNLOAD_PO=only;;
  90. *)
  91. echo >&2 "$0: $option: unknown option"
  92. exit 1;;
  93. esac
  94. done
  95. case $DOWNLOAD_PO in
  96. only) update_po
  97. exit 0
  98. ;;
  99. no|yes) ;;
  100. *) update_po $DOWNLOAD_PO
  101. exit 0
  102. esac
  103. echo "$0: Bootstrapping CVS tar..."
  104. build_cvs_prefix() {
  105. CVS_PREFIX=:${1}:
  106. if [ "${2}" != - ]; then
  107. CVS_PREFIX=${CVS_PREFIX}${2}@
  108. fi
  109. if [ "$1" = "ext" ]; then
  110. if [ -z "${CVS_RSH}" ]; then
  111. CVS_RSH=ssh
  112. export CVS_RSH
  113. fi
  114. fi
  115. }
  116. # checkout package
  117. checkout() {
  118. if [ ! -d $1 ]; then
  119. echo "$0: getting $1 files..."
  120. trap exit 1 2 13 15
  121. trap 'rm -fr $1; exit 1' 0
  122. case "${CVS_AUTH--}" in
  123. -) build_cvs_prefix ext anoncvs
  124. ;;
  125. pserver) build_cvs_prefix $CVS_AUTH ${CVS_USER:-anoncvs}
  126. ;;
  127. gserver|server)
  128. build_cvs_prefix $CVS_AUTH ${CVS_USER--}
  129. ;;
  130. ext) build_cvs_prefix $CVS_AUTH ${CVS_USER--}
  131. ;;
  132. *) echo "$0: Unknown CVS access method" >&2
  133. exit 1;;
  134. esac
  135. if [ "${CVS_AUTH--}" = "pserver" ]; then
  136. cvs -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/$1 login || exit
  137. fi
  138. cvs -q -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/$1 co $1 || exit
  139. trap 0
  140. fi
  141. }
  142. # Get gnulib files.
  143. case ${GNULIB_SRCDIR--} in
  144. -) checkout gnulib
  145. GNULIB_SRCDIR=gnulib
  146. esac
  147. <$GNULIB_SRCDIR/gnulib-tool || exit
  148. gnulib_modules='
  149. alloca
  150. argmatch
  151. argp
  152. backupfile
  153. dirname
  154. error
  155. exclude
  156. fileblocks
  157. fnmatch-gnu
  158. ftruncate
  159. full-write
  160. getdate
  161. getline
  162. getopt
  163. getpagesize
  164. gettext
  165. gettime
  166. hash
  167. human
  168. lchown
  169. localcharset
  170. memset
  171. modechange
  172. obstack
  173. quote
  174. quotearg
  175. rmdir
  176. safe-read
  177. save-cwd
  178. savedir
  179. setenv
  180. stdbool
  181. stpcpy
  182. strtol
  183. strtoul
  184. timespec
  185. unlocked-io
  186. utime
  187. xalloc
  188. xalloc-die
  189. xgetcwd
  190. xstrtoumax
  191. '
  192. previous_gnulib_modules=
  193. while [ "$gnulib_modules" != "$previous_gnulib_modules" ]; do
  194. previous_gnulib_modules=$gnulib_modules
  195. # In gnulib `alloca-opt' duplicates `alloca', so make sure not
  196. # to use it.
  197. gnulib_modules=`
  198. (echo "$gnulib_modules"
  199. for gnulib_module in $gnulib_modules; do
  200. $GNULIB_SRCDIR/gnulib-tool --extract-dependencies $gnulib_module
  201. done) | sort -u
  202. `
  203. done
  204. gnulib_files=`
  205. (for gnulib_module in $gnulib_modules; do
  206. $GNULIB_SRCDIR/gnulib-tool --extract-filelist $gnulib_module
  207. done) | sort -u
  208. `
  209. gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u`
  210. mkdir -p $gnulib_dirs || exit
  211. for gnulib_file in $gnulib_files; do
  212. dest=$gnulib_file
  213. case $gnulib_file in
  214. m4/codeset.m4) continue;;
  215. m4/intdiv0.m4) continue;;
  216. m4/inttypes-pri.m4) continue;;
  217. m4/isc-posix.m4) continue;;
  218. m4/lcmessage.m4) continue;;
  219. m4/onceonly_2_57.m4) dest=m4/onceonly.m4;;
  220. # These will be overwritten by autopoint, which still uses
  221. # old jm_.* macro names, so we have to keep both copies.
  222. m4/gettext.m4 | m4/glibc21.m4 | m4/inttypes_h.m4 | m4/lib-ld.m4 | \
  223. m4/lib-prefix.m4 | m4/po.m4 | m4/stdint_h.m4 | m4/uintmax_t.m4 | \
  224. m4/ulonglong.m4)
  225. dest=`expr $gnulib_file : '\(.*\).m4'`_gl.m4;;
  226. esac
  227. rm -f $dest &&
  228. echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file" &&
  229. cp -p $GNULIB_SRCDIR/$gnulib_file $dest || exit
  230. done
  231. echo "$0: Creating m4/gnulib.m4"
  232. (echo "# This file is generated automatically. Please, do not edit."
  233. echo "#"
  234. echo "AC_DEFUN([tar_GNULIB],["
  235. for gnulib_module in $gnulib_modules; do
  236. echo "# $gnulib_module"
  237. $GNULIB_SRCDIR/gnulib-tool --extract-autoconf-snippet $gnulib_module
  238. done | sed '/AM_GNU_GETTEXT/d'
  239. echo "])") > ./m4/gnulib.m4
  240. echo "$0: Creating lib/Makefile.am"
  241. (echo "# This file is generated automatically from lib/Makefile.am. Do not edit!"
  242. cat lib/Makefile.tmpl
  243. for gnulib_module in $gnulib_modules; do
  244. echo "# $gnulib_module"
  245. $GNULIB_SRCDIR/gnulib-tool --extract-automake-snippet $gnulib_module
  246. done | sed 's/lib_SOURCES/libtar_a_SOURCES/g' ) > lib/Makefile.am
  247. # Get paxutils files
  248. case ${PAXUTILS_SRCDIR--} in
  249. -) checkout paxutils
  250. PAXUTILS_SRCDIR=paxutils
  251. esac
  252. # copy_files srcdir dstdir
  253. copy_files() {
  254. for file in `cat $1/DISTFILES`
  255. do
  256. case $file in
  257. "#*") continue;;
  258. esac
  259. echo "$0: Copying file $1/$file"
  260. cp -p $1/$file $2/`expr $file : '.*/\(.*\)'`
  261. done
  262. }
  263. copy_files ${PAXUTILS_SRCDIR}/m4 m4
  264. echo "$0: Creating m4/paxutils.m4"
  265. (echo "# This file is generated automatically. Please, do not edit."
  266. echo "#"
  267. echo "AC_DEFUN([tar_PAXUTILS],["
  268. cat ${PAXUTILS_SRCDIR}/m4/DISTFILES | sed '/^#/d;s/\(.*\)\.m4/pu_\1/' | tr a-z A-Z
  269. echo "])") > ./m4/paxutils.m4
  270. if [ -d rmt ]; then
  271. :
  272. else
  273. mkdir rmt
  274. fi
  275. copy_files ${PAXUTILS_SRCDIR}/rmt rmt
  276. copy_files ${PAXUTILS_SRCDIR}/lib lib
  277. copy_files ${PAXUTILS_SRCDIR}/tests tests
  278. # Get translations.
  279. if test "$DOWNLOAD_PO" = "yes"; then
  280. update_po
  281. fi
  282. # Reconfigure, getting other files.
  283. echo "$0: autoreconf --verbose --install --force ..."
  284. autoreconf --verbose --install --force || exit 1
  285. echo "$0: done. Now you can run './configure'."