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