From 70c87619ee9ca7d037720b7bd1b9652c098d7a5e Mon Sep 17 00:00:00 2001 From: Dave Beckett Date: Sun, 6 Sep 2020 15:36:02 -0700 Subject: Move to bison 3.4+ --- scripts/install-bison3.sh | 72 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 22 deletions(-) (limited to 'scripts') diff --git a/scripts/install-bison3.sh b/scripts/install-bison3.sh index 3f2f133a..9eaebb2b 100755 --- a/scripts/install-bison3.sh +++ b/scripts/install-bison3.sh @@ -1,36 +1,64 @@ #!/bin/sh -# Helper script to install bison 3 (primarily for travis CI) +# Helper script to install bison 3 into system via SUDO +# +# This is primarily for travis CI set -x -PACKAGE=bison -MIN_VERSION=3.0.0 -INSTALL_VERSION=3.0.5 -# Bison requires that CC is a C compiler -CC=cc -export CC +# Binary that is installed that should be checked for version +program_name=${BISON:-bison} +# Name of package - will be tarball prefix +package_name=${PACKAGE:-bison} + + +########### Should be generic for any GNU package below here ######## + +package_ucname=$(echo "${package_name}" | tr '[:lower:]' '[:upper:]') +package_min_version=$(awk -F= "/^${package_ucname}_MIN_VERSION/ {print \$2}" configure.ac) +package_rec_version=$(awk -F= "/^${package_ucname}_REC_VERSION/ {print \$2}" configure.ac) + + +# Package specific overrides +case "$package_name" in + bison) + # Bison requires that CC is a C compiler + CC=cc + export CC + ;; + *) + ;; +esac AWK=${AWK:-awk} -BISON=${BISON:-bison} CURL=${CURL:-curl} WGET=${WGET:-wget} - -FILE="$PACKAGE-$INSTALL_VERSION.tar.gz" -URL="http://ftp.gnu.org/gnu/bison/$PACKAGE-$INSTALL_VERSION.tar.gz" +DESTDIR=${DESTDIR:-/usr} ROOT_DIR=${TMPDIR:-/tmp} -BUILD_DIR="$ROOT_DIR/build-$PACKAGE" +BUILD_DIR="$ROOT_DIR/build-${package_name}" -installed_version=`$BISON --version 2>&1 | sed -ne 's/^.*GNU Bison[^0-9]*//p'` -installed_version_dec=`echo $installed_version | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'` -min_version_dec=`echo $MIN_VERSION | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'` -if test $installed_version_dec -ge $min_version_dec; then - echo "$PACKAGE $installed_version is new enough" +installed_version=$(${program_name} --version 2>&1 | $AWK "/^${package_name}.*[.0-9]\$/ { print \$NF}") +# shellcheck disable=SC2016 +installed_version_dec=$(echo "$installed_version" | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};') +# shellcheck disable=SC2016 +min_version_dec=$(echo "$package_min_version" | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};') + +if test "$installed_version_dec" -ge "$min_version_dec"; then + echo "${package_name} $installed_version is new enough" else - mkdir $BUILD_DIR && cd $BUILD_DIR - $WGET -O $FILE $URL || $CURL -o $FILE $URL - tar -x -z -f $FILE && rm $FILE - cd $PACKAGE-$INSTALL_VERSION && ./configure --prefix=/usr && make && sudo make install - cd / && rm -rf $BUILD_DIR + echo "Building and installing ${package_rec_version} from source into ${DESTDIR}" + mkdir "$BUILD_DIR" && cd "$BUILD_DIR" || exit 1 + package_dir="${package_name}-${package_rec_version}" + tarball_file="${package_dir}.tar.gz" + package_url="http://ftp.gnu.org/gnu/${package_name}/${tarball_file}" + + $WGET -O "$tarball_file" "$package_url" || \ + $CURL -o "$tarball_file" "$package_url" + tar -x -z -f "$tarball_file" && rm "$tarball_file" + cd "${package_dir}" && \ + ./configure "--prefix=${DESTDIR}" && \ + make && \ + sudo make install + cd / && rm -rf "$BUILD_DIR" fi -- cgit v1.2.1