summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDave Beckett <dave@dajobe.org>2020-09-06 15:36:02 -0700
committerDave Beckett <dave@dajobe.org>2020-09-06 15:36:02 -0700
commit70c87619ee9ca7d037720b7bd1b9652c098d7a5e (patch)
tree4ba98a4dfc1c9b35dc0fa3966339938cbf13b29b /scripts
parent8a11759c69c2629edc7395528ad1439a653e1837 (diff)
downloadraptor-70c87619ee9ca7d037720b7bd1b9652c098d7a5e.tar.gz
Move to bison 3.4+
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/install-bison3.sh72
1 files changed, 50 insertions, 22 deletions
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