Install script for MakeMkV for Linux

The place to discuss linux version of MakeMKV
thisisaname
Posts: 3
Joined: Sun Jul 09, 2017 6:54 pm

Re: Install script for MakeMkV for Linux

Post by thisisaname » Sun Jul 09, 2017 7:00 pm

Hahahaha, okay, so I probably should have googled first before performing this but I wrote my own script today. Registered on the forum specifically to share it back with you nice people only finding the script here and the even easier to use PPA. How silly of me to solve a problem that's been solved two times or more.

Regardless, here's the script I wrote today that should be functional on Debian/Ubuntu/Mint etc. If you have better curls or greps I'll take them. Each run will fresh build from source, self contained in /tmp/build-makemkv/, with minor error checking, grab latest beta key/register it for you, and clean itself up.

Code: Select all

#! /bin/bash
##Save as "installmkv/sh", then run (not as root)
##chmod + x installmkv.sh && ./installmkv.sh 

build_dir="/tmp/build-makemkv/"
build_log="/tmp/makemkv_install.log"
url_ffmpeg_releases="https://www.ffmpeg.org/releases/"
url_makemkv="http://www.makemkv.com/download/"
url_makemkv_serial="http://www.makemkv.com/forum2/viewtopic.php?f=5&t=1053"
serial_makemkv=$(curl -s4 --url ""${url_makemkv_serial}"" | grep -oP 'T-[\w\d@]{66}')
vers_ffmpeg="ffmpeg-3.2.4"
vers_makemkv=$(curl -s4 "${url_makemkv}" | grep -oP '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)

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

if [ "$vers_ffmpeg" -eq "ffmpeg-3.2.4" ]; then
    echo "INFO: Using ffmepg-3.2.4 until fix is available http://www.makemkv.com/forum2/viewtopic.php?f=3&t=16059" 
    ##Once fix is prepared, go back to the most recent ffmpeg:
    ##vers_ffmpeg=$(curl -s4 "${url_ffmpeg_releases}" | grep -oP 'ffmpeg-[0-9]+\.[0-9]+\.[0-9]+' | sort -t. -rn | head -n 1)
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}
echo "INFO: Installing dependencies with apt-get (ordered)." | tee -a "$build_log"
sudo apt-get install -y build-essential pkg-config libc6-dev libssl-dev libexpat1-dev libavcodec-dev libgl1-mesa-dev libqt4-dev libfdk-aac-dev | tee -a "$build_log" 

echo "INFO: Downloading latest ffmpeg and makemkv from source." | tee -a "$build_log"
wget "${url_ffmpeg_releases}${vers_ffmpeg}.tar.bz2" | tee -a "$build_log" 
wget "${url_makemkv}makemkv-bin-${vers_makemkv}.tar.gz" | tee -a "$build_log" 
wget "${url_makemkv}makemkv-oss-${vers_makemkv}.tar.gz" | tee -a "$build_log" 

echo "INFO: Extracting archives." | tee -a "$build_log"
tar xvf ${vers_ffmpeg}.tar.bz2 | tee -a "$build_log" 
tar xvf makemkv-bin-${vers_makemkv}.tar.gz | tee -a "$build_log" 
tar xvf makemkv-oss-${vers_makemkv}.tar.gz | tee -a "$build_log" 

echo "INFO: Building ffmpeg." | tee -a "$build_log"
cd ${build_dir}${vers_ffmpeg}
PKG_CONFIG_PATH="${build_dir}/ffmpeg_build/lib/pkgconfig"
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" 
echo "INFO: Installing ffmpeg." | tee -a "$build_log"
sudo make -j4 install | tee -a "$build_log"
 
echo "INFO: Building makemkv-oss." | tee -a "$build_log"
cd ${build_dir}makemkv-oss-${vers_makemkv}
PKG_CONFIG_PATH={build_dir}ffmpeg/lib/pkgconfig ./configure
echo "INFO: Making make-mkvoss." | tee -a "$build_log"
make -j4 | tee -a "$build_log" 
echo "INFO: Installing makemkv-oss." | tee -a "$build_log"
sudo make -j4 install | tee -a "$build_log" 

cd ${build_dir}makemkv-bin-${vers_makemkv}
echo "INFO: Making makemkv-bin." | tee -a "$build_log"
make -j4 | tee -a "$build_log"  
echo "INFO: Installing makemkv-bin." | tee -a "$build_log"
sudo make -j4 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_makemkvW" | tee -a "$build_log"    
echo "app_Key = \"$serial_makemkv\"" > /home/$USER/.MakeMKV/settings.conf

echo "Info: Remove libaacs0 and link those libraries to the better libmmdb http://www.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
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 "INFO: Exiting."

Post Reply