forked from jonathanong/heroku-buildpack-ffmpeg-latest
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Safety improvements (jonathanong#40)
- Loading branch information
Showing
2 changed files
with
47 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,59 @@ | ||
#!/bin/sh | ||
#!/usr/bin/env bash | ||
# bin/compile <build-dir> <cache-dir> <env-dir> | ||
|
||
indent() { | ||
sed -u 's/^/ /' | ||
header() { | ||
echo "" || true | ||
echo "-----> $*" || true | ||
} | ||
|
||
echo "-----> Install ffmpeg" | ||
BUILD_DIR=$1 | ||
VENDOR_DIR="vendor" | ||
DOWNLOAD_URL="https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz" | ||
output() { | ||
while IFS= read -r LINE; do | ||
# do not indent headers that are being piped through the output | ||
if [[ "$LINE" =~ ^-----\>.* ]]; then | ||
echo "$LINE" || true | ||
else | ||
echo " $LINE" || true | ||
fi | ||
done | ||
} | ||
|
||
echo "DOWNLOAD_URL = " $DOWNLOAD_URL | indent | ||
header "Installing ffmpeg" | ||
|
||
BUILD_DIR=${1:-} | ||
VENDOR_DIR="vendor" | ||
FFMPEG_ARCHIVE_NAME="ffmpeg.tar.xz" | ||
|
||
cd $BUILD_DIR | ||
mkdir -p $VENDOR_DIR | ||
cd $VENDOR_DIR | ||
mkdir -p ffmpeg | ||
cd ffmpeg | ||
curl -L --silent $DOWNLOAD_URL | tar xJ --strip-components=1 | ||
|
||
echo "exporting PATH" | indent | ||
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" | ||
fi | ||
|
||
echo "Downloading $FFMPEG_DOWNLOAD_URL" | output | ||
|
||
code=$(curl "$FFMPEG_DOWNLOAD_URL" -L --silent --fail --retry 5 --retry-max-time 15 -o ./$FFMPEG_ARCHIVE_NAME --write-out "%{http_code}") | ||
|
||
if [ "$code" != "200" ]; then | ||
echo "Unable to download ffmpeg: $code" | output && exit 1 | ||
fi | ||
|
||
echo "Unpacking the archive" | output | ||
|
||
tar xJf "./$FFMPEG_ARCHIVE_NAME" --strip-components=1 | ||
|
||
if [ "$?" != "0" ]; then | ||
echo "Failed to unpack" | output && exit 1 | ||
fi | ||
|
||
rm $FFMPEG_ARCHIVE_NAME | ||
|
||
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 |