diff --git a/bin/compile b/bin/compile index e8f1cd3..533fbd2 100755 --- a/bin/compile +++ b/bin/compile @@ -6,6 +6,19 @@ header() { echo "-----> $*" || true } +export_env_dir() { + env_dir=$1 + acceptlist_regex=${2:-''} + denylist_regex=${3:-'^(PATH|GIT_DIR|CPATH|CPPATH|LD_PRELOAD|LIBRARY_PATH)$'} + if [ -d "$env_dir" ]; then + for e in $(ls $env_dir); do + echo "$e" | grep -E "$acceptlist_regex" | grep -qvE "$denylist_regex" && + export "$e=$(cat $env_dir/$e)" + : + done + fi +} + output() { while IFS= read -r LINE; do # do not indent headers that are being piped through the output @@ -20,9 +33,12 @@ output() { header "Installing ffmpeg" BUILD_DIR=${1:-} +ENV_DIR=${3:-} VENDOR_DIR="vendor" FFMPEG_ARCHIVE_NAME="ffmpeg.tar.xz" +export_env_dir $ENV_DIR + cd $BUILD_DIR mkdir -p $VENDOR_DIR cd $VENDOR_DIR @@ -31,7 +47,7 @@ cd ffmpeg if [[ -z $FFMPEG_DOWNLOAD_URL ]]; then echo "Variable FFMPEG_DOWNLOAD_URL isn't set, using default value" | output - FFMPEG_DOWNLOAD_URL="https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz" + FFMPEG_DOWNLOAD_URL="https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-4.2.2-amd64-static.tar.xz" fi echo "Downloading $FFMPEG_DOWNLOAD_URL" | output @@ -56,4 +72,4 @@ PROFILE_PATH="$BUILD_DIR/.profile.d/ffmpeg.sh" mkdir -p $(dirname $PROFILE_PATH) echo 'export PATH="$PATH:${HOME}/vendor/ffmpeg"' >> $PROFILE_PATH -echo "Installation successful" | output \ No newline at end of file +echo "Installation successful" | output