Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Tom Tromey | 919adfe | 2019-12-15 07:37:06 -0700 | [diff] [blame] | 2 | # Copyright (C) 1990-2020 Free Software Foundation |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 3 | # |
| 4 | # This file is free software; you can redistribute it and/or modify |
| 5 | # it under the terms of the GNU General Public License as published by |
| 6 | # the Free Software Foundation; either version 3 of the License, or |
| 7 | # (at your option) any later version. |
| 8 | # |
| 9 | # This program is distributed in the hope that it will be useful, |
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | # GNU General Public License for more details. |
| 13 | # |
| 14 | # You should have received a copy of the GNU General Public License |
| 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | # |
| 17 | |
| 18 | # This script creates release packages for gdb, binutils, and other |
| 19 | # packages which live in src. It used to be implemented as the src-release |
| 20 | # Makefile and prior to that was part of the top level Makefile, but that |
| 21 | # turned out to be very messy and hard to maintain. |
| 22 | |
| 23 | set -e |
| 24 | |
| 25 | BZIPPROG=bzip2 |
| 26 | GZIPPROG=gzip |
Nick Clifton | ef87240 | 2017-09-15 16:18:20 +0100 | [diff] [blame] | 27 | LZIPPROG=lzip |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 28 | XZPROG=xz |
Andreas Rammhold | ce04ca3 | 2020-10-26 04:03:29 +0100 | [diff] [blame] | 29 | SHA256PROG=sha256sum |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 30 | MAKE=make |
| 31 | CC=gcc |
| 32 | CXX=g++ |
| 33 | |
| 34 | # Default to avoid splitting info files by setting the threshold high. |
| 35 | MAKEINFOFLAGS=--split-size=5000000 |
| 36 | |
| 37 | # |
| 38 | # Support for building net releases |
| 39 | |
Nick Clifton | 19e2900 | 2018-01-13 14:29:27 +0000 | [diff] [blame] | 40 | # Files in root used in any net release. |
Nick Clifton | 2012bf0 | 2019-02-07 14:30:02 +0000 | [diff] [blame] | 41 | DEVO_SUPPORT="ar-lib ChangeLog compile config config-ml.in config.guess \ |
| 42 | config.rpath config.sub configure configure.ac COPYING COPYING.LIB \ |
| 43 | COPYING3 COPYING3.LIB depcomp install-sh libtool.m4 ltgcc.m4 \ |
| 44 | ltmain.sh ltoptions.m4 ltsugar.m4 ltversion.m4 lt~obsolete.m4 \ |
| 45 | MAINTAINERS Makefile.def Makefile.in Makefile.tpl missing mkdep \ |
| 46 | mkinstalldirs move-if-change README README-maintainer-mode \ |
| 47 | src-release.sh symlink-tree test-driver ylwrap" |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 48 | |
| 49 | # Files in devo/etc used in any net release. |
| 50 | ETC_SUPPORT="Makefile.in configure configure.in standards.texi \ |
| 51 | make-stds.texi standards.info* configure.texi configure.info* \ |
| 52 | ChangeLog configbuild.* configdev.* fdl.texi texi2pod.pl gnu-oids.texi" |
| 53 | |
| 54 | # Get the version number of a given tool |
| 55 | getver() |
| 56 | { |
| 57 | tool=$1 |
| 58 | if grep 'AC_INIT.*BFD_VERSION' $tool/configure.ac >/dev/null 2>&1; then |
| 59 | bfd/configure --version | sed -n -e '1s,.* ,,p' |
| 60 | elif test -f $tool/common/create-version.sh; then |
| 61 | $tool/common/create-version.sh $tool 'dummy-host' 'dummy-target' VER.tmp |
Joel Brobecker | b677098 | 2016-01-17 10:01:55 +0400 | [diff] [blame] | 62 | cat VER.tmp | grep 'version\[\]' | sed 's/.*"\([^"]*\)".*/\1/' | sed 's/-git$//' |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 63 | rm -f VER.tmp |
Sergio Durigan Junior | fc1ca14 | 2020-01-28 17:21:41 -0500 | [diff] [blame] | 64 | elif test $tool = "gdb"; then |
| 65 | ./gdbsupport/create-version.sh $tool 'dummy-host' 'dummy-target' VER.tmp |
Joel Brobecker | 48b550c | 2019-07-13 18:00:32 -0700 | [diff] [blame] | 66 | cat VER.tmp | grep 'version\[\]' | sed 's/.*"\([^"]*\)".*/\1/' | sed 's/-git$//' |
| 67 | rm -f VER.tmp |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 68 | elif test -f $tool/version.in; then |
Alan Modra | a315e14 | 2019-10-17 16:25:38 +1030 | [diff] [blame] | 69 | head -n 1 $tool/version.in |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 70 | else |
| 71 | echo VERSION |
| 72 | fi |
| 73 | } |
| 74 | |
| 75 | # Setup build directory for building release tarball |
| 76 | do_proto_toplev() |
| 77 | { |
| 78 | package=$1 |
| 79 | ver=$2 |
| 80 | tool=$3 |
| 81 | support_files=$4 |
Nick Clifton | b431b4e | 2018-01-29 13:19:02 +0000 | [diff] [blame] | 82 | |
| 83 | echo "==> Cleaning sources." |
Nick Clifton | 52b2f30 | 2018-01-30 17:48:24 +0000 | [diff] [blame] | 84 | find \( -name "*.orig" -o -name "*.rej" -o -name "*~" -o -name ".#*" -o -name "*~$bkpat" \) -exec rm {} \; |
Nick Clifton | b431b4e | 2018-01-29 13:19:02 +0000 | [diff] [blame] | 85 | |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 86 | echo "==> Making $package-$ver/" |
| 87 | # Take out texinfo from a few places. |
| 88 | sed -e '/^all\.normal: /s/\all-texinfo //' \ |
| 89 | -e '/^ install-texinfo /d' \ |
| 90 | <Makefile.in >tmp |
| 91 | mv -f tmp Makefile.in |
Alan Modra | 817b771 | 2017-09-15 14:33:58 +0930 | [diff] [blame] | 92 | # configure. --enable-gold is needed to ensure .c/.h from .y are |
| 93 | # built in the gold dir. The disables speed the build a little. |
| 94 | enables= |
| 95 | disables= |
Nick Clifton | e33f231 | 2019-05-29 12:49:13 +0100 | [diff] [blame] | 96 | for dir in binutils gas gdb gold gprof ld libctf libdecnumber readline sim; do |
Alan Modra | 817b771 | 2017-09-15 14:33:58 +0930 | [diff] [blame] | 97 | case " $tool $support_files " in |
| 98 | *" $dir "*) enables="$enables --enable-$dir" ;; |
| 99 | *) disables="$disables --disable-$dir" ;; |
| 100 | esac |
| 101 | done |
| 102 | echo "==> configure --target=i386-pc-linux-gnu $disables $enables" |
| 103 | ./configure --target=i386-pc-linux-gnu $disables $enables |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 104 | $MAKE configure-host configure-target \ |
| 105 | ALL_GCC="" ALL_GCC_C="" ALL_GCC_CXX="" \ |
| 106 | CC_FOR_TARGET="$CC" CXX_FOR_TARGET="$CXX" |
| 107 | # Make links, and run "make diststuff" or "make info" when needed. |
| 108 | rm -rf proto-toplev |
| 109 | mkdir proto-toplev |
| 110 | dirs="$DEVO_SUPPORT $support_files $tool" |
| 111 | for d in $dirs ; do |
| 112 | if [ -d $d ]; then |
| 113 | if [ ! -f $d/Makefile ] ; then |
| 114 | true |
| 115 | elif grep '^diststuff:' $d/Makefile >/dev/null ; then |
| 116 | (cd $d ; $MAKE MAKEINFOFLAGS="$MAKEINFOFLAGS" diststuff) \ |
| 117 | || exit 1 |
| 118 | elif grep '^info:' $d/Makefile >/dev/null ; then |
| 119 | (cd $d ; $MAKE MAKEINFOFLAGS="$MAKEINFOFLAGS" info) \ |
| 120 | || exit 1 |
| 121 | fi |
| 122 | if [ -d $d/proto-$d.dir ]; then |
| 123 | ln -s ../$d/proto-$d.dir proto-toplev/$d |
| 124 | else |
| 125 | ln -s ../$d proto-toplev/$d |
| 126 | fi |
| 127 | else |
| 128 | if (echo x$d | grep / >/dev/null); then |
Mike Frysinger | 3034143 | 2021-01-09 19:06:27 -0500 | [diff] [blame] | 129 | mkdir -p proto-toplev/`dirname $d` |
| 130 | x=`dirname $d` |
| 131 | ln -s ../`echo $x/ | sed -e 's,[^/]*/,../,g'`$d proto-toplev/$d |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 132 | else |
Mike Frysinger | 3034143 | 2021-01-09 19:06:27 -0500 | [diff] [blame] | 133 | ln -s ../$d proto-toplev/$d |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 134 | fi |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 135 | fi |
Mike Frysinger | 3034143 | 2021-01-09 19:06:27 -0500 | [diff] [blame] | 136 | done |
| 137 | (cd etc; $MAKE MAKEINFOFLAGS="$MAKEINFOFLAGS" info) |
| 138 | $MAKE distclean |
| 139 | mkdir proto-toplev/etc |
| 140 | (cd proto-toplev/etc; |
| 141 | for i in $ETC_SUPPORT; do |
| 142 | ln -s ../../etc/$i . |
| 143 | done) |
| 144 | # |
| 145 | # Take out texinfo from configurable dirs |
| 146 | rm proto-toplev/configure.ac |
| 147 | sed -e '/^host_tools=/s/texinfo //' \ |
| 148 | <configure.ac >proto-toplev/configure.ac |
| 149 | # |
| 150 | mkdir proto-toplev/texinfo |
| 151 | ln -s ../../texinfo/texinfo.tex proto-toplev/texinfo/ |
| 152 | if test -r texinfo/util/tex3patch ; then |
| 153 | mkdir proto-toplev/texinfo/util && \ |
| 154 | ln -s ../../../texinfo/util/tex3patch proto-toplev/texinfo/util |
| 155 | fi |
| 156 | chmod -R og=u . || chmod og=u `find . -print` |
| 157 | # |
| 158 | # Create .gmo files from .po files. |
| 159 | for f in `find . -name '*.po' -type f -print`; do |
| 160 | msgfmt -o `echo $f | sed -e 's/\.po$/.gmo/'` $f |
| 161 | done |
| 162 | # |
| 163 | rm -f $package-$ver |
| 164 | ln -s proto-toplev $package-$ver |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | CVS_NAMES='-name CVS -o -name .cvsignore' |
| 168 | |
Andreas Rammhold | ce04ca3 | 2020-10-26 04:03:29 +0100 | [diff] [blame] | 169 | # Add a sha256sum to the built tarball |
| 170 | do_sha256sum() |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 171 | { |
Andreas Rammhold | ce04ca3 | 2020-10-26 04:03:29 +0100 | [diff] [blame] | 172 | echo "==> Adding sha256 checksum to top-level directory" |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 173 | (cd proto-toplev && find * -follow \( $CVS_NAMES \) -prune \ |
| 174 | -o -type f -print \ |
Andreas Rammhold | ce04ca3 | 2020-10-26 04:03:29 +0100 | [diff] [blame] | 175 | | xargs $SHA256PROG > ../sha256.new) |
| 176 | rm -f proto-toplev/sha256.sum |
| 177 | mv sha256.new proto-toplev/sha256.sum |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | # Build the release tarball |
| 181 | do_tar() |
| 182 | { |
| 183 | package=$1 |
| 184 | ver=$2 |
| 185 | echo "==> Making $package-$ver.tar" |
| 186 | rm -f $package-$ver.tar |
| 187 | find $package-$ver -follow \( $CVS_NAMES \) -prune \ |
| 188 | -o -type f -print \ |
| 189 | | tar cTfh - $package-$ver.tar |
| 190 | } |
| 191 | |
| 192 | # Compress the output with bzip2 |
| 193 | do_bz2() |
| 194 | { |
| 195 | package=$1 |
| 196 | ver=$2 |
| 197 | echo "==> Bzipping $package-$ver.tar.bz2" |
| 198 | rm -f $package-$ver.tar.bz2 |
| 199 | $BZIPPROG -k -v -9 $package-$ver.tar |
| 200 | } |
| 201 | |
| 202 | # Compress the output with gzip |
| 203 | do_gz() |
| 204 | { |
| 205 | package=$1 |
| 206 | ver=$2 |
| 207 | echo "==> Gzipping $package-$ver.tar.gz" |
| 208 | rm -f $package-$ver.tar.gz |
| 209 | $GZIPPROG -k -v -9 $package-$ver.tar |
| 210 | } |
| 211 | |
Nick Clifton | ef87240 | 2017-09-15 16:18:20 +0100 | [diff] [blame] | 212 | # Compress the output with lzip |
| 213 | do_lz() |
| 214 | { |
| 215 | package=$1 |
| 216 | ver=$2 |
| 217 | echo "==> Lzipping $package-$ver.tar.lz" |
| 218 | rm -f $package-$ver.tar.lz |
| 219 | $LZIPPROG -k -v -9 $package-$ver.tar |
| 220 | } |
| 221 | |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 222 | # Compress the output with xz |
| 223 | do_xz() |
| 224 | { |
| 225 | package=$1 |
| 226 | ver=$2 |
| 227 | echo "==> Xzipping $package-$ver.tar.xz" |
| 228 | rm -f $package-$ver.tar.xz |
| 229 | $XZPROG -k -v -9 $package-$ver.tar |
| 230 | } |
| 231 | |
| 232 | # Compress the output with all selected compresion methods |
| 233 | do_compress() |
| 234 | { |
| 235 | package=$1 |
| 236 | ver=$2 |
| 237 | compressors=$3 |
| 238 | for comp in $compressors; do |
| 239 | case $comp in |
| 240 | bz2) |
| 241 | do_bz2 $package $ver;; |
| 242 | gz) |
| 243 | do_gz $package $ver;; |
Nick Clifton | ef87240 | 2017-09-15 16:18:20 +0100 | [diff] [blame] | 244 | lz) |
| 245 | do_lz $package $ver;; |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 246 | xz) |
| 247 | do_xz $package $ver;; |
| 248 | *) |
| 249 | echo "Unknown compression method: $comp" && exit 1;; |
| 250 | esac |
| 251 | done |
| 252 | } |
| 253 | |
| 254 | # Add djunpack.bat the tarball |
| 255 | do_djunpack() |
| 256 | { |
| 257 | package=$1 |
| 258 | ver=$2 |
| 259 | echo "==> Adding updated djunpack.bat to top-level directory" |
| 260 | echo - 's /gdb-[0-9\.]*/$package-'"$ver"'/' |
| 261 | sed < djunpack.bat > djunpack.new \ |
| 262 | -e 's/gdb-[0-9][0-9\.]*/$package-'"$ver"'/' |
| 263 | rm -f proto-toplev/djunpack.bat |
| 264 | mv djunpack.new proto-toplev/djunpack.bat |
| 265 | } |
| 266 | |
| 267 | # Create a release package, tar it and compress it |
| 268 | tar_compress() |
| 269 | { |
| 270 | package=$1 |
| 271 | tool=$2 |
| 272 | support_files=$3 |
| 273 | compressors=$4 |
Hans-Peter Nilsson | ec5b946 | 2015-04-15 04:08:21 +0200 | [diff] [blame] | 274 | verdir=${5:-$tool} |
| 275 | ver=$(getver $verdir) |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 276 | do_proto_toplev $package $ver $tool "$support_files" |
Andreas Rammhold | ce04ca3 | 2020-10-26 04:03:29 +0100 | [diff] [blame] | 277 | do_sha256sum |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 278 | do_tar $package $ver |
| 279 | do_compress $package $ver "$compressors" |
| 280 | } |
| 281 | |
| 282 | # Create a gdb release package, tar it and compress it |
| 283 | gdb_tar_compress() |
| 284 | { |
| 285 | package=$1 |
| 286 | tool=$2 |
| 287 | support_files=$3 |
| 288 | compressors=$4 |
| 289 | ver=$(getver $tool) |
| 290 | do_proto_toplev $package $ver $tool "$support_files" |
Andreas Rammhold | ce04ca3 | 2020-10-26 04:03:29 +0100 | [diff] [blame] | 291 | do_sha256sum |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 292 | do_djunpack $package $ver |
| 293 | do_tar $package $ver |
| 294 | do_compress $package $ver "$compressors" |
| 295 | } |
| 296 | |
| 297 | # The FSF "binutils" release includes gprof and ld. |
Nick Clifton | e33f231 | 2019-05-29 12:49:13 +0100 | [diff] [blame] | 298 | BINUTILS_SUPPORT_DIRS="bfd gas include libiberty libctf opcodes ld elfcpp gold gprof intl setup.com makefile.vms cpu zlib" |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 299 | binutils_release() |
| 300 | { |
| 301 | compressors=$1 |
| 302 | package=binutils |
| 303 | tool=binutils |
| 304 | tar_compress $package $tool "$BINUTILS_SUPPORT_DIRS" "$compressors" |
| 305 | } |
| 306 | |
H.J. Lu | 92c695a | 2015-03-28 06:48:43 -0700 | [diff] [blame] | 307 | GAS_SUPPORT_DIRS="bfd include libiberty opcodes intl setup.com makefile.vms zlib" |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 308 | gas_release() |
| 309 | { |
| 310 | compressors=$1 |
| 311 | package=gas |
| 312 | tool=gas |
| 313 | tar_compress $package $tool "$GAS_SUPPORT_DIRS" "$compressors" |
| 314 | } |
| 315 | |
Andrew Burgess | 890026e | 2021-09-24 18:25:20 +0100 | [diff] [blame] | 316 | GDB_SUPPORT_DIRS="bfd include libiberty libctf opcodes readline sim intl libdecnumber cpu zlib contrib gnulib gdbsupport gdbserver libbacktrace" |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 317 | gdb_release() |
| 318 | { |
| 319 | compressors=$1 |
| 320 | package=gdb |
| 321 | tool=gdb |
| 322 | gdb_tar_compress $package $tool "$GDB_SUPPORT_DIRS" "$compressors" |
| 323 | } |
| 324 | |
| 325 | # Corresponding to the CVS "sim" module. |
Hans-Peter Nilsson | ec5b946 | 2015-04-15 04:08:21 +0200 | [diff] [blame] | 326 | SIM_SUPPORT_DIRS="bfd opcodes libiberty include intl gdb/version.in gdb/common/create-version.sh makefile.vms zlib" |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 327 | sim_release() |
| 328 | { |
| 329 | compressors=$1 |
| 330 | package=sim |
| 331 | tool=sim |
Hans-Peter Nilsson | ec5b946 | 2015-04-15 04:08:21 +0200 | [diff] [blame] | 332 | tar_compress $package $tool "$SIM_SUPPORT_DIRS" "$compressors" gdb |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | usage() |
| 336 | { |
| 337 | echo "src-release.sh <options> <release>" |
| 338 | echo "options:" |
| 339 | echo " -b: Compress with bzip2" |
| 340 | echo " -g: Compress with gzip" |
Nick Clifton | ef87240 | 2017-09-15 16:18:20 +0100 | [diff] [blame] | 341 | echo " -l: Compress with lzip" |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 342 | echo " -x: Compress with xz" |
| 343 | exit 1 |
| 344 | } |
| 345 | |
| 346 | build_release() |
| 347 | { |
| 348 | release=$1 |
| 349 | compressors=$2 |
| 350 | case $release in |
| 351 | binutils) |
| 352 | binutils_release "$compressors";; |
| 353 | gas) |
| 354 | gas_release "$compressors";; |
| 355 | gdb) |
| 356 | gdb_release "$compressors";; |
| 357 | sim) |
| 358 | sim_release "$compressors";; |
| 359 | *) |
| 360 | echo "Unknown release name: $release" && usage;; |
| 361 | esac |
| 362 | } |
| 363 | |
| 364 | compressors="" |
| 365 | |
Nick Clifton | ef87240 | 2017-09-15 16:18:20 +0100 | [diff] [blame] | 366 | while getopts ":bglx" opt; do |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 367 | case $opt in |
| 368 | b) |
| 369 | compressors="$compressors bz2";; |
| 370 | g) |
| 371 | compressors="$compressors gz";; |
Nick Clifton | ef87240 | 2017-09-15 16:18:20 +0100 | [diff] [blame] | 372 | l) |
| 373 | compressors="$compressors lz";; |
Will Newton | 2536ee9 | 2014-08-07 14:38:55 +0100 | [diff] [blame] | 374 | x) |
| 375 | compressors="$compressors xz";; |
| 376 | \?) |
| 377 | echo "Invalid option: -$OPTARG" && usage;; |
| 378 | esac |
| 379 | done |
| 380 | shift $((OPTIND -1)) |
| 381 | release=$1 |
| 382 | |
| 383 | build_release $release "$compressors" |