gcc_release 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. #! /bin/sh
  2. ########################################################################
  3. #
  4. # File: gcc_release
  5. # Author: Jeffrey Law, Bernd Schmidt, Mark Mitchell
  6. # Date: 2001-05-25
  7. #
  8. # Contents:
  9. # Script to create a GCC release.
  10. #
  11. # Copyright (c) 2001-2014 Free Software Foundation.
  12. #
  13. # This file is part of GCC.
  14. #
  15. # GCC is free software; you can redistribute it and/or modify
  16. # it under the terms of the GNU General Public License as published by
  17. # the Free Software Foundation; either version 3, or (at your option)
  18. # any later version.
  19. #
  20. # GCC is distributed in the hope that it will be useful,
  21. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. # GNU General Public License for more details.
  24. #
  25. # You should have received a copy of the GNU General Public License
  26. # along with GCC; see the file COPYING3. If not see
  27. # <http://www.gnu.org/licenses/>.
  28. #
  29. ########################################################################
  30. ########################################################################
  31. # Notes
  32. ########################################################################
  33. # Here is an example usage of this script, to create a GCC 3.0.2
  34. # prerelease:
  35. #
  36. # gcc_release -r 3.0.2
  37. #
  38. # This script will automatically use the head of the release branch
  39. # to generate the release.
  40. ########################################################################
  41. # Functions
  42. ########################################################################
  43. # Issue the error message given by $1 and exit with a non-zero
  44. # exit code.
  45. error() {
  46. echo "gcc_release: error: $1"
  47. exit 1
  48. }
  49. # Issue the informational message given by $1.
  50. inform() {
  51. echo "gcc_release: $1"
  52. }
  53. # Issue a usage message explaining how to use this script.
  54. usage() {
  55. cat <<EOF
  56. gcc_release -r release [-f] [further options]
  57. gcc_release -s name:svnbranch [further options]
  58. Options:
  59. -r release Version of the form X.Y or X.Y.Z.
  60. -s name:svnbranch Create a snapshot, not a real release.
  61. -d destination Local working directory where we will build the release
  62. (default=${HOME}).
  63. -f Create a final release (and update ChangeLogs,...).
  64. -l Indicate that we are running on gcc.gnu.org.
  65. -p previous-tarball Location of a previous tarball (to generate diff files).
  66. -t tag Tag to mark the release in SVN.
  67. -u username Username for upload operations.
  68. EOF
  69. exit 1
  70. }
  71. # Change to the directory given by $1.
  72. changedir() {
  73. cd $1 || \
  74. error "Could not change directory to $1"
  75. }
  76. # Build the source tree that will be the basis for the release
  77. # in ${WORKING_DIRECTORY}/gcc-${RELEASE}.
  78. build_sources() {
  79. # If the WORKING_DIRECTORY already exists, do not risk destroying it.
  80. if [ -r ${WORKING_DIRECTORY} ]; then
  81. error "\`${WORKING_DIRECTORY}' already exists"
  82. fi
  83. # Create the WORKING_DIRECTORY.
  84. mkdir "${WORKING_DIRECTORY}" \
  85. || error "Could not create \`${WORKING_DIRECTORY}'"
  86. changedir "${WORKING_DIRECTORY}"
  87. # If this is a final release, make sure that the ChangeLogs
  88. # and version strings are updated.
  89. if [ ${FINAL} -ne 0 ]; then
  90. inform "Updating ChangeLogs and version files"
  91. ${SVN} -q co "${SVNROOT}/${SVNBRANCH}" "`basename ${SOURCE_DIRECTORY}`" ||\
  92. error "Could not check out release sources"
  93. for x in `find ${SOURCE_DIRECTORY} -name ChangeLog`; do
  94. # Update this ChangeLog file only if it does not yet contain the
  95. # entry we are going to add. (This is a safety net for repeated
  96. # runs of this script for the same release.)
  97. if ! grep "GCC ${RELEASE} released." ${x} > /dev/null ; then
  98. cat - ${x} > ${x}.new <<EOF
  99. ${LONG_DATE} Release Manager
  100. * GCC ${RELEASE} released.
  101. EOF
  102. mv ${x}.new ${x} || \
  103. error "Could not update ${x}"
  104. (changedir `dirname ${x}` && \
  105. ${SVN} -q ci -m 'Mark ChangeLog' `basename ${x}`) || \
  106. error "Could not commit ${x}"
  107. fi
  108. done
  109. # Update gcc/DEV-PHASE.
  110. [ `cat ${SOURCE_DIRECTORY}/gcc/BASE-VER` = ${RELEASE} ] || \
  111. error "Release number ${RELEASE} does not match BASE-VER"
  112. (changedir ${SOURCE_DIRECTORY}/gcc && \
  113. : > DEV-PHASE && \
  114. ${SVN} -q ci -m 'Mark as release' DEV-PHASE) || \
  115. error "Could not update DEV-PHASE"
  116. # Make sure we tag the sources for a final release.
  117. TAG="tags/gcc_`echo ${RELEASE} | tr . _`_release"
  118. rm -rf ${SOURCE_DIRECTORY}
  119. fi
  120. # Tag the sources.
  121. if [ -n "${TAG}" ]; then
  122. inform "Tagging sources as ${TAG}"
  123. # We don't want to overwrite an existing tag. So, if the tag
  124. # already exists, issue an error message; the release manager can
  125. # manually remove the tag if appropriate.
  126. echo "${SVN} ls ${SVNROOT}/${TAG}/ChangeLog"
  127. if ${SVN} ls "${SVNROOT}/${TAG}/ChangeLog"; then
  128. error "Tag ${TAG} already exists"
  129. fi
  130. ${SVN} -m "Tagging source as ${TAG}" cp "${SVNROOT}/${SVNBRANCH}" "${SVNROOT}/${TAG}" || \
  131. error "Could not tag sources"
  132. SVNBRANCH=${TAG}
  133. fi
  134. SVNREV=`${SVN} info "${SVNROOT}/${SVNBRANCH}"|awk '/Revision:/ {print $2}'`
  135. # Export the current sources.
  136. inform "Retrieving sources (svn export -r ${SVNREV} ${SVNROOT}/${SVNBRANCH})"
  137. ${SVN} -q export -r${SVNREV} "${SVNROOT}/${SVNBRANCH}" "`basename ${SOURCE_DIRECTORY}`" ||\
  138. error "Could not retrieve sources"
  139. # Run gcc_update on them to set up the timestamps nicely, and (re)write
  140. # the LAST_UPDATED file containing the SVN tag/revision used.
  141. changedir "gcc-${RELEASE}"
  142. contrib/gcc_update --touch
  143. echo "Obtained from SVN: ${SVNBRANCH} revision ${SVNREV}" > LAST_UPDATED
  144. # For a prerelease or real release, we need to generate additional
  145. # files not present in SVN.
  146. changedir "${SOURCE_DIRECTORY}"
  147. if [ $SNAPSHOT -ne 1 ]; then
  148. # Generate the documentation.
  149. inform "Building install docs"
  150. SOURCEDIR=${SOURCE_DIRECTORY}/gcc/doc
  151. DESTDIR=${SOURCE_DIRECTORY}/INSTALL
  152. export SOURCEDIR
  153. export DESTDIR
  154. ${SOURCE_DIRECTORY}/gcc/doc/install.texi2html
  155. # Regenerate the NEWS file.
  156. contrib/gennews > NEWS || \
  157. error "Could not regenerate NEWS files"
  158. # Now, we must build the compiler in order to create any generated
  159. # files that are supposed to go in the source directory. This is
  160. # also a good sanity check to make sure that the release builds
  161. # on at least one platform.
  162. inform "Building compiler"
  163. OBJECT_DIRECTORY=../objdir
  164. contrib/gcc_build -d ${SOURCE_DIRECTORY} -o ${OBJECT_DIRECTORY} \
  165. -c "--enable-generated-files-in-srcdir --disable-multilib" build || \
  166. error "Could not rebuild GCC"
  167. fi
  168. # Move message catalogs to source directory.
  169. mv ../objdir/gcc/po/*.gmo gcc/po/
  170. [ -f libcpp/po/cpplib.pot ] && mv ../objdir/libcpp/po/*.gmo libcpp/po/
  171. # Create a "MD5SUMS" file to use for checking the validity of the release.
  172. echo \
  173. "# This file contains the MD5 checksums of the files in the
  174. # gcc-"${RELEASE}".tar.bz2 tarball.
  175. #
  176. # Besides verifying that all files in the tarball were correctly expanded,
  177. # it also can be used to determine if any files have changed since the
  178. # tarball was expanded or to verify that a patchfile was correctly applied.
  179. #
  180. # Suggested usage:
  181. # md5sum -c MD5SUMS | grep -v \"OK$\"
  182. #" > MD5SUMS
  183. find . -type f |
  184. sed -e 's:^\./::' -e '/MD5SUMS/d' |
  185. sort |
  186. xargs md5sum >>MD5SUMS
  187. }
  188. # Build a single tarfile. The first argument is the name of the tarfile
  189. # to build, without any suffixes. They will be added automatically. The
  190. # rest of the arguments are files or directories to include, and possibly
  191. # other arguments to tar.
  192. build_tarfile() {
  193. # Get the name of the destination tar file.
  194. TARFILE="$1.tar.bz2"
  195. shift
  196. # Build the tar file itself.
  197. (${TAR} cf - "$@" | ${BZIP2} > ${TARFILE}) || \
  198. error "Could not build tarfile"
  199. FILE_LIST="${FILE_LIST} ${TARFILE}"
  200. }
  201. # Build the various tar files for the release.
  202. build_tarfiles() {
  203. inform "Building tarfiles"
  204. changedir "${WORKING_DIRECTORY}"
  205. # The GNU Coding Standards specify that all files should
  206. # world readable.
  207. chmod -R a+r ${SOURCE_DIRECTORY}
  208. # And that all directories have mode 755.
  209. find ${SOURCE_DIRECTORY} -type d -exec chmod 755 {} \;
  210. # Build one huge tarfile for the entire distribution.
  211. build_tarfile gcc-${RELEASE} `basename ${SOURCE_DIRECTORY}`
  212. }
  213. # Build .gz files.
  214. build_gzip() {
  215. for f in ${FILE_LIST}; do
  216. target=${f%.bz2}.gz
  217. (${BZIP2} -d -c $f | ${GZIP} > ${target}) || error "Could not create ${target}"
  218. done
  219. }
  220. # Build diffs against an old release.
  221. build_diffs() {
  222. old_dir=${1%/*}
  223. old_file=${1##*/}
  224. old_vers=${old_file%.tar.bz2}
  225. old_vers=${old_vers#gcc-}
  226. inform "Building diffs against version $old_vers"
  227. for f in gcc; do
  228. old_tar=${old_dir}/${f}-${old_vers}.tar.bz2
  229. new_tar=${WORKING_DIRECTORY}/${f}-${RELEASE}.tar.bz2
  230. if [ ! -e $old_tar ]; then
  231. inform "$old_tar not found; not generating diff file"
  232. elif [ ! -e $new_tar ]; then
  233. inform "$new_tar not found; not generating diff file"
  234. else
  235. build_diff $old_tar gcc-${old_vers} $new_tar gcc-${RELEASE} \
  236. ${f}-${old_vers}-${RELEASE}.diff.bz2
  237. fi
  238. done
  239. }
  240. # Build an individual diff.
  241. build_diff() {
  242. changedir "${WORKING_DIRECTORY}"
  243. tmpdir=gccdiff.$$
  244. mkdir $tmpdir || error "Could not create directory $tmpdir"
  245. changedir $tmpdir
  246. (${BZIP2} -d -c $1 | ${TAR} xf - ) || error "Could not unpack $1 for diffs"
  247. (${BZIP2} -d -c $3 | ${TAR} xf - ) || error "Could not unpack $3 for diffs"
  248. ${DIFF} $2 $4 > ../${5%.bz2}
  249. if [ $? -eq 2 ]; then
  250. error "Trouble making diffs from $1 to $3"
  251. fi
  252. ${BZIP2} ../${5%.bz2} || error "Could not generate ../$5"
  253. changedir ..
  254. rm -rf $tmpdir
  255. FILE_LIST="${FILE_LIST} $5"
  256. }
  257. # Upload the files to the FTP server.
  258. upload_files() {
  259. inform "Uploading files"
  260. changedir "${WORKING_DIRECTORY}"
  261. # Make sure the directory exists on the server.
  262. if [ $LOCAL -eq 0 ]; then
  263. ${SSH} -l ${GCC_USERNAME} ${GCC_HOSTNAME} \
  264. mkdir -p "${FTP_PATH}/diffs"
  265. UPLOAD_PATH="${GCC_USERNAME}@${GCC_HOSTNAME}:${FTP_PATH}"
  266. else
  267. mkdir -p "${FTP_PATH}/diffs" \
  268. || error "Could not create \`${FTP_PATH}'"
  269. UPLOAD_PATH=${FTP_PATH}
  270. fi
  271. # Then copy files to their respective (sub)directories.
  272. for x in gcc*.gz gcc*.bz2; do
  273. if [ -e ${x} ]; then
  274. # Make sure the file will be readable on the server.
  275. chmod a+r ${x}
  276. # Copy it.
  277. case ${x} in
  278. *.diff.*)
  279. SUBDIR="diffs/";
  280. ;;
  281. *)
  282. SUBDIR="";
  283. esac
  284. ${SCP} ${x} ${UPLOAD_PATH}/${SUBDIR} \
  285. || error "Could not upload ${x}"
  286. fi
  287. done
  288. }
  289. # Print description if snapshot exists.
  290. snapshot_print() {
  291. if [ -e ${RELEASE}/$1 ]; then
  292. hash=`openssl md5 ${RELEASE}/$1 | sed -e 's#(.*)##' -e 's# *= *#=#'`
  293. hash2=`openssl sha1 ${RELEASE}/$1 | sed -e 's#(.*)##' -e 's# *= *#=#'`
  294. printf " %-37s%s\n\n %s\n %s\n\n" "$1" "$2" "$hash" "$hash2" \
  295. >> ${SNAPSHOT_README}
  296. echo " <tr><td><a href=\"$1\">$1</a></td>" >> ${SNAPSHOT_INDEX}
  297. echo " <td>$2</td></tr>" >> ${SNAPSHOT_INDEX}
  298. fi
  299. }
  300. # Announce a snapshot, both on the web and via mail.
  301. announce_snapshot() {
  302. inform "Updating links and READMEs on the FTP server"
  303. TEXT_DATE=`date --date=$DATE +%B\ %d,\ %Y`
  304. SNAPSHOT_README=${RELEASE}/README
  305. SNAPSHOT_INDEX=${RELEASE}/index.html
  306. changedir "${SNAPSHOTS_DIR}"
  307. echo \
  308. "Snapshot gcc-"${RELEASE}" is now available on
  309. ftp://gcc.gnu.org/pub/gcc/snapshots/"${RELEASE}"/
  310. and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.
  311. This snapshot has been generated from the GCC "${BRANCH}" SVN branch
  312. with the following options: "svn://gcc.gnu.org/svn/gcc/${SVNBRANCH} revision ${SVNREV}"
  313. You'll find:
  314. " > ${SNAPSHOT_README}
  315. echo \
  316. "<html>
  317. <head>
  318. <title>GCC "${RELEASE}" Snapshot</title>
  319. </head>
  320. <body>
  321. <h1>GCC "${RELEASE}" Snapshot</h1>
  322. <p>The <a href =\"http://gcc.gnu.org/\">GCC Project</a> makes
  323. periodic snapshots of the GCC source tree available to the public
  324. for testing purposes.</p>
  325. <p>If you are planning to download and use one of our snapshots, then
  326. we highly recommend you join the GCC developers list. Details for
  327. how to sign up can be found on the GCC project home page.</p>
  328. <p>This snapshot has been generated from the GCC "${BRANCH}" SVN branch
  329. with the following options: <code>"svn://gcc.gnu.org/svn/gcc/${SVNBRANCH} revision ${SVNREV}"</code></p>
  330. <table>" > ${SNAPSHOT_INDEX}
  331. snapshot_print gcc-${RELEASE}.tar.bz2 "Complete GCC"
  332. echo \
  333. "Diffs from "${BRANCH}"-"${LAST_DATE}" are available in the diffs/ subdirectory.
  334. When a particular snapshot is ready for public consumption the LATEST-"${BRANCH}"
  335. link is updated and a message is sent to the gcc list. Please do not use
  336. a snapshot before it has been announced that way." >> ${SNAPSHOT_README}
  337. echo \
  338. "</table>
  339. <p>Diffs from "${BRANCH}"-"${LAST_DATE}" are available in the
  340. <a href=\"diffs/\">diffs/ subdirectory</a>.</p>
  341. <p>When a particular snapshot is ready for public consumption the LATEST-"${BRANCH}"
  342. link is updated and a message is sent to the gcc list. Please do not use
  343. a snapshot before it has been announced that way.</p>
  344. <hr />
  345. <address>
  346. <a href=\"mailto:gcc@gcc.gnu.org\">gcc@gcc.gnu.org</a>
  347. <br />
  348. Last modified "${TEXT_DATE}"
  349. </address>
  350. </body>
  351. </html>" >> ${SNAPSHOT_INDEX}
  352. rm -f LATEST-${BRANCH}
  353. ln -s ${RELEASE} LATEST-${BRANCH}
  354. inform "Sending mail"
  355. export QMAILHOST=gcc.gnu.org
  356. mail -s "gcc-${RELEASE} is now available" gcc@gcc.gnu.org < ${SNAPSHOT_README}
  357. }
  358. ########################################################################
  359. # Initialization
  360. ########################################################################
  361. LC_ALL=C
  362. export LC_ALL
  363. # Today's date.
  364. DATE=`date "+%Y%m%d"`
  365. LONG_DATE=`date "+%Y-%m-%d"`
  366. SVN=${SVN:-svn}
  367. # The CVS server containing the GCC repository.
  368. SVN_SERVER="gcc.gnu.org"
  369. # The path to the repository on that server.
  370. SVN_REPOSITORY="/svn/gcc"
  371. # The username to use when connecting to the server.
  372. SVN_USERNAME="${USER}"
  373. # The machine to which files will be uploaded.
  374. GCC_HOSTNAME="gcc.gnu.org"
  375. # The name of the account on the machine to which files are uploaded.
  376. GCC_USERNAME="gccadmin"
  377. # The directory in which the files will be placed (do not use ~user syntax).
  378. FTP_PATH=/var/ftp/pub/gcc
  379. # The directory in which snapshots will be placed.
  380. SNAPSHOTS_DIR=${FTP_PATH}/snapshots
  381. # The major number for the release. For release `3.0.2' this would be
  382. # `3'
  383. RELEASE_MAJOR=""
  384. # The minor number for the release. For release `3.0.2' this would be
  385. # `0'.
  386. RELEASE_MINOR=""
  387. # The revision number for the release. For release `3.0.2' this would
  388. # be `2'.
  389. RELEASE_REVISION=""
  390. # The complete name of the release.
  391. RELEASE=""
  392. # The name of the branch from which the release should be made, in a
  393. # user-friendly form.
  394. BRANCH=""
  395. # The name of the branch from which the release should be made, as used
  396. # for our version control system.
  397. SVNBRANCH=""
  398. # The tag to apply to the sources used for the release.
  399. TAG=""
  400. # The old tarballs from which to generate diffs.
  401. OLD_TARS=""
  402. # The directory that will be used to construct the release. The
  403. # release itself will be placed in a subdirectory of this directory.
  404. DESTINATION=${HOME}
  405. # The subdirectory.
  406. WORKING_DIRECTORY=""
  407. # The directory that will contain the GCC sources.
  408. SOURCE_DIRECTORY=""
  409. # Non-zero if this is the final release, rather than a prerelease.
  410. FINAL=0
  411. # Non-zero if we are building a snapshot, and don't build gcc or
  412. # include generated files.
  413. SNAPSHOT=0
  414. # Non-zero if we are running locally on gcc.gnu.org, and use local CVS
  415. # and copy directly to the FTP directory.
  416. LOCAL=0
  417. # Major operation modes.
  418. MODE_GZIP=0
  419. MODE_DIFFS=0
  420. MODE_SOURCES=0
  421. MODE_TARFILES=0
  422. MODE_UPLOAD=0
  423. # List of archive files generated; used to create .gz files from .bz2.
  424. FILE_LIST=""
  425. # Programs we use.
  426. BZIP2="${BZIP2:-bzip2}"
  427. CVS="${CVS:-cvs -f -Q -z9}"
  428. DIFF="${DIFF:-diff -Nrcpad}"
  429. ENV="${ENV:-env}"
  430. GZIP="${GZIP:-gzip --best}"
  431. SCP="${SCP:-scp -p}"
  432. SSH="${SSH:-ssh}"
  433. TAR="${TAR:-tar}"
  434. ########################################################################
  435. # Command Line Processing
  436. ########################################################################
  437. # Parse the options.
  438. while getopts "d:fr:u:t:p:s:l" ARG; do
  439. case $ARG in
  440. d) DESTINATION="${OPTARG}";;
  441. r) RELEASE="${OPTARG}";;
  442. t) TAG="${OPTARG}";;
  443. u) SVN_USERNAME="${OPTARG}";;
  444. f) FINAL=1;;
  445. s) SNAPSHOT=1
  446. BRANCH=${OPTARG%:*}
  447. SVNBRANCH=${OPTARG#*:}
  448. ;;
  449. l) LOCAL=1
  450. SCP=cp
  451. PATH=~:/usr/local/bin:$PATH;;
  452. p) OLD_TARS="${OLD_TARS} ${OPTARG}"
  453. if [ ! -f ${OPTARG} ]; then
  454. error "-p argument must name a tarball"
  455. fi;;
  456. \?) usage;;
  457. esac
  458. done
  459. shift `expr ${OPTIND} - 1`
  460. # Handle the major modes.
  461. while [ $# -ne 0 ]; do
  462. case $1 in
  463. diffs) MODE_DIFFS=1;;
  464. gzip) MODE_GZIP=1;;
  465. sources) MODE_SOURCES=1;;
  466. tarfiles) MODE_TARFILES=1;;
  467. upload) MODE_UPLOAD=1;;
  468. all) MODE_SOURCES=1; MODE_TARFILES=1; MODE_DIFFS=1; MODE_UPLOAD=1;
  469. if [ $SNAPSHOT -ne 1 ]; then
  470. # Only for releases and pre-releases.
  471. MODE_GZIP=1;
  472. fi
  473. ;;
  474. *) error "Unknown mode $1";;
  475. esac
  476. shift
  477. done
  478. # Perform consistency checking.
  479. if [ ${LOCAL} -eq 0 ] && [ -z ${SVN_USERNAME} ]; then
  480. error "No username specified"
  481. fi
  482. if [ ! -d ${DESTINATION} ]; then
  483. error "\`${DESTINATION}' is not a directory"
  484. fi
  485. if [ $SNAPSHOT -eq 0 ]; then
  486. if [ -z ${RELEASE} ]; then
  487. error "No release number specified"
  488. fi
  489. # Compute the major and minor release numbers.
  490. RELEASE_MAJOR=`echo $RELEASE | awk --assign FS=. '{ print $1; }'`
  491. RELEASE_MINOR=`echo $RELEASE | awk --assign FS=. '{ print $2; }'`
  492. RELEASE_REVISION=`echo $RELEASE | awk --assign FS=. '{ print $3; }'`
  493. if [ -z "${RELEASE_MAJOR}" ] || [ -z "${RELEASE_MINOR}" ]; then
  494. error "Release number \`${RELEASE}' is invalid"
  495. fi
  496. # Compute the full name of the release.
  497. if [ -z "${RELEASE_REVISION}" ]; then
  498. RELEASE="${RELEASE_MAJOR}.${RELEASE_MINOR}"
  499. else
  500. RELEASE="${RELEASE_MAJOR}.${RELEASE_MINOR}.${RELEASE_REVISION}"
  501. fi
  502. # Compute the name of the branch, which is based solely on the major
  503. # and minor release numbers.
  504. SVNBRANCH="branches/gcc-${RELEASE_MAJOR}_${RELEASE_MINOR}-branch"
  505. # If this is not a final release, set various parameters accordingly.
  506. if [ ${FINAL} -ne 1 ]; then
  507. RELEASE="${RELEASE}-RC-${DATE}"
  508. FTP_PATH="${SNAPSHOTS_DIR}/${RELEASE}"
  509. else
  510. FTP_PATH="${FTP_PATH}/releases/gcc-${RELEASE}/"
  511. fi
  512. else
  513. RELEASE=${BRANCH}-${DATE}
  514. FTP_PATH="${FTP_PATH}/snapshots/${RELEASE}"
  515. # If diffs are requested when building locally on gcc.gnu.org, we (usually)
  516. # know what the last snapshot date was and take the corresponding tarballs,
  517. # unless the user specified tarballs explicitly.
  518. if [ $MODE_DIFFS -ne 0 ] && [ $LOCAL -ne 0 ] && [ -z "${OLD_TARS}" ]; then
  519. LAST_DATE=`cat ~/.snapshot_date-${BRANCH}`
  520. OLD_TARS=${SNAPSHOTS_DIR}/${BRANCH}-${LAST_DATE}/gcc-${BRANCH}-${LAST_DATE}.tar.bz2
  521. fi
  522. fi
  523. # Compute the name of the WORKING_DIRECTORY and the SOURCE_DIRECTORY.
  524. WORKING_DIRECTORY="${DESTINATION}/gcc-${RELEASE}"
  525. SOURCE_DIRECTORY="${WORKING_DIRECTORY}/gcc-${RELEASE}"
  526. # Set up SVNROOT.
  527. if [ $LOCAL -eq 0 ]; then
  528. SVNROOT="svn+ssh://${SVN_USERNAME}@${SVN_SERVER}${SVN_REPOSITORY}"
  529. else
  530. SVNROOT="file:///svn/gcc"
  531. fi
  532. export SVNROOT
  533. ########################################################################
  534. # Main Program
  535. ########################################################################
  536. # Set the timezone to UTC
  537. TZ="UTC0"
  538. export TZ
  539. # Build the source directory.
  540. if [ $MODE_SOURCES -ne 0 ]; then
  541. build_sources
  542. fi
  543. # Build the tar files.
  544. if [ $MODE_TARFILES -ne 0 ]; then
  545. build_tarfiles
  546. fi
  547. # Build diffs
  548. if [ $MODE_DIFFS -ne 0 ]; then
  549. # Possibly build diffs.
  550. if [ -n "$OLD_TARS" ]; then
  551. for old_tar in $OLD_TARS; do
  552. build_diffs $old_tar
  553. done
  554. fi
  555. fi
  556. # Build gzip files
  557. if [ $MODE_GZIP -ne 0 ]; then
  558. build_gzip
  559. fi
  560. # Upload them to the FTP server.
  561. if [ $MODE_UPLOAD -ne 0 ]; then
  562. upload_files
  563. # For snapshots, make some further updates.
  564. if [ $SNAPSHOT -ne 0 ] && [ $LOCAL -ne 0 ]; then
  565. announce_snapshot
  566. # Update snapshot date file.
  567. changedir ~
  568. echo $DATE > .snapshot_date-${BRANCH}
  569. # Remove working directory
  570. rm -rf ${WORKING_DIRECTORY}
  571. fi
  572. fi