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