Skip to content

Commit

Permalink
Remove GnuTLS from install_ffmpeg.sh
Browse files Browse the repository at this point in the history
Remove http and https protocols from FFmpeg configuration in install_ffmpeg.sh
Use newer x264 lib on Apple Silicon
  • Loading branch information
darkdarkdragon committed Dec 8, 2021
1 parent c4dd506 commit 1b9cc9a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
&& sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 15CF4D18AF4F7421 \
&& sudo add-apt-repository "deb [arch=amd64] http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" \
&& sudo apt-get update \
&& sudo apt-get -y install clang-8 clang-tools-8 build-essential pkg-config autoconf gnutls-dev git python
&& sudo apt-get -y install clang-8 clang-tools-8 build-essential pkg-config autoconf git python
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 30 \
&& sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 30
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.build-linux
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN apt-get update \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv 15CF4D18AF4F7421 \
&& add-apt-repository "deb [arch=amd64] http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" \
&& apt-get update \
&& apt-get -y install clang-8 clang-tools-8 build-essential pkg-config autoconf gnutls-dev sudo git python docker-ce-cli
&& apt-get -y install clang-8 clang-tools-8 build-essential pkg-config autoconf sudo git python docker-ce-cli

RUN update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 30 \
&& update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 30
Expand Down
63 changes: 17 additions & 46 deletions install_ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
set -ex

ROOT="${1:-$HOME}"
ARCH="$(uname -m)"

if [[ $ARCH == "arm64" ]] && [[ $(uname) == "Darwin" ]]; then
# Detect Apple Silicon
IS_M1=1
fi
echo "Arch $ARCH ${IS_M1:+(Apple Silicon)}"

# Windows (MSYS2) needs a few tweaks
if [[ $(uname) == *"MSYS"* ]]; then
Expand Down Expand Up @@ -37,8 +44,7 @@ if [ $(uname) != "Darwin" ]; then
fi
fi

# Static linking of gnutls on Linux/Mac
if [[ $(uname) != *"MSYS"* ]]; then
if [[ $(uname) != *"MSYS"* ]] && [[ ! $IS_M1 ]]; then
if [ ! -e "$ROOT/nasm-2.14.02" ]; then
# sudo apt-get -y install asciidoc xmlto # this fails :(
cd "$ROOT"
Expand All @@ -52,58 +58,23 @@ if [[ $(uname) != *"MSYS"* ]]; then
make
make install || echo "Installing docs fails but should be OK otherwise"
fi

# rm -rf "$ROOT/gmp-6.1.2"
if [ ! -e "$ROOT/gmp-6.1.2" ]; then
cd "$ROOT"
curl -LO https://github.com/livepeer/livepeer-builddeps/raw/34900f2b1be4e366c5270e3ee5b0d001f12bd8a4/gmp-6.1.2.tar.xz
tar xf gmp-6.1.2.tar.xz
cd "$ROOT/gmp-6.1.2"
./configure --prefix="$ROOT/compiled" --disable-shared --with-pic --enable-fat
make
make install
fi

# rm -rf "$ROOT/nettle-3.7"
if [ ! -e "$ROOT/nettle-3.7" ]; then
cd $ROOT
curl -LO https://github.com/livepeer/livepeer-builddeps/raw/657a86b78759b1ab36dae227253c26ff50cb4b0a/nettle-3.7.tar.gz
tar xf nettle-3.7.tar.gz
cd nettle-3.7
LDFLAGS="-L${ROOT}/compiled/lib" CFLAGS="-I${ROOT}/compiled/include" ./configure --prefix="$ROOT/compiled" --disable-shared --enable-pic
make
make install
fi

fi

if [ ! -e "$ROOT/x264" ]; then
git clone http://git.videolan.org/git/x264.git "$ROOT/x264"
cd "$ROOT/x264"
# git master as of this writing
git checkout 545de2ffec6ae9a80738de1b2c8cf820249a2530
if [[ ! $IS_M1 ]]; then
# newer git master, compiles on Apple Silicon
git checkout 66a5bc1bd1563d8227d5d18440b525a09bcf17ca
else
# git master as of this writing
git checkout 545de2ffec6ae9a80738de1b2c8cf820249a2530
fi
./configure --prefix="$ROOT/compiled" --enable-pic --enable-static ${HOST_OS:-} --disable-cli
make
make install-lib-static
fi

if [ ! -e "$ROOT/gnutls-3.7.0" ]; then
EXTRA_GNUTLS_LIBS=""
if [[ $(uname) == *"MSYS"* ]]; then
EXTRA_GNUTLS_LIBS="-lncrypt -lcrypt32 -lwsock32 -lws2_32 -lwinpthread"
fi
cd $ROOT
curl -LO https://www.gnupg.org/ftp/gcrypt/gnutls/v3.7/gnutls-3.7.0.tar.xz
tar xf gnutls-3.7.0.tar.xz
cd gnutls-3.7.0
LDFLAGS="-L${ROOT}/compiled/lib" CFLAGS="-I${ROOT}/compiled/include -O2" LIBS="-lhogweed -lnettle -lgmp $EXTRA_GNUTLS_LIBS" ./configure ${BUILD_OS:-} --prefix="$ROOT/compiled" --enable-static --disable-shared --with-pic --with-included-libtasn1 --with-included-unistring --without-p11-kit --without-idn --without-zlib --disable-doc --disable-cxx --disable-tools --disable-hardware-acceleration --disable-guile --disable-libdane --disable-tests --disable-rpath --disable-nls
make
make install
# gnutls doesn't properly set up its pkg-config or something? without this line ffmpeg and go
# don't know that they need gmp, nettle, and hogweed
sed -i'' -e "s/-lgnutls/-lgnutls -lhogweed -lnettle -lgmp $EXTRA_GNUTLS_LIBS/g" $ROOT/compiled/lib/pkgconfig/gnutls.pc
fi

