PR c++/29518
[official-gcc.git] / maintainer-scripts / gcc_release
blob5fe825e84638d55ce68bdd9ced829a0a86894718
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 # Obtain some documentation files from the wwwdocs module.
197 inform "Retrieving HTML documentation"
198 changedir "${WORKING_DIRECTORY}"
199 for x in bugs faq; do
200 (${CVS} export -r HEAD wwwdocs/htdocs/${x}.html && \
201 cp ${WORKING_DIRECTORY}/wwwdocs/htdocs/${x}.html \
202 ${SOURCE_DIRECTORY}) || \
203 error "Could not retrieve ${x}.html"
204 done
206 inform "Generating plain-text documentation from HTML"
207 changedir "${SOURCE_DIRECTORY}"
208 for file in *.html; do
209 newfile=`echo $file | sed -e 's/.html//' | tr "[:lower:]" "[:upper:]"`
210 (${ENV} TERM=vt100 lynx -dump $file \
211 | sed -e "s#file://localhost`/bin/pwd`\(.*\)#http://gcc.gnu.org\1#g" \
212 > $newfile) || \
213 error "Could not generate text-only version of ${file}"
214 done
216 # For a prerelease or real release, we need to generate additional
217 # files not present in SVN.
218 changedir "${SOURCE_DIRECTORY}"
219 if [ $SNAPSHOT -ne 1 ]; then
220 # Generate the documentation.
221 inform "Building install docs"
222 SOURCEDIR=${SOURCE_DIRECTORY}/gcc/doc
223 DESTDIR=${SOURCE_DIRECTORY}/INSTALL
224 export SOURCEDIR
225 export DESTDIR
226 ${SOURCE_DIRECTORY}/gcc/doc/install.texi2html
228 # Regenerate the NEWS file.
229 contrib/gennews > NEWS || \
230 error "Could not regenerate NEWS files"
232 # Now, we must build the compiler in order to create any generated
233 # files that are supposed to go in the source directory. This is
234 # also a good sanity check to make sure that the release builds
235 # on at least one platform.
236 inform "Building compiler"
237 OBJECT_DIRECTORY=../objdir
238 contrib/gcc_build -d ${SOURCE_DIRECTORY} -o ${OBJECT_DIRECTORY} \
239 -c "--enable-generated-files-in-srcdir" build || \
240 error "Could not rebuild GCC"
243 # Move message catalogs to source directory.
244 mv ../objdir/gcc/po/*.gmo gcc/po/
245 [ -f libcpp/po/cpplib.pot ] && mv ../objdir/libcpp/po/*.gmo libcpp/po/
247 # Create a "MD5SUMS" file to use for checking the validity of the release.
248 echo \
249 "# This file contains the MD5 checksums of the files in the
250 # gcc-"${RELEASE}".tar.bz2 tarball.
252 # Besides verifying that all files in the tarball were correctly expanded,
253 # it also can be used to determine if any files have changed since the
254 # tarball was expanded or to verify that a patchfile was correctly applied.
256 # Suggested usage:
257 # md5sum -c MD5SUMS | grep -v \"OK$\"
258 " > MD5SUMS
260 find . -type f |
261 sed -e 's:^\./::' -e '/MD5SUMS/d' |
262 sort |
263 xargs md5sum >>MD5SUMS
266 # Buid a single tarfile. The first argument is the name of the name
267 # of the tarfile to build, without any suffixes. They will be added
268 # automatically. The rest of the arguments are the files or
269 # directories to include, and possibly other arguments to tar.
271 build_tarfile() {
272 # Get the name of the destination tar file.
273 TARFILE="$1.tar.bz2"
274 shift
276 # Build the tar file itself.
277 (${TAR} cf - "$@" | ${BZIP2} > ${TARFILE}) || \
278 error "Could not build tarfile"
279 FILE_LIST="${FILE_LIST} ${TARFILE}"
282 # Build a single tarfile if any of the directories listed exist,
283 # but not if none of them do (because that component doesn't exist
284 # on this branch).
285 maybe_build_tarfile() {
286 dest=$1
287 shift
288 dir_exists=0
289 for maybe_dir in "$@"; do
290 if [ -d "$maybe_dir" ]; then
291 dir_exists=1
293 done
294 if [ $dir_exists = 1 ]; then
295 build_tarfile "$dest" "$@"
296 else
297 echo "Not building $dest tarfile"
301 # Build the various tar files for the release.
303 build_tarfiles() {
304 inform "Building tarfiles"
306 changedir "${WORKING_DIRECTORY}"
308 # The GNU Coding Standards specify that all files should
309 # world readable.
310 chmod -R a+r ${SOURCE_DIRECTORY}
311 # And that all directories have mode 777.
312 find ${SOURCE_DIRECTORY} -type d -exec chmod 777 {} \;
314 # Build one huge tarfile for the entire distribution.
315 build_tarfile gcc-${RELEASE} `basename ${SOURCE_DIRECTORY}`
317 # Now, build one for each of the languages.
318 maybe_build_tarfile gcc-ada-${RELEASE} ${ADA_DIRS}
319 maybe_build_tarfile gcc-g++-${RELEASE} ${CPLUSPLUS_DIRS}
320 maybe_build_tarfile gcc-g77-${RELEASE} ${FORTRAN_DIRS}
321 maybe_build_tarfile gcc-fortran-${RELEASE} ${FORTRAN95_DIRS}
322 maybe_build_tarfile gcc-java-${RELEASE} ${JAVA_DIRS}
323 maybe_build_tarfile gcc-objc-${RELEASE} ${OBJECTIVEC_DIRS}
324 maybe_build_tarfile gcc-testsuite-${RELEASE} ${TESTSUITE_DIRS}
326 # The core is everything else.
327 EXCLUDES=""
328 for x in ${ADA_DIRS} ${CPLUSPLUS_DIRS} ${FORTRAN_DIRS} ${FORTRAN95_DIRS}\
329 ${JAVA_DIRS} ${OBJECTIVEC_DIRS} ${TESTSUITE_DIRS}; do
330 EXCLUDES="${EXCLUDES} --exclude $x"
331 done
332 build_tarfile gcc-core-${RELEASE} ${EXCLUDES} \
333 `basename ${SOURCE_DIRECTORY}`
336 # Build .gz files.
337 build_gzip() {
338 for f in ${FILE_LIST}; do
339 target=${f%.bz2}.gz
340 (${BZIP2} -d -c $f | ${GZIP} > ${target}) || error "Could not create ${target}"
341 done
344 # Build diffs against an old release.
345 build_diffs() {
346 old_dir=${1%/*}
347 old_file=${1##*/}
348 old_vers=${old_file%.tar.bz2}
349 old_vers=${old_vers#gcc-}
350 inform "Building diffs against version $old_vers"
351 for f in gcc gcc-ada gcc-g++ gcc-g77 gcc-fortran gcc-java gcc-objc gcc-testsuite gcc-core; do
352 old_tar=${old_dir}/${f}-${old_vers}.tar.bz2
353 new_tar=${WORKING_DIRECTORY}/${f}-${RELEASE}.tar.bz2
354 if [ ! -e $old_tar ]; then
355 inform "$old_tar not found; not generating diff file"
356 elif [ ! -e $new_tar ]; then
357 inform "$new_tar not found; not generating diff file"
358 else
359 build_diff $old_tar gcc-${old_vers} $new_tar gcc-${RELEASE} \
360 ${f}-${old_vers}-${RELEASE}.diff.bz2
362 done
365 # Build an individual diff.
366 build_diff() {
367 changedir "${WORKING_DIRECTORY}"
368 tmpdir=gccdiff.$$
369 mkdir $tmpdir || error "Could not create directory $tmpdir"
370 changedir $tmpdir
371 (${BZIP2} -d -c $1 | ${TAR} xf - ) || error "Could not unpack $1 for diffs"
372 (${BZIP2} -d -c $3 | ${TAR} xf - ) || error "Could not unpack $3 for diffs"
373 ${DIFF} $2 $4 > ../${5%.bz2}
374 if [ $? -eq 2 ]; then
375 error "Trouble making diffs from $1 to $3"
377 ${BZIP2} ../${5%.bz2} || error "Could not generate ../$5"
378 changedir ..
379 rm -rf $tmpdir
380 FILE_LIST="${FILE_LIST} $5"
383 # Upload the files to the FTP server.
384 upload_files() {
385 inform "Uploading files"
387 changedir "${WORKING_DIRECTORY}"
389 # Make sure the directory exists on the server.
390 if [ $LOCAL -eq 0 ]; then
391 ${SSH} -l ${GCC_USERNAME} ${GCC_HOSTNAME} \
392 mkdir -p "${FTP_PATH}/diffs"
393 UPLOAD_PATH="${GCC_USERNAME}@${GCC_HOSTNAME}:${FTP_PATH}"
394 else
395 mkdir -p "${FTP_PATH}/diffs" \
396 || error "Could not create \`${FTP_PATH}'"
397 UPLOAD_PATH=${FTP_PATH}
400 # Then copy files to their respective (sub)directories.
401 for x in gcc*.gz gcc*.bz2; do
402 if [ -e ${x} ]; then
403 # Make sure the file will be readable on the server.
404 chmod a+r ${x}
405 # Copy it.
406 case ${x} in
407 *.diff.*)
408 SUBDIR="diffs/";
411 SUBDIR="";
412 esac
413 ${SCP} ${x} ${UPLOAD_PATH}/${SUBDIR} \
414 || error "Could not upload ${x}"
416 done
419 #Print description if snapshot exists
420 snapshot_print() {
421 if [ -e ${RELEASE}/$1 ]; then
422 printf "%-38s%s\n\n" "$1" "$2" >> ${SNAPSHOT_README}
423 echo " <tr><td><a href=\"$1\">$1</a></td>" >> ${SNAPSHOT_INDEX}
424 echo " <td>$2</td></tr>" >> ${SNAPSHOT_INDEX}
428 # Announce a snapshot, both on the web and via mail.
429 announce_snapshot() {
430 inform "Updating links and READMEs on the FTP server"
432 TEXT_DATE=`date --date=$DATE +%B\ %d,\ %Y`
433 SNAPSHOT_README=${RELEASE}/README
434 SNAPSHOT_INDEX=${RELEASE}/index.html
436 changedir "${SNAPSHOTS_DIR}"
437 echo \
438 "Snapshot gcc-"${RELEASE}" is now available on
439 ftp://gcc.gnu.org/pub/gcc/snapshots/"${RELEASE}"/
440 and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.
442 This snapshot has been generated from the GCC "${BRANCH}" SVN branch
443 with the following options: "svn://gcc.gnu.org/svn/gcc/${SVNBRANCH} revision ${SVNREV}"
445 You'll find:
446 " > ${SNAPSHOT_README}
448 echo \
449 "<html>
451 <head>
452 <title>GCC "${RELEASE}" Snapshot</title>
453 </head>
455 <body>
456 <h1>GCC "${RELEASE}" Snapshot</h1>
458 <p>The <a href =\"http://gcc.gnu.org/\">GCC Project</a> makes
459 periodic snapshots of the GCC source tree available to the public
460 for testing purposes.</p>
462 <p>If you are planning to download and use one of our snapshots, then
463 we highly recommend you join the GCC developers list. Details for
464 how to sign up can be found on the GCC project home page.</p>
466 <p>This snapshot has been generated from the GCC "${BRANCH}" SVN branch
467 with the following options: <code>"svn://gcc.gnu.org/svn/gcc/${SVNBRANCH} revision ${SVNREV}"</code></p>
469 <table>" > ${SNAPSHOT_INDEX}
471 snapshot_print gcc-${RELEASE}.tar.bz2 "Complete GCC (includes all of below)"
472 snapshot_print gcc-core-${RELEASE}.tar.bz2 "C front end and core compiler"
473 snapshot_print gcc-ada-${RELEASE}.tar.bz2 "Ada front end and runtime"
474 snapshot_print gcc-fortran-${RELEASE}.tar.bz2 "Fortran front end and runtime"
475 snapshot_print gcc-g++-${RELEASE}.tar.bz2 "C++ front end and runtime"
476 snapshot_print gcc-g77-${RELEASE}.tar.bz2 "Fortran 77 front end and runtime"
477 snapshot_print gcc-java-${RELEASE}.tar.bz2 "Java front end and runtime"
478 snapshot_print gcc-objc-${RELEASE}.tar.bz2 "Objective-C front end and runtime"
479 snapshot_print gcc-testsuite-${RELEASE}.tar.bz2 "The GCC testsuite"
481 echo \
482 "Diffs from "${BRANCH}"-"${LAST_DATE}" are available in the diffs/ subdirectory.
484 When a particular snapshot is ready for public consumption the LATEST-"${BRANCH}"
485 link is updated and a message is sent to the gcc list. Please do not use
486 a snapshot before it has been announced that way." >> ${SNAPSHOT_README}
488 echo \
489 "</table>
490 <p>Diffs from "${BRANCH}"-"${LAST_DATE}" are available in the
491 <a href=\"diffs/\">diffs/ subdirectory</a>.</p>
493 <p>When a particular snapshot is ready for public consumption the LATEST-"${BRANCH}"
494 link is updated and a message is sent to the gcc list. Please do not use
495 a snapshot before it has been announced that way.</p>
497 <hr />
499 <address>
500 <a href=\"mailto:gcc@gcc.gnu.org\">gcc@gcc.gnu.org</a>
501 <br />
502 Last modified "${TEXT_DATE}"
503 </address>
504 </body>
506 </html>" >> ${SNAPSHOT_INDEX}
508 rm -f LATEST-${BRANCH}
509 ln -s ${RELEASE} LATEST-${BRANCH}
511 inform "Sending mail"
513 export QMAILHOST=gcc.gnu.org
514 mail -s "gcc-${RELEASE} is now available" gcc@gcc.gnu.org < ${SNAPSHOT_README}
517 ########################################################################
518 # Initialization
519 ########################################################################
521 LC_ALL=C
522 export LC_ALL
524 # Today's date.
525 DATE=`date "+%Y%m%d"`
526 LONG_DATE=`date "+%Y-%m-%d"`
528 SVN=${SVN:-/usr/bin/svn}
529 # The CVS server containing the GCC repository.
530 SVN_SERVER="gcc.gnu.org"
531 # The path to the repository on that server.
532 SVN_REPOSITORY="/svn/gcc"
533 # The username to use when connecting to the server.
534 SVN_USERNAME="${USER}"
536 # The machine to which files will be uploaded.
537 GCC_HOSTNAME="gcc.gnu.org"
538 # The name of the account on the machine to which files are uploaded.
539 GCC_USERNAME="gccadmin"
540 # The directory in which the files will be placed (do not use ~user syntax).
541 FTP_PATH=/var/ftp/pub/gcc
542 # The directory in which snapshots will be placed.
543 SNAPSHOTS_DIR=${FTP_PATH}/snapshots
545 # The major number for the release. For release `3.0.2' this would be
546 # `3'
547 RELEASE_MAJOR=""
548 # The minor number for the release. For release `3.0.2' this would be
549 # `0'.
550 RELEASE_MINOR=""
551 # The revision number for the release. For release `3.0.2' this would
552 # be `2'.
553 RELEASE_REVISION=""
554 # The complete name of the release.
555 RELEASE=""
557 # The name of the branch from which the release should be made, in a
558 # user-friendly form.
559 BRANCH=""
561 # The name of the branch from which the release should be made, as used
562 # for our version control system.
563 SVNBRANCH=""
565 # The tag to apply to the sources used for the release.
566 TAG=""
568 # The old tarballs from which to generate diffs.
569 OLD_TARS=""
571 # The directory that will be used to construct the release. The
572 # release itself will be placed in a subdirectory of this diretory.
573 DESTINATION=${HOME}
574 # The subdirectory.
575 WORKING_DIRECTORY=""
576 # The directory that will contain the GCC sources.
577 SOURCE_DIRECTORY=""
579 # The directories that should be part of the various language-specific
580 # tar files. These are all relative to the top of the source tree.
581 ADA_DIRS="gcc/ada libada gnattools"
582 CPLUSPLUS_DIRS="gcc/cp libstdc++-v3"
583 FORTRAN_DIRS="gcc/f libf2c"
584 FORTRAN95_DIRS="gcc/fortran libgfortran"
585 JAVA_DIRS="gcc/java libjava libffi fastjar zlib boehm-gc"
586 OBJECTIVEC_DIRS="gcc/objc libobjc"
587 TESTSUITE_DIRS="gcc/testsuite"
589 # Non-zero if this is the final release, rather than a prerelease.
590 FINAL=0
592 # Non-zero if we are building a snapshot, and don't build gcc or
593 # include generated files.
594 SNAPSHOT=0
596 # Non-zero if we are running locally on gcc.gnu.org, and use local CVS
597 # and copy directly to the FTP directory.
598 LOCAL=0
600 # Major operation modes.
601 MODE_GZIP=0
602 MODE_DIFFS=0
603 MODE_SOURCES=0
604 MODE_TARFILES=0
605 MODE_UPLOAD=0
607 # List of archive files generated; used to create .gz files from .bz2.
608 FILE_LIST=""
610 # Programs we use.
612 BZIP2="${BZIP2:-bzip2}"
613 CVS="${CVS:-cvs -f -Q -z9}"
614 DIFF="${DIFF:-diff -Nrcpad}"
615 ENV="${ENV:-env}"
616 GZIP="${GZIP:-gzip --best}"
617 SCP="${SCP:-scp -p}"
618 SSH="${SSH:-ssh}"
619 TAR="${TAR:-tar}"
621 ########################################################################
622 # Command Line Processing
623 ########################################################################
625 # Parse the options.
626 while getopts "d:fr:u:t:p:s:l" ARG; do
627 case $ARG in
628 d) DESTINATION="${OPTARG}";;
629 r) RELEASE="${OPTARG}";;
630 t) TAG="${OPTARG}";;
631 u) SVN_USERNAME="${OPTARG}";;
632 f) FINAL=1;;
633 s) SNAPSHOT=1
634 BRANCH=${OPTARG%:*}
635 SVNBRANCH=${OPTARG#*:}
637 l) LOCAL=1
638 SCP=cp
639 PATH=~:/usr/local/bin:$PATH;;
640 p) OLD_TARS="${OLD_TARS} ${OPTARG}"
641 if [ ! -f ${OPTARG} ]; then
642 error "-p argument must name a tarball"
643 fi;;
644 \?) usage;;
645 esac
646 done
647 shift `expr ${OPTIND} - 1`
649 # Handle the major modes.
650 while [ $# -ne 0 ]; do
651 case $1 in
652 diffs) MODE_DIFFS=1;;
653 gzip) MODE_GZIP=1;;
654 sources) MODE_SOURCES=1;;
655 tarfiles) MODE_TARFILES=1;;
656 upload) MODE_UPLOAD=1;;
657 all) MODE_SOURCES=1; MODE_TARFILES=1; MODE_DIFFS=1; MODE_UPLOAD=1;
658 if [ $SNAPSHOT -ne 1 ]; then
659 # Only for releases and pre-releases.
660 MODE_GZIP=1;
663 *) error "Unknown mode $1";;
664 esac
665 shift
666 done
668 # Perform consistency checking.
669 if [ ${LOCAL} -eq 0 ] && [ -z ${SVN_USERNAME} ]; then
670 error "No username specified"
673 if [ ! -d ${DESTINATION} ]; then
674 error "\`${DESTINATION}' is not a directory"
677 if [ $SNAPSHOT -eq 0 ]; then
678 if [ -z ${RELEASE} ]; then
679 error "No release number specified"
682 # Compute the major and minor release numbers.
683 RELEASE_MAJOR=`echo $RELEASE | awk --assign FS=. '{ print $1; }'`
684 RELEASE_MINOR=`echo $RELEASE | awk --assign FS=. '{ print $2; }'`
685 RELEASE_REVISION=`echo $RELEASE | awk --assign FS=. '{ print $3; }'`
687 if [ -z "${RELEASE_MAJOR}" ] || [ -z "${RELEASE_MINOR}" ]; then
688 error "Release number \`${RELEASE}' is invalid"
691 # Compute the full name of the release.
692 if [ -z "${RELEASE_REVISION}" ]; then
693 RELEASE="${RELEASE_MAJOR}.${RELEASE_MINOR}"
694 else
695 RELEASE="${RELEASE_MAJOR}.${RELEASE_MINOR}.${RELEASE_REVISION}"
698 # Compute the name of the branch, which is based solely on the major
699 # and minor release numbers.
700 SVNBRANCH="branches/gcc-${RELEASE_MAJOR}_${RELEASE_MINOR}-branch"
702 # If this is not a final release, set various parameters acordingly.
703 if [ ${FINAL} -ne 1 ]; then
704 RELEASE="${RELEASE}-${DATE}"
705 FTP_PATH="${FTP_PATH}/prerelease-${RELEASE}/"
706 else
707 FTP_PATH="${FTP_PATH}/releases/gcc-${RELEASE}/"
709 else
710 RELEASE=${BRANCH}-${DATE}
711 FTP_PATH="${FTP_PATH}/snapshots/${RELEASE}"
713 # If diffs are requested when building locally on gcc.gnu.org, we (usually)
714 # know what the last snapshot date was and take the corresponding tarballs,
715 # unless the user specified tarballs explictly.
716 if [ $MODE_DIFFS -ne 0 ] && [ $LOCAL -ne 0 ] && [ -z "${OLD_TARS}" ]; then
717 LAST_DATE=`cat ~/.snapshot_date-${BRANCH}`
718 OLD_TARS=${SNAPSHOTS_DIR}/${BRANCH}-${LAST_DATE}/gcc-${BRANCH}-${LAST_DATE}.tar.bz2
722 # Compute the name of the WORKING_DIRECTORY and the SOURCE_DIRECTORY.
723 WORKING_DIRECTORY="${DESTINATION}/gcc-${RELEASE}"
724 SOURCE_DIRECTORY="${WORKING_DIRECTORY}/gcc-${RELEASE}"
726 # Recompute the names of all the language-specific directories,
727 # relative to the WORKING_DIRECTORY.
728 ADA_DIRS=`adjust_dirs ${ADA_DIRS}`
729 CPLUSPLUS_DIRS=`adjust_dirs ${CPLUSPLUS_DIRS}`
730 FORTRAN_DIRS=`adjust_dirs ${FORTRAN_DIRS}`
731 FORTRAN95_DIRS=`adjust_dirs ${FORTRAN95_DIRS}`
732 JAVA_DIRS=`adjust_dirs ${JAVA_DIRS}`
733 OBJECTIVEC_DIRS=`adjust_dirs ${OBJECTIVEC_DIRS}`
734 TESTSUITE_DIRS=`adjust_dirs ${TESTSUITE_DIRS}`
736 # Set up SVNROOT.
737 if [ $LOCAL -eq 0 ]; then
738 SVNROOT="svn+ssh://${SVN_USERNAME}@${SVN_SERVER}${SVN_REPOSITORY}"
739 CVSROOT=":ext:${SVN_USERNAME}@gcc.gnu.org/cvs/gcc"
740 else
741 SVNROOT="file:///svn/gcc"
742 CVSROOT="/cvs/gcc"
744 export SVNROOT
745 export CVSROOT
747 ########################################################################
748 # Main Program
749 ########################################################################
751 # Set the timezone to UTC
752 TZ="UTC0"
753 export TZ
755 # Build the source directory.
757 if [ $MODE_SOURCES -ne 0 ]; then
758 build_sources
761 # Build the tar files.
763 if [ $MODE_TARFILES -ne 0 ]; then
764 build_tarfiles
767 # Build diffs
769 if [ $MODE_DIFFS -ne 0 ]; then
770 # Possibly build diffs.
771 if [ -n "$OLD_TARS" ]; then
772 for old_tar in $OLD_TARS; do
773 build_diffs $old_tar
774 done
778 # Build gzip files
779 if [ $MODE_GZIP -ne 0 ]; then
780 build_gzip
783 # Upload them to the FTP server.
784 if [ $MODE_UPLOAD -ne 0 ]; then
785 upload_files
787 # For snapshots, make some further updates.
788 if [ $SNAPSHOT -ne 0 ] && [ $LOCAL -ne 0 ]; then
789 announce_snapshot
791 # Update snapshot date file.
792 changedir ~
793 echo $DATE > .snapshot_date-${BRANCH}
795 # Remove working directory
796 rm -rf ${WORKING_DIRECTORY}