[WIP] build deps

This commit is contained in:
Romain Vimont 2022-05-21 14:07:20 +02:00
parent faf4535487
commit a1117c58ac
3 changed files with 100 additions and 0 deletions

2
app/deps/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/data
/target-*

54
app/deps/src/build-ffmpeg.sh Executable file
View file

@ -0,0 +1,54 @@
#!/usr/bin/env bash
. init_deps
VERSION=5.0.1
FILENAME=ffmpeg-$VERSION.tar.xz
URL=http://ffmpeg.org/releases/ffmpeg-$VERSION.tar.xz
SHA256SUM=ef2efae259ce80a240de48ec85ecb062cecca26e4352ffb3fda562c21a93007b
DEP_DIR="$DATA_DIR/ffmpeg-$VERSION-$SHA256SUM"
if [[ ! -d "$DEP_DIR" ]]
then
get_file "$URL" "$FILENAME" "$SHA256SUM"
mkdir "$DEP_DIR"
cd "$DEP_DIR"
tar xvf "../$FILENAME"
else
echo "$DEP_DIR found"
cd "$DEP_DIR"
fi
cd "ffmpeg-$VERSION"
rm -rf "build-$HOST"
mkdir "build-$HOST"
cd "build-$HOST"
params=(
--prefix="$INSTALL_DIR"
--disable-autodetect
--disable-programs
--disable-everything
--disable-doc
--disable-swresample
--disable-swscale
--disable-avfilter
--disable-postproc
--disable-static
--enable-shared
--enable-decoder=h264
--enable-decoder=png
--enable-muxer=mp4
--enable-muxer=matroska
)
if [[ "$HOST_SYSTEM" == 'linux' ]]
then
params+=(--enable-libv4l2)
fi
../configure "${params[@]}"
make -j $NJOBS
make install

44
app/deps/src/init_deps Normal file
View file

@ -0,0 +1,44 @@
set -e
# The caller must set the following environment variable
# - $HOST (e.g. "x86_64-linux-gnu")
# - $HOST_SYSTEM ("linux", "windows", "apple"), for scripts convenience
fail() {
echo "$1" >&2
exit 1
}
[[ -z "$HOST" ]] && fail '$HOST not defined'
[[ -z "$HOST_SYSTEM" ]] && fail '$HOST_SYSTEM not defined'
DIR=$(dirname ${BASH_SOURCE[0]})
cd "$DIR"
DATA_DIR=$(realpath ../data)
INSTALL_DIR=$(realpath ../target-"$HOST")
NJOBS=$(grep -c ^processor /proc/cpuinfo)
mkdir -p "$DATA_DIR"
cd "$DATA_DIR"
checksum() {
local file="$1"
local sum="$2"
echo "$file: verifying checksum..."
echo "$sum $file" | sha256sum -c
}
get_file() {
local url="$1"
local file="$2"
local sum="$3"
if [[ -f "$file" ]]
then
echo "$file: found"
else
echo "$file: not found, downloading..."
wget "$url" -O "$file"
fi
checksum "$file" "$sum"
}