Skip to content

Instantly share code, notes, and snippets.

@LaurenceJJones
Created August 9, 2023 11:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save LaurenceJJones/d17f7839b03acbe0e4e879fd60f4b433 to your computer and use it in GitHub Desktop.
RE2 compile from source: tested debian
#!/bin/bash
RE2_VERSION=${RE2_VERSION:-2023-03-01}
## Utilities ##
download() {
if [ -z "$1" ]; then
echo "download() requires a URL as first argument"
exit 1
fi
if [ -z "$2" ]; then
echo "download() requires a destination directory as second argument"
exit 1
fi
if [ ! -d "$2" ]; then
echo "$2 is not a directory"
exit 1
fi
if command -v curl >/dev/null; then
cd "$2" || (echo "Could not cd to $2" && exit 1)
# older versions of curl don't support --output-dir
curl -sSLO --fail --remote-name "$1"
cd - >/dev/null || exit
elif command -v wget >/dev/null; then
wget -nv -P "$2" "$1"
else
echo "Neither curl nor wget is available, cannot download files."
exit 1
fi
}
# Download RE2
download "https://github.com/google/re2/archive/refs/tags/${RE2_VERSION}.tar.gz" "/tmp"
# Exract RE2
sudo tar -C /opt/ -xzf "/tmp/${RE2_VERSION}.tar.gz"
# Elevate permissions and run make install within output dir
sudo su -c "cd /opt/re2-${RE2_VERSION} && make install"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment