target-supports.exp (check_effective_target_weak_undefined): Return 0 on hppa*-*...
[official-gcc.git] / maintainer-scripts / gcc_release
blobbfb6b037bb16aa183820d4813ba6e0db4ad798ef
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-2018 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 3, 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 COPYING3. If not see
28 # <http://www.gnu.org/licenses/>.
30 ########################################################################
32 ########################################################################
33 # Notes
34 ########################################################################
36 # Here is an example usage of this script, to create a GCC 3.0.2
37 # prerelease:
39 # gcc_release -r 3.0.2
41 # This script will automatically use the head of the release branch
42 # to generate the release.
44 ########################################################################
45 # Functions
46 ########################################################################
48 # Issue the error message given by $@ and exit with a non-zero
49 # exit code.
51 error() {
52 echo "gcc_release: error: $@"
53 exit 1
56 # Issue the informational message given by $@.
58 inform() {
59 echo "gcc_release: $@"
62 # Issue a usage message explaining how to use this script.
64 usage() {
65 cat <<EOF
66 gcc_release -r release [-f] [further options]
67 gcc_release -s name:svnbranch [further options]
69 Options:
71 -r release Version of the form X.Y or X.Y.Z.
72 -s name:svnbranch Create a snapshot, not a real release.
74 -d destination Local working directory where we will build the release
75 (default=${HOME}).
76 -f Create a final release (and update ChangeLogs,...).
77 -l Indicate that we are running on gcc.gnu.org.
78 -p previous-tarball Location of a previous tarball (to generate diff files).
79 -t tag Tag to mark the release in SVN.
80 -u username Username for upload operations.
81 EOF
82 exit 1
85 # Change to the directory given by $1.
87 changedir() {
88 cd $1 || \
89 error "Could not change directory to $1"
92 # Build the source tree that will be the basis for the release
93 # in ${WORKING_DIRECTORY}/gcc-${RELEASE}.
95 build_sources() {
96 # If the WORKING_DIRECTORY already exists, do not risk destroying it.
97 if [ -r ${WORKING_DIRECTORY} ]; then
98 error "\`${WORKING_DIRECTORY}' already exists"
100 # Create the WORKING_DIRECTORY.
101 mkdir "${WORKING_DIRECTORY}" \
102 || error "Could not create \`${WORKING_DIRECTORY}'"
103 changedir "${WORKING_DIRECTORY}"
105 # If this is a final release, make sure that the ChangeLogs
106 # and version strings are updated.
107 if [ ${FINAL} -ne 0 ]; then
108 inform "Updating ChangeLogs and version files"
110 ${SVN} -q co "${SVNROOT}/${SVNBRANCH}" "`basename ${SOURCE_DIRECTORY}`" ||\
111 error "Could not check out release sources"
113 grep -q "gcc-${RELEASE_MAJOR}/index.html gcc-${RELEASE_MAJOR}/changes.html" \
114 ${SOURCE_DIRECTORY}/contrib/gennews ||\
115 error "New release not listed in contrib/gennews"
117 ${SOURCE_DIRECTORY}/contrib/gennews > NEWS ||\
118 error "Could not regenerate NEWS files"
120 grep -q "no releases of GCC ${RELEASE_MAJOR} have yet been made" NEWS &&\
121 error "gcc-${RELEASE_MAJOR}/index.html has not been updated yet"
123 grep -q "GCC ${RELEASE_MAJOR} has not been released yet" NEWS &&\
124 error "gcc-${RELEASE_MAJOR}/changes.html has not been updated yet"
126 thisindex="http:\/\/gcc.gnu.org\/gcc-${RELEASE_MAJOR}\/index.html"
127 thischanges="http:\/\/gcc.gnu.org\/gcc-${RELEASE_MAJOR}\/changes.html"
128 previndex="http:\/\/gcc.gnu.org\/gcc-`expr ${RELEASE_MAJOR} - 1`\/index.html"
129 sed -n -e "/^${thisindex}/,/^${thischanges}/p" NEWS |\
130 sed -n -e "/Release History/,/References and Acknowledgments/p" |\
131 grep -q "^[[:blank:]]*GCC ${RELEASE_MAJOR}.${RELEASE_MINOR}" ||\
132 error "GCC ${RELEASE_MAJOR}.${RELEASE_MINOR} not mentioned "\
133 "in gcc-${RELEASE_MAJOR}/index.html"
135 sed -n -e "/^${thischanges}/,/^${previndex}/p" NEWS |\
136 grep -q "^[[:blank:]]*GCC ${RELEASE_MAJOR}.${RELEASE_MINOR}" ||\
137 error "GCC ${RELEASE_MAJOR}.${RELEASE_MINOR} not mentioned "\
138 "in gcc-${RELEASE_MAJOR}/changes.html"
140 rm -f NEWS
142 svnciargs=""
143 for x in `changedir ${SOURCE_DIRECTORY} && \
144 find . -name ChangeLog`; do
145 # Update this ChangeLog file only if it does not yet contain the
146 # entry we are going to add. (This is a safety net for repeated
147 # runs of this script for the same release.)
148 if ! grep "GCC ${RELEASE} released." ${SOURCE_DIRECTORY}/${x} > /dev/null ; then
149 cat - ${SOURCE_DIRECTORY}/${x} > ${SOURCE_DIRECTORY}/${x}.new <<EOF
150 ${LONG_DATE} Release Manager
152 * GCC ${RELEASE} released.
155 mv ${SOURCE_DIRECTORY}/${x}.new ${SOURCE_DIRECTORY}/${x} \
156 || error "Could not update ${x}"
157 svnciargs="${svnciargs} ${x}"
159 done
161 # Update gcc/DEV-PHASE.
163 if [ `cat ${SOURCE_DIRECTORY}/gcc/BASE-VER` != ${RELEASE} ]; then
164 [ ${RELEASE_MAJOR} -lt 5 ] && \
165 error "Release number ${RELEASE} does not match BASE-VER"
166 if [ `cat ${SOURCE_DIRECTORY}/gcc/BASE-VER` \
167 = ${RELEASE_MAJOR}.`expr ${RELEASE_MINOR} - 1`.1 \
168 -a x${RELEASE_REVISION} = x0 ]; then
169 (changedir ${SOURCE_DIRECTORY}/gcc && \
170 echo ${RELEASE} > BASE-VER) || \
171 error "Could not update BASE-VER"
172 svnciargs="${svnciargs} gcc/BASE-VER"
173 else
174 error "Release number ${RELEASE} does not immediately follow BASE-VER"
177 (changedir ${SOURCE_DIRECTORY}/gcc && \
178 : > DEV-PHASE) || \
179 error "Could not update DEV-PHASE"
180 svnciargs="${svnciargs} gcc/DEV-PHASE"
182 (changedir ${SOURCE_DIRECTORY} && \
183 ${SVN} -q ci -m 'Update ChangeLog and version files for release' ${svnciargs}) || \
184 error "Could not commit ChangeLog and version file updates"
186 # Make sure we tag the sources for a final release.
187 TAG="tags/gcc_`echo ${RELEASE} | tr . _`_release"
189 rm -rf ${SOURCE_DIRECTORY}
192 # Tag the sources.
193 if [ -n "${TAG}" ]; then
194 inform "Tagging sources as ${TAG}"
195 # We don't want to overwrite an existing tag. So, if the tag
196 # already exists, issue an error message; the release manager can
197 # manually remove the tag if appropriate.
198 echo "${SVN} ls ${SVNROOT}/${TAG}/ChangeLog"
199 if ${SVN} ls "${SVNROOT}/${TAG}/ChangeLog"; then
200 error "Tag ${TAG} already exists"
202 ${SVN} -m "Tagging source as ${TAG}" cp "${SVNROOT}/${SVNBRANCH}" "${SVNROOT}/${TAG}" || \
203 error "Could not tag sources"
204 SVNBRANCH=${TAG}
206 SVNREV=`${SVN} info "${SVNROOT}/${SVNBRANCH}"|awk '/Revision:/ {print $2}'`
208 # Export the current sources.
209 inform "Retrieving sources (svn export -r ${SVNREV} ${SVNROOT}/${SVNBRANCH})"
211 ${SVN} -q export -r${SVNREV} "${SVNROOT}/${SVNBRANCH}" "`basename ${SOURCE_DIRECTORY}`" ||\
212 error "Could not retrieve sources"
214 # Run gcc_update on them to set up the timestamps nicely, and (re)write
215 # the LAST_UPDATED file containing the SVN tag/revision used.
216 changedir "gcc-${RELEASE}"
217 contrib/gcc_update --touch
218 echo "Obtained from SVN: ${SVNBRANCH} revision ${SVNREV}" > LAST_UPDATED
220 # For a prerelease or real release, we need to generate additional
221 # files not present in SVN.
222 changedir "${SOURCE_DIRECTORY}"
223 if [ $SNAPSHOT -ne 1 ]; then
224 # Generate the documentation.
225 inform "Building install docs"
226 SOURCEDIR=${SOURCE_DIRECTORY}/gcc/doc
227 DESTDIR=${SOURCE_DIRECTORY}/INSTALL
228 export SOURCEDIR
229 export DESTDIR
230 ${SOURCE_DIRECTORY}/gcc/doc/install.texi2html
232 # Regenerate the NEWS file.
233 contrib/gennews > NEWS || \
234 error "Could not regenerate NEWS files"
236 # Now, we must build the compiler in order to create any generated
237 # files that are supposed to go in the source directory. This is
238 # also a good sanity check to make sure that the release builds
239 # on at least one platform.
240 inform "Building compiler"
241 OBJECT_DIRECTORY=../objdir
242 num_cpus=1
243 if type -p getconf 2>/dev/null; then
244 num_cpus=`getconf _NPROCESSORS_ONLN 2>/dev/null`
245 case "$num_cpus" in
246 '' | 0* | *[!0-9]*) num_cpus=1;;
247 esac
249 contrib/gcc_build -d ${SOURCE_DIRECTORY} -o ${OBJECT_DIRECTORY} \
250 -c "--enable-generated-files-in-srcdir --disable-multilib" \
251 -m "-j$num_cpus" build || \
252 error "Could not rebuild GCC"
255 # Move message catalogs to source directory.
256 mv ../objdir/gcc/po/*.gmo gcc/po/
257 [ -f libcpp/po/cpplib.pot ] && mv ../objdir/libcpp/po/*.gmo libcpp/po/
259 # Create a "MD5SUMS" file to use for checking the validity of the release.
260 echo \
261 "# This file contains the MD5 checksums of the files in the
262 # gcc-"${RELEASE}".tar.xz tarball.
264 # Besides verifying that all files in the tarball were correctly expanded,
265 # it also can be used to determine if any files have changed since the
266 # tarball was expanded or to verify that a patchfile was correctly applied.
268 # Suggested usage:
269 # md5sum -c MD5SUMS | grep -v \"OK$\"
270 #" > MD5SUMS
272 find . -type f |
273 sed -e 's:^\./::' -e '/MD5SUMS/d' |
274 sort |
275 xargs md5sum >>MD5SUMS
278 # Build a single tarfile. The first argument is the name of the tarfile
279 # to build, without any suffixes. They will be added automatically. The
280 # rest of the arguments are files or directories to include, and possibly
281 # other arguments to tar.
283 build_tarfile() {
284 # Get the name of the destination tar file.
285 TARFILE="$1.tar.xz"
286 shift
288 # Build the tar file itself.
289 (${TAR} cf - "$@" | ${XZ} > ${TARFILE}) || \
290 error "Could not build tarfile"
291 FILE_LIST="${FILE_LIST} ${TARFILE}"
294 # Build the various tar files for the release.
296 build_tarfiles() {
297 inform "Building tarfiles"
299 changedir "${WORKING_DIRECTORY}"
301 # The GNU Coding Standards specify that all files should
302 # world readable.
303 chmod -R a+r ${SOURCE_DIRECTORY}
304 # And that all directories have mode 755.
305 find ${SOURCE_DIRECTORY} -type d -exec chmod 755 {} \;
307 # Build one huge tarfile for the entire distribution.
308 build_tarfile gcc-${RELEASE} `basename ${SOURCE_DIRECTORY}`
311 # Build .gz files.
312 build_gzip() {
313 for f in ${FILE_LIST}; do
314 target=${f%.xz}.gz
315 (${XZ} -d -c $f | ${GZIP} > ${target}) || error "Could not create ${target}"
316 done
319 # Build diffs against an old release.
320 build_diffs() {
321 old_dir=${1%/*}
322 old_file=${1##*/}
323 case "$old_file" in
324 *.tar.xz) old_vers=${old_file%.tar.xz};;
325 *) old_vers=${old_file%.tar.bz2};;
326 esac
327 old_vers=${old_vers#gcc-}
328 inform "Building diffs against version $old_vers"
329 for f in gcc; do
330 if [ -e ${old_dir}/${f}-${old_vers}.tar.xz ]; then
331 old_tar=${old_dir}/${f}-${old_vers}.tar.xz
332 else
333 old_tar=${old_dir}/${f}-${old_vers}.tar.bz2
335 new_tar=${WORKING_DIRECTORY}/${f}-${RELEASE}.tar.xz
336 if [ ! -e $old_tar ]; then
337 inform "$old_tar not found; not generating diff file"
338 elif [ ! -e $new_tar ]; then
339 inform "$new_tar not found; not generating diff file"
340 else
341 build_diff $old_tar gcc-${old_vers} $new_tar gcc-${RELEASE} \
342 ${f}-${old_vers}-${RELEASE}.diff.xz
344 done
347 # Build an individual diff.
348 build_diff() {
349 changedir "${WORKING_DIRECTORY}"
350 tmpdir=gccdiff.$$
351 mkdir $tmpdir || error "Could not create directory $tmpdir"
352 changedir $tmpdir
353 case "$1" in
354 *.tar.bz2)
355 (${BZIP2} -d -c $1 | ${TAR} xf - ) || error "Could not unpack $1 for diffs"
357 *.tar.xz)
358 (${XZ} -d -c $1 | ${TAR} xf - ) || error "Could not unpack $1 for diffs"
360 esac
361 (${XZ} -d -c $3 | ${TAR} xf - ) || error "Could not unpack $3 for diffs"
362 ${DIFF} $2 $4 > ../${5%.xz}
363 if [ $? -eq 2 ]; then
364 error "Trouble making diffs from $1 to $3"
366 ${XZ} ../${5%.xz} || error "Could not generate ../$5"
367 changedir ..
368 rm -rf $tmpdir
369 FILE_LIST="${FILE_LIST} $5"
372 # Upload the files to the FTP server.
373 upload_files() {
374 inform "Uploading files"
376 changedir "${WORKING_DIRECTORY}"
378 # Make sure the directory exists on the server.
379 if [ $LOCAL -eq 0 ]; then
380 ${SSH} -l ${GCC_USERNAME} ${GCC_HOSTNAME} \
381 mkdir -p "${FTP_PATH}/diffs"
382 UPLOAD_PATH="${GCC_USERNAME}@${GCC_HOSTNAME}:${FTP_PATH}"
383 else
384 mkdir -p "${FTP_PATH}/diffs" \
385 || error "Could not create \`${FTP_PATH}'"
386 UPLOAD_PATH=${FTP_PATH}
389 # Then copy files to their respective (sub)directories.
390 for x in gcc*.gz gcc*.xz; do
391 if [ -e ${x} ]; then
392 # Make sure the file will be readable on the server.
393 chmod a+r ${x}
394 # Copy it.
395 case ${x} in
396 *.diff.*)
397 SUBDIR="diffs/";
400 SUBDIR="";
401 esac
402 ${SCP} ${x} ${UPLOAD_PATH}/${SUBDIR} \
403 || error "Could not upload ${x}"
405 done
408 # Print description if snapshot exists.
409 snapshot_print() {
410 if [ -e ${RELEASE}/$1 ]; then
411 hash=`openssl sha256 ${RELEASE}/$1 | sed -e 's#(.*)##' -e 's# *= *#=#'`
412 hash2=`openssl sha1 ${RELEASE}/$1 | sed -e 's#(.*)##' -e 's# *= *#=#'`
414 printf " %-37s%s\n\n %s\n %s\n\n" "$1" "$2" "$hash" "$hash2" \
415 >> ${SNAPSHOT_README}
417 echo " <tr><td><a href=\"$1\">$1</a></td>" >> ${SNAPSHOT_INDEX}
418 echo " <td>$2</td></tr>" >> ${SNAPSHOT_INDEX}
422 # Announce a snapshot, both on the web and via mail.
423 announce_snapshot() {
424 inform "Updating links and READMEs on the FTP server"
426 TEXT_DATE=`date --date=$DATE +%B\ %d,\ %Y`
427 SNAPSHOT_README=${RELEASE}/README
428 SNAPSHOT_INDEX=${RELEASE}/index.html
430 changedir "${SNAPSHOTS_DIR}"
431 echo \
432 "Snapshot gcc-"${RELEASE}" is now available on
433 ftp://gcc.gnu.org/pub/gcc/snapshots/"${RELEASE}"/
434 and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.
436 This snapshot has been generated from the GCC "${BRANCH}" SVN branch
437 with the following options: "svn://gcc.gnu.org/svn/gcc/${SVNBRANCH} revision ${SVNREV}"
439 You'll find:
440 " > ${SNAPSHOT_README}
442 echo \
443 "<html>
445 <head>
446 <title>GCC "${RELEASE}" Snapshot</title>
447 </head>
449 <body>
450 <h1>GCC "${RELEASE}" Snapshot</h1>
452 <p>The <a href =\"http://gcc.gnu.org/\">GCC Project</a> makes
453 periodic snapshots of the GCC source tree available to the public
454 for testing purposes.</p>
456 <p>If you are planning to download and use one of our snapshots, then
457 we highly recommend you join the GCC developers list. Details for
458 how to sign up can be found on the GCC project home page.</p>
460 <p>This snapshot has been generated from the GCC "${BRANCH}" SVN branch
461 with the following options: <code>"svn://gcc.gnu.org/svn/gcc/${SVNBRANCH} revision ${SVNREV}"</code></p>
463 <table>" > ${SNAPSHOT_INDEX}
465 snapshot_print gcc-${RELEASE}.tar.xz "Complete GCC"
467 echo \
468 "Diffs from "${BRANCH}"-"${LAST_DATE}" are available in the diffs/ subdirectory.
470 When a particular snapshot is ready for public consumption the LATEST-"${BRANCH}"
471 link is updated and a message is sent to the gcc list. Please do not use
472 a snapshot before it has been announced that way." >> ${SNAPSHOT_README}
474 echo \
475 "</table>
476 <p>Diffs from "${BRANCH}"-"${LAST_DATE}" are available in the
477 <a href=\"diffs/\">diffs/ subdirectory</a>.</p>
479 <p>When a particular snapshot is ready for public consumption the LATEST-"${BRANCH}"
480 link is updated and a message is sent to the gcc list. Please do not use
481 a snapshot before it has been announced that way.</p>
483 <hr />
485 <address>
486 <a href=\"mailto:gcc@gcc.gnu.org\">gcc@gcc.gnu.org</a>
487 <br />
488 Last modified "${TEXT_DATE}"
489 </address>
490 </body>
492 </html>" >> ${SNAPSHOT_INDEX}
494 rm -f LATEST-${BRANCH}
495 ln -s ${RELEASE} LATEST-${BRANCH}
497 inform "Sending mail"
499 export QMAILHOST=gcc.gnu.org
500 mail -s "gcc-${RELEASE} is now available" gcc@gcc.gnu.org < ${SNAPSHOT_README}
503 ########################################################################
504 # Initialization
505 ########################################################################
507 LC_ALL=C
508 export LC_ALL
510 # Today's date.
511 DATE=`date "+%Y%m%d"`
512 LONG_DATE=`date "+%Y-%m-%d"`
514 SVN=${SVN:-svn}
515 # The CVS server containing the GCC repository.
516 SVN_SERVER="gcc.gnu.org"
517 # The path to the repository on that server.
518 SVN_REPOSITORY="/svn/gcc"
519 # The username to use when connecting to the server.
520 SVN_USERNAME="${USER}"
522 # The machine to which files will be uploaded.
523 GCC_HOSTNAME="gcc.gnu.org"
524 # The name of the account on the machine to which files are uploaded.
525 GCC_USERNAME="gccadmin"
526 # The directory in which the files will be placed (do not use ~user syntax).
527 FTP_PATH=/var/ftp/pub/gcc
528 # The directory in which snapshots will be placed.
529 SNAPSHOTS_DIR=${FTP_PATH}/snapshots
531 # The major number for the release. For release `3.0.2' this would be
532 # `3'
533 RELEASE_MAJOR=""
534 # The minor number for the release. For release `3.0.2' this would be
535 # `0'.
536 RELEASE_MINOR=""
537 # The revision number for the release. For release `3.0.2' this would
538 # be `2'.
539 RELEASE_REVISION=""
540 # The complete name of the release.
541 RELEASE=""
543 # The name of the branch from which the release should be made, in a
544 # user-friendly form.
545 BRANCH=""
547 # The name of the branch from which the release should be made, as used
548 # for our version control system.
549 SVNBRANCH=""
551 # The tag to apply to the sources used for the release.
552 TAG=""
554 # The old tarballs from which to generate diffs.
555 OLD_TARS=""
557 # The directory that will be used to construct the release. The
558 # release itself will be placed in a subdirectory of this directory.
559 DESTINATION=${HOME}
560 # The subdirectory.
561 WORKING_DIRECTORY=""
562 # The directory that will contain the GCC sources.
563 SOURCE_DIRECTORY=""
565 # Non-zero if this is the final release, rather than a prerelease.
566 FINAL=0
568 # Non-zero if we are building a snapshot, and don't build gcc or
569 # include generated files.
570 SNAPSHOT=0
572 # Non-zero if we are running locally on gcc.gnu.org, and use local CVS
573 # and copy directly to the FTP directory.
574 LOCAL=0
576 # Major operation modes.
577 MODE_GZIP=0
578 MODE_DIFFS=0
579 MODE_SOURCES=0
580 MODE_TARFILES=0
581 MODE_UPLOAD=0
583 # List of archive files generated; used to create .gz files from .xz.
584 FILE_LIST=""
586 # Programs we use.
588 BZIP2="${BZIP2:-bzip2}"
589 XZ="${XZ:-xz --best}"
590 CVS="${CVS:-cvs -f -Q -z9}"
591 DIFF="${DIFF:-diff -Nrcpad}"
592 ENV="${ENV:-env}"
593 GZIP="${GZIP:-gzip --best}"
594 SCP="${SCP:-scp -p}"
595 SSH="${SSH:-ssh}"
596 TAR="${TAR:-tar}"
598 ########################################################################
599 # Command Line Processing
600 ########################################################################
602 # Parse the options.
603 while getopts "d:fr:u:t:p:s:l" ARG; do
604 case $ARG in
605 d) DESTINATION="${OPTARG}";;
606 r) RELEASE="${OPTARG}";;
607 t) TAG="${OPTARG}";;
608 u) SVN_USERNAME="${OPTARG}";;
609 f) FINAL=1;;
610 s) SNAPSHOT=1
611 BRANCH=${OPTARG%:*}
612 SVNBRANCH=${OPTARG#*:}
614 l) LOCAL=1
615 SCP=cp
616 PATH=~:/usr/local/bin:$PATH;;
617 p) OLD_TARS="${OLD_TARS} ${OPTARG}"
618 if [ ! -f ${OPTARG} ]; then
619 error "-p argument must name a tarball"
620 fi;;
621 \?) usage;;
622 esac
623 done
624 shift `expr ${OPTIND} - 1`
626 # Handle the major modes.
627 while [ $# -ne 0 ]; do
628 case $1 in
629 diffs) MODE_DIFFS=1;;
630 gzip) MODE_GZIP=1;;
631 sources) MODE_SOURCES=1;;
632 tarfiles) MODE_TARFILES=1;;
633 upload) MODE_UPLOAD=1;;
634 all) MODE_SOURCES=1; MODE_TARFILES=1; MODE_DIFFS=1; MODE_UPLOAD=1;
635 if [ $SNAPSHOT -ne 1 ]; then
636 # Only for releases and pre-releases.
637 MODE_GZIP=1;
640 *) error "Unknown mode $1";;
641 esac
642 shift
643 done
645 # Perform consistency checking.
646 if [ ${LOCAL} -eq 0 ] && [ -z ${SVN_USERNAME} ]; then
647 error "No username specified"
650 if [ ! -d ${DESTINATION} ]; then
651 error "\`${DESTINATION}' is not a directory"
654 if [ $SNAPSHOT -eq 0 ]; then
655 if [ -z ${RELEASE} ]; then
656 error "No release number specified"
659 # Compute the major and minor release numbers.
660 RELEASE_MAJOR=`echo $RELEASE | awk --assign FS=. '{ print $1; }'`
661 RELEASE_MINOR=`echo $RELEASE | awk --assign FS=. '{ print $2; }'`
662 RELEASE_REVISION=`echo $RELEASE | awk --assign FS=. '{ print $3; }'`
664 if [ -z "${RELEASE_MAJOR}" ] || [ -z "${RELEASE_MINOR}" ]; then
665 error "Release number \`${RELEASE}' is invalid"
668 # Compute the full name of the release.
669 if [ -z "${RELEASE_REVISION}" ]; then
670 RELEASE="${RELEASE_MAJOR}.${RELEASE_MINOR}"
671 else
672 RELEASE="${RELEASE_MAJOR}.${RELEASE_MINOR}.${RELEASE_REVISION}"
675 # Compute the name of the branch, which is based solely on the major
676 # and minor release numbers.
677 if [ ${RELEASE_MAJOR} -ge 5 ]; then
678 SVNBRANCH="branches/gcc-${RELEASE_MAJOR}-branch"
679 else
680 SVNBRANCH="branches/gcc-${RELEASE_MAJOR}_${RELEASE_MINOR}-branch"
683 # If this is not a final release, set various parameters accordingly.
684 if [ ${FINAL} -ne 1 ]; then
685 RELEASE="${RELEASE}-RC-${DATE}"
686 FTP_PATH="${SNAPSHOTS_DIR}/${RELEASE}"
687 else
688 FTP_PATH="${FTP_PATH}/releases/gcc-${RELEASE}/"
690 else
691 RELEASE=${BRANCH}-${DATE}
692 FTP_PATH="${FTP_PATH}/snapshots/${RELEASE}"
694 # If diffs are requested when building locally on gcc.gnu.org, we (usually)
695 # know what the last snapshot date was and take the corresponding tarballs,
696 # unless the user specified tarballs explicitly.
697 if [ $MODE_DIFFS -ne 0 ] && [ $LOCAL -ne 0 ] && [ -z "${OLD_TARS}" ]; then
698 LAST_DATE=`cat ~/.snapshot_date-${BRANCH}`
699 OLD_TARS=${SNAPSHOTS_DIR}/${BRANCH}-${LAST_DATE}/gcc-${BRANCH}-${LAST_DATE}.tar.bz2
700 if [ ! -e $OLD_TARS ]; then
701 OLD_TARS=${SNAPSHOTS_DIR}/${BRANCH}-${LAST_DATE}/gcc-${BRANCH}-${LAST_DATE}.tar.xz
706 # Compute the name of the WORKING_DIRECTORY and the SOURCE_DIRECTORY.
707 WORKING_DIRECTORY="${DESTINATION}/gcc-${RELEASE}"
708 SOURCE_DIRECTORY="${WORKING_DIRECTORY}/gcc-${RELEASE}"
710 # Set up SVNROOT.
711 if [ $LOCAL -eq 0 ]; then
712 SVNROOT="svn+ssh://${SVN_USERNAME}@${SVN_SERVER}${SVN_REPOSITORY}"
713 else
714 SVNROOT="file:///svn/gcc"
716 export SVNROOT
718 ########################################################################
719 # Main Program
720 ########################################################################
722 # Set the timezone to UTC
723 TZ="UTC0"
724 export TZ
726 # Build the source directory.
728 if [ $MODE_SOURCES -ne 0 ]; then
729 build_sources
732 # Build the tar files.
734 if [ $MODE_TARFILES -ne 0 ]; then
735 build_tarfiles
738 # Build diffs
740 if [ $MODE_DIFFS -ne 0 ]; then
741 # Possibly build diffs.
742 if [ -n "$OLD_TARS" ]; then
743 for old_tar in $OLD_TARS; do
744 build_diffs $old_tar
745 done
749 # Build gzip files
750 if [ $MODE_GZIP -ne 0 ]; then
751 build_gzip
754 # Upload them to the FTP server.
755 if [ $MODE_UPLOAD -ne 0 ]; then
756 upload_files
758 # For snapshots, make some further updates.
759 if [ $SNAPSHOT -ne 0 ] && [ $LOCAL -ne 0 ]; then
760 announce_snapshot
762 # Update snapshot date file.
763 changedir ~
764 echo $DATE > .snapshot_date-${BRANCH}
766 # Remove working directory
767 rm -rf ${WORKING_DIRECTORY}