mirror of
https://github.com/mtan93/Apps-Community.git
synced 2026-03-08 05:31:59 +00:00
formatting
This commit is contained in:
@@ -15,39 +15,39 @@ ADDITIONAL_CONFIGURE_OPTIONS=""
|
||||
# Speed up the process
|
||||
# Env Var NUMJOBS overrides automatic detection
|
||||
if [[ -n $NUMJOBS ]]; then
|
||||
MJOBS=$NUMJOBS
|
||||
MJOBS=$NUMJOBS
|
||||
elif [[ -f /proc/cpuinfo ]]; then
|
||||
MJOBS=$(grep -c processor /proc/cpuinfo)
|
||||
MJOBS=$(grep -c processor /proc/cpuinfo)
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
MJOBS=$(sysctl -n machdep.cpu.thread_count)
|
||||
ADDITIONAL_CONFIGURE_OPTIONS="--enable-videotoolbox"
|
||||
else
|
||||
MJOBS=4
|
||||
MJOBS=4
|
||||
fi
|
||||
|
||||
make_dir () {
|
||||
make_dir() {
|
||||
if [ ! -d $1 ]; then
|
||||
if ! mkdir $1; then
|
||||
printf "\n Failed to create dir %s" "$1";
|
||||
printf "\n Failed to create dir %s" "$1"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
remove_dir () {
|
||||
remove_dir() {
|
||||
if [ -d $1 ]; then
|
||||
rm -r "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
download () {
|
||||
download() {
|
||||
|
||||
DOWNLOAD_PATH=$PACKAGES
|
||||
|
||||
DOWNLOAD_PATH=$PACKAGES;
|
||||
|
||||
if [ ! -z "$3" ]; then
|
||||
mkdir -p $PACKAGES/$3
|
||||
DOWNLOAD_PATH=$PACKAGES/$3
|
||||
fi;
|
||||
fi
|
||||
|
||||
if [ ! -f "$DOWNLOAD_PATH/$2" ]; then
|
||||
|
||||
@@ -57,7 +57,7 @@ download () {
|
||||
EXITCODE=$?
|
||||
if [ $EXITCODE -ne 0 ]; then
|
||||
echo ""
|
||||
echo "Failed to download $1. Exitcode $EXITCODE. Retrying in 10 seconds";
|
||||
echo "Failed to download $1. Exitcode $EXITCODE. Retrying in 10 seconds"
|
||||
sleep 10
|
||||
curl -L --silent -o "$DOWNLOAD_PATH/$2" "$1"
|
||||
fi
|
||||
@@ -65,34 +65,34 @@ download () {
|
||||
EXITCODE=$?
|
||||
if [ $EXITCODE -ne 0 ]; then
|
||||
echo ""
|
||||
echo "Failed to download $1. Exitcode $EXITCODE";
|
||||
echo "Failed to download $1. Exitcode $EXITCODE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "... Done"
|
||||
|
||||
if ! tar -xvf "$DOWNLOAD_PATH/$2" -C "$DOWNLOAD_PATH" 2>/dev/null >/dev/null; then
|
||||
echo "Failed to extract $2";
|
||||
echo "Failed to extract $2"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
execute () {
|
||||
execute() {
|
||||
echo "$ $*"
|
||||
|
||||
OUTPUT=$($@ 2>&1)
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$OUTPUT"
|
||||
echo ""
|
||||
echo "Failed to Execute $*" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "$OUTPUT"
|
||||
echo ""
|
||||
echo "Failed to Execute $*" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
build () {
|
||||
build() {
|
||||
echo ""
|
||||
echo "building $1"
|
||||
echo "======================="
|
||||
@@ -106,15 +106,14 @@ build () {
|
||||
}
|
||||
|
||||
command_exists() {
|
||||
if ! [[ -x $(command -v "$1") ]]; then
|
||||
return 1
|
||||
fi
|
||||
if ! [[ -x $(command -v "$1") ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
build_done () {
|
||||
build_done() {
|
||||
touch "$PACKAGES/$1.done"
|
||||
}
|
||||
|
||||
@@ -129,18 +128,18 @@ case "$1" in
|
||||
echo "Cleanup done."
|
||||
echo ""
|
||||
exit 0
|
||||
;;
|
||||
"--build")
|
||||
;;
|
||||
"--build") ;;
|
||||
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0"
|
||||
echo " --build: start building process"
|
||||
echo " --cleanup: remove all working dirs"
|
||||
echo " --help: show this help"
|
||||
echo ""
|
||||
exit 0
|
||||
;;
|
||||
\
|
||||
*)
|
||||
echo "Usage: $0"
|
||||
echo " --build: start building process"
|
||||
echo " --cleanup: remove all working dirs"
|
||||
echo " --help: show this help"
|
||||
echo ""
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Using $MJOBS make jobs simultaneously."
|
||||
@@ -151,18 +150,18 @@ make_dir $WORKSPACE
|
||||
export PATH=${WORKSPACE}/bin:$PATH
|
||||
|
||||
if ! command_exists "make"; then
|
||||
echo "make not installed.";
|
||||
exit 1
|
||||
echo "make not installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command_exists "g++"; then
|
||||
echo "g++ not installed.";
|
||||
exit 1
|
||||
echo "g++ not installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command_exists "curl"; then
|
||||
echo "curl not installed.";
|
||||
exit 1
|
||||
echo "curl not installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if build "yasm"; then
|
||||
@@ -193,14 +192,14 @@ if build "opencore"; then
|
||||
fi
|
||||
|
||||
if build "libvpx"; then
|
||||
download "https://github.com/webmproject/libvpx/archive/v1.7.0.tar.gz" "libvpx-1.7.0.tar.gz"
|
||||
cd $PACKAGES/libvpx-*0 || exit
|
||||
download "https://github.com/webmproject/libvpx/archive/v1.7.0.tar.gz" "libvpx-1.7.0.tar.gz"
|
||||
cd $PACKAGES/libvpx-*0 || exit
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
echo "Applying Darwin patch"
|
||||
sed "s/,--version-script//g" build/make/Makefile > build/make/Makefile.patched
|
||||
sed "s/-Wl,--no-undefined -Wl,-soname/-Wl,-undefined,error -Wl,-install_name/g" build/make/Makefile.patched > build/make/Makefile
|
||||
fi
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
echo "Applying Darwin patch"
|
||||
sed "s/,--version-script//g" build/make/Makefile >build/make/Makefile.patched
|
||||
sed "s/-Wl,--no-undefined -Wl,-soname/-Wl,-undefined,error -Wl,-install_name/g" build/make/Makefile.patched >build/make/Makefile
|
||||
fi
|
||||
|
||||
execute ./configure --prefix=${WORKSPACE} --disable-unit-tests --disable-shared
|
||||
execute make -j $MJOBS
|
||||
@@ -219,14 +218,14 @@ fi
|
||||
|
||||
if build "xvidcore"; then
|
||||
download "http://downloads.xvid.org/downloads/xvidcore-1.3.4.tar.gz" "xvidcore-1.3.4.tar.gz"
|
||||
cd $PACKAGES/xvidcore || exit
|
||||
cd build/generic || exit
|
||||
cd $PACKAGES/xvidcore || exit
|
||||
cd build/generic || exit
|
||||
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
|
||||
execute make -j $MJOBS
|
||||
execute make install
|
||||
|
||||
if [[ -f ${WORKSPACE}/lib/libxvidcore.4.dylib ]]; then
|
||||
execute rm "${WORKSPACE}/lib/libxvidcore.4.dylib"
|
||||
execute rm "${WORKSPACE}/lib/libxvidcore.4.dylib"
|
||||
fi
|
||||
|
||||
build_done "xvidcore"
|
||||
@@ -238,11 +237,11 @@ if build "x264"; then
|
||||
|
||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||
execute ./configure --prefix=${WORKSPACE} --enable-static --enable-pic CXXFLAGS="-fPIC"
|
||||
else
|
||||
execute ./configure --prefix=${WORKSPACE} --enable-static --enable-pic
|
||||
fi
|
||||
else
|
||||
execute ./configure --prefix=${WORKSPACE} --enable-static --enable-pic
|
||||
fi
|
||||
|
||||
execute make -j $MJOBS
|
||||
execute make -j $MJOBS
|
||||
execute make install
|
||||
execute make install-lib-static
|
||||
build_done "x264"
|
||||
@@ -269,7 +268,7 @@ fi
|
||||
if build "libtheora"; then
|
||||
download "http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz" "libtheora-1.1.1.tar.bz"
|
||||
cd $PACKAGES/libtheora-1.1.1 || exit
|
||||
sed "s/-fforce-addr//g" configure > configure.patched
|
||||
sed "s/-fforce-addr//g" configure >configure.patched
|
||||
chmod +x configure.patched
|
||||
mv configure.patched configure
|
||||
execute ./configure --prefix=${WORKSPACE} --with-ogg-libraries=${WORKSPACE}/lib --with-ogg-includes=${WORKSPACE}/include/ --with-vorbis-libraries=${WORKSPACE}/lib --with-vorbis-includes=${WORKSPACE}/include/ --enable-static --disable-shared --disable-oggtest --disable-vorbistest --disable-examples --disable-asm
|
||||
@@ -289,7 +288,7 @@ fi
|
||||
|
||||
if build "cmake"; then
|
||||
download "https://cmake.org/files/v3.11/cmake-3.11.3.tar.gz" "cmake-3.11.3.tar.gz"
|
||||
cd $PACKAGES/cmake-3.11.3 || exit
|
||||
cd $PACKAGES/cmake-3.11.3 || exit
|
||||
rm Modules/FindJava.cmake
|
||||
perl -p -i -e "s/get_filename_component.JNIPATH/#get_filename_component(JNIPATH/g" Tests/CMakeLists.txt
|
||||
perl -p -i -e "s/get_filename_component.JNIPATH/#get_filename_component(JNIPATH/g" Tests/CMakeLists.txt
|
||||
@@ -315,7 +314,7 @@ if build "x265"; then
|
||||
execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} -DENABLE_SHARED:bool=off .
|
||||
execute make -j $MJOBS
|
||||
execute make install
|
||||
sed "s/-lx265/-lx265 -lstdc++/g" "$WORKSPACE/lib/pkgconfig/x265.pc" > "$WORKSPACE/lib/pkgconfig/x265.pc.tmp"
|
||||
sed "s/-lx265/-lx265 -lstdc++/g" "$WORKSPACE/lib/pkgconfig/x265.pc" >"$WORKSPACE/lib/pkgconfig/x265.pc.tmp"
|
||||
mv "$WORKSPACE/lib/pkgconfig/x265.pc.tmp" "$WORKSPACE/lib/pkgconfig/x265.pc"
|
||||
build_done "x265"
|
||||
fi
|
||||
@@ -329,17 +328,16 @@ if build "fdk_aac"; then
|
||||
build_done "fdk_aac"
|
||||
fi
|
||||
|
||||
|
||||
build "ffmpeg"
|
||||
download "http://ffmpeg.org/releases/ffmpeg-4.1.tar.bz2" "ffmpeg-snapshot.tar.bz2"
|
||||
cd $PACKAGES/ffmpeg-4.1 || exit
|
||||
./configure $ADDITIONAL_CONFIGURE_OPTIONS \
|
||||
--pkgconfigdir="$WORKSPACE/lib/pkgconfig" \
|
||||
--prefix=${WORKSPACE} \
|
||||
--pkg-config-flags="--static" \
|
||||
--extra-cflags="-I$WORKSPACE/include" \
|
||||
--extra-ldflags="-L$WORKSPACE/lib" \
|
||||
--extra-libs="-lpthread -lm" \
|
||||
--pkgconfigdir="$WORKSPACE/lib/pkgconfig" \
|
||||
--prefix=${WORKSPACE} \
|
||||
--pkg-config-flags="--static" \
|
||||
--extra-cflags="-I$WORKSPACE/include" \
|
||||
--extra-ldflags="-L$WORKSPACE/lib" \
|
||||
--extra-libs="-lpthread -lm" \
|
||||
--enable-static \
|
||||
--disable-debug \
|
||||
--disable-shared \
|
||||
@@ -368,14 +366,13 @@ execute make install
|
||||
|
||||
INSTALL_FOLDER="/usr/bin"
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
INSTALL_FOLDER="/usr/local/bin"
|
||||
INSTALL_FOLDER="/usr/local/bin"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Building done. The binary can be found here: $WORKSPACE/bin/ffmpeg"
|
||||
echo ""
|
||||
|
||||
|
||||
if [[ $AUTOINSTALL == "yes" ]]; then
|
||||
if command_exists "sudo"; then
|
||||
sudo cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg"
|
||||
@@ -388,11 +385,11 @@ elif [[ ! $SKIPINSTALL == "yes" ]]; then
|
||||
read -r -p "Install the binary to your $INSTALL_FOLDER folder? [Y/n] " response
|
||||
|
||||
case $response in
|
||||
[yY][eE][sS]|[yY])
|
||||
sudo cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg"
|
||||
sudo cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe"
|
||||
echo "Done. ffmpeg is now installed to your system"
|
||||
;;
|
||||
[yY][eE][sS] | [yY])
|
||||
sudo cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg"
|
||||
sudo cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe"
|
||||
echo "Done. ffmpeg is now installed to your system"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#!/bin/bash
|
||||
# Helper script to download and run the build-ffmpeg script.
|
||||
|
||||
make_dir () {
|
||||
make_dir() {
|
||||
if [ ! -d $1 ]; then
|
||||
if ! mkdir $1; then
|
||||
printf "\n Failed to create dir %s" "$1";
|
||||
if ! mkdir $1; then
|
||||
printf "\n Failed to create dir %s" "$1"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
command_exists() {
|
||||
@@ -21,7 +21,7 @@ command_exists() {
|
||||
TARGET='ffmpeg-build'
|
||||
|
||||
if ! command_exists "curl"; then
|
||||
echo "curl not installed.";
|
||||
echo "curl not installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -37,4 +37,3 @@ echo "Now we download and execute the build script"
|
||||
echo ""
|
||||
|
||||
bash build-ffmpeg --build
|
||||
|
||||
|
||||
Reference in New Issue
Block a user