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