Installing as non-root user

The place to discuss linux version of MakeMKV
Post Reply
camjac251
Posts: 4
Joined: Sun Jan 31, 2016 8:17 pm

Installing as non-root user

Post by camjac251 »

I am on a shared Debian 8 system with a Chrooted user. I wanted to be able to install makemkvcon so I can use the command line from my jailed user but have been getting some errors.

I configured makemkv-oss with "./configure --prefix=$HOME --disable-gui" and then ran make && make install. Afterward I'd open the makemkv-bin folder and change the prefix in Makefile to my full $HOME path, then run make && make install. When I tried to use makemkvcon though I got this error "./makemkvcon: error while loading shared libraries: libmakemkv.so.1: cannot open shared object file: No such file or directory"

libmakemkv.so.1 did exist in my user's home folder under ~/lib but it wasn't detected. Also I must add that ldconfig didn't work when compiling makemkv-oss, so I removed the line and ran make && make install again without issue.

I'm guessing makemkvcon has it's shared libraries hardcoded in, so it'll always look in /usr/lib instead of ~/lib or ~/usr/lib?

Could this be changed? I'd very much like to use it in this environment.
sebekk23
Posts: 4
Joined: Fri Jan 30, 2015 5:29 pm

Re: Installing as non-root user

Post by sebekk23 »

Bump - it will be great option.
Woodstock
Posts: 9892
Joined: Sun Jul 24, 2011 11:21 pm

Re: Installing as non-root user

Post by Woodstock »

I would think the biggest obstacle to installing as a non-root user would be the same as non-admin users on Windows and OS X.... permissions when talking to the hardware. MakeMKV needs to talk directly to the drive for some operations, and that is normally prohibited to non-root users, for obvious security reasons.
MakeMKV Frequently Asked Questions
How to aid in finding the answer to your problem: Activating Debug Logging
camjac251
Posts: 4
Joined: Sun Jan 31, 2016 8:17 pm

Re: Installing as non-root user

Post by camjac251 »

Woodstock wrote:I would think the biggest obstacle to installing as a non-root user would be the same as non-admin users on Windows and OS X.... permissions when talking to the hardware. MakeMKV needs to talk directly to the drive for some operations, and that is normally prohibited to non-root users, for obvious security reasons.
You can also have it use a directory instead or an iso, which makes it easier for me since I could run a command like this

Code: Select all

makemkvcon mkv --progress=-same file:"/folder/name/something" all "/folder/name/something"
camjac251
Posts: 4
Joined: Sun Jan 31, 2016 8:17 pm

Re: Installing as non-root user

Post by camjac251 »

Will it become possible one day?
fallenguru
Posts: 4
Joined: Thu Mar 31, 2016 11:57 am

Re: Installing as non-root user

Post by fallenguru »

It's possible now, from memory:

1) oss part
Call configure with --prefix=$HOME.
Comment out the call to ldconfig in the Makefile (it would require root).
$ make
$ make install
$ export LD_LIBRARY_PATH="$HOME/lib:$LD_LIBRARY_PATH"

2) closed part
Edit the Makefile to say PREFIX=$HOME instead of PREFIX=/usr (it's close to the top).
$ make
$ make install

3) misc stuff
You probably want $HOME/bin in your PATH, the right place to do that is distro-dependent.
Since you can't install the libraries to a system location nor tell ld about it, LD_LIBRARY_PATH must contain $HOME/lib for the binaries to work. In theory, it's an environment variable like PATH, in practice setting it permanently can be a challenge, as it's sometimes *unset* for security reasons, e.g. for X sessions of Debian based distros. You can always run ' export LD_LIBRARY_PATH="$HOME/lib:$LD_LIBRARY_PATH" ' again, if it isn't there (check using env).
camjac251
Posts: 4
Joined: Sun Jan 31, 2016 8:17 pm

Re: Installing as non-root user

Post by camjac251 »

I have a working script now for installing makemkvcon on linux through a user (requiring no sudo access)

It is based on the script by mdPlusPlus who based their script on thisisaname
Credited you two in the script itself as well. Also credited you fallenguru. Without your help this wouldn't have been possible.

If anyone would like to use this, it's very useful as it can be used to automatically install (or reinstall if updating) makemkvcon on linux with a regular user.

install_makemkv.sh

Code: Select all