EXTRA_FFMPEG_FLAGS=""
EXTRA_LDFLAGS=""

Expand Down Expand Up @@ -132,8 +103,8 @@ if [ ! -e "$ROOT/ffmpeg/libavcodec/libavcodec.a" ]; then
--disable-muxers --disable-demuxers --disable-parsers --disable-protocols \
--disable-encoders --disable-decoders --disable-filters --disable-bsfs \
--disable-postproc --disable-lzma \
--enable-gnutls --enable-libx264 --enable-gpl \
--enable-protocol=https,http,rtmp,file,pipe \
--enable-libx264 --enable-gpl \
--enable-protocol=rtmp,file,pipe \
--enable-muxer=mpegts,hls,segment,mp4,null --enable-demuxer=flv,mpegts,mp4,mov \
--enable-bsf=h264_mp4toannexb,aac_adtstoasc,h264_metadata,h264_redundant_pps,extract_extradata \
--enable-parser=aac,aac_latm,h264 \
Expand Down
36 changes: 4 additions & 32 deletions prepare_mingw64.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,14 @@
#!/bin/bash

set -eo pipefail
set -x

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

export MINGW_INSTALLS=mingw64
pacman -S --noconfirm --noprogressbar --ask=20 --needed mingw-w64-x86_64-binutils mingw-w64-x86_64-gcc mingw-w64-x86_64-pkg-config mingw-w64-x86_64-go mingw-w64-x86_64-nasm mingw-w64-x86_64-clang git make autoconf automake patch libtool texinfo gtk-doc zip
gpg --keyserver keyserver.ubuntu.com --recv-keys F3599FF828C67298 249B39D24F25E3B6 2071B08A33BD3F06 29EE58B996865171 D605848ED7E69871

# winpthreads needs git config for some reason
git config --get user.email || git config --global user.email "[email protected]"
git config --get user.name || git config --global user.name "Livepeer Windows Build"

rm -rf "$DIR/.build"
mkdir -p "$DIR/.build"
git clone https://github.com/msys2/MINGW-packages.git "$DIR/.build/MINGW-packages"
cd "$DIR/.build/MINGW-packages"
git checkout f4c989755fdbca217e0c53c01a6206d36a9c3e0d

for x in zlib gmp nettle winpthreads-git; do
echo ""
echo "---------"
echo "building $x"
echo "---------"
echo ""
cd "$DIR/.build/MINGW-packages/mingw-w64-$x"
set +e
makepkg-mingw -CL --nocheck
EXIT=$?
set -e
if [[ $EXIT != "13" ]] && [[ $EXIT != "0" ]]; then
echo "exiting $EXIT"
exit $EXIT
fi
pacman -U --noconfirm *.zst
echo "prepare_mingw64: deleting shared libraries"
# https://narkive.com/Fjlrbrjg:20.646.48
find /mingw64/lib -name "*.dll.a" -exec rm -v {} \;
done
# And one more dynamic library to remove, this one in the system itself...
rm -rfv /mingw64/x86_64-w64-mingw32/lib/libwinpthread.dll.a
echo "removing all dlls"
# https://narkive.com/Fjlrbrjg:20.646.48
find /mingw64 -name "*.dll.a" -exec rm -v {} \;
4 changes: 3 additions & 1 deletion upload_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,7 @@ curl -X PUT -T "${FILE}" \
-H "Authorization: AWS ${GCLOUD_KEY}:${signature}" \
$fullUrl

curl --fail -s -H "Content-Type: application/json" -X POST -d "{\"content\": \"Build succeeded ✅\nBranch: $BRANCH\nPlatform: $ARCH-amd64\nLast commit: $(git log -1 --pretty=format:'%s by %an')\nhttps://build.livepeer.live/$VERSION_AND_NETWORK/${FILE}\nSHA256:\n${FILE_SHA256}\"}" $DISCORD_URL 2>/dev/null
echo "upload done"

curl --fail -s -H "Content-Type: application/json" -X POST -d "{\"content\": \"Build succeeded ✅\nBranch: $BRANCH\nPlatform: $ARCH-amd64\nLast commit: $(git log -1 --pretty=format:'%s by %an')\nhttps://build.livepeer.live/$VERSION_AND_NETWORK/${FILE}\nSHA256:\n${FILE_SHA256}\"}" $DISCORD_URL
echo "done"

0 comments on commit 1b9cc9a

Please sign in to comment.