gcc_release 23 KB

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