http://gcc.gnu.org/ml/gcc-patches/2008-02/msg00140.html
[official-gcc.git] / maintainer-scripts / gcc_release
blobbacb25b0ceb2a008f7addeedc9ce7808b6785acc
1 #! /bin/sh
3 ########################################################################
5 # File: gcc_release
6 # Author: Jeffrey Law, Bernd Schmidt, Mark Mitchell
7 # Date: 2001-05-25
9 # Contents:
10 # Script to create a GCC release.
12 # Copyright (c) 2001, 2002, 2006 Free Software Foundation.
14 # This file is part of GCC.
16 # GCC is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2, or (at your option)
19 # any later version.
21 # GCC is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with GCC; see the file COPYING. If not, write to
28 # the Free Software Foundation, 51 Franklin Street, Fifth Floor,
29 # Boston, MA 02110-1301, USA.
31 ########################################################################
33 ########################################################################
34 # Notes
35 ########################################################################
37 # Here is an example usage of this script, to create a GCC 3.0.2
38 # prerelease:
40 # gcc_release -r 3.0.2
42 # This script will automatically use the head of the release branch
43 # to generate the release.
45 ########################################################################
46 # Functions
47 ########################################################################
49 # Issue the error message given by $1 and exit with a non-zero
50 # exit code.
52 error() {
53 echo "gcc_release: error: $1"
54 exit 1
57 # Issue the informational message given by $1.
59 inform() {
60 echo "gcc_release: $1"
63 # Issue a usage message explaining how to use this script.
65 usage() {
66 cat <<EOF
67 gcc_release -r release [-f] [further options]
68 gcc_release -s name:svnbranch [further options]
70 Options:
72 -r release Version of the form X.Y or X.Y.Z.
73 -s name:svnbranch Create a snapshot, not a real release.
75 -d destination Local working directory where we will build the release
76 (default=${HOME}).
77 -f Create a final release (and update ChangeLogs,...).
78 -l Indicate that we are running on gcc.gnu.org.
79 -p previous-tarball Location of a previous tarball (to generate diff files).
80 -t tag Tag to mark the release in SVN.
81 -u username Username for upload operations.
82 EOF
83 exit 1
86 # Change to the directory given by $1.
88 changedir() {
89 cd $1 || \
90 error "Could not change directory to $1"
93 # Each of the arguments is a directory name, relative to the top
94 # of the source tree. Return another name for that directory, relative
95 # to the working directory.
97 adjust_dirs() {
98 for x in $@; do
99 echo `basename ${SOURCE_DIRECTORY}`/$x
100 done
103 # Build the source tree that will be the basis for the release
104 # in ${WORKING_DIRECTORY}/gcc-${RELEASE}.
106 build_sources() {
107 # If the WORKING_DIRECTORY already exists, do not risk destroying it.
108 if [ -r ${WORKING_DIRECTORY} ]; then
109 error "\`${WORKING_DIRECTORY}' already exists"
111 # Create the WORKING_DIRECTORY.
112 mkdir "${WORKING_DIRECTORY}" \
113 || error "Could not create \`${WORKING_DIRECTORY}'"
114 changedir "${WORKING_DIRECTORY}"
116 # If this is a final release, make sure that the ChangeLogs
117 # and version strings are updated.
118 if [ ${FINAL} -ne 0 ]; then
119 inform "Updating ChangeLogs and version files"
121 ${SVN} -q co "${SVNROOT}/${SVNBRANCH}" "`basename ${SOURCE_DIRECTORY}`" ||\
122 error "Could not check out release sources"
123 for x in `find ${SOURCE_DIRECTORY} -name ChangeLog`; do
124 # Update this ChangeLog file only if it does not yet contain the
125 # entry we are going to add. (This is a safety net for repeated
126 # runs of this script for the same release.)
127 if ! grep "GCC ${RELEASE} released." ${x} > /dev/null ; then
128 cat - ${x} > ${x}.new <<EOF
129 ${LONG_DATE} Release Manager
131 * GCC ${RELEASE} released.
134 mv ${x}.new ${x} || \
135 error "Could not update ${x}"
136 (changedir `dirname ${x}` && \
137 ${SVN} -q ci -m 'Mark ChangeLog' `basename ${x}`) || \
138 error "Could not commit ${x}"
140 done
142 # Update gcc/DEV-PHASE if it exists, otherwise gcc/version.c.
144 if [ -f ${SOURCE_DIRECTORY}/gcc/DEV-PHASE ]; then
145 [ `cat ${SOURCE_DIRECTORY}/gcc/BASE-VER` = ${RELEASE} ] || \
146 error "Release number ${RELEASE} does not match BASE-VER"
147 (changedir ${SOURCE_DIRECTORY}/gcc && \
148 : > DEV-PHASE && \
149 ${SVN} -q ci -m 'Mark as release' DEV-PHASE) || \
150 error "Could not update DEV-PHASE"
151 else
152 for x in gcc/version.c; do
153 y=`basename ${x}`
154 (changedir `dirname ${SOURCE_DIRECTORY}/${x}` && \
155 sed -e 's|version_string\[\] = \".*\"|version_string\[\] = \"'${RELEASE}'\"|g' < ${y} > ${y}.new && \
156 mv ${y}.new ${y} && \
157 ${SVN} -q ci -m 'Update version' ${y}) || \
158 error "Could not update ${x}"
159 done
162 # Make sure we tag the sources for a final release.
163 TAG="tags/gcc_`echo ${RELEASE} | tr . _`_release"
165 rm -rf ${SOURCE_DIRECTORY}
168 # Tag the sources.
169 if [ -n "${TAG}" ]; then
170 inform "Tagging sources as ${TAG}"
171 # We don't want to overwrite an existing tag. So, if the tag
172 # already exists, issue an error message; the release manager can
173 # manually remove the tag if appropriate.
174 echo "${SVN} ls ${SVNROOT}/${TAG}/ChangeLog"
175 if ${SVN} ls "${SVNROOT}/${TAG}/ChangeLog"; then
176 error "Tag ${TAG} already exists"
178 ${SVN} -m "Tagging source as ${TAG}" cp "${SVNROOT}/${SVNBRANCH}" "${SVNROOT}/${TAG}" || \
179 error "Could not tag sources"
180 SVNBRANCH=${TAG}
182 SVNREV=`${SVN} info "${SVNROOT}/${SVNBRANCH}"|awk '/Revision:/ {print $2}'`
184 # Export the current sources.
185 inform "Retrieving sources (svn export -r ${SVNREV} ${SVNROOT}/${SVNBRANCH})"
187 ${SVN} -q export -r${SVNREV} "${SVNROOT}/${SVNBRANCH}" "`basename ${SOURCE_DIRECTORY}`" ||\
188 error "Could not retrieve sources"
190 # Run gcc_update on them to set up the timestamps nicely, and (re)write
191 # the LAST_UPDATED file containing the SVN tag/revision used.
192 changedir "gcc-${RELEASE}"
193 contrib/gcc_update --touch
194 echo "Obtained from SVN: ${SVNBRANCH} revision ${SVNREV}" > LAST_UPDATED
196 # For a prerelease or real release, we need to generate additional
197 # files not present in SVN.
198 changedir "${SOURCE_DIRECTORY}"
199 if [ $SNAPSHOT -ne 1 ]; then
200 # Generate the documentation.
201 inform "Building install docs"
202 SOURCEDIR=${SOURCE_DIRECTORY}/gcc/doc
203 DESTDIR=${SOURCE_DIRECTORY}/INSTALL
204 export SOURCEDIR
205 export DESTDIR
206 ${SOURCE_DIRECTORY}/gcc/doc/install.texi2html
208 # Regenerate the NEWS file.
209 contrib/gennews > NEWS || \
210 error "Could not regenerate NEWS files"
212 # Now, we must build the compiler in order to create any generated
213 # files that are supposed to go in the source directory. This is
214 # also a good sanity check to make sure that the release builds
215 # on at least one platform.
216 inform "Building compiler"
217 OBJECT_DIRECTORY=../objdir
218 contrib/gcc_build -d ${SOURCE_DIRECTORY} -o ${OBJECT_DIRECTORY} \
219 -c "--enable-generated-files-in-srcdir --disable-multilib" build || \
220 error "Could not rebuild GCC"
223 # Move message catalogs to source directory.
224 mv ../objdir/gcc/po/*.gmo gcc/po/
225 [ -f libcpp/po/cpplib.pot ] && mv ../objdir/libcpp/po/*.gmo libcpp/po/
227 # Create a "MD5SUMS" file to use for checking the validity of the release.
228 echo \
229 "# This file contains the MD5 checksums of the files in the
230 # gcc-"${RELEASE}".tar.bz2 tarball.
232 # Besides verifying that all files in the tarball were correctly expanded,
233 # it also can be used to determine if any files have changed since the
234 # tarball was expanded or to verify that a patchfile was correctly applied.
236 # Suggested usage:
237 # md5sum -c MD5SUMS | grep -v \"OK$\"
238 " > MD5SUMS
240 find . -type f |
241 sed -e 's:^\./::' -e '/MD5SUMS/d' |
242 sort |
243 xargs md5sum >>MD5SUMS
246 # Buid a single tarfile. The first argument is the name of the name
247 # of the tarfile to build, without any suffixes. They will be added
248 # automatically. The rest of the arguments are the files or
249 # directories to include, and possibly other arguments to tar.
251 build_tarfile() {
252 # Get the name of the destination tar file.
253 TARFILE="$1.tar.bz2"
254 shift
256 # Build the tar file itself.
257 (${TAR} cf - "$@" | ${BZIP2} > ${TARFILE}) || \
258 error "Could not build tarfile"
259 FILE_LIST="${FILE_LIST} ${TARFILE}"
262 # Build a single tarfile if any of the directories listed exist,
263 # but not if none of them do (because that component doesn't exist
264 # on this branch).
265 maybe_build_tarfile() {
266 dest=$1
267 shift
268 dir_exists=0
269 for maybe_dir in "$@"; do
270 if [ -d "$maybe_dir" ]; then
271 dir_exists=1
273 done
274 if [ $dir_exists = 1 ]; then
275 build_tarfile "$dest" "$@"
276 else
277 echo "Not building $dest tarfile"
281 # Build the various tar files for the release.
283 build_tarfiles() {
284 inform "Building tarfiles"
286 changedir "${WORKING_DIRECTORY}"
288 # The GNU Coding Standards specify that all files should
289 # world readable.
290 chmod -R a+r ${SOURCE_DIRECTORY}
291 # And that all directories have mode 777.
292 find ${SOURCE_DIRECTORY} -type d -exec chmod 777 {} \;
294 # Build one huge tarfile for the entire distribution.
295 build_tarfile gcc-${RELEASE} `basename ${SOURCE_DIRECTORY}`
297 # Now, build one for each of the languages.
298 maybe_build_tarfile gcc-ada-${RELEASE} ${ADA_DIRS}
299 maybe_build_tarfile gcc-g++-${RELEASE} ${CPLUSPLUS_DIRS}
300 maybe_build_tarfile gcc-g77-${RELEASE} ${FORTRAN_DIRS}
301 maybe_build_tarfile gcc-fortran-${RELEASE} ${FORTRAN95_DIRS}
302 maybe_build_tarfile gcc-java-${RELEASE} ${JAVA_DIRS}
303 maybe_build_tarfile gcc-objc-${RELEASE} ${OBJECTIVEC_DIRS}
304 maybe_build_tarfile gcc-testsuite-${RELEASE} ${TESTSUITE_DIRS}
306 # The core is everything else.
307 EXCLUDES=""
308 for x in ${ADA_DIRS} ${CPLUSPLUS_DIRS} ${FORTRAN_DIRS} ${FORTRAN95_DIRS}\
309 ${JAVA_DIRS} ${OBJECTIVEC_DIRS} ${TESTSUITE_DIRS}; do
310 EXCLUDES="${EXCLUDES} --exclude $x"
311 done
312 build_tarfile gcc-core-${RELEASE} ${EXCLUDES} \
313 `basename ${SOURCE_DIRECTORY}`
316 # Build .gz files.
317 build_gzip() {
318 for f in ${FILE_LIST}; do
319 target=${f%.bz2}.gz
320 (${BZIP2} -d -c $f | ${GZIP} > ${target}) || error "Could not create ${target}"
321 done
324 # Build diffs against an old release.
325 build_diffs() {
326 old_dir=${1%/*}
327 old_file=${1##*/}
328 old_vers=${old_file%.tar.bz2}
329 old_vers=${old_vers#gcc-}
330 inform "Building diffs against version $old_vers"
331 for f in gcc gcc-ada gcc-g++ gcc-g77 gcc-fortran gcc-java gcc-objc gcc-testsuite gcc-core; do
332 old_tar=${old_dir}/${f}-${old_vers}.tar.bz2
333 new_tar=${WORKING_DIRECTORY}/${f}-${RELEASE}.tar.bz2
334 if [ ! -e $old_tar ]; then
335 inform "$old_tar not found; not generating diff file"
336 elif [ ! -e $new_tar ]; then
337 inform "$new_tar not found; not generating diff file"
338 else
339 build_diff $old_tar gcc-${old_vers} $new_tar gcc-${RELEASE} \
340 ${f}-${old_vers}-${RELEASE}.diff.bz2
342 done
345 # Build an individual diff.
346 build_diff() {
347 changedir "${WORKING_DIRECTORY}"
348 tmpdir=gccdiff.$$
349 mkdir $tmpdir || error "Could not create directory $tmpdir"
350 changedir $tmpdir
351 (${BZIP2} -d -c $1 | ${TAR} xf - ) || error "Could not unpack $1 for diffs"
352 (${BZIP2} -d -c $3 | ${TAR} xf - ) || error "Could not unpack $3 for diffs"
353 ${DIFF} $2 $4 > ../${5%.bz2}
354 if [ $? -eq 2 ]; then
355 error "Trouble making diffs from $1 to $3"
357 ${BZIP2} ../${5%.bz2} || error "Could not generate ../$5"
358 changedir ..
359 rm -rf $tmpdir
360 FILE_LIST="${FILE_LIST} $5"
363 # Upload the files to the FTP server.
364 upload_files() {
365 inform "Uploading files"
367 changedir "${WORKING_DIRECTORY}"
369 # Make sure the directory exists on the server.
370 if [ $LOCAL -eq 0 ]; then
371 ${SSH} -l ${GCC_USERNAME} ${GCC_HOSTNAME} \
372 mkdir -p "${FTP_PATH}/diffs"
373 UPLOAD_PATH="${GCC_USERNAME}@${GCC_HOSTNAME}:${FTP_PATH}"
374 else
375 mkdir -p "${FTP_PATH}/diffs" \
376 || error "Could not create \`${FTP_PATH}'"
377 UPLOAD_PATH=${FTP_PATH}
380 # Then copy files to their respective (sub)directories.
381 for x in gcc*.gz gcc*.bz2; do
382 if [ -e ${x} ]; then
383 # Make sure the file will be readable on the server.
384 chmod a+r ${x}
385 # Copy it.
386 case ${x} in
387 *.diff.*)
388 SUBDIR="diffs/";
391 SUBDIR="";
392 esac
393 ${SCP} ${x} ${UPLOAD_PATH}/${SUBDIR} \
394 || error "Could not upload ${x}"
396 done
399 #Print description if snapshot exists
400 snapshot_print() {
401 if [ -e ${RELEASE}/$1 ]; then
402 printf "%-38s%s\n\n" "$1" "$2" >> ${SNAPSHOT_README}
403 echo " <tr><td><a href=\"$1\">$1</a></td>" >> ${SNAPSHOT_INDEX}
404 echo " <td>$2</td></tr>" >> ${SNAPSHOT_INDEX}
408 # Announce a snapshot, both on the web and via mail.
409 announce_snapshot() {
410 inform "Updating links and READMEs on the FTP server"
412 TEXT_DATE=`date --date=$DATE +%B\ %d,\ %Y`
413 SNAPSHOT_README=${RELEASE}/README
414 SNAPSHOT_INDEX=${RELEASE}/index.html
416 changedir "${SNAPSHOTS_DIR}"
417 echo \
418 "Snapshot gcc-"${RELEASE}" is now available on
419 ftp://gcc.gnu.org/pub/gcc/snapshots/"${RELEASE}"/
420 and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.
422 This snapshot has been generated from the GCC "${BRANCH}" SVN branch
423 with the following options: "svn://gcc.gnu.org/svn/gcc/${SVNBRANCH} revision ${SVNREV}"
425 You'll find:
426 " > ${SNAPSHOT_README}
428 echo \
429 "<html>
431 <head>
432 <title>GCC "${RELEASE}" Snapshot</title>
433 </head>
435 <body>
436 <h1>GCC "${RELEASE}" Snapshot</h1>
438 <p>The <a href =\"http://gcc.gnu.org/\">GCC Project</a> makes
439 periodic snapshots of the GCC source tree available to the public
440 for testing purposes.</p>
442 <p>If you are planning to download and use one of our snapshots, then
443 we highly recommend you join the GCC developers list. Details for
444 how to sign up can be found on the GCC project home page.</p>
446 <p>This snapshot has been generated from the GCC "${BRANCH}" SVN branch
447 with the following options: <code>"svn://gcc.gnu.org/svn/gcc/${SVNBRANCH} revision ${SVNREV}"</code></p>
449 <table>" > ${SNAPSHOT_INDEX}
451 snapshot_print gcc-${RELEASE}.tar.bz2 "Complete GCC (includes all of below)"
452 snapshot_print gcc-core-${RELEASE}.tar.bz2 "C front end and core compiler"
453 snapshot_print gcc-ada-${RELEASE}.tar.bz2 "Ada front end and runtime"
454 snapshot_print gcc-fortran-${RELEASE}.tar.bz2 "Fortran front end and runtime"
455 snapshot_print gcc-g++-${RELEASE}.tar.bz2 "C++ front end and runtime"
456 snapshot_print gcc-g77-${RELEASE}.tar.bz2 "Fortran 77 front end and runtime"
457 snapshot_print gcc-java-${RELEASE}.tar.bz2 "Java front end and runtime"
458 snapshot_print gcc-objc-${RELEASE}.tar.bz2 "Objective-C front end and runtime"
459 snapshot_print gcc-testsuite-${RELEASE}.tar.bz2 "The GCC testsuite"
461 echo \
462 "Diffs from "${BRANCH}"-"${LAST_DATE}" are available in the diffs/ subdirectory.
464 When a particular snapshot is ready for public consumption the LATEST-"${BRANCH}"
465 link is updated and a message is sent to the gcc list. Please do not use
466 a snapshot before it has been announced that way." >> ${SNAPSHOT_README}
468 echo \
469 "</table>
470 <p>Diffs from "${BRANCH}"-"${LAST_DATE}" are available in the
471 <a href=\"diffs/\">diffs/ subdirectory</a>.</p>
473 <p>When a particular snapshot is ready for public consumption the LATEST-"${BRANCH}"
474 link is updated and a message is sent to the gcc list. Please do not use
475 a snapshot before it has been announced that way.</p>
477 <hr />
479 <address>
480 <a href=\"mailto:gcc@gcc.gnu.org\">gcc@gcc.gnu.org</a>
481 <br />
482 Last modified "${TEXT_DATE}"
483 </address>
484 </body>
486 </html>" >> ${SNAPSHOT_INDEX}
488 rm -f LATEST-${BRANCH}
489 ln -s ${RELEASE} LATEST-${BRANCH}
491 inform "Sending mail"
493 export QMAILHOST=gcc.gnu.org
494 mail -s "gcc-${RELEASE} is now available" gcc@gcc.gnu.org < ${SNAPSHOT_README}
497 ########################################################################
498 # Initialization
499 ########################################################################
501 LC_ALL=C
502 export LC_ALL
504 # Today's date.
505 DATE=`date "+%Y%m%d"`
506 LONG_DATE=`date "+%Y-%m-%d"`
508 SVN=${SVN:-svn}
509 # The CVS server containing the GCC repository.
510 SVN_SERVER="gcc.gnu.org"
511 # The path to the repository on that server.
512 SVN_REPOSITORY="/svn/gcc"
513 # The username to use when connecting to the server.
514 SVN_USERNAME="${USER}"
516 # The machine to which files will be uploaded.
517 GCC_HOSTNAME="gcc.gnu.org"
518 # The name of the account on the machine to which files are uploaded.
519 GCC_USERNAME="gccadmin"
520 # The directory in which the files will be placed (do not use ~user syntax).
521 FTP_PATH=/var/ftp/pub/gcc
522 # The directory in which snapshots will be placed.
523 SNAPSHOTS_DIR=${FTP_PATH}/snapshots
525 # The major number for the release. For release `3.0.2' this would be
526 # `3'
527 RELEASE_MAJOR=""
528 # The minor number for the release. For release `3.0.2' this would be
529 # `0'.
530 RELEASE_MINOR=""
531 # The revision number for the release. For release `3.0.2' this would
532 # be `2'.
533 RELEASE_REVISION=""
534 # The complete name of the release.
535 RELEASE=""
537 # The name of the branch from which the release should be made, in a
538 # user-friendly form.
539 BRANCH=""
541 # The name of the branch from which the release should be made, as used
542 # for our version control system.
543 SVNBRANCH=""
545 # The tag to apply to the sources used for the release.
546 TAG=""
548 # The old tarballs from which to generate diffs.
549 OLD_TARS=""
551 # The directory that will be used to construct the release. The
552 # release itself will be placed in a subdirectory of this diretory.
553 DESTINATION=${HOME}
554 # The subdirectory.
555 WORKING_DIRECTORY=""
556 # The directory that will contain the GCC sources.
557 SOURCE_DIRECTORY=""
559 # The directories that should be part of the various language-specific
560 # tar files. These are all relative to the top of the source tree.
561 ADA_DIRS="gcc/ada libada gnattools"
562 CPLUSPLUS_DIRS="gcc/cp libstdc++-v3"
563 FORTRAN_DIRS="gcc/f libf2c"
564 FORTRAN95_DIRS="gcc/fortran libgfortran"
565 JAVA_DIRS="gcc/java libjava libffi fastjar zlib boehm-gc"
566 OBJECTIVEC_DIRS="gcc/objc gcc/objcp libobjc"
567 TESTSUITE_DIRS="gcc/testsuite"
569 # Non-zero if this is the final release, rather than a prerelease.
570 FINAL=0
572 # Non-zero if we are building a snapshot, and don't build gcc or
573 # include generated files.
574 SNAPSHOT=0
576 # Non-zero if we are running locally on gcc.gnu.org, and use local CVS
577 # and copy directly to the FTP directory.
578 LOCAL=0
580 # Major operation modes.
581 MODE_GZIP=0
582 MODE_DIFFS=0
583 MODE_SOURCES=0
584 MODE_TARFILES=0
585 MODE_UPLOAD=0
587 # List of archive files generated; used to create .gz files from .bz2.
588 FILE_LIST=""
590 # Programs we use.
592 BZIP2="${BZIP2:-bzip2}"
593 CVS="${CVS:-cvs -f -Q -z9}"
594 DIFF="${DIFF:-diff -Nrcpad}"
595 ENV="${ENV:-env}"
596 GZIP="${GZIP:-gzip --best}"
597 SCP="${SCP:-scp -p}"
598 SSH="${SSH:-ssh}"
599 TAR="${TAR:-tar}"
601 ########################################################################
602 # Command Line Processing
603 ########################################################################
605 # Parse the options.
606 while getopts "d:fr:u:t:p:s:l" ARG; do
607 case $ARG in
608 d) DESTINATION="${OPTARG}";;
609 r) RELEASE="${OPTARG}";;
610 t) TAG="${OPTARG}";;
611 u) SVN_USERNAME="${OPTARG}";;
612 f) FINAL=1;;
613 s) SNAPSHOT=1
614 BRANCH=${OPTARG%:*}
615 SVNBRANCH=${OPTARG#*:}
617 l) LOCAL=1
618 SCP=cp
619 PATH=~:/usr/local/bin:$PATH;;
620 p) OLD_TARS="${OLD_TARS} ${OPTARG}"
621 if [ ! -f ${OPTARG} ]; then
622 error "-p argument must name a tarball"
623 fi;;
624 \?) usage;;
625 esac
626 done
627 shift `expr ${OPTIND} - 1`
629 # Handle the major modes.
630 while [ $# -ne 0 ]; do
631 case $1 in
632 diffs) MODE_DIFFS=1;;
633 gzip) MODE_GZIP=1;;
634 sources) MODE_SOURCES=1;;
635 tarfiles) MODE_TARFILES=1;;
636 upload) MODE_UPLOAD=1;;
637 all) MODE_SOURCES=1; MODE_TARFILES=1; MODE_DIFFS=1; MODE_UPLOAD=1;
638 if [ $SNAPSHOT -ne 1 ]; then
639 # Only for releases and pre-releases.
640 MODE_GZIP=1;
643 *) error "Unknown mode $1";;
644 esac
645 shift
646 done
648 # Perform consistency checking.
649 if [ ${LOCAL} -eq 0 ] && [ -z ${SVN_USERNAME} ]; then
650 error "No username specified"
653 if [ ! -d ${DESTINATION} ]; then
654 error "\`${DESTINATION}' is not a directory"
657 if [ $SNAPSHOT -eq 0 ]; then
658 if [ -z ${RELEASE} ]; then
659 error "No release number specified"
662 # Compute the major and minor release numbers.
663 RELEASE_MAJOR=`echo $RELEASE | awk --assign FS=. '{ print $1; }'`
664 RELEASE_MINOR=`echo $RELEASE | awk --assign FS=. '{ print $2; }'`
665 RELEASE_REVISION=`echo $RELEASE | awk --assign FS=. '{ print $3; }'`
667 if [ -z "${RELEASE_MAJOR}" ] || [ -z "${RELEASE_MINOR}" ]; then
668 error "Release number \`${RELEASE}' is invalid"
671 # Compute the full name of the release.
672 if [ -z "${RELEASE_REVISION}" ]; then
673 RELEASE="${RELEASE_MAJOR}.${RELEASE_MINOR}"
674 else
675 RELEASE="${RELEASE_MAJOR}.${RELEASE_MINOR}.${RELEASE_REVISION}"
678 # Compute the name of the branch, which is based solely on the major
679 # and minor release numbers.
680 SVNBRANCH="branches/gcc-${RELEASE_MAJOR}_${RELEASE_MINOR}-branch"
682 # If this is not a final release, set various parameters accordingly.
683 if [ ${FINAL} -ne 1 ]; then
684 RELEASE="${RELEASE}-RC-${DATE}"
685 FTP_PATH="${SNAPSHOTS_DIR}/${RELEASE}"
686 else
687 FTP_PATH="${FTP_PATH}/releases/gcc-${RELEASE}/"
689 else
690 RELEASE=${BRANCH}-${DATE}
691 FTP_PATH="${FTP_PATH}/snapshots/${RELEASE}"
693 # If diffs are requested when building locally on gcc.gnu.org, we (usually)
694 # know what the last snapshot date was and take the corresponding tarballs,
695 # unless the user specified tarballs explictly.
696 if [ $MODE_DIFFS -ne 0 ] && [ $LOCAL -ne 0 ] && [ -z "${OLD_TARS}" ]; then
697 LAST_DATE=`cat ~/.snapshot_date-${BRANCH}`
698 OLD_TARS=${SNAPSHOTS_DIR}/${BRANCH}-${LAST_DATE}/gcc-${BRANCH}-${LAST_DATE}.tar.bz2
702 # Compute the name of the WORKING_DIRECTORY and the SOURCE_DIRECTORY.
703 WORKING_DIRECTORY="${DESTINATION}/gcc-${RELEASE}"
704 SOURCE_DIRECTORY="${WORKING_DIRECTORY}/gcc-${RELEASE}"
706 # Recompute the names of all the language-specific directories,
707 # relative to the WORKING_DIRECTORY.
708 ADA_DIRS=`adjust_dirs ${ADA_DIRS}`
709 CPLUSPLUS_DIRS=`adjust_dirs ${CPLUSPLUS_DIRS}`
710 FORTRAN_DIRS=`adjust_dirs ${FORTRAN_DIRS}`
711 FORTRAN95_DIRS=`adjust_dirs ${FORTRAN95_DIRS}`
712 JAVA_DIRS=`adjust_dirs ${JAVA_DIRS}`
713 OBJECTIVEC_DIRS=`adjust_dirs ${OBJECTIVEC_DIRS}`
714 TESTSUITE_DIRS=`adjust_dirs ${TESTSUITE_DIRS}`
716 # Set up SVNROOT.
717 if [ $LOCAL -eq 0 ]; then
718 SVNROOT="svn+ssh://${SVN_USERNAME}@${SVN_SERVER}${SVN_REPOSITORY}"
719 CVSROOT=":ext:${SVN_USERNAME}@gcc.gnu.org/cvs/gcc"
720 else
721 SVNROOT="file:///svn/gcc"
722 CVSROOT="/cvs/gcc"
724 export SVNROOT
725 export CVSROOT
727 ########################################################################
728 # Main Program
729 ########################################################################
731 # Set the timezone to UTC
732 TZ="UTC0"
733 export TZ
735 # Build the source directory.
737 if [ $MODE_SOURCES -ne 0 ]; then
738 build_sources
741 # Build the tar files.
743 if [ $MODE_TARFILES -ne 0 ]; then
744 build_tarfiles
747 # Build diffs
749 if [ $MODE_DIFFS -ne 0 ]; then
750 # Possibly build diffs.
751 if [ -n "$OLD_TARS" ]; then
752 for old_tar in $OLD_TARS; do
753 build_diffs $old_tar
754 done
758 # Build gzip files
759 if [ $MODE_GZIP -ne 0 ]; then
760 build_gzip
763 # Upload them to the FTP server.
764 if [ $MODE_UPLOAD -ne 0 ]; then
765 upload_files
767 # For snapshots, make some further updates.
768 if [ $SNAPSHOT -ne 0 ] && [ $LOCAL -ne 0 ]; then
769 announce_snapshot
771 # Update snapshot date file.
772 changedir ~
773 echo $DATE > .snapshot_date-${BRANCH}
775 # Remove working directory
776 rm -rf ${WORKING_DIRECTORY}