bootstrap 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. #! /bin/sh
  2. # Bootstrap this package from CVS.
  3. # Copyright (C) 2003, 2004, 2005, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
  15. # 02110-1301, USA.
  16. # Written by Paul Eggert and Sergey Poznyakoff.
  17. package=tar
  18. # Translation Project URL, for the registry of all projects.
  19. TP_URL='http://www.iro.umontreal.ca/translation/registry.cgi?domain='
  20. # Ensure file names are sorted consistently across platforms.
  21. # Also, ensure diagnostics are in English, e.g., "wget --help" below.
  22. LC_ALL=C
  23. export LC_ALL
  24. usage() {
  25. cat <<EOF
  26. usage: $0 [--gnulib-srcdir=DIR][--paxutils-srcdir=DIR][--cvs-auth=AUTH-METHOD][--cvs-user=USERNAME][--no-po]
  27. Options are:
  28. --paxutils-srcdir=DIRNAME Specify the local directory where paxutils
  29. sources reside. Use this if you already
  30. have paxutils sources on your machine, and
  31. do not want to waste your bandwidth dowloading
  32. them again.
  33. --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
  34. sources reside. Use this if you already
  35. have gnulib sources on your machine, and
  36. do not want to waste your bandwidth dowloading
  37. them again.
  38. --cvs-auth=METHOD Set the CVS access method used for downloading
  39. gnulib files. METHOD is one of the keywords
  40. accepted by cvs -d option (see info cvs
  41. repository).
  42. --cvs-user=USERNAME Set the CVS username to be used when accessing
  43. the gnulib repository.
  44. --no-po Do not download po files.
  45. --update-po[=LANG] Update po file(s) and exit.
  46. If the file \`.bootstrap' exists in the current working directory, its
  47. contents is read, comments and empty lines removed, shell variables expanded
  48. and the result is prepended to the command line options.
  49. Running without arguments will suffice in most cases. It is equivalent
  50. to
  51. ./bootstrap --cvs-auth=pserver
  52. EOF
  53. }
  54. # Read configuration file
  55. if [ -r .bootstrap ]; then
  56. echo "$0: Reading configuration file .bootstrap"
  57. eval set -- "`sed 's/#.*$//;/^$/d' .bootstrap | tr '\n' ' '` $*"
  58. fi
  59. # Parse options.
  60. DOWNLOAD_PO=yes
  61. for option
  62. do
  63. case $option in
  64. --help)
  65. usage
  66. exit;;
  67. --gnulib-srcdir=*)
  68. GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
  69. --paxutils-srcdir=*)
  70. PAXUTILS_SRCDIR=`expr "$option" : '--paxutils-srcdir=\(.*\)'`;;
  71. --cvs-auth=*)
  72. CVS_AUTH=`expr "$option" : '--cvs-auth=\(.*\)'`;;
  73. --cvs-user=*)
  74. CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
  75. --no-po)
  76. DOWNLOAD_PO=no;;
  77. --update-po=*)
  78. DOWNLOAD_PO=`expr "$option" : '--update-po=\(.*\)'`;;
  79. --update-po)
  80. DOWNLOAD_PO=only;;
  81. *)
  82. echo >&2 "$0: $option: unknown option"
  83. exit 1;;
  84. esac
  85. done
  86. # Get translations.
  87. get_translations() {
  88. subdir=$1
  89. domain=$2
  90. po_file=$3
  91. echo "$0: getting translations into $subdir for $domain..."
  92. (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`) &&
  93. $WGET_COMMAND -O "$subdir/$domain.html" "$TP_URL$domain" &&
  94. sed -n 's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p' <"$subdir/$domain.html" |
  95. sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 |
  96. awk -F. '
  97. { if (lang && $1 != lang) print lang, ver }
  98. { lang = $1; ver = substr($0, index($0, ".") + 1) }
  99. END { if (lang) print lang, ver }
  100. ' |
  101. awk -v domain="$domain" -v po_file="$po_file" -v subdir="$subdir" '
  102. {
  103. lang = $1
  104. if (po_file == (lang ".po")) next
  105. # Work around bugs in translations uncovered by gettext 0.15.
  106. # This workaround can be removed once the translations are fixed.
  107. if (lang == "hu" || lang == "ja" || lang == "ky" || lang == "zh_TW") next
  108. ver = $2
  109. urlfmt = ""
  110. 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
  111. }
  112. END { print ":" }
  113. ' |
  114. sh &&
  115. ls "$subdir"/*.po | sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" &&
  116. : rm "$subdir/$domain.html"
  117. }
  118. update_po() {
  119. if [ $# = 1 ]; then
  120. case $1 in
  121. *.po) POFILE=$1;;
  122. *) POFILE=${1}.po;;
  123. esac
  124. get_translations po $package "$POFILE" &&
  125. LANG=`expr $POFILE : '\(.*\)\.po'` &&
  126. { grep -q $LANG po/LINGUAS ||
  127. (echo $LANG; cat po/LINGUAS) | sort -o po/LINGUAS; }
  128. else
  129. get_translations po $package
  130. fi
  131. }
  132. case $DOWNLOAD_PO in
  133. no) ;;
  134. *)
  135. case `wget --help` in
  136. *'--no-cache'*)
  137. no_cache='--no-cache';;
  138. *'--cache=on/off'*)
  139. no_cache='--cache=off';;
  140. *)
  141. no_cache='';;
  142. esac
  143. WGET_COMMAND="wget -nv $no_cache"
  144. export WGET_COMMAND
  145. esac
  146. case $DOWNLOAD_PO in
  147. only) update_po
  148. exit
  149. ;;
  150. no|yes) ;;
  151. *) update_po $DOWNLOAD_PO
  152. exit
  153. esac
  154. echo "$0: Bootstrapping CVS $package..."
  155. build_cvs_prefix() {
  156. CVS_PREFIX=:${1}:
  157. if [ "${2}" != - ]; then
  158. CVS_PREFIX=${CVS_PREFIX}${2}@
  159. fi
  160. if [ "$1" = "ext" ]; then
  161. if [ -z "${CVS_RSH}" ]; then
  162. CVS_RSH=ssh
  163. export CVS_RSH
  164. fi
  165. fi
  166. }
  167. # checkout package
  168. checkout() {
  169. if [ ! -d $1 ]; then
  170. echo "$0: getting $1 files..."
  171. trap exit 1 2 13 15
  172. trap 'rm -fr $1; exit 1' 0
  173. case "${CVS_AUTH-pserver}" in
  174. pserver) build_cvs_prefix pserver ${CVS_USER:-anonymous}
  175. ;;
  176. gserver|server)
  177. build_cvs_prefix $CVS_AUTH ${CVS_USER--}
  178. ;;
  179. ext) build_cvs_prefix $CVS_AUTH ${CVS_USER--}
  180. ;;
  181. *) echo "$0: Unknown CVS access method" >&2
  182. exit 1;;
  183. esac
  184. cvs -q -d ${CVS_PREFIX}cvs.sv.gnu.org:/cvsroot/$1 co $1 || exit
  185. trap - 0
  186. fi
  187. }
  188. gnulib_modules=
  189. newline='
  190. '
  191. get_modules() {
  192. new_gnulib_modules=`sed '/^[ ]*#/d; /^[ ]*$/d' $*`
  193. case $gnulib_modules,$new_gnulib_modules in
  194. ?*,?*) new_gnulib_modules=$newline$new_gnulib_modules;;
  195. esac
  196. gnulib_modules=$gnulib_modules$new_gnulib_modules
  197. }
  198. # Get paxutils files
  199. case ${PAXUTILS_SRCDIR--} in
  200. -) checkout paxutils
  201. PAXUTILS_SRCDIR=paxutils
  202. esac
  203. if [ -r $PAXUTILS_SRCDIR/gnulib.modules ]; then
  204. get_modules $PAXUTILS_SRCDIR/gnulib.modules
  205. fi
  206. # copy_files srcdir dstdir
  207. copy_files() {
  208. for file in `cat $1/DISTFILES`
  209. do
  210. case $file in
  211. "#*") continue;;
  212. esac
  213. dst=`echo $file | sed 's^.*/^^'`
  214. if [ $# -eq 3 ]; then
  215. case $dst in
  216. ${3}*) ;;
  217. *) dst=${3}$dst;;
  218. esac
  219. fi
  220. echo "$0: Copying file $1/$file to $2/$dst"
  221. cp -p $1/$file $2/$dst
  222. done
  223. }
  224. copy_files ${PAXUTILS_SRCDIR}/m4 m4
  225. echo "$0: Creating m4/paxutils.m4"
  226. (echo "# This file is generated automatically. Please, do not edit."
  227. echo "#"
  228. echo "AC_DEFUN([tar_PAXUTILS],["
  229. cat ${PAXUTILS_SRCDIR}/m4/DISTFILES | sed '/^#/d;s/\(.*\)\.m4/pu_\1/' | tr a-z A-Z
  230. echo "])") > ./m4/paxutils.m4
  231. if [ -d rmt ]; then
  232. :
  233. else
  234. mkdir rmt
  235. fi
  236. for dir in doc rmt lib tests
  237. do
  238. copy_files ${PAXUTILS_SRCDIR}/$dir $dir
  239. done
  240. copy_files ${PAXUTILS_SRCDIR}/paxlib lib pax
  241. # Get gnulib files.
  242. case ${GNULIB_SRCDIR--} in
  243. -) checkout gnulib
  244. GNULIB_SRCDIR=gnulib
  245. esac
  246. gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
  247. <$gnulib_tool || exit
  248. get_modules gnulib.modules
  249. gnulib_modules=`echo "$gnulib_modules" | sort -u`
  250. previous_gnulib_modules=
  251. while [ "$gnulib_modules" != "$previous_gnulib_modules" ]; do
  252. previous_gnulib_modules=$gnulib_modules
  253. gnulib_modules=`
  254. (echo "$gnulib_modules"
  255. for gnulib_module in $gnulib_modules; do
  256. $gnulib_tool --extract-dependencies $gnulib_module
  257. done) | sort -u
  258. `
  259. done
  260. gnulib_files=`
  261. (for gnulib_module in $gnulib_modules; do
  262. $gnulib_tool --extract-filelist $gnulib_module
  263. done) | sort -u
  264. `
  265. gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u`
  266. mkdir -p $gnulib_dirs || exit
  267. for gnulib_file in $gnulib_files; do
  268. dest=$gnulib_file
  269. rm -f $dest &&
  270. echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file" &&
  271. cp -p $GNULIB_SRCDIR/$gnulib_file $dest || exit
  272. done
  273. # This suppresses a bogus diagnostic
  274. # "warning: macro `AM_LANGINFO_CODESET' not found in library".
  275. echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
  276. sed '
  277. /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
  278. AC_DEFUN([AM_INTL_SUBDIR], [])
  279. /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
  280. AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
  281. ' m4/gettext.m4 >m4/gettext_gl.m4 || exit
  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_tool --extract-autoconf-snippet $gnulib_module
  289. done | sed '/AM_GNU_GETTEXT/d'
  290. echo "])") > ./m4/gnulib.m4
  291. echo "$0: Creating lib/Makefile.am"
  292. (echo "# This file is generated automatically. Do not edit!"
  293. cat lib/Makefile.tmpl
  294. for gnulib_module in $gnulib_modules; do
  295. echo "# $gnulib_module"
  296. $gnulib_tool --extract-automake-snippet $gnulib_module
  297. done | sed 's/lib_SOURCES/libtar_a_SOURCES/g' ) > lib/Makefile.am
  298. # Get translations.
  299. if test "$DOWNLOAD_PO" = "yes"; then
  300. update_po
  301. fi
  302. # Reconfigure, getting other files.
  303. echo "$0: autopoint --force ..."
  304. autopoint --force || exit
  305. # We don't need intl, so remove it.
  306. intl_files_to_remove='
  307. intl
  308. m4/gettext.m4
  309. m4/glibc2.m4
  310. m4/intdiv0.m4
  311. m4/intmax.m4
  312. m4/inttypes-h.m4
  313. m4/inttypes-pri.m4
  314. m4/lcmessage.m4
  315. m4/lock.m4
  316. m4/printf-posix.m4
  317. m4/visibility.m4
  318. '
  319. echo $0: rm -fr $intl_files_to_remove ...
  320. rm -fr $intl_files_to_remove || exit
  321. # Undo changes to gnulib files that autoreconf made.
  322. for gnulib_file in $gnulib_files; do
  323. test ! -f $gnulib_file || cmp -s $gnulib_file $GNULIB_SRCDIR/$gnulib_file || {
  324. rm -f $gnulib_file &&
  325. echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file again" &&
  326. cp -p $GNULIB_SRCDIR/$gnulib_file $gnulib_file || exit
  327. }
  328. done
  329. # Make sure aclocal.m4 is not older than input files.
  330. sleep 1
  331. for command in \
  332. 'aclocal --force -I m4' \
  333. 'autoconf --force' \
  334. 'autoheader --force' \
  335. 'automake --add-missing --copy --force-missing';
  336. do
  337. echo "$0: $command ..."
  338. $command || exit
  339. done
  340. # Put bug-reporting address into po/Makevars.
  341. echo "$0: sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-$package@gnu.org/' po/Makevars.template >po/Makevars ..."
  342. sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/' po/Makevars.template >po/Makevars
  343. echo "$0: done. Now you can run './configure'."