#!/bin/bash
# set -x #Uncomment to see the commands being executed
##Based on https://gist.github.com/mdPlusPlus/b110cad4cdd920950c10dc6b5bce4dc6
##Original from here: https://www.makemkv.com/forum2/viewtopic.php?f=3&t=5266&start=30#p56468
##Credit to mdPlusPlus and thisisaname for scripts, fallenguru for non root steps.
build_dir="$HOME/.tmp/build-makemkv"
build_log="$HOME/.tmp/makemkv_install.log" # Keep this outside of your build_dir as it gets removed at the end of the script.
url_ffmpeg_releases="https://www.ffmpeg.org/releases/"
url_makemkv="http://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=$(curl -s4 "${url_ffmpeg_releases}" | egrep -o 'ffmpeg-([0-9]{1,}\.)+[0-9]{1,}' | sort -t. -rn | head -n 1)
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

echo "INFO: See $build_log for details...."
mkdir -p ${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: Downloading latest ffmpeg and makemkv from source." | tee -a "$build_log"
wget "${url_ffmpeg_releases}${vers_ffmpeg}.tar.bz2" -O "${vers_ffmpeg}.tar.bz2" | tee -a "$build_log"
wget "${url_makemkv}makemkv-bin-${vers_makemkv}.tar.gz" -O "makemkv-bin-${vers_makemkv}.tar.gz" | tee -a "$build_log"
wget "${url_makemkv}makemkv-oss-${vers_makemkv}.tar.gz" -O "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 | 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}
sed -i '/ldconfig/d' Makefile.in
PKG_CONFIG_PATH={build_dir}ffmpeg/lib/pkgconfig ./configure --prefix=$HOME --disable-gui
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"
make -j `getconf _NPROCESSORS_ONLN` install | tee -a "$build_log"
export LD_LIBRARY_PATH="$HOME/lib:$LD_LIBRARY_PATH"
cd ${build_dir}/makemkv-bin-${vers_makemkv}
echo "Auto Accepting License Agreement" | tee -a "$build_log"
mkdir tmp
echo -n accepted >tmp/eula_accepted
echo "INFO: Making makemkv-bin." | tee -a "$build_log"
sed -i "s|/usr|${HOME}|" Makefile
make -j `getconf _NPROCESSORS_ONLN` | tee -a "$build_log" 
echo "INFO: Installing makemkv-bin." | tee -a "$build_log"
make -j `getconf _NPROCESSORS_ONLN` install | tee -a "$build_log"

echo "INFO: Testing makemkv binary." | tee -a "$build_log"
if [ ! -f "$HOME/bin/makemkvcon" ]; then
    echo "ERR: Missing $HOME/bin/makemkvcon, 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/.MakeMKV/
echo "app_Key = \"$serial_makemkv\"" > $HOME/.MakeMKV/settings.conf
cd $HOME/.tmp
echo "INFO: Cleaning up build directory" | tee -a "$build_log"
rm -rf "$build_dir"
echo "If you haven't already, make sure that these two lines are in your .bashrc file.
LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH"
echo "INFO: Exiting."
exit
basvdw
Posts: 1
Joined: Sat Feb 19, 2022 4:19 pm

Re: Installing as non-root user

Post by basvdw »

Apologies for necroposting, I'm not a regular here so don't know if it's appropriate, but I updated the script a bit to fit the needs of someone at Ultra.cc/UltraSeedbox.
It's heavily based on the script posted here by camjac251, I appreciate you and everyone else. Mine does essentially the same thing with a few small changes:
  • Added NASM as a dependency since FFmpeg needs it and it doesn't come preinstalled at Ultra.cc
  • Changed the build directory to /tmp/makemkv
  • Changed the prefix to $HOME/.local
  • Adds $LD_LIBRARY_PATH and $PATH insertions to .bashrc if they don't exist yet (kind of hacky but it's useful to us)
  • Changed cleanup of build directory to be on exit
  • Changed curl commands to follow redirects
  • Removed the build log since we don't really need it, you can just redirect the output of the script itself if you do
I'm hosting it at https://get.bas.sh/install-makemkv.sh so you can easily run it with a one-liner (or download it first if you want to read it before running it).

Code: Select all

curl -fsSL https://get.bas.sh/install-makemkv.sh | bash
and here's the script in full:

Code: Select all

#!/usr/bin/env bash
#set -x
set -e

### Based on https://forum.makemkv.com/forum/viewtopic.php?p=62349#p62349

p() {
    echo -e "\n==> $@\n"
}

build_dir=/tmp/makemkv

cleanup() {
    p 'Cleaning up build directory...'
    rm -rf $build_dir
}

trap cleanup EXIT

PREFIX=$HOME/.local
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
export PATH=$PREFIX/bin:$PATH

nasm_url="https://www.nasm.us"
ffmpeg_url="https://www.ffmpeg.org/releases"
makemkv_url="http://makemkv.com/download"
makemkv_serial_url="http://www.makemkv.com/forum2/viewtopic.php?f=5&t=1053"

p 'Checking latest versions'
nasm_version=$(curl -fsSL $nasm_url | grep -oP '\d+\.\d+\.\d+' | head -n1)
echo "nasm $nasm_version"
ffmpeg_version=$(curl -fsSL $ffmpeg_url | grep -oP 'ffmpeg-(\d+\.)+\d+' | sort -V | tail -n1)
echo $ffmpeg_version
makemkv_version=$(curl -fsSL $makemkv_url | grep -oP '\d+\.\d+\.\d+' | head -n1)
echo "MakeMKV $makemkv_version"
makemkv_serial=$(curl -fsSL $makemkv_serial_url | grep -oP 'T-[\w\d@]{66}')
echo "MakeMKV key: $makemkv_serial"

if [[ -z $nasm_version ]] || [[ -z $ffmpeg_version ]] || [[ -z $makemkv_version ]] || [[ -z $makemkv_serial ]]; then
    p 'At least one of the version checks failed, aborting'
    exit
fi

p "Compiling NASM, MakeMKV, and FFmpeg in $build_dir"
mkdir -p $build_dir && cd $build_dir

p 'Downloading NASM, ffmpeg, and makemkv sources'
wget --no-verbose "$nasm_url/pub/nasm/releasebuilds/$nasm_version/nasm-$nasm_version.tar.gz" \
    "$ffmpeg_url/$ffmpeg_version.tar.bz2" \
    "$makemkv_url/makemkv-bin-$makemkv_version.tar.gz" \
    "$makemkv_url/makemkv-oss-$makemkv_version.tar.gz"

p 'Extracting archives'
echo -n 'nasm: ' && tar xf nasm-$nasm_version.tar.gz --totals
echo -n 'ffmpeg: ' && tar xf $ffmpeg_version.tar.bz2 --totals
echo -n 'makemkv-oss: ' && tar xf makemkv-bin-$makemkv_version.tar.gz --totals
echo -n 'makemkv-bin: ' && tar xf makemkv-oss-$makemkv_version.tar.gz --totals

p 'Configuring NASM'
cd $build_dir/nasm-$nasm_version
./autogen.sh
./configure --prefix=$PREFIX
p 'Compiling NASM'
make -j
p 'Installing NASM'
make install

p 'Configuring FFmpeg'
cd $build_dir/$ffmpeg_version
./configure --prefix=$PREFIX --extra-cflags="-I$PREFIX/include" --extra-ldflags="-L$PREFIX/lib" --enable-static --enable-pic
p 'Compiling FFmpeg'
make -j
p 'Installing FFmpeg'
make install

p 'Configuring makemkv-oss'
cd $build_dir/makemkv-oss-$makemkv_version
sed -i '/ldconfig/d' Makefile.in
./configure --prefix=$PREFIX --disable-gui
p 'Compiling makemkv-oss'
make -j
p 'Installing makemkv-oss'
make install

p 'Compiling makemkv-bin'
cd $build_dir/makemkv-bin-$makemkv_version
mkdir tmp
echo -n "accepted" > tmp/eula_accepted
sed -i "s|/usr|$HOME/.local|" Makefile
make -j > /dev/null
p 'Installing makemkv-bin'
make install

p 'Registering MakeMKV with latest beta key'
mkdir -p $HOME/.MakeMKV
echo "app_Key = \"$makemkv_serial\"" > $HOME/.MakeMKV/settings.conf

if ! grep -qE '\$HOME/.local/lib(:|"$|$)' $HOME/.bashrc; then
    p 'Adding $LD_LIBRARY_PATH insertion to .bashrc'
    echo 'export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH' >> $HOME/.bashrc
fi

if ! grep -qE '\$HOME/.local/bin(:|"$|$)' $HOME/.bashrc; then
    p 'Adding $PATH insertion to .bashrc'
    echo 'export PATH=$HOME/.local/bin:$PATH' >> $HOME/.bashrc
fi

p 'Restart your SSH session or run "source ~/.bashrc" to be able to run makemkvcon (if everything went well, which I sure hope it did). Enjoy! :)'
Post Reply