3 ########################################################################
6 # Author: Jeffrey Law, Bernd Schmidt, Mark Mitchell
10 # Script to create a GCC release.
12 # Copyright (c) 2001-2015 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)
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 ########################################################################
34 ########################################################################
36 # Here is an example usage of this script, to create a GCC 3.0.2
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 ########################################################################
46 ########################################################################
48 # Issue the error message given by $1 and exit with a non-zero
52 echo "gcc_release: error: $1"
56 # Issue the informational message given by $1.
59 echo "gcc_release: $1"
62 # Issue a usage message explaining how to use this script.
66 gcc_release -r release [-f] [further options]
67 gcc_release -s name:svnbranch [further 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
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.
85 # Change to the directory given by $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}.
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 for x in `changedir
${SOURCE_DIRECTORY} && \
114 find .
-name ChangeLog
`; do
115 # Update this ChangeLog file only if it does not yet contain the
116 # entry we are going to add. (This is a safety net for repeated
117 # runs of this script for the same release.)
118 if ! grep "GCC ${RELEASE} released." ${SOURCE_DIRECTORY}/${x} > /dev/null ; then
119 cat - ${SOURCE_DIRECTORY}/${x} > ${SOURCE_DIRECTORY}/${x}.new <<EOF
120 ${LONG_DATE} Release Manager
122 * GCC ${RELEASE} released.
125 mv ${SOURCE_DIRECTORY}/${x}.new ${SOURCE_DIRECTORY}/${x} \
126 || error "Could not update ${x}"
127 svnciargs="${svnciargs} ${x}"
131 # Update gcc/DEV-PHASE.
133 if [ `cat ${SOURCE_DIRECTORY}/gcc
/BASE-VER
` != ${RELEASE} ]; then
134 [ ${RELEASE_MAJOR} -lt 5 ] && \
135 error "Release number ${RELEASE} does not match BASE-VER"
136 if [ `cat ${SOURCE_DIRECTORY}/gcc
/BASE-VER
` \
137 = ${RELEASE_MAJOR}.`expr ${RELEASE_MINOR} - 1`.1 \
138 -a x${RELEASE_REVISION} = x0 ]; then
139 (changedir ${SOURCE_DIRECTORY}/gcc && \
140 echo ${RELEASE} > BASE-VER) || \
141 error "Could not update BASE-VER"
142 svnciargs="${svnciargs} gcc/BASE-VER"
144 error "Release number ${RELEASE} does not immediately follow BASE-VER"
147 (changedir ${SOURCE_DIRECTORY}/gcc && \
149 error "Could not update DEV-PHASE"
150 svnciargs="${svnciargs} gcc/DEV-PHASE"
152 (changedir ${SOURCE_DIRECTORY} && \
153 ${SVN} -q ci -m 'Update ChangeLog and version files for release' ${svnciargs}) || \
154 error "Could not commit ChangeLog and version file updates"
156 # Make sure we tag the sources for a final release.
157 TAG="tags/gcc_`echo ${RELEASE} |
tr . _
`_release"
159 rm -rf ${SOURCE_DIRECTORY}
163 if [ -n "${TAG}" ]; then
164 inform "Tagging sources as ${TAG}"
165 # We don't want to overwrite an existing tag. So, if the tag
166 # already exists, issue an error message; the release manager can
167 # manually remove the tag if appropriate.
168 echo "${SVN} ls ${SVNROOT}/${TAG}/ChangeLog"
169 if ${SVN} ls "${SVNROOT}/${TAG}/ChangeLog"; then
170 error "Tag ${TAG} already exists"
172 ${SVN} -m "Tagging source as ${TAG}" cp "${SVNROOT}/${SVNBRANCH}" "${SVNROOT}/${TAG}" || \
173 error "Could not tag sources"
176 SVNREV=`${SVN} info "${SVNROOT}/${SVNBRANCH}"|awk '/Revision:/ {print $2}'`
178 # Export the current sources.
179 inform "Retrieving sources (svn export -r ${SVNREV} ${SVNROOT}/${SVNBRANCH})"
181 ${SVN} -q export -r${SVNREV} "${SVNROOT}/${SVNBRANCH}" "`basename ${SOURCE_DIRECTORY}`" ||\
182 error "Could not retrieve sources"
184 # Run gcc_update on them to set up the timestamps nicely, and (re)write
185 # the LAST_UPDATED file containing the SVN tag/revision used.
186 changedir "gcc-${RELEASE}"
187 contrib/gcc_update --touch
188 echo "Obtained from SVN: ${SVNBRANCH} revision ${SVNREV}" > LAST_UPDATED
190 # For a prerelease or real release, we need to generate additional
191 # files not present in SVN.
192 changedir "${SOURCE_DIRECTORY}"
193 if [ $SNAPSHOT -ne 1 ]; then
194 # Generate the documentation.
195 inform "Building install docs"
196 SOURCEDIR=${SOURCE_DIRECTORY}/gcc/doc
197 DESTDIR=${SOURCE_DIRECTORY}/INSTALL
200 ${SOURCE_DIRECTORY}/gcc/doc/install.texi2html
202 # Regenerate the NEWS file.
203 contrib/gennews > NEWS || \
204 error "Could not regenerate NEWS files"
206 # Now, we must build the compiler in order to create any generated
207 # files that are supposed to go in the source directory. This is
208 # also a good sanity check to make sure that the release builds
209 # on at least one platform.
210 inform "Building compiler"
211 OBJECT_DIRECTORY=../objdir
212 contrib/gcc_build -d ${SOURCE_DIRECTORY} -o ${OBJECT_DIRECTORY} \
213 -c "--enable-generated-files-in-srcdir --disable-multilib" build || \
214 error "Could not rebuild GCC"
217 # Move message catalogs to source directory.
218 mv ../objdir/gcc/po/*.gmo gcc/po/
219 [ -f libcpp/po/cpplib.pot ] && mv ../objdir/libcpp/po/*.gmo libcpp/po/
221 # Create a "MD5SUMS" file to use for checking the validity of the release.
223 "# This file contains the MD5 checksums of the files in the
224 # gcc-"${RELEASE}".tar.bz2 tarball.
226 # Besides verifying that all files in the tarball were correctly expanded,
227 # it also can be used to determine if any files have changed since the
228 # tarball was expanded or to verify that a patchfile was correctly applied.
231 # md5sum -c MD5SUMS | grep -v \"OK$\"
235 sed -e 's
:^\.
/::' -e '/MD5SUMS
/d
' |
237 xargs md5sum >>MD5SUMS
240 # Build a single tarfile. The first argument is the name of the tarfile
241 # to build, without any suffixes. They will be added automatically. The
242 # rest of the arguments are files or directories to include, and possibly
243 # other arguments to tar.
246 # Get the name of the destination tar file.
250 # Build the tar file itself.
251 (${TAR} cf - "$@" | ${BZIP2} > ${TARFILE}) || \
252 error "Could not build tarfile"
253 FILE_LIST="${FILE_LIST} ${TARFILE}"
256 # Build the various tar files for the release.
259 inform "Building tarfiles"
261 changedir "${WORKING_DIRECTORY}"
263 # The GNU Coding Standards specify that all files should
265 chmod -R a+r ${SOURCE_DIRECTORY}
266 # And that all directories have mode 755.
267 find ${SOURCE_DIRECTORY} -type d -exec chmod 755 {} \;
269 # Build one huge tarfile for the entire distribution.
270 build_tarfile gcc-${RELEASE} `basename ${SOURCE_DIRECTORY}`
275 for f in ${FILE_LIST}; do
277 (${BZIP2} -d -c $f | ${GZIP} > ${target}) || error "Could not create ${target}"
281 # Build diffs against an old release.
285 old_vers=${old_file%.tar.bz2}
286 old_vers=${old_vers#gcc-}
287 inform "Building diffs against version $old_vers"
289 old_tar=${old_dir}/${f}-${old_vers}.tar.bz2
290 new_tar=${WORKING_DIRECTORY}/${f}-${RELEASE}.tar.bz2
291 if [ ! -e $old_tar ]; then
292 inform "$old_tar not found; not generating diff file"
293 elif [ ! -e $new_tar ]; then
294 inform "$new_tar not found; not generating diff file"
296 build_diff $old_tar gcc-${old_vers} $new_tar gcc-${RELEASE} \
297 ${f}-${old_vers}-${RELEASE}.diff.bz2
302 # Build an individual diff.
304 changedir "${WORKING_DIRECTORY}"
306 mkdir $tmpdir || error "Could not create directory $tmpdir"
308 (${BZIP2} -d -c $1 | ${TAR} xf - ) || error "Could not unpack $1 for diffs"
309 (${BZIP2} -d -c $3 | ${TAR} xf - ) || error "Could not unpack $3 for diffs"
310 ${DIFF} $2 $4 > ../${5%.bz2}
311 if [ $? -eq 2 ]; then
312 error "Trouble making diffs from $1 to $3"
314 ${BZIP2} ../${5%.bz2} || error "Could not generate ../$5"
317 FILE_LIST="${FILE_LIST} $5"
320 # Upload the files to the FTP server.
322 inform "Uploading files"
324 changedir "${WORKING_DIRECTORY}"
326 # Make sure the directory exists on the server.
327 if [ $LOCAL -eq 0 ]; then
328 ${SSH} -l ${GCC_USERNAME} ${GCC_HOSTNAME} \
329 mkdir -p "${FTP_PATH}/diffs"
330 UPLOAD_PATH="${GCC_USERNAME}@${GCC_HOSTNAME}:${FTP_PATH}"
332 mkdir -p "${FTP_PATH}/diffs" \
333 || error "Could not create \`${FTP_PATH}'"
334 UPLOAD_PATH=${FTP_PATH}
337 # Then copy files to their respective (sub)directories.
338 for x in gcc*.gz gcc*.bz2; do
340 # Make sure the file will be readable on the server.
350 ${SCP} ${x} ${UPLOAD_PATH}/${SUBDIR} \
351 || error "Could not upload
${x}"
356 # Print description if snapshot exists.
358 if [ -e ${RELEASE}/$1 ]; then
359 hash=`openssl md5 ${RELEASE}/$1 | sed -e 's#(.*)##' -e 's# *= *#=#'`
360 hash2=`openssl sha1 ${RELEASE}/$1 | sed -e 's#(.*)##' -e 's# *= *#=#'`
362 printf " %-37s%s
\n\n %s
\n %s
\n\n" "$1" "$2" "$hash" "$hash2" \
363 >> ${SNAPSHOT_README}
365 echo " <tr><td
><a href
=\"$1\">$1</a
></td
>" >> ${SNAPSHOT_INDEX}
366 echo " <td
>$2</td
></tr>" >> ${SNAPSHOT_INDEX}
370 # Announce a snapshot, both on the web and via mail.
371 announce_snapshot() {
372 inform "Updating links and READMEs on the FTP server
"
374 TEXT_DATE=`date --date=$DATE +%B\ %d,\ %Y`
375 SNAPSHOT_README=${RELEASE}/README
376 SNAPSHOT_INDEX=${RELEASE}/index.html
378 changedir "${SNAPSHOTS_DIR}"
380 "Snapshot gcc-
"${RELEASE}" is now available on
381 ftp://gcc.gnu.org
/pub
/gcc
/snapshots
/"${RELEASE}"/
382 and on various mirrors
, see http
://gcc.gnu.org
/mirrors.html
for details.
384 This snapshot has been generated from the GCC
"${BRANCH}" SVN branch
385 with the following options
: "svn://gcc.gnu.org/svn/gcc/${SVNBRANCH} revision ${SVNREV}"
388 " > ${SNAPSHOT_README}
394 <title>GCC "${RELEASE}" Snapshot</title>
398 <h1>GCC "${RELEASE}" Snapshot</h1>
400 <p>The <a href =\"http://gcc.gnu.org/\">GCC Project</a> makes
401 periodic snapshots of the GCC source tree available to the public
402 for testing purposes.</p>
404 <p>If you are planning to download and use one of our snapshots, then
405 we highly recommend you join the GCC developers list. Details for
406 how to sign up can be found on the GCC project home page.</p>
408 <p>This snapshot has been generated from the GCC "${BRANCH}" SVN branch
409 with the following options: <code>"svn://gcc.gnu.org/svn/gcc/${SVNBRANCH} revision ${SVNREV}"</code></p>
411 <table>" > ${SNAPSHOT_INDEX}
413 snapshot_print gcc-${RELEASE}.tar.bz2 "Complete GCC"
416 "Diffs from "${BRANCH}"-"${LAST_DATE}" are available in the diffs/ subdirectory.
418 When a particular snapshot is ready for public consumption the LATEST-"${BRANCH}"
419 link is updated and a message is sent to the gcc list. Please do not use
420 a snapshot before it has been announced that way." >> ${SNAPSHOT_README}
424 <p>Diffs from "${BRANCH}"-"${LAST_DATE}" are available in the
425 <a href=\"diffs/\">diffs/ subdirectory</a>.</p>
427 <p>When a particular snapshot is ready for public consumption the LATEST-"${BRANCH}"
428 link is updated and a message is sent to the gcc list. Please do not use
429 a snapshot before it has been announced that way.</p>
434 <a href=\"mailto:gcc@gcc.gnu.org\">gcc@gcc.gnu.org</a>
436 Last modified "${TEXT_DATE}"
440 </html>" >> ${SNAPSHOT_INDEX}
442 rm -f LATEST-${BRANCH}
443 ln -s ${RELEASE} LATEST-${BRANCH}
445 inform "Sending mail"
447 export QMAILHOST=gcc.gnu.org
448 mail -s "gcc-${RELEASE} is now available" gcc@gcc.gnu.org < ${SNAPSHOT_README}
451 ########################################################################
453 ########################################################################
459 DATE
=`date "+%Y%m%d"`
460 LONG_DATE
=`date "+%Y-%m-%d"`
463 # The CVS server containing the GCC repository.
464 SVN_SERVER
="gcc.gnu.org"
465 # The path to the repository on that server.
466 SVN_REPOSITORY
="/svn/gcc"
467 # The username to use when connecting to the server.
468 SVN_USERNAME
="${USER}"
470 # The machine to which files will be uploaded.
471 GCC_HOSTNAME
="gcc.gnu.org"
472 # The name of the account on the machine to which files are uploaded.
473 GCC_USERNAME
="gccadmin"
474 # The directory in which the files will be placed (do not use ~user syntax).
475 FTP_PATH
=/var
/ftp
/pub
/gcc
476 # The directory in which snapshots will be placed.
477 SNAPSHOTS_DIR
=${FTP_PATH}/snapshots
479 # The major number for the release. For release `3.0.2' this would be
482 # The minor number for the release. For release `3.0.2' this would be
485 # The revision number for the release. For release `3.0.2' this would
488 # The complete name of the release.
491 # The name of the branch from which the release should be made, in a
492 # user-friendly form.
495 # The name of the branch from which the release should be made, as used
496 # for our version control system.
499 # The tag to apply to the sources used for the release.
502 # The old tarballs from which to generate diffs.
505 # The directory that will be used to construct the release. The
506 # release itself will be placed in a subdirectory of this directory.
510 # The directory that will contain the GCC sources.
513 # Non-zero if this is the final release, rather than a prerelease.
516 # Non-zero if we are building a snapshot, and don't build gcc or
517 # include generated files.
520 # Non-zero if we are running locally on gcc.gnu.org, and use local CVS
521 # and copy directly to the FTP directory.
524 # Major operation modes.
531 # List of archive files generated; used to create .gz files from .bz2.
536 BZIP2
="${BZIP2:-bzip2}"
537 CVS
="${CVS:-cvs -f -Q -z9}"
538 DIFF
="${DIFF:-diff -Nrcpad}"
540 GZIP
="${GZIP:-gzip --best}"
545 ########################################################################
546 # Command Line Processing
547 ########################################################################
550 while getopts "d:fr:u:t:p:s:l" ARG
; do
552 d
) DESTINATION
="${OPTARG}";;
553 r
) RELEASE
="${OPTARG}";;
555 u
) SVN_USERNAME
="${OPTARG}";;
559 SVNBRANCH
=${OPTARG#*:}
563 PATH
=~
:/usr
/local
/bin
:$PATH;;
564 p
) OLD_TARS
="${OLD_TARS} ${OPTARG}"
565 if [ ! -f ${OPTARG} ]; then
566 error
"-p argument must name a tarball"
571 shift `expr ${OPTIND} - 1`
573 # Handle the major modes.
574 while [ $# -ne 0 ]; do
576 diffs
) MODE_DIFFS
=1;;
578 sources
) MODE_SOURCES
=1;;
579 tarfiles
) MODE_TARFILES
=1;;
580 upload
) MODE_UPLOAD
=1;;
581 all
) MODE_SOURCES
=1; MODE_TARFILES
=1; MODE_DIFFS
=1; MODE_UPLOAD
=1;
582 if [ $SNAPSHOT -ne 1 ]; then
583 # Only for releases and pre-releases.
587 *) error
"Unknown mode $1";;
592 # Perform consistency checking.
593 if [ ${LOCAL} -eq 0 ] && [ -z ${SVN_USERNAME} ]; then
594 error
"No username specified"
597 if [ ! -d ${DESTINATION} ]; then
598 error
"\`${DESTINATION}' is not a directory"
601 if [ $SNAPSHOT -eq 0 ]; then
602 if [ -z ${RELEASE} ]; then
603 error
"No release number specified"
606 # Compute the major and minor release numbers.
607 RELEASE_MAJOR
=`echo $RELEASE | awk --assign FS=. '{ print $1; }'`
608 RELEASE_MINOR
=`echo $RELEASE | awk --assign FS=. '{ print $2; }'`
609 RELEASE_REVISION
=`echo $RELEASE | awk --assign FS=. '{ print $3; }'`
611 if [ -z "${RELEASE_MAJOR}" ] ||
[ -z "${RELEASE_MINOR}" ]; then
612 error
"Release number \`${RELEASE}' is invalid"
615 # Compute the full name of the release.
616 if [ -z "${RELEASE_REVISION}" ]; then
617 RELEASE
="${RELEASE_MAJOR}.${RELEASE_MINOR}"
619 RELEASE
="${RELEASE_MAJOR}.${RELEASE_MINOR}.${RELEASE_REVISION}"
622 # Compute the name of the branch, which is based solely on the major
623 # and minor release numbers.
624 if [ ${RELEASE_MAJOR} -ge 5 ]; then
625 SVNBRANCH
="branches/gcc-${RELEASE_MAJOR}-branch"
627 SVNBRANCH
="branches/gcc-${RELEASE_MAJOR}_${RELEASE_MINOR}-branch"
630 # If this is not a final release, set various parameters accordingly.
631 if [ ${FINAL} -ne 1 ]; then
632 RELEASE
="${RELEASE}-RC-${DATE}"
633 FTP_PATH
="${SNAPSHOTS_DIR}/${RELEASE}"
635 FTP_PATH
="${FTP_PATH}/releases/gcc-${RELEASE}/"
638 RELEASE
=${BRANCH}-${DATE}
639 FTP_PATH
="${FTP_PATH}/snapshots/${RELEASE}"
641 # If diffs are requested when building locally on gcc.gnu.org, we (usually)
642 # know what the last snapshot date was and take the corresponding tarballs,
643 # unless the user specified tarballs explicitly.
644 if [ $MODE_DIFFS -ne 0 ] && [ $LOCAL -ne 0 ] && [ -z "${OLD_TARS}" ]; then
645 LAST_DATE
=`cat ~/.snapshot_date-${BRANCH}`
646 OLD_TARS
=${SNAPSHOTS_DIR}/${BRANCH}-${LAST_DATE}/gcc-${BRANCH}-${LAST_DATE}.
tar.bz2
650 # Compute the name of the WORKING_DIRECTORY and the SOURCE_DIRECTORY.
651 WORKING_DIRECTORY
="${DESTINATION}/gcc-${RELEASE}"
652 SOURCE_DIRECTORY
="${WORKING_DIRECTORY}/gcc-${RELEASE}"
655 if [ $LOCAL -eq 0 ]; then
656 SVNROOT
="svn+ssh://${SVN_USERNAME}@${SVN_SERVER}${SVN_REPOSITORY}"
658 SVNROOT
="file:///svn/gcc"
662 ########################################################################
664 ########################################################################
666 # Set the timezone to UTC
670 # Build the source directory.
672 if [ $MODE_SOURCES -ne 0 ]; then
676 # Build the tar files.
678 if [ $MODE_TARFILES -ne 0 ]; then
684 if [ $MODE_DIFFS -ne 0 ]; then
685 # Possibly build diffs.
686 if [ -n "$OLD_TARS" ]; then
687 for old_tar
in $OLD_TARS; do
694 if [ $MODE_GZIP -ne 0 ]; then
698 # Upload them to the FTP server.
699 if [ $MODE_UPLOAD -ne 0 ]; then
702 # For snapshots, make some further updates.
703 if [ $SNAPSHOT -ne 0 ] && [ $LOCAL -ne 0 ]; then
706 # Update snapshot date file.
708 echo $DATE > .snapshot_date-
${BRANCH}
710 # Remove working directory
711 rm -rf ${WORKING_DIRECTORY}