]> git.ipfire.org Git - thirdparty/gcc.git/blob - maintainer-scripts/gcc_release
OpenMP: Fix for ICE in tree-nested.cc.
[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-2018 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 $@ and exit with a non-zero
49 # exit code.
50
51 error() {
52 echo "gcc_release: error: $@"
53 exit 1
54 }
55
56 # Issue the informational message given by $@.
57
58 inform() {
59 echo "gcc_release: $@"
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 # Build the source tree that will be the basis for the release
93 # in ${WORKING_DIRECTORY}/gcc-${RELEASE}.
94
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"
99 fi
100 # Create the WORKING_DIRECTORY.
101 mkdir "${WORKING_DIRECTORY}" \
102 || error "Could not create \`${WORKING_DIRECTORY}'"
103 changedir "${WORKING_DIRECTORY}"
104
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"
109
110 ${SVN} -q co "${SVNROOT}/${SVNBRANCH}" "`basename ${SOURCE_DIRECTORY}`" ||\
111 error "Could not check out release sources"
112
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"
116
117 ${SOURCE_DIRECTORY}/contrib/gennews > NEWS ||\
118 error "Could not regenerate NEWS files"
119
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"
122
123 grep -q "GCC ${RELEASE_MAJOR} has not been released yet" NEWS &&\
124 error "gcc-${RELEASE_MAJOR}/changes.html has not been updated yet"
125
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"
134
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"
139
140 rm -f NEWS
141
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
151
152 * GCC ${RELEASE} released.
153
154 EOF
155 mv ${SOURCE_DIRECTORY}/${x}.new ${SOURCE_DIRECTORY}/${x} \
156 || error "Could not update ${x}"
157 svnciargs="${svnciargs} ${x}"
158 fi
159 done
160
161 # Update gcc/DEV-PHASE.
162
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"
175 fi
176 fi
177 (changedir ${SOURCE_DIRECTORY}/gcc && \
178 : > DEV-PHASE) || \
179 error "Could not update DEV-PHASE"
180 svnciargs="${svnciargs} gcc/DEV-PHASE"
181
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"
185
186 # Make sure we tag the sources for a final release.
187 TAG="tags/gcc_`echo ${RELEASE} | tr . _`_release"
188
189 rm -rf ${SOURCE_DIRECTORY}
190 fi
191
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"
201 fi
202 ${SVN} -m "Tagging source as ${TAG}" cp "${SVNROOT}/${SVNBRANCH}" "${SVNROOT}/${TAG}" || \
203 error "Could not tag sources"
204 SVNBRANCH=${TAG}
205 fi
206 SVNREV=`${SVN} info "${SVNROOT}/${SVNBRANCH}"|awk '/Revision:/ {print $2}'`
207
208 # Export the current sources.
209 inform "Retrieving sources (svn export -r ${SVNREV} ${SVNROOT}/${SVNBRANCH})"
210
211 ${SVN} -q export -r${SVNREV} "${SVNROOT}/${SVNBRANCH}" "`basename ${SOURCE_DIRECTORY}`" ||\
212 error "Could not retrieve sources"
213
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
219
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
231
232 # Regenerate the NEWS file.
233 contrib/gennews > NEWS || \
234 error "Could not regenerate NEWS files"
235
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
248 fi
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"
253 fi
254
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/
258
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.
263 #
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.
267 #
268 # Suggested usage:
269 # md5sum -c MD5SUMS | grep -v \"OK$\"
270 #" > MD5SUMS
271
272 find . -type f |
273 sed -e 's:^\./::' -e '/MD5SUMS/d' |
274 sort |
275 xargs md5sum >>MD5SUMS
276 }
277
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.
282
283 build_tarfile() {
284 # Get the name of the destination tar file.
285 TARFILE="$1.tar.xz"
286 shift
287
288 # Build the tar file itself.
289 (${TAR} cf - "$@" | ${XZ} > ${TARFILE}) || \
290 error "Could not build tarfile"
291 FILE_LIST="${FILE_LIST} ${TARFILE}"
292 }
293
294 # Build the various tar files for the release.
295
296 build_tarfiles() {
297 inform "Building tarfiles"
298
299 changedir "${WORKING_DIRECTORY}"
300
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 {} \;
306
307 # Build one huge tarfile for the entire distribution.
308 build_tarfile gcc-${RELEASE} `basename ${SOURCE_DIRECTORY}`
309 }
310
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
317 }
318
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
334 fi
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
343 fi
344 done
345 }
346
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"
356 ;;
357 *.tar.xz)
358 (${XZ} -d -c $1 | ${TAR} xf - ) || error "Could not unpack $1 for diffs"
359 ;;
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"
365 fi
366 ${XZ} ../${5%.xz} || error "Could not generate ../$5"
367 changedir ..
368 rm -rf $tmpdir
369 FILE_LIST="${FILE_LIST} $5"
370 }
371
372 # Upload the files to the FTP server.
373 upload_files() {
374 inform "Uploading files"
375
376 changedir "${WORKING_DIRECTORY}"
377
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}
387 fi
388
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/";
398 ;;
399 *)
400 SUBDIR="";
401 esac
402 ${SCP} ${x} ${UPLOAD_PATH}/${SUBDIR} \
403 || error "Could not upload ${x}"
404 fi
405 done
406 }
407
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# *= *#=#'`
413
414 printf " %-37s%s\n\n %s\n %s\n\n" "$1" "$2" "$hash" "$hash2" \
415 >> ${SNAPSHOT_README}
416
417 echo " <tr><td><a href=\"$1\">$1</a></td>" >> ${SNAPSHOT_INDEX}
418 echo " <td>$2</td></tr>" >> ${SNAPSHOT_INDEX}
419 fi
420 }
421
422 # Announce a snapshot, both on the web and via mail.
423 announce_snapshot() {
424 inform "Updating links and READMEs on the FTP server"
425
426 TEXT_DATE=`date --date=$DATE +%B\ %d,\ %Y`
427 SNAPSHOT_README=${RELEASE}/README
428 SNAPSHOT_INDEX=${RELEASE}/index.html
429
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.
435
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}"
438
439 You'll find:
440 " > ${SNAPSHOT_README}
441
442 echo \
443 "<html>
444
445 <head>
446 <title>GCC "${RELEASE}" Snapshot</title>
447 </head>
448
449 <body>
450 <h1>GCC "${RELEASE}" Snapshot</h1>
451
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>
455
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>
459
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>
462
463 <table>" > ${SNAPSHOT_INDEX}
464
465 snapshot_print gcc-${RELEASE}.tar.xz "Complete GCC"
466
467 echo \
468 "Diffs from "${BRANCH}"-"${LAST_DATE}" are available in the diffs/ subdirectory.
469
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}
473
474 echo \
475 "</table>
476 <p>Diffs from "${BRANCH}"-"${LAST_DATE}" are available in the
477 <a href=\"diffs/\">diffs/ subdirectory</a>.</p>
478
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>
482
483 <hr />
484
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>
491
492 </html>" >> ${SNAPSHOT_INDEX}
493
494 rm -f LATEST-${BRANCH}
495 ln -s ${RELEASE} LATEST-${BRANCH}
496
497 inform "Sending mail"
498
499 export QMAILHOST=gcc.gnu.org
500 mail -s "gcc-${RELEASE} is now available" gcc@gcc.gnu.org < ${SNAPSHOT_README}
501 }
502
503 ########################################################################
504 # Initialization
505 ########################################################################
506
507 LC_ALL=C
508 export LC_ALL
509
510 # Today's date.
511 DATE=`date "+%Y%m%d"`
512 LONG_DATE=`date "+%Y-%m-%d"`
513
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}"
521
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
530
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=""
542
543 # The name of the branch from which the release should be made, in a
544 # user-friendly form.
545 BRANCH=""
546
547 # The name of the branch from which the release should be made, as used
548 # for our version control system.
549 SVNBRANCH=""
550
551 # The tag to apply to the sources used for the release.
552 TAG=""
553
554 # The old tarballs from which to generate diffs.
555 OLD_TARS=""
556
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=""
564
565 # Non-zero if this is the final release, rather than a prerelease.
566 FINAL=0
567
568 # Non-zero if we are building a snapshot, and don't build gcc or
569 # include generated files.
570 SNAPSHOT=0
571
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
575
576 # Major operation modes.
577 MODE_GZIP=0
578 MODE_DIFFS=0
579 MODE_SOURCES=0
580 MODE_TARFILES=0
581 MODE_UPLOAD=0
582
583 # List of archive files generated; used to create .gz files from .xz.
584 FILE_LIST=""
585
586 # Programs we use.
587
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}"
597
598 ########################################################################
599 # Command Line Processing
600 ########################################################################
601
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#*:}
613 ;;
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`
625
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;
638 fi
639 ;;
640 *) error "Unknown mode $1";;
641 esac
642 shift
643 done
644
645 # Perform consistency checking.
646 if [ ${LOCAL} -eq 0 ] && [ -z ${SVN_USERNAME} ]; then
647 error "No username specified"
648 fi
649
650 if [ ! -d ${DESTINATION} ]; then
651 error "\`${DESTINATION}' is not a directory"
652 fi
653
654 if [ $SNAPSHOT -eq 0 ]; then
655 if [ -z ${RELEASE} ]; then
656 error "No release number specified"
657 fi
658
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; }'`
663
664 if [ -z "${RELEASE_MAJOR}" ] || [ -z "${RELEASE_MINOR}" ]; then
665 error "Release number \`${RELEASE}' is invalid"
666 fi
667
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}"
673 fi
674
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"
681 fi
682
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}/"
689 fi
690 else
691 RELEASE=${BRANCH}-${DATE}
692 FTP_PATH="${FTP_PATH}/snapshots/${RELEASE}"
693
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
702 fi
703 fi
704 fi
705
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}"
709
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"
715 fi
716 export SVNROOT
717
718 ########################################################################
719 # Main Program
720 ########################################################################
721
722 # Set the timezone to UTC
723 TZ="UTC0"
724 export TZ
725
726 # Build the source directory.
727
728 if [ $MODE_SOURCES -ne 0 ]; then
729 build_sources
730 fi
731
732 # Build the tar files.
733
734 if [ $MODE_TARFILES -ne 0 ]; then
735 build_tarfiles
736 fi
737
738 # Build diffs
739
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
746 fi
747 fi
748
749 # Build gzip files
750 if [ $MODE_GZIP -ne 0 ]; then
751 build_gzip
752 fi
753
754 # Upload them to the FTP server.
755 if [ $MODE_UPLOAD -ne 0 ]; then
756 upload_files
757
758 # For snapshots, make some further updates.
759 if [ $SNAPSHOT -ne 0 ] && [ $LOCAL -ne 0 ]; then
760 announce_snapshot
761
762 # Update snapshot date file.
763 changedir ~
764 echo $DATE > .snapshot_date-${BRANCH}
765
766 # Remove working directory
767 rm -rf ${WORKING_DIRECTORY}
768 fi
769 fi