Last active
March 23, 2023 08:36
-
-
Save mdPlusPlus/b110cad4cdd920950c10dc6b5bce4dc6 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
##Original from here: https://www.makemkv.com/forum2/viewtopic.php?f=3&t=5266&start=30#p56468 | |
build_dir="/tmp/build-makemkv/" | |
build_log="/tmp/makemkv_install.log" | |
url_ffmpeg_releases="https://www.ffmpeg.org/releases/" | |
url_makemkv="https://makemkv.com/download/" | |
url_makemkv_serial="https://forum.makemkv.com/forum/viewtopic.php?f=5&t=1053" | |
serial_makemkv=$(curl -s4 --url "${url_makemkv_serial}" | grep -oP 'T-[\w\d@]{66}') | |
vers_ffmpeg=$(curl -s4 "${url_ffmpeg_releases}" | grep -E -o 'ffmpeg-([0-9]{1,}\.)+[0-9]{1,}' | sort -t. -rn | head -n 1) | |
##If there are problems, use 3.2.4 - https://makemkv.com/forum2/viewtopic.php?f=3&t=16059 | |
#vers_ffmpeg="ffmpeg-3.2.4" | |
vers_makemkv=$(curl -s4 "${url_makemkv}" | grep -E -o 'v([0-9]{1,}\.)+[0-9]{1,}' | sort -Vr | head -n 1 | cut -d 'v' -f 2) | |
# Update the repositories | |
echo "Preparing..." | tee -a "${build_log}" | |
DEBIAN_FRONTEND=noninteractive sudo apt-get update -qq < /dev/null > /dev/null | |
# We need curl to check the links | |
if ! command -v curl &> /dev/null | |
then | |
DEBIAN_FRONTEND=noninteractive sudo apt-get install -qq curl < /dev/null > /dev/null | |
fi | |
if [ -z "${url_ffmpeg_releases}" ] || [ -z "${url_makemkv}" ] || [ -z "${url_makemkv_serial}" ] || [ -z "${serial_makemkv}" ] || [ -z "${vers_ffmpeg}" ] || [ -z "${vers_makemkv}" ]; then | |
echo "ERR: Uh-oh, looks like one of the URLs has changed and the curls were no good. Aborting..." | tee -a "${build_log}" | |
exit | |
fi | |
echo "INFO: See ${build_log} for details...." | |
mkdir ${build_dir} | tee -a "${build_log}" | |
if [ ! -d "${build_dir}" ]; then | |
echo "ERR: Seems like you don't have permission to /tmp/. Aborting.." | tee -a "${build_log}" | |
exit | |
fi | |
cd ${build_dir} || exit | |
echo "INFO: Installing dependencies with apt-get (ordered)." | tee -a "${build_log}" | |
sudo apt-get install -y curl less build-essential pkg-config libc6-dev libssl-dev libexpat1-dev libavcodec-dev libgl1-mesa-dev qtbase5-dev zlib1g-dev libfdk-aac-dev | tee -a "${build_log}" | |
echo "INFO: Downloading latest ffmpeg and makemkv from source." | tee -a "${build_log}" | |
wget -c "${url_ffmpeg_releases}${vers_ffmpeg}.tar.bz2" | tee -a "${build_log}" | |
wget -c "${url_makemkv}makemkv-bin-${vers_makemkv}.tar.gz" | tee -a "${build_log}" | |
wget -c "${url_makemkv}makemkv-oss-${vers_makemkv}.tar.gz" | tee -a "${build_log}" | |
echo "INFO: Extracting archives." | tee -a "${build_log}" | |
tar xf "${vers_ffmpeg}.tar.bz2" | tee -a "${build_log}" | |
tar xf "makemkv-bin-${vers_makemkv}.tar.gz" | tee -a "${build_log}" | |
tar xf "makemkv-oss-${vers_makemkv}.tar.gz" | tee -a "${build_log}" | |
echo "INFO: Building ffmpeg." | tee -a "${build_log}" | |
cd "${build_dir}${vers_ffmpeg}" || exit | |
echo "INFO: Configuring ffmpeg." | tee -a "${build_log}" | |
#./configure --prefix="${build_dir}ffmpeg_build" --extra-cflags="-I${build_dir}ffmpeg_build/include" --extra-ldflags="-L${build_dir}ffmpeg_build/lib" --enable-static --disable-shared --enable-pic --disable-yasm --enable-libfdk-aac | tee -a "${build_log}" | |
./configure --prefix="${build_dir}ffmpeg_build" --enable-static --disable-shared --enable-pic --enable-libfdk-aac | tee -a "${build_log}" | |
echo "INFO: Installing ffmpeg." | tee -a "${build_log}" | |
make -j "$(getconf _NPROCESSORS_ONLN)" install | tee -a "${build_log}" | |
echo "INFO: Building makemkv-oss." | tee -a "${build_log}" | |
cd "${build_dir}makemkv-oss-${vers_makemkv}" || exit | |
PKG_CONFIG_PATH="${build_dir}ffmpeg_build/lib/pkgconfig" ./configure | tee -a "${build_log}" | |
echo "INFO: Making makemkv-oss." | tee -a "${build_log}" | |
make -j "$(getconf _NPROCESSORS_ONLN)" | tee -a "${build_log}" | |
echo "INFO: Installing makemkv-oss." | tee -a "${build_log}" | |
sudo make -j "$(getconf _NPROCESSORS_ONLN)" install | tee -a "${build_log}" | |
##TODO automatically write "yes" to dialog | |
cd "${build_dir}makemkv-bin-${vers_makemkv}" || exit | |
echo "INFO: Making makemkv-bin." | tee -a "${build_log}" | |
make -j "$(getconf _NPROCESSORS_ONLN)" | tee -a "${build_log}" | |
echo "INFO: Installing makemkv-bin." | tee -a "${build_log}" | |
sudo make -j "$(getconf _NPROCESSORS_ONLN)" install | tee -a "${build_log}" | |
echo "INFO: Testing makemkv binary." | tee -a "${build_log}" | |
if [ ! -f "/usr/bin/makemkv" ]; then | |
echo "ERR: Missing /usr/bin/makemkv, better check the logs. Aborting.." | tee -a "${build_log}" | |
exit | |
fi | |
echo "INFO: Registering MakeMKV with latest beta key for you." | tee -a "${build_log}" | |
echo "INFO: Current key ${serial_makemkv}" | tee -a "${build_log}" | |
mkdir -p "/home/${USER}/.MakeMKV/" | |
##TODO check for existing app_key and replace, otherwise append | |
echo "app_Key = \"${serial_makemkv}\"" > "/home/${USER}/.MakeMKV/settings.conf" | |
echo "Info: Remove libaacs0 and link those libraries to the better libmmdb https://makemkv.com/forum2/viewtopic.php?f=3&t=7009" | tee -a "${build_log}" | |
sudo apt-get remove -y libaacs0 | |
echo "Info: Linking libaacs0/libbdplus to libmmbd" | tee -a "${build_log}" | |
sudo ln -s /usr/lib/libmmdb.so.0 /usr/lib/libaacs.so.0 | tee -a "${build_log}" | |
sudo ln -s /usr/lib/libmmdb.so.0 /usr/lib/libbdplus.so.0 | tee -a "${build_log}" | |
cd /tmp || exit | |
echo "INFO: Cleaning up build directory" | tee -a "${build_log}" | |
rm -rf "${build_dir}" | |
if [ -d "${build_dir}" ]; then | |
echo "ERR: Can't delete ${build_dir}, trying with sudo..." | tee -a "${build_log}" | |
sudo rm -rf "${build_dir}" | |
fi | |
echo "Buildlog at ${build_log}" | |
echo "INFO: Exiting." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment