| 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-2020 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 |
# <https://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 $@ and exit with a non-zero |
| 49 |
# exit code. |
| 50 |
|
| 51 |
error() { |
| 52 |
echo "gcc_release: error: $@" |
| 53 |
exit 1 |
| 54 |
} |
| 55 |
|
| 56 |
# Issue the informational message given by $@. |
| 57 |
|
| 58 |
inform() { |
| 59 |
echo "gcc_release: $@" |
| 60 |
} |
| 61 |
|
| 62 |
# Issue a usage message explaining how to use this script. |
| 63 |
|
| 64 |
usage() { |
| 65 |
cat <<EOF |
| 66 |
gcc_release -r release [-f] [further options] |
| 67 |
gcc_release -s name:gitbranch [further options] |
| 68 |
|
| 69 |
Options: |
| 70 |
|
| 71 |
-r release Version of the form X.Y or X.Y.Z. |
| 72 |
-s name:gitbranch 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 git. |
| 80 |
-u username Username for upload operations. |
| 81 |
-b local-git-repo Local git repository to speed up cloning. |
| 82 |
EOF |
| 83 |
exit 1 |
| 84 |
} |
| 85 |
|
| 86 |
# Change to the directory given by $1. |
| 87 |
|
| 88 |
changedir() { |
| 89 |
cd $1 || \ |
| 90 |
error "Could not change directory to $1" |
| 91 |
} |
| 92 |
|
| 93 |
# Build the source tree that will be the basis for the release |
| 94 |
# in ${WORKING_DIRECTORY}/gcc-${RELEASE}. |
| 95 |
|
| 96 |
build_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 |
|
| 106 |
# Check out the sources. |
| 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 |
| 115 |
|
| 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 |
|
| 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" |\ |
| 139 |
grep -q "^[[:blank:]]*GCC ${RELEASE_MAJOR}.${RELEASE_MINOR}" ||\ |
| 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 |\ |
| 144 |
grep -q "^[[:blank:]]*\(\[[0-9]\{1,\}\][[:blank:]]*\)\{0,1\}GCC ${RELEASE_MAJOR}.${RELEASE_MINOR}" ||\ |
| 145 |
error "GCC ${RELEASE_MAJOR}.${RELEASE_MINOR} not mentioned "\ |
| 146 |
"in gcc-${RELEASE_MAJOR}/changes.html" |
| 147 |
|
| 148 |
rm -f NEWS |
| 149 |
|
| 150 |
commit_files="" |
| 151 |
for x in `changedir ${SOURCE_DIRECTORY} && \ |
| 152 |
find . -name ChangeLog`; do |
| 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.) |
| 156 |
if ! grep "GCC ${RELEASE} released." ${SOURCE_DIRECTORY}/${x} > /dev/null ; then |
| 157 |
cat - ${SOURCE_DIRECTORY}/${x} > ${SOURCE_DIRECTORY}/${x}.new <<EOF |
| 158 |
${LONG_DATE} Release Manager |
| 159 |
|
| 160 |
* GCC ${RELEASE} released. |
| 161 |
|
| 162 |
EOF |
| 163 |
mv ${SOURCE_DIRECTORY}/${x}.new ${SOURCE_DIRECTORY}/${x} \ |
| 164 |
|| error "Could not update ${x}" |
| 165 |
commit_files="${commit_files} ${x}" |
| 166 |
fi |
| 167 |
done |
| 168 |
|
| 169 |
# Update gcc/DEV-PHASE. |
| 170 |
|
| 171 |
if [ `cat ${SOURCE_DIRECTORY}/gcc/BASE-VER` != ${RELEASE} ]; then |
| 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 && \ |
| 178 |
echo ${RELEASE} > BASE-VER) || \ |
| 179 |
error "Could not update BASE-VER" |
| 180 |
commit_files="${commit_files} gcc/BASE-VER" |
| 181 |
else |
| 182 |
error "Release number ${RELEASE} does not immediately follow BASE-VER" |
| 183 |
fi |
| 184 |
fi |
| 185 |
(changedir ${SOURCE_DIRECTORY}/gcc && \ |
| 186 |
: > DEV-PHASE) || \ |
| 187 |
error "Could not update DEV-PHASE" |
| 188 |
commit_files="${commit_files} gcc/DEV-PHASE" |
| 189 |
|
| 190 |
(changedir ${SOURCE_DIRECTORY} && \ |
| 191 |
${GIT} commit -q -m 'Update ChangeLog and version files for release' ${commit_files} && \ |
| 192 |
${GIT} push) || \ |
| 193 |
error "Could not commit ChangeLog and version file updates" |
| 194 |
|
| 195 |
# Make sure we tag the sources for a final release. |
| 196 |
TAG="releases/gcc-${RELEASE}" |
| 197 |
fi |
| 198 |
|
| 199 |
# Tag the sources. |
| 200 |
if [ -n "${TAG}" ]; then |
| 201 |
inform "Tagging sources as ${TAG}" |
| 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. |
| 205 |
if (changedir ${SOURCE_DIRECTORY} && \ |
| 206 |
${GIT} rev-parse "refs/tags/${TAG}" > /dev/null 2>&1); then |
| 207 |
error "Tag ${TAG} already exists" |
| 208 |
fi |
| 209 |
(changedir ${SOURCE_DIRECTORY} && \ |
| 210 |
${GIT} tag -s -m "GCC ${RELEASE} release" "${TAG}" && \ |
| 211 |
${GIT} push origin tag "${TAG}") || \ |
| 212 |
error "Could not tag sources" |
| 213 |
GITBRANCH=${TAG} |
| 214 |
fi |
| 215 |
|
| 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" |
| 229 |
|
| 230 |
# Remove .git from the sources. |
| 231 |
rm -rf "${SOURCE_DIRECTORY}/.git" || \ |
| 232 |
error "Could not remove .git from sources" |
| 233 |
|
| 234 |
# Run gcc_update on them to set up the timestamps nicely, and (re)write |
| 235 |
# the LAST_UPDATED file containing the git tag/revision used. |
| 236 |
changedir "gcc-${RELEASE}" |
| 237 |
contrib/gcc_update --touch |
| 238 |
echo "Obtained from git: ${GITBRANCH} revision ${GITREV}" > LAST_UPDATED |
| 239 |
|
| 240 |
# For a prerelease or real release, we need to generate additional |
| 241 |
# files not present in git. |
| 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. |
| 253 |
contrib/gennews > NEWS || \ |
| 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 |
| 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 |
| 269 |
enable_langs=c,c++,lto |
| 270 |
if [ -f ${SOURCE_DIRECTORY}/gcc/m2/Make-lang.in ]; then |
| 271 |
enable_langs=$enable_langs,m2 |
| 272 |
fi |
| 273 |
contrib/gcc_build -d ${SOURCE_DIRECTORY} -o ${OBJECT_DIRECTORY} \ |
| 274 |
-c "--enable-languages=$enable_langs --enable-generated-files-in-srcdir --disable-multilib" \ |
| 275 |
-m "-j$num_cpus" build || \ |
| 276 |
error "Could not rebuild GCC" |
| 277 |
cd ${OBJECT_DIRECTORY}/gcc |
| 278 |
all_languages=`sed -n -e '/"all_languages"/s/^.*=//p' config.status \ |
| 279 |
| sed -e 's/"//g'` |
| 280 |
for lang in $all_languages; do |
| 281 |
make $lang.srcextra $lang.srcinfo $lang.srcman || \ |
| 282 |
error "Could not build GCC $lang source extras" |
| 283 |
done |
| 284 |
if [ -d ${SOURCE_DIRECTORY}/libffi/doc ]; then |
| 285 |
makeinfo --split-size=5000000 -I ${SOURCE_DIRECTORY}/gcc/doc/include \ |
| 286 |
-I ${SOURCE_DIRECTORY}/libffi/doc/ -o ${SOURCE_DIRECTORY}/libffi/doc/libffi.info \ |
| 287 |
${SOURCE_DIRECTORY}/libffi/doc/libffi.texi || \ |
| 288 |
error "Could not build libffi.info" |
| 289 |
fi |
| 290 |
cd ${SOURCE_DIRECTORY} |
| 291 |
fi |
| 292 |
|
| 293 |
# Move message catalogs to source directory. |
| 294 |
mv ../objdir/gcc/po/*.gmo gcc/po/ |
| 295 |
[ -f libcpp/po/cpplib.pot ] && mv ../objdir/libcpp/po/*.gmo libcpp/po/ |
| 296 |
|
| 297 |
# Create a "MD5SUMS" file to use for checking the validity of the release. |
| 298 |
echo \ |
| 299 |
"# This file contains the MD5 checksums of the files in the |
| 300 |
# gcc-"${RELEASE}".tar.xz tarball. |
| 301 |
# |
| 302 |
# Besides verifying that all files in the tarball were correctly expanded, |
| 303 |
# it also can be used to determine if any files have changed since the |
| 304 |
# tarball was expanded or to verify that a patchfile was correctly applied. |
| 305 |
# |
| 306 |
# Suggested usage: |
| 307 |
# md5sum -c MD5SUMS | grep -v \"OK$\" |
| 308 |
#" > MD5SUMS |
| 309 |
|
| 310 |
find . -type f | |
| 311 |
sed -e 's:^\./::' -e '/MD5SUMS/d' | |
| 312 |
sort | |
| 313 |
xargs md5sum >>MD5SUMS |
| 314 |
} |
| 315 |
|
| 316 |
# Build a single tarfile. The first argument is the name of the tarfile |
| 317 |
# to build, without any suffixes. They will be added automatically. The |
| 318 |
# rest of the arguments are files or directories to include, and possibly |
| 319 |
# other arguments to tar. |
| 320 |
|
| 321 |
build_tarfile() { |
| 322 |
# Get the name of the destination tar file. |
| 323 |
TARFILE="$1.tar.xz" |
| 324 |
shift |
| 325 |
|
| 326 |
# Build the tar file itself. |
| 327 |
(${TAR} cf - "$@" | ${XZ} > ${TARFILE}) || \ |
| 328 |
error "Could not build tarfile" |
| 329 |
FILE_LIST="${FILE_LIST} ${TARFILE}" |
| 330 |
} |
| 331 |
|
| 332 |
# Build the various tar files for the release. |
| 333 |
|
| 334 |
build_tarfiles() { |
| 335 |
inform "Building tarfiles" |
| 336 |
|
| 337 |
changedir "${WORKING_DIRECTORY}" |
| 338 |
|
| 339 |
# The GNU Coding Standards specify that all files should |
| 340 |
# world readable. |
| 341 |
chmod -R a+r ${SOURCE_DIRECTORY} |
| 342 |
# And that all directories have mode 755. |
| 343 |
find ${SOURCE_DIRECTORY} -type d -exec chmod 755 {} \; |
| 344 |
|
| 345 |
# Build one huge tarfile for the entire distribution. |
| 346 |
build_tarfile gcc-${RELEASE} `basename ${SOURCE_DIRECTORY}` |
| 347 |
} |
| 348 |
|
| 349 |
# Build .gz files. |
| 350 |
build_gzip() { |
| 351 |
for f in ${FILE_LIST}; do |
| 352 |
target=${f%.xz}.gz |
| 353 |
(${XZ} -d -c $f | ${GZIP} > ${target}) || error "Could not create ${target}" |
| 354 |
done |
| 355 |
} |
| 356 |
|
| 357 |
# Build diffs against an old release. |
| 358 |
build_diffs() { |
| 359 |
old_dir=${1%/*} |
| 360 |
old_file=${1##*/} |
| 361 |
case "$old_file" in |
| 362 |
*.tar.xz) old_vers=${old_file%.tar.xz};; |
| 363 |
*) old_vers=${old_file%.tar.bz2};; |
| 364 |
esac |
| 365 |
old_vers=${old_vers#gcc-} |
| 366 |
inform "Building diffs against version $old_vers" |
| 367 |
for f in gcc; do |
| 368 |
if [ -e ${old_dir}/${f}-${old_vers}.tar.xz ]; then |
| 369 |
old_tar=${old_dir}/${f}-${old_vers}.tar.xz |
| 370 |
else |
| 371 |
old_tar=${old_dir}/${f}-${old_vers}.tar.bz2 |
| 372 |
fi |
| 373 |
new_tar=${WORKING_DIRECTORY}/${f}-${RELEASE}.tar.xz |
| 374 |
if [ ! -e $old_tar ]; then |
| 375 |
inform "$old_tar not found; not generating diff file" |
| 376 |
elif [ ! -e $new_tar ]; then |
| 377 |
inform "$new_tar not found; not generating diff file" |
| 378 |
else |
| 379 |
build_diff $old_tar gcc-${old_vers} $new_tar gcc-${RELEASE} \ |
| 380 |
${f}-${old_vers}-${RELEASE}.diff.xz |
| 381 |
fi |
| 382 |
done |
| 383 |
} |
| 384 |
|
| 385 |
# Build an individual diff. |
| 386 |
build_diff() { |
| 387 |
changedir "${WORKING_DIRECTORY}" |
| 388 |
tmpdir=gccdiff.$$ |
| 389 |
mkdir $tmpdir || error "Could not create directory $tmpdir" |
| 390 |
changedir $tmpdir |
| 391 |
case "$1" in |
| 392 |
*.tar.bz2) |
| 393 |
(${BZIP2} -d -c $1 | ${TAR} xf - ) || error "Could not unpack $1 for diffs" |
| 394 |
;; |
| 395 |
*.tar.xz) |
| 396 |
(${XZ} -d -c $1 | ${TAR} xf - ) || error "Could not unpack $1 for diffs" |
| 397 |
;; |
| 398 |
esac |
| 399 |
(${XZ} -d -c $3 | ${TAR} xf - ) || error "Could not unpack $3 for diffs" |
| 400 |
${DIFF} $2 $4 > ../${5%.xz} |
| 401 |
if [ $? -eq 2 ]; then |
| 402 |
error "Trouble making diffs from $1 to $3" |
| 403 |
fi |
| 404 |
${XZ} ../${5%.xz} || error "Could not generate ../$5" |
| 405 |
changedir .. |
| 406 |
rm -rf $tmpdir |
| 407 |
FILE_LIST="${FILE_LIST} $5" |
| 408 |
} |
| 409 |
|
| 410 |
# Upload the files to the FTP server. |
| 411 |
upload_files() { |
| 412 |
inform "Uploading files" |
| 413 |
|
| 414 |
changedir "${WORKING_DIRECTORY}" |
| 415 |
|
| 416 |
# Make sure the directory exists on the server. |
| 417 |
if [ $LOCAL -eq 0 ]; then |
| 418 |
${SSH} -l ${GCC_USERNAME} ${GCC_HOSTNAME} \ |
| 419 |
mkdir -m 755 -p "${FTP_PATH}/diffs" |
| 420 |
UPLOAD_PATH="${GCC_USERNAME}@${GCC_HOSTNAME}:${FTP_PATH}" |
| 421 |
else |
| 422 |
mkdir -p "${FTP_PATH}/diffs" \ |
| 423 |
|| error "Could not create \`${FTP_PATH}'" |
| 424 |
UPLOAD_PATH=${FTP_PATH} |
| 425 |
fi |
| 426 |
|
| 427 |
# Then copy files to their respective (sub)directories. |
| 428 |
for x in gcc*.gz gcc*.xz; do |
| 429 |
if [ -e ${x} ]; then |
| 430 |
# Make sure the file will be readable on the server. |
| 431 |
chmod a+r ${x} |
| 432 |
# Copy it. |
| 433 |
case ${x} in |
| 434 |
*.diff.*) |
| 435 |
SUBDIR="diffs/"; |
| 436 |
;; |
| 437 |
*) |
| 438 |
SUBDIR=""; |
| 439 |
esac |
| 440 |
${SCP} ${x} ${UPLOAD_PATH}/${SUBDIR} \ |
| 441 |
|| error "Could not upload ${x}" |
| 442 |
fi |
| 443 |
done |
| 444 |
} |
| 445 |
|
| 446 |
# Print description if snapshot exists. |
| 447 |
snapshot_print() { |
| 448 |
if [ -e ${RELEASE}/$1 ]; then |
| 449 |
hash=`openssl sha256 ${RELEASE}/$1 | sed -e 's#(.*)##' -e 's# *= *#=#'` |
| 450 |
hash2=`openssl sha1 ${RELEASE}/$1 | sed -e 's#(.*)##' -e 's# *= *#=#'` |
| 451 |
|
| 452 |
printf " %-37s%s\n\n %s\n %s\n\n" "$1" "$2" "$hash" "$hash2" \ |
| 453 |
>> ${SNAPSHOT_README} |
| 454 |
|
| 455 |
echo " <tr><td><a href=\"$1\">$1</a></td>" >> ${SNAPSHOT_INDEX} |
| 456 |
echo " <td>$2</td></tr>" >> ${SNAPSHOT_INDEX} |
| 457 |
fi |
| 458 |
} |
| 459 |
|
| 460 |
# Announce a snapshot, both on the web and via mail. |
| 461 |
announce_snapshot() { |
| 462 |
inform "Updating links and READMEs on the FTP server" |
| 463 |
|
| 464 |
TEXT_DATE=`date --date=$DATE +%B\ %d,\ %Y` |
| 465 |
SNAPSHOT_README=${RELEASE}/README |
| 466 |
SNAPSHOT_INDEX=${RELEASE}/index.html |
| 467 |
|
| 468 |
changedir "${SNAPSHOTS_DIR}" |
| 469 |
echo \ |
| 470 |
"Snapshot gcc-"${RELEASE}" is now available on |
| 471 |
https://gcc.gnu.org/pub/gcc/snapshots/"${RELEASE}"/ |
| 472 |
and on various mirrors, see https://gcc.gnu.org/mirrors.html for details. |
| 473 |
|
| 474 |
This snapshot has been generated from the GCC "${BRANCH}" git branch |
| 475 |
with the following options: "git://gcc.gnu.org/git/gcc.git branch ${GITBRANCH} revision ${GITREV}" |
| 476 |
|
| 477 |
You'll find: |
| 478 |
" > ${SNAPSHOT_README} |
| 479 |
|
| 480 |
echo \ |
| 481 |
"<html> |
| 482 |
|
| 483 |
<head> |
| 484 |
<title>GCC "${RELEASE}" Snapshot</title> |
| 485 |
</head> |
| 486 |
|
| 487 |
<body> |
| 488 |
<h1>GCC "${RELEASE}" Snapshot</h1> |
| 489 |
|
| 490 |
<p>The <a href =\"https://gcc.gnu.org/\">GCC Project</a> makes |
| 491 |
periodic snapshots of the GCC source tree available to the public |
| 492 |
for testing purposes.</p> |
| 493 |
|
| 494 |
<p>If you are planning to download and use one of our snapshots, then |
| 495 |
we highly recommend you join the GCC developers list. Details for |
| 496 |
how to sign up can be found on the GCC project home page.</p> |
| 497 |
|
| 498 |
<p>This snapshot has been generated from the GCC "${BRANCH}" git branch |
| 499 |
with the following options: <code>"git://gcc.gnu.org/git/gcc.git branch ${GITBRANCH} revision ${GITREV}"</code></p> |
| 500 |
|
| 501 |
<table>" > ${SNAPSHOT_INDEX} |
| 502 |
|
| 503 |
snapshot_print gcc-${RELEASE}.tar.xz "Complete GCC" |
| 504 |
|
| 505 |
echo \ |
| 506 |
"Diffs from "${BRANCH}"-"${LAST_DATE}" are available in the diffs/ subdirectory. |
| 507 |
|
| 508 |
When a particular snapshot is ready for public consumption the LATEST-"${BRANCH}" |
| 509 |
link is updated and a message is sent to the gcc list. Please do not use |
| 510 |
a snapshot before it has been announced that way." >> ${SNAPSHOT_README} |
| 511 |
|
| 512 |
echo \ |
| 513 |
"</table> |
| 514 |
<p>Diffs from "${BRANCH}"-"${LAST_DATE}" are available in the |
| 515 |
<a href=\"diffs/\">diffs/ subdirectory</a>.</p> |
| 516 |
|
| 517 |
<p>When a particular snapshot is ready for public consumption the LATEST-"${BRANCH}" |
| 518 |
link is updated and a message is sent to the gcc list. Please do not use |
| 519 |
a snapshot before it has been announced that way.</p> |
| 520 |
|
| 521 |
<hr /> |
| 522 |
|
| 523 |
<address> |
| 524 |
<a href=\"mailto:[email protected]\">[email protected]</a> |
| 525 |
<br /> |
| 526 |
Last modified "${TEXT_DATE}" |
| 527 |
</address> |
| 528 |
</body> |
| 529 |
|
| 530 |
</html>" >> ${SNAPSHOT_INDEX} |
| 531 |
|
| 532 |
rm -f LATEST-${BRANCH} |
| 533 |
ln -s ${RELEASE} LATEST-${BRANCH} |
| 534 |
|
| 535 |
inform "Sending mail" |
| 536 |
|
| 537 |
export QMAILHOST=gcc.gnu.org |
| 538 |
mail -s "gcc-${RELEASE} is now available" [email protected] < ${SNAPSHOT_README} |
| 539 |
} |
| 540 |
|
| 541 |
######################################################################## |
| 542 |
# Initialization |
| 543 |
######################################################################## |
| 544 |
|
| 545 |
LC_ALL=C |
| 546 |
export LC_ALL |
| 547 |
|
| 548 |
# Today's date. |
| 549 |
DATE=`date "+%Y%m%d"` |
| 550 |
LONG_DATE=`date "+%Y-%m-%d"` |
| 551 |
|
| 552 |
GIT=${GIT:-git} |
| 553 |
# The server containing the GCC repository. |
| 554 |
GIT_SERVER="gcc.gnu.org" |
| 555 |
# The path to the repository on that server. |
| 556 |
GIT_REPOSITORY="/git/gcc.git" |
| 557 |
# The username to use when connecting to the server. |
| 558 |
GIT_USERNAME="${USER}" |
| 559 |
|
| 560 |
# The machine to which files will be uploaded. |
| 561 |
GCC_HOSTNAME="gcc.gnu.org" |
| 562 |
# The name of the account on the machine to which files are uploaded. |
| 563 |
GCC_USERNAME="gccadmin" |
| 564 |
# The directory in which the files will be placed (do not use ~user syntax). |
| 565 |
FTP_PATH=/var/ftp/pub/gcc |
| 566 |
# The directory in which snapshots will be placed. |
| 567 |
SNAPSHOTS_DIR=${FTP_PATH}/snapshots |
| 568 |
|
| 569 |
# The major number for the release. For release `3.0.2' this would be |
| 570 |
# `3' |
| 571 |
RELEASE_MAJOR="" |
| 572 |
# The minor number for the release. For release `3.0.2' this would be |
| 573 |
# `0'. |
| 574 |
RELEASE_MINOR="" |
| 575 |
# The revision number for the release. For release `3.0.2' this would |
| 576 |
# be `2'. |
| 577 |
RELEASE_REVISION="" |
| 578 |
# The complete name of the release. |
| 579 |
RELEASE="" |
| 580 |
|
| 581 |
# The name of the branch from which the release should be made, in a |
| 582 |
# user-friendly form. |
| 583 |
BRANCH="" |
| 584 |
|
| 585 |
# The name of the branch from which the release should be made, as used |
| 586 |
# for our version control system. |
| 587 |
GITBRANCH="" |
| 588 |
|
| 589 |
# The tag to apply to the sources used for the release. |
| 590 |
TAG="" |
| 591 |
|
| 592 |
# The old tarballs from which to generate diffs. |
| 593 |
OLD_TARS="" |
| 594 |
|
| 595 |
# Local gcc git checkout to speed up git cloning. |
| 596 |
GIT_REFERENCE="" |
| 597 |
|
| 598 |
# The directory that will be used to construct the release. The |
| 599 |
# release itself will be placed in a subdirectory of this directory. |
| 600 |
DESTINATION=${HOME} |
| 601 |
# The subdirectory. |
| 602 |
WORKING_DIRECTORY="" |
| 603 |
# The directory that will contain the GCC sources. |
| 604 |
SOURCE_DIRECTORY="" |
| 605 |
|
| 606 |
# Non-zero if this is the final release, rather than a prerelease. |
| 607 |
FINAL=0 |
| 608 |
|
| 609 |
# Non-zero if we are building a snapshot, and don't build gcc or |
| 610 |
# include generated files. |
| 611 |
SNAPSHOT=0 |
| 612 |
|
| 613 |
# Non-zero if we are running locally on gcc.gnu.org, and use local CVS |
| 614 |
# and copy directly to the FTP directory. |
| 615 |
LOCAL=0 |
| 616 |
|
| 617 |
# Major operation modes. |
| 618 |
MODE_GZIP=0 |
| 619 |
MODE_DIFFS=0 |
| 620 |
MODE_SOURCES=0 |
| 621 |
MODE_TARFILES=0 |
| 622 |
MODE_UPLOAD=0 |
| 623 |
|
| 624 |
# List of archive files generated; used to create .gz files from .xz. |
| 625 |
FILE_LIST="" |
| 626 |
|
| 627 |
# Programs we use. |
| 628 |
|
| 629 |
BZIP2="${BZIP2:-bzip2}" |
| 630 |
XZ="${XZ:-xz -T0 --best}" |
| 631 |
CVS="${CVS:-cvs -f -Q -z9}" |
| 632 |
DIFF="${DIFF:-diff -Nrcpad}" |
| 633 |
ENV="${ENV:-env}" |
| 634 |
GZIP="${GZIP:-gzip --best}" |
| 635 |
SCP="${SCP:-scp -p}" |
| 636 |
SSH="${SSH:-ssh}" |
| 637 |
TAR="${TAR:-tar}" |
| 638 |
|
| 639 |
######################################################################## |
| 640 |
# Command Line Processing |
| 641 |
######################################################################## |
| 642 |
|
| 643 |
# Parse the options. |
| 644 |
while getopts "d:fr:u:t:p:s:lb:" ARG; do |
| 645 |
case $ARG in |
| 646 |
d) DESTINATION="${OPTARG}";; |
| 647 |
r) RELEASE="${OPTARG}";; |
| 648 |
t) TAG="${OPTARG}";; |
| 649 |
u) GIT_USERNAME="${OPTARG}";; |
| 650 |
f) FINAL=1;; |
| 651 |
s) SNAPSHOT=1 |
| 652 |
BRANCH=${OPTARG%:*} |
| 653 |
GITBRANCH=${OPTARG#*:} |
| 654 |
;; |
| 655 |
l) LOCAL=1 |
| 656 |
SCP=cp |
| 657 |
PATH=~:/usr/local/bin:$PATH;; |
| 658 |
p) OLD_TARS="${OLD_TARS} ${OPTARG}" |
| 659 |
if [ ! -f ${OPTARG} ]; then |
| 660 |
error "-p argument must name a tarball" |
| 661 |
fi;; |
| 662 |
b) GIT_REFERENCE="${OPTARG}";; |
| 663 |
\?) usage;; |
| 664 |
esac |
| 665 |
done |
| 666 |
shift `expr ${OPTIND} - 1` |
| 667 |
|
| 668 |
# Handle the major modes. |
| 669 |
while [ $# -ne 0 ]; do |
| 670 |
case $1 in |
| 671 |
diffs) MODE_DIFFS=1;; |
| 672 |
gzip) MODE_GZIP=1;; |
| 673 |
sources) MODE_SOURCES=1;; |
| 674 |
tarfiles) MODE_TARFILES=1;; |
| 675 |
upload) MODE_UPLOAD=1;; |
| 676 |
all) MODE_SOURCES=1; MODE_TARFILES=1; MODE_DIFFS=1; MODE_UPLOAD=1; |
| 677 |
if [ $SNAPSHOT -ne 1 ]; then |
| 678 |
# Only for releases and pre-releases. |
| 679 |
MODE_GZIP=1; |
| 680 |
fi |
| 681 |
;; |
| 682 |
*) error "Unknown mode $1";; |
| 683 |
esac |
| 684 |
shift |
| 685 |
done |
| 686 |
|
| 687 |
# Perform consistency checking. |
| 688 |
if [ ${LOCAL} -eq 0 ] && [ -z ${GIT_USERNAME} ]; then |
| 689 |
error "No username specified" |
| 690 |
fi |
| 691 |
|
| 692 |
if [ ! -d ${DESTINATION} ]; then |
| 693 |
error "\`${DESTINATION}' is not a directory" |
| 694 |
fi |
| 695 |
|
| 696 |
if [ $SNAPSHOT -eq 0 ]; then |
| 697 |
if [ -z ${RELEASE} ]; then |
| 698 |
error "No release number specified" |
| 699 |
fi |
| 700 |
|
| 701 |
# Compute the major and minor release numbers. |
| 702 |
RELEASE_MAJOR=`echo $RELEASE | awk --assign FS=. '{ print $1; }'` |
| 703 |
RELEASE_MINOR=`echo $RELEASE | awk --assign FS=. '{ print $2; }'` |
| 704 |
RELEASE_REVISION=`echo $RELEASE | awk --assign FS=. '{ print $3; }'` |
| 705 |
|
| 706 |
if [ -z "${RELEASE_MAJOR}" ] || [ -z "${RELEASE_MINOR}" ]; then |
| 707 |
error "Release number \`${RELEASE}' is invalid" |
| 708 |
fi |
| 709 |
|
| 710 |
# Compute the full name of the release. |
| 711 |
if [ -z "${RELEASE_REVISION}" ]; then |
| 712 |
RELEASE="${RELEASE_MAJOR}.${RELEASE_MINOR}" |
| 713 |
else |
| 714 |
RELEASE="${RELEASE_MAJOR}.${RELEASE_MINOR}.${RELEASE_REVISION}" |
| 715 |
fi |
| 716 |
|
| 717 |
# Compute the name of the branch, which is based solely on the major |
| 718 |
# release number. |
| 719 |
GITBRANCH="releases/gcc-${RELEASE_MAJOR}" |
| 720 |
|
| 721 |
# If this is not a final release, set various parameters accordingly. |
| 722 |
if [ ${FINAL} -ne 1 ]; then |
| 723 |
RELEASE="${RELEASE}-RC-${DATE}" |
| 724 |
FTP_PATH="${SNAPSHOTS_DIR}/${RELEASE}" |
| 725 |
else |
| 726 |
FTP_PATH="${FTP_PATH}/releases/gcc-${RELEASE}/" |
| 727 |
fi |
| 728 |
else |
| 729 |
RELEASE=${BRANCH}-${DATE} |
| 730 |
FTP_PATH="${FTP_PATH}/snapshots/${RELEASE}" |
| 731 |
|
| 732 |
# If diffs are requested when building locally on gcc.gnu.org, we (usually) |
| 733 |
# know what the last snapshot date was and take the corresponding tarballs, |
| 734 |
# unless the user specified tarballs explicitly. |
| 735 |
if [ $MODE_DIFFS -ne 0 ] && [ $LOCAL -ne 0 ] && [ -z "${OLD_TARS}" ]; then |
| 736 |
LAST_DATE=`cat ~/.snapshot_date-${BRANCH}` |
| 737 |
OLD_TARS=${SNAPSHOTS_DIR}/${BRANCH}-${LAST_DATE}/gcc-${BRANCH}-${LAST_DATE}.tar.bz2 |
| 738 |
if [ ! -e $OLD_TARS ]; then |
| 739 |
OLD_TARS=${SNAPSHOTS_DIR}/${BRANCH}-${LAST_DATE}/gcc-${BRANCH}-${LAST_DATE}.tar.xz |
| 740 |
fi |
| 741 |
fi |
| 742 |
fi |
| 743 |
|
| 744 |
# Compute the name of the WORKING_DIRECTORY and the SOURCE_DIRECTORY. |
| 745 |
WORKING_DIRECTORY="${DESTINATION}/gcc-${RELEASE}" |
| 746 |
SOURCE_DIRECTORY="${WORKING_DIRECTORY}/gcc-${RELEASE}" |
| 747 |
|
| 748 |
# Set up GITROOT. |
| 749 |
if [ $LOCAL -eq 0 ]; then |
| 750 |
GITROOT="git+ssh://${GIT_USERNAME}@${GIT_SERVER}${GIT_REPOSITORY}" |
| 751 |
else |
| 752 |
GITROOT="/git/gcc.git" |
| 753 |
fi |
| 754 |
export GITROOT |
| 755 |
|
| 756 |
######################################################################## |
| 757 |
# Main Program |
| 758 |
######################################################################## |
| 759 |
|
| 760 |
# Set the timezone to UTC |
| 761 |
TZ="UTC0" |
| 762 |
export TZ |
| 763 |
|
| 764 |
# Build the source directory. |
| 765 |
|
| 766 |
if [ $MODE_SOURCES -ne 0 ]; then |
| 767 |
build_sources |
| 768 |
fi |
| 769 |
|
| 770 |
# Build the tar files. |
| 771 |
|
| 772 |
if [ $MODE_TARFILES -ne 0 ]; then |
| 773 |
build_tarfiles |
| 774 |
fi |
| 775 |
|
| 776 |
# Build diffs |
| 777 |
|
| 778 |
if [ $MODE_DIFFS -ne 0 ]; then |
| 779 |
# Possibly build diffs. |
| 780 |
if [ -n "$OLD_TARS" ]; then |
| 781 |
for old_tar in $OLD_TARS; do |
| 782 |
build_diffs $old_tar |
| 783 |
done |
| 784 |
fi |
| 785 |
fi |
| 786 |
|
| 787 |
# Build gzip files |
| 788 |
if [ $MODE_GZIP -ne 0 ]; then |
| 789 |
build_gzip |
| 790 |
fi |
| 791 |
|
| 792 |
# Upload them to the FTP server. |
| 793 |
if [ $MODE_UPLOAD -ne 0 ]; then |
| 794 |
upload_files |
| 795 |
|
| 796 |
# For snapshots, make some further updates. |
| 797 |
if [ $SNAPSHOT -ne 0 ] && [ $LOCAL -ne 0 ]; then |
| 798 |
announce_snapshot |
| 799 |
|
| 800 |
# Update snapshot date file. |
| 801 |
changedir ~ |
| 802 |
echo $DATE > .snapshot_date-${BRANCH} |
| 803 |
|
| 804 |
# Remove working directory |
| 805 |
rm -rf ${WORKING_DIRECTORY} |
| 806 |
fi |
| 807 |
fi |