]> git.ipfire.org Git - thirdparty/gcc.git/blame - maintainer-scripts/gcc_release
2019-08-21 Richard Biener <rguenther@suse.de>
[thirdparty/gcc.git] / maintainer-scripts / gcc_release
CommitLineData
b5842c1f 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#
1019ee83 12# Copyright (c) 2001-2018 Free Software Foundation.
b5842c1f 13#
3eb4724d 14# This file is part of GCC.
b5842c1f 15#
3eb4724d 16# GCC is free software; you can redistribute it and/or modify
b5842c1f 17# it under the terms of the GNU General Public License as published by
6bc9506f 18# the Free Software Foundation; either version 3, or (at your option)
b5842c1f 19# any later version.
20#
3eb4724d 21# GCC is distributed in the hope that it will be useful,
b5842c1f 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
6bc9506f 27# along with GCC; see the file COPYING3. If not see
28# <http://www.gnu.org/licenses/>.
b5842c1f 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
c01accc7 48# Issue the error message given by $@ and exit with a non-zero
b5842c1f 49# exit code.
50
51error() {
c01accc7 52 echo "gcc_release: error: $@"
b5842c1f 53 exit 1
54}
55
c01accc7 56# Issue the informational message given by $@.
b5842c1f 57
58inform() {
c01accc7 59 echo "gcc_release: $@"
b5842c1f 60}
61
62# Issue a usage message explaining how to use this script.
63
64usage() {
65cat <<EOF
c80cb483 66gcc_release -r release [-f] [further options]
92264cad 67gcc_release -s name:svnbranch [further options]
da33415c 68
69Options:
70
71 -r release Version of the form X.Y or X.Y.Z.
92264cad 72 -s name:svnbranch Create a snapshot, not a real release.
da33415c 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).
92264cad 79 -t tag Tag to mark the release in SVN.
da33415c 80 -u username Username for upload operations.
b5842c1f 81EOF
82 exit 1
83}
84
85# Change to the directory given by $1.
86
87changedir() {
88 cd $1 || \
89 error "Could not change directory to $1"
90}
91
b5842c1f 92# Build the source tree that will be the basis for the release
93# in ${WORKING_DIRECTORY}/gcc-${RELEASE}.
94
95build_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
194ce62a 110 ${SVN} -q co "${SVNROOT}/${SVNBRANCH}" "`basename ${SOURCE_DIRECTORY}`" ||\
b5842c1f 111 error "Could not check out release sources"
1019ee83 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" |\
c01accc7 131 grep -q "^[[:blank:]]*GCC ${RELEASE_MAJOR}.${RELEASE_MINOR}" ||\
1019ee83 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 |\
c01accc7 136 grep -q "^[[:blank:]]*GCC ${RELEASE_MAJOR}.${RELEASE_MINOR}" ||\
1019ee83 137 error "GCC ${RELEASE_MAJOR}.${RELEASE_MINOR} not mentioned "\
138 "in gcc-${RELEASE_MAJOR}/changes.html"
139
140 rm -f NEWS
141
76442697 142 svnciargs=""
143 for x in `changedir ${SOURCE_DIRECTORY} && \
144 find . -name ChangeLog`; do
afd2f2ab 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.)
76442697 148 if ! grep "GCC ${RELEASE} released." ${SOURCE_DIRECTORY}/${x} > /dev/null ; then
149 cat - ${SOURCE_DIRECTORY}/${x} > ${SOURCE_DIRECTORY}/${x}.new <<EOF
b5842c1f 150${LONG_DATE} Release Manager
151
afd2f2ab 152 * GCC ${RELEASE} released.
b5842c1f 153
154EOF
76442697 155 mv ${SOURCE_DIRECTORY}/${x}.new ${SOURCE_DIRECTORY}/${x} \
156 || error "Could not update ${x}"
157 svnciargs="${svnciargs} ${x}"
afd2f2ab 158 fi
b5842c1f 159 done
160
27535f93 161 # Update gcc/DEV-PHASE.
162
76442697 163 if [ `cat ${SOURCE_DIRECTORY}/gcc/BASE-VER` != ${RELEASE} ]; then
ec17f826 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 && \
76442697 170 echo ${RELEASE} > BASE-VER) || \
ec17f826 171 error "Could not update BASE-VER"
76442697 172 svnciargs="${svnciargs} gcc/BASE-VER"
ec17f826 173 else
76442697 174 error "Release number ${RELEASE} does not immediately follow BASE-VER"
ec17f826 175 fi
176 fi
27535f93 177 (changedir ${SOURCE_DIRECTORY}/gcc && \
76442697 178 : > DEV-PHASE) || \
27535f93 179 error "Could not update DEV-PHASE"
76442697 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"
b5842c1f 185
186 # Make sure we tag the sources for a final release.
10bef3ca 187 TAG="tags/gcc_`echo ${RELEASE} | tr . _`_release"
b5842c1f 188
189 rm -rf ${SOURCE_DIRECTORY}
190 fi
191
192 # Tag the sources.
193 if [ -n "${TAG}" ]; then
9656fddb 194 inform "Tagging sources as ${TAG}"
92264cad 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
5fd21b6e 200 error "Tag ${TAG} already exists"
201 fi
10bef3ca 202 ${SVN} -m "Tagging source as ${TAG}" cp "${SVNROOT}/${SVNBRANCH}" "${SVNROOT}/${TAG}" || \
3e45039a 203 error "Could not tag sources"
92264cad 204 SVNBRANCH=${TAG}
b5842c1f 205 fi
92264cad 206 SVNREV=`${SVN} info "${SVNROOT}/${SVNBRANCH}"|awk '/Revision:/ {print $2}'`
b5842c1f 207
208 # Export the current sources.
92264cad 209 inform "Retrieving sources (svn export -r ${SVNREV} ${SVNROOT}/${SVNBRANCH})"
3e45039a 210
211 ${SVN} -q export -r${SVNREV} "${SVNROOT}/${SVNBRANCH}" "`basename ${SOURCE_DIRECTORY}`" ||\
212 error "Could not retrieve sources"
b5842c1f 213
18e24ca4 214 # Run gcc_update on them to set up the timestamps nicely, and (re)write
92264cad 215 # the LAST_UPDATED file containing the SVN tag/revision used.
b5842c1f 216 changedir "gcc-${RELEASE}"
217 contrib/gcc_update --touch
92264cad 218 echo "Obtained from SVN: ${SVNBRANCH} revision ${SVNREV}" > LAST_UPDATED
b5842c1f 219
b5842c1f 220 # For a prerelease or real release, we need to generate additional
194ce62a 221 # files not present in SVN.
b5842c1f 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.
cab974a1 233 contrib/gennews > NEWS || \
b5842c1f 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
68e38cc4 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
fa311483 249 contrib/gcc_build -d ${SOURCE_DIRECTORY} -o ${OBJECT_DIRECTORY} \
68e38cc4 250 -c "--enable-generated-files-in-srcdir --disable-multilib" \
251 -m "-j$num_cpus" build || \
b5842c1f 252 error "Could not rebuild GCC"
b5842c1f 253 fi
254
255 # Move message catalogs to source directory.
256 mv ../objdir/gcc/po/*.gmo gcc/po/
dd6e5561 257 [ -f libcpp/po/cpplib.pot ] && mv ../objdir/libcpp/po/*.gmo libcpp/po/
b5842c1f 258
ad2d5047 259 # Create a "MD5SUMS" file to use for checking the validity of the release.
014a4961 260 echo \
261"# This file contains the MD5 checksums of the files in the
3efd104e 262# gcc-"${RELEASE}".tar.xz tarball.
014a4961 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$\"
69811c67 270#" > MD5SUMS
014a4961 271
272 find . -type f |
273 sed -e 's:^\./::' -e '/MD5SUMS/d' |
274 sort |
275 xargs md5sum >>MD5SUMS
b5842c1f 276}
277
7078e5bb 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.
b5842c1f 282
283build_tarfile() {
284 # Get the name of the destination tar file.
3efd104e 285 TARFILE="$1.tar.xz"
b5842c1f 286 shift
287
288 # Build the tar file itself.
3efd104e 289 (${TAR} cf - "$@" | ${XZ} > ${TARFILE}) || \
b5842c1f 290 error "Could not build tarfile"
291 FILE_LIST="${FILE_LIST} ${TARFILE}"
292}
293
294# Build the various tar files for the release.
295
296build_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}
d47ee723 304 # And that all directories have mode 755.
305 find ${SOURCE_DIRECTORY} -type d -exec chmod 755 {} \;
b5842c1f 306
307 # Build one huge tarfile for the entire distribution.
308 build_tarfile gcc-${RELEASE} `basename ${SOURCE_DIRECTORY}`
babdb60f 309}
b5842c1f 310
6d03e4eb 311# Build .gz files.
312build_gzip() {
b5842c1f 313 for f in ${FILE_LIST}; do
3efd104e 314 target=${f%.xz}.gz
315 (${XZ} -d -c $f | ${GZIP} > ${target}) || error "Could not create ${target}"
b5842c1f 316 done
317}
318
319# Build diffs against an old release.
320build_diffs() {
f19d7d57 321 old_dir=${1%/*}
b5842c1f 322 old_file=${1##*/}
3efd104e 323 case "$old_file" in
324 *.tar.xz) old_vers=${old_file%.tar.xz};;
325 *) old_vers=${old_file%.tar.bz2};;
326 esac
b5842c1f 327 old_vers=${old_vers#gcc-}
328 inform "Building diffs against version $old_vers"
9d92f62d 329 for f in gcc; do
3efd104e 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
4c192185 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
b5842c1f 341 build_diff $old_tar gcc-${old_vers} $new_tar gcc-${RELEASE} \
3efd104e 342 ${f}-${old_vers}-${RELEASE}.diff.xz
b5842c1f 343 fi
344 done
345}
346
347# Build an individual diff.
348build_diff() {
349 changedir "${WORKING_DIRECTORY}"
350 tmpdir=gccdiff.$$
351 mkdir $tmpdir || error "Could not create directory $tmpdir"
352 changedir $tmpdir
3efd104e 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}
b5842c1f 363 if [ $? -eq 2 ]; then
364 error "Trouble making diffs from $1 to $3"
365 fi
3efd104e 366 ${XZ} ../${5%.xz} || error "Could not generate ../$5"
b5842c1f 367 changedir ..
368 rm -rf $tmpdir
369 FILE_LIST="${FILE_LIST} $5"
370}
371
372# Upload the files to the FTP server.
b5842c1f 373upload_files() {
374 inform "Uploading files"
375
376 changedir "${WORKING_DIRECTORY}"
377
f19d7d57 378 # Make sure the directory exists on the server.
379 if [ $LOCAL -eq 0 ]; then
e43a8b47 380 ${SSH} -l ${GCC_USERNAME} ${GCC_HOSTNAME} \
381 mkdir -p "${FTP_PATH}/diffs"
8ae3f78d 382 UPLOAD_PATH="${GCC_USERNAME}@${GCC_HOSTNAME}:${FTP_PATH}"
f19d7d57 383 else
e43a8b47 384 mkdir -p "${FTP_PATH}/diffs" \
b5842c1f 385 || error "Could not create \`${FTP_PATH}'"
8ae3f78d 386 UPLOAD_PATH=${FTP_PATH}
b5842c1f 387 fi
388
e43a8b47 389 # Then copy files to their respective (sub)directories.
3efd104e 390 for x in gcc*.gz gcc*.xz; do
b5842c1f 391 if [ -e ${x} ]; then
392 # Make sure the file will be readable on the server.
393 chmod a+r ${x}
394 # Copy it.
e43a8b47 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}"
b5842c1f 404 fi
405 done
406}
407
7078e5bb 408# Print description if snapshot exists.
709ab98b 409snapshot_print() {
f1f85ed2 410 if [ -e ${RELEASE}/$1 ]; then
fe344883 411 hash=`openssl sha256 ${RELEASE}/$1 | sed -e 's#(.*)##' -e 's# *= *#=#'`
86b9346b 412 hash2=`openssl sha1 ${RELEASE}/$1 | sed -e 's#(.*)##' -e 's# *= *#=#'`
773ddbb1 413
86b9346b 414 printf " %-37s%s\n\n %s\n %s\n\n" "$1" "$2" "$hash" "$hash2" \
415 >> ${SNAPSHOT_README}
773ddbb1 416
f1f85ed2 417 echo " <tr><td><a href=\"$1\">$1</a></td>" >> ${SNAPSHOT_INDEX}
418 echo " <td>$2</td></tr>" >> ${SNAPSHOT_INDEX}
709ab98b 419 fi
420}
421
caabe34c 422# Announce a snapshot, both on the web and via mail.
423announce_snapshot() {
424 inform "Updating links and READMEs on the FTP server"
425
426 TEXT_DATE=`date --date=$DATE +%B\ %d,\ %Y`
709ab98b 427 SNAPSHOT_README=${RELEASE}/README
428 SNAPSHOT_INDEX=${RELEASE}/index.html
429
b85989a9 430 changedir "${SNAPSHOTS_DIR}"
f1f85ed2 431 echo \
432"Snapshot gcc-"${RELEASE}" is now available on
433 ftp://gcc.gnu.org/pub/gcc/snapshots/"${RELEASE}"/
434and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.
435
194ce62a 436This snapshot has been generated from the GCC "${BRANCH}" SVN branch
10bef3ca 437with the following options: "svn://gcc.gnu.org/svn/gcc/${SVNBRANCH} revision ${SVNREV}"
f1f85ed2 438
439You'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
453periodic snapshots of the GCC source tree available to the public
454for testing purposes.</p>
455
456<p>If you are planning to download and use one of our snapshots, then
457we highly recommend you join the GCC developers list. Details for
458how to sign up can be found on the GCC project home page.</p>
459
194ce62a 460<p>This snapshot has been generated from the GCC "${BRANCH}" SVN branch
10bef3ca 461with the following options: <code>"svn://gcc.gnu.org/svn/gcc/${SVNBRANCH} revision ${SVNREV}"</code></p>
f1f85ed2 462
463<table>" > ${SNAPSHOT_INDEX}
709ab98b 464
3efd104e 465 snapshot_print gcc-${RELEASE}.tar.xz "Complete GCC"
f1f85ed2 466
467 echo \
468"Diffs from "${BRANCH}"-"${LAST_DATE}" are available in the diffs/ subdirectory.
469
470When a particular snapshot is ready for public consumption the LATEST-"${BRANCH}"
471link is updated and a message is sent to the gcc list. Please do not use
472a 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}"
480link is updated and a message is sent to the gcc list. Please do not use
481a 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 />
488Last modified "${TEXT_DATE}"
489</address>
490</body>
491
492</html>" >> ${SNAPSHOT_INDEX}
709ab98b 493
494 rm -f LATEST-${BRANCH}
495 ln -s ${RELEASE} LATEST-${BRANCH}
caabe34c 496
497 inform "Sending mail"
498
499 export QMAILHOST=gcc.gnu.org
709ab98b 500 mail -s "gcc-${RELEASE} is now available" gcc@gcc.gnu.org < ${SNAPSHOT_README}
caabe34c 501}
502
b5842c1f 503########################################################################
504# Initialization
505########################################################################
506
fc0f602c 507LC_ALL=C
508export LC_ALL
509
b5842c1f 510# Today's date.
511DATE=`date "+%Y%m%d"`
512LONG_DATE=`date "+%Y-%m-%d"`
513
389f1077 514SVN=${SVN:-svn}
b5842c1f 515# The CVS server containing the GCC repository.
194ce62a 516SVN_SERVER="gcc.gnu.org"
b5842c1f 517# The path to the repository on that server.
194ce62a 518SVN_REPOSITORY="/svn/gcc"
b5842c1f 519# The username to use when connecting to the server.
194ce62a 520SVN_USERNAME="${USER}"
b5842c1f 521
99c15276 522# The machine to which files will be uploaded.
523GCC_HOSTNAME="gcc.gnu.org"
524# The name of the account on the machine to which files are uploaded.
525GCC_USERNAME="gccadmin"
bfff3310 526# The directory in which the files will be placed (do not use ~user syntax).
527FTP_PATH=/var/ftp/pub/gcc
b85989a9 528# The directory in which snapshots will be placed.
529SNAPSHOTS_DIR=${FTP_PATH}/snapshots
b5842c1f 530
531# The major number for the release. For release `3.0.2' this would be
532# `3'
533RELEASE_MAJOR=""
534# The minor number for the release. For release `3.0.2' this would be
535# `0'.
536RELEASE_MINOR=""
537# The revision number for the release. For release `3.0.2' this would
538# be `2'.
539RELEASE_REVISION=""
540# The complete name of the release.
541RELEASE=""
542
fec57524 543# The name of the branch from which the release should be made, in a
544# user-friendly form.
b5842c1f 545BRANCH=""
546
fec57524 547# The name of the branch from which the release should be made, as used
548# for our version control system.
194ce62a 549SVNBRANCH=""
fec57524 550
b5842c1f 551# The tag to apply to the sources used for the release.
552TAG=""
553
554# The old tarballs from which to generate diffs.
555OLD_TARS=""
556
557# The directory that will be used to construct the release. The
7078e5bb 558# release itself will be placed in a subdirectory of this directory.
b5842c1f 559DESTINATION=${HOME}
560# The subdirectory.
561WORKING_DIRECTORY=""
562# The directory that will contain the GCC sources.
563SOURCE_DIRECTORY=""
564
b5842c1f 565# Non-zero if this is the final release, rather than a prerelease.
566FINAL=0
567
568# Non-zero if we are building a snapshot, and don't build gcc or
569# include generated files.
570SNAPSHOT=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.
574LOCAL=0
575
576# Major operation modes.
6d03e4eb 577MODE_GZIP=0
99c15276 578MODE_DIFFS=0
b5842c1f 579MODE_SOURCES=0
580MODE_TARFILES=0
581MODE_UPLOAD=0
582
3efd104e 583# List of archive files generated; used to create .gz files from .xz.
b5842c1f 584FILE_LIST=""
585
586# Programs we use.
587
588BZIP2="${BZIP2:-bzip2}"
45f45073 589XZ="${XZ:-xz --best}"
b5842c1f 590CVS="${CVS:-cvs -f -Q -z9}"
8d9e913e 591DIFF="${DIFF:-diff -Nrcpad}"
b5842c1f 592ENV="${ENV:-env}"
593GZIP="${GZIP:-gzip --best}"
594SCP="${SCP:-scp -p}"
99c15276 595SSH="${SSH:-ssh}"
b5842c1f 596TAR="${TAR:-tar}"
597
598########################################################################
599# Command Line Processing
600########################################################################
601
602# Parse the options.
c80cb483 603while getopts "d:fr:u:t:p:s:l" ARG; do
b5842c1f 604 case $ARG in
605 d) DESTINATION="${OPTARG}";;
606 r) RELEASE="${OPTARG}";;
607 t) TAG="${OPTARG}";;
194ce62a 608 u) SVN_USERNAME="${OPTARG}";;
b5842c1f 609 f) FINAL=1;;
c80cb483 610 s) SNAPSHOT=1
611 BRANCH=${OPTARG%:*}
194ce62a 612 SVNBRANCH=${OPTARG#*:}
c80cb483 613 ;;
b5842c1f 614 l) LOCAL=1
615 SCP=cp
df21ac14 616 PATH=~:/usr/local/bin:$PATH;;
f19d7d57 617 p) OLD_TARS="${OLD_TARS} ${OPTARG}"
1e241437 618 if [ ! -f ${OPTARG} ]; then
f19d7d57 619 error "-p argument must name a tarball"
620 fi;;
b5842c1f 621 \?) usage;;
622 esac
623done
624shift `expr ${OPTIND} - 1`
625
03da418a 626# Handle the major modes.
627while [ $# -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
643done
644
b5842c1f 645# Perform consistency checking.
194ce62a 646if [ ${LOCAL} -eq 0 ] && [ -z ${SVN_USERNAME} ]; then
b5842c1f 647 error "No username specified"
648fi
649
650if [ ! -d ${DESTINATION} ]; then
651 error "\`${DESTINATION}' is not a directory"
652fi
653
654if [ $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.
ec17f826 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
b5842c1f 682
3674518f 683 # If this is not a final release, set various parameters accordingly.
b5842c1f 684 if [ ${FINAL} -ne 1 ]; then
3674518f 685 RELEASE="${RELEASE}-RC-${DATE}"
686 FTP_PATH="${SNAPSHOTS_DIR}/${RELEASE}"
b5842c1f 687 else
99c15276 688 FTP_PATH="${FTP_PATH}/releases/gcc-${RELEASE}/"
b5842c1f 689 fi
690else
81fa4da1 691 RELEASE=${BRANCH}-${DATE}
692 FTP_PATH="${FTP_PATH}/snapshots/${RELEASE}"
b5842c1f 693
1e241437 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,
7078e5bb 696 # unless the user specified tarballs explicitly.
1e241437 697 if [ $MODE_DIFFS -ne 0 ] && [ $LOCAL -ne 0 ] && [ -z "${OLD_TARS}" ]; then
fec57524 698 LAST_DATE=`cat ~/.snapshot_date-${BRANCH}`
b85989a9 699 OLD_TARS=${SNAPSHOTS_DIR}/${BRANCH}-${LAST_DATE}/gcc-${BRANCH}-${LAST_DATE}.tar.bz2
3efd104e 700 if [ ! -e $OLD_TARS ]; then
701 OLD_TARS=${SNAPSHOTS_DIR}/${BRANCH}-${LAST_DATE}/gcc-${BRANCH}-${LAST_DATE}.tar.xz
702 fi
b5842c1f 703 fi
704fi
705
706# Compute the name of the WORKING_DIRECTORY and the SOURCE_DIRECTORY.
707WORKING_DIRECTORY="${DESTINATION}/gcc-${RELEASE}"
708SOURCE_DIRECTORY="${WORKING_DIRECTORY}/gcc-${RELEASE}"
709
194ce62a 710# Set up SVNROOT.
b5842c1f 711if [ $LOCAL -eq 0 ]; then
3e45039a 712 SVNROOT="svn+ssh://${SVN_USERNAME}@${SVN_SERVER}${SVN_REPOSITORY}"
b5842c1f 713else
194ce62a 714 SVNROOT="file:///svn/gcc"
b5842c1f 715fi
194ce62a 716export SVNROOT
b5842c1f 717
718########################################################################
719# Main Program
720########################################################################
721
50e4412f 722# Set the timezone to UTC
723TZ="UTC0"
724export TZ
725
b5842c1f 726# Build the source directory.
727
728if [ $MODE_SOURCES -ne 0 ]; then
729 build_sources
730fi
731
732# Build the tar files.
733
734if [ $MODE_TARFILES -ne 0 ]; then
735 build_tarfiles
736fi
737
99c15276 738# Build diffs
739
740if [ $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
747fi
748
6d03e4eb 749# Build gzip files
750if [ $MODE_GZIP -ne 0 ]; then
751 build_gzip
babdb60f 752fi
753
b5842c1f 754# Upload them to the FTP server.
b5842c1f 755if [ $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
caabe34c 760 announce_snapshot
b5842c1f 761
762 # Update snapshot date file.
763 changedir ~
fec57524 764 echo $DATE > .snapshot_date-${BRANCH}
b5842c1f 765
b5842c1f 766 # Remove working directory
767 rm -rf ${WORKING_DIRECTORY}
768 fi
769fi