3 ########################################################################
6 # Author: Jeffrey Law, Bernd Schmidt, Mark Mitchell
10 # Script to create a GCC release.
12 # Copyright (c) 2001 Free Software Foundation.
14 # This file is part of GNU CC.
16 # GNU CC 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 2, or (at your option)
21 # GNU CC 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 GNU CC; see the file COPYING. If not, write to
28 # the Free Software Foundation, 59 Temple Place - Suite 330,
29 # Boston, MA 02111-1307, USA.
31 ########################################################################
33 ########################################################################
35 ########################################################################
37 # Here is an example usage of this script, to create the GCC 3.0.2
40 # gcc_release -r 3.0.2
42 # This script will automatically use the head of the release branch
43 # to generate the release.
45 ########################################################################
47 ########################################################################
49 # Issue the error message given by $1 and exit with a non-zero
53 echo "gcc_release: error: $1"
57 # Issue the informational message given by $1.
60 echo "gcc_release: $1"
63 # Issue a usage message explaining how to use this script.
67 gcc_release [-d destination]
77 # Change to the directory given by $1.
81 error
"Could not change directory to $1"
84 # Each of the arguments is a directory name, relative to the top
85 # of the source tree. Return another name for that directory, relative
86 # to the working directory.
90 echo `basename ${SOURCE_DIRECTORY}`/$x
94 # Build the source tree that will be the basis for the release
95 # in ${WORKING_DIRECTORY}/gcc-${RELEASE}.
98 # If the WORKING_DIRECTORY already exists, do not risk destroying it.
99 if [ -r ${WORKING_DIRECTORY} ]; then
100 error
"\`${WORKING_DIRECTORY}' already exists"
102 # Create the WORKING_DIRECTORY.
103 mkdir
"${WORKING_DIRECTORY}" \
104 || error
"Could not create \`${WORKING_DIRECTORY}'"
105 changedir
"${WORKING_DIRECTORY}"
107 if [ -n "${TAG}" ]; then
108 inform
"Tagging release sources"
109 ${CVS} -z 9 rtag -r ${BRANCH} ${TAG} gcc || \
110 error
"Could not tag release sources"
114 # Export the current sources.
115 inform
"Retrieving release sources"
117 -z 9 export -d "`basename ${SOURCE_DIRECTORY}`" \
118 -r ${BRANCH} gcc || \
119 error
"Could not retrieve release sources"
121 # Run gcc_update on them to set up the timestamps nicely.
122 changedir
"gcc-${RELEASE}"
123 contrib
/gcc_update
--touch
125 # Now, we must build the compiler in order to create any generated
126 # files that are supposed to go in the source directory. This is
127 # also a good sanity check to make sure that the release builds
128 # on at least one platform.
129 if [ $SNAPSHOT -ne 1 ]; then
130 inform
"Building compiler"
131 contrib
/gcc_build
-d ${SOURCE_DIRECTORY} -o ..
/objdir build || \
132 error
"Could not rebuild GCC"
135 # Move message catalogs to source directory.
136 mv ..
/objdir
/gcc
/po
/*.gmo gcc
/po
/
138 # Create a `.brik' file to use for checking the validity of the
140 changedir
"${SOURCE_DIRECTORY}"
141 BRIK_FILE
=`mktemp /tmp/gcc_release.XXXXXXX`
142 ((find .
-type f |
sort > $BRIK_FILE) && \
143 brik
-Gb -f ${BRIK_FILE} > .brik
&& \
144 rm ${BRIK_FILE}) || \
145 error
"Could not compute brik checksum"
148 # Buid a single tarfile. The first argument is the name of the name
149 # of the tarfile to build, without any suffixes. They will be added
150 # automatically. The rest of the arguments are the files or
151 # directories to include.
154 # Get the name of the destination tar file.
158 # Build the tar file itself.
159 (${TAR} cf - "$@" | ${GZIP} > ${TARFILE}) || \
160 error
"Could not build tarfile"
161 FILE_LIST
="${FILE_LIST} ${TARFILE}"
164 # Build the various tar files for the release.
167 inform
"Building tarfiles"
169 changedir
"${WORKING_DIRECTORY}"
171 # Build one huge tarfile for the entire distribution.
172 build_tarfile gcc-
${RELEASE} `basename ${SOURCE_DIRECTORY}`
174 # Now, build one for each of the languages.
175 build_tarfile gcc-g
++-${RELEASE} ${CPLUSPLUS_DIRS}
176 build_tarfile gcc-g77-
${RELEASE} ${FORTRAN_DIRS}
177 build_tarfile gcc-java-
${RELEASE} ${JAVA_DIRS}
178 build_tarfile gcc-objc-
${RELEASE} ${OBJECTIVEC_DIRS}
179 build_tarfile gcc-testsuite-
${RELEASE} ${TESTSUITE_DIRS}
181 # The core is everything else.
183 for x
in ${CPLUSPLUS_DIRS} ${FORTRAN_DIRS} ${JAVA_DIRS} \
184 ${OBJECTIVEC_DIRS} ${TESTSUITE_DIRS}; do
185 EXCLUDES
="${EXCLUDES} --exclude $x"
187 build_tarfile gcc-core-
${RELEASE} ${EXCLUDES} \
188 `basename ${SOURCE_DIRECTORY}`
190 # Possibly build diffs.
191 if [ -n "$OLD_TARS" ]; then
192 for old_tar
in $OLD_TARS; do
197 # Possibly build .bz2 files.
198 if [ $CREATE_BZIP2 -ne 0 ]; then
199 for f
in ${FILE_LIST}; do
201 zcat
$f |
${BZIP2} > ${bzfile}
202 FILE_LIST
="${FILE_LIST} ${bzfile}"
207 # Build diffs against an old release.
211 old_vers
=${old_file%.tar.gz}
212 old_vers
=${old_vers#gcc-}
213 inform
"Building diffs against version $old_vers"
214 for f
in gcc gcc-g
++ gcc-g77 gcc-java gcc-objc gcc-testsuite gcc-core
; do
215 old_tar
=${old_dir}/${f}-${old_vers}.
tar.gz
216 new_tar
=${WORKING_DIRECTORY}/${f}-${RELEASE}.
tar.gz
217 if [ -e $old_tar ] && [ -e $new_tar ]; then
218 build_diff
$old_tar gcc-
${old_vers} $new_tar gcc-
${RELEASE} \
219 ${f}-${old_vers}-${RELEASE}.
diff.gz
224 # Build an individual diff.
226 changedir
"${WORKING_DIRECTORY}"
228 mkdir
$tmpdir || error
"Could not create directory $tmpdir"
230 tar xfz
$1 || error
"Could not unpack $1 for diffs"
231 tar xfz
$3 || error
"Could not unpack $3 for diffs"
232 ${DIFF} $2 $4 |
${GZIP} > ..
/$5
233 if [ $?
-eq 2 ]; then
234 error
"Trouble making diffs from $1 to $3"
238 FILE_LIST
="${FILE_LIST} $5"
241 # Upload the files to the FTP server.
244 inform
"Uploading files"
246 changedir
"${WORKING_DIRECTORY}"
248 # Copy the tar files to the FTP server.
249 for x
in gcc
*.gz gcc
*.bz2
; do
251 ${SCP} ${x} ${FTP_PATH} || \
252 error
"Could not upload ${x}"
257 ########################################################################
259 ########################################################################
262 DATE
=`date "+%Y%m%d"`
264 # The CVS server containing the GCC repository.
265 CVS_SERVER
="gcc.gnu.org"
266 # The path to the repository on that server.
267 CVS_REPOSITORY
="/cvs/gcc"
268 # The CVS protocol to use.
270 # The username to use when connecting to the server.
271 CVS_USERNAME
="${USER}"
273 # The path to the directory where the files are uploaded for FTP.
274 FTP_PATH
="gccadmin@gcc.gnu.org:~ftp/pub/gcc"
276 # The major number for the release. For release `3.0.2' this would be
279 # The minor number for the release. For release `3.0.2' this would be
282 # The revision number for the release. For release `3.0.2' this would
285 # The complete name of the release.
288 # The name of the branch from which the release should be made.
291 # The tag to apply to the sources used for the release.
294 # The old tarballs from which to generate diffs.
297 # The directory that will be used to construct the release. The
298 # release itself will be placed in a subdirectory of this diretory.
302 # The directory that will contain the GCC sources.
305 # The directories that should be part of the various language-specific
306 # tar files. These are all relative to the top of the source tree.
307 CPLUSPLUS_DIRS
="gcc/cp libstdc++-v3"
308 FORTRAN_DIRS
="gcc/f libf2c"
309 JAVA_DIRS
="gcc/java libjava libffi fastjar zlib boehm-gc"
310 OBJECTIVEC_DIRS
="gcc/objc libobjc"
311 TESTSUITE_DIRS
="gcc/testsuite"
313 # Non-zero if this is the final release, rather than a prerelease.
316 # Non-zero if we create .bz2 files.
319 # Non-zero if we are building a snapshot, and don't build gcc or
320 # include generated files.
323 # Major operation modes.
328 # Files generated to upload.
333 BZIP2
="${BZIP2:-bzip2}"
334 CVS
="${CVS:-cvs -f -Q}"
335 DIFF
="${DIFF:-diff -Nrc3pad}"
336 GZIP
="${GZIP:-gzip --best}"
340 ########################################################################
341 # Command Line Processing
342 ########################################################################
345 while getopts "d:fr:u:t:p:bs" ARG
; do
347 d
) DESTINATION
="${OPTARG}";;
348 r
) RELEASE
="${OPTARG}";;
350 u
) CVS_USERNAME
="${OPTARG}";;
354 p
) OLD_TARS
="${OLD_TARS} ${OPTARG}";;
358 shift `expr ${OPTIND} - 1`
360 # Perform consistency checking.
361 if [ -z ${CVS_USERNAME} ]; then
362 error
"No username specified"
365 if [ -z ${RELEASE} ]; then
366 error
"No release number specified"
369 if [ ! -d ${DESTINATION} ]; then
370 error
"\`${DESTINATION}' is not a directory"
373 # Compute the major and minor release numbers.
374 RELEASE_MAJOR
=`echo $RELEASE | awk --assign FS=. '{ print $1; }'`
375 RELEASE_MINOR
=`echo $RELEASE | awk --assign FS=. '{ print $2; }'`
376 RELEASE_REVISION
=`echo $RELEASE | awk --assign FS=. '{ print $3; }'`
378 if [ -z "${RELEASE_MAJOR}" ] ||
[ -z "${RELEASE_MINOR}" ]; then
379 error
"Release number \`${RELEASE}' is invalid"
382 if [ -n "${RELEASE_REVISION}" ]; then
383 error
"Revision releases are unsupported"
386 # Compute the full name of the release.
387 if [ -z "${RELEASE_REVISION}" ]; then
388 RELEASE
="${RELEASE_MAJOR}.${RELEASE_MINOR}"
390 RELEASE
="${RELEASE_MAJOR}.${RELEASE_MINOR}.${RELEASE_REVISION}"
393 # Compute the name of the branch, which is based solely on the major
395 BRANCH
="gcc-${RELEASE_MAJOR}_${RELEASE_MINOR}-branch"
397 # If this is not a final release, set various parameters acordingly.
398 if [ ${FINAL} -ne 1 ]; then
399 RELEASE
="${RELEASE}-${DATE}"
400 FTP_PATH
="${FTP_PATH}/snapshots"
402 FTP_PATH
="${FTP_PATH}/releases"
405 # Compute the name of the WORKING_DIRECTORY and the SOURCE_DIRECTORY.
406 WORKING_DIRECTORY
="${DESTINATION}/gcc-${RELEASE}"
407 SOURCE_DIRECTORY
="${WORKING_DIRECTORY}/gcc-${RELEASE}"
409 # Recompute the names of all the language-specific directories,
410 # relative to the WORKING_DIRECTORY.
411 CPLUSPLUS_DIRS
=`adjust_dirs ${CPLUSPLUS_DIRS}`
412 FORTRAN_DIRS
=`adjust_dirs ${FORTRAN_DIRS}`
413 JAVA_DIRS
=`adjust_dirs ${JAVA_DIRS}`
414 OBJECTIVEC_DIRS
=`adjust_dirs ${OBJECTIVEC_DIRS}`
415 TESTSUITE_DIRS
=`adjust_dirs ${TESTSUITE_DIRS}`
418 CVSROOT
=":${CVS_PROTOCOL}:${CVS_USERNAME}@"
419 CVSROOT
="${CVSROOT}${CVS_SERVER}:${CVS_REPOSITORY}"
422 ########################################################################
424 ########################################################################
426 # Handle the major modes.
427 while [ $# -ne 0 ]; do
429 sources
) MODE_SOURCES
=1;;
430 tarfiles
) MODE_TARFILES
=1;;
431 upload
) MODE_UPLOAD
=1;;
432 all
) MODE_SOURCES
=1; MODE_TARFILES
=1; MODE_UPLOAD
=1;;
433 *) error
"Unknown mode $1";;
438 # Build the source directory.
440 if [ $MODE_SOURCES -ne 0 ]; then
444 # Build the tar files.
446 if [ $MODE_TARFILES -ne 0 ]; then
450 # Upload them to the FTP server.
452 if [ $MODE_UPLOAD -ne 0 ]; then