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