Sometimes you may work on a remote machine and you don't have sudo permissions to install software you like. If the system administrator cannot add you to the sudoers file due to the strict security policy, then you will need to find a way to install your package. It happened to me on Ubuntu 16.04 with the graphviz package and usual
1 |
[johndoe@UbuntuXenial]% sudo apt-get install graphviz |
did not work.
The solution here is to create a fake root environment with the whole system directory structure, download your *.deb packages with all dependencies, extract them to the fake root and use the LD_LIBRARY_PATH trick to make the dynamic linker/loader (ld-linux.so) load the packages and allow execution of the program. Inspiration was taken from chroot, Python virtual environment and famous LD_PRELOAD trick.
The first step would be to find all package dependencies. They are available on the Ubuntu 16.04's website: https://launchpad.net/ubuntu/xenial/amd64/graphviz/2.38.0-12ubuntu2
Here is the script which does the installation of graphviz and tests its dot program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
#! /bin/bash mkdir -p /home/johndoe/tmp cd /home/johndoe/tmp # Download the package and its dependencies wget -c http://mirrors.edge.kernel.org/ubuntu/pool/main/g/graphviz/graphviz_2.38.0-12ubuntu2_amd64.deb wget -c http://mirrors.edge.kernel.org/ubuntu/pool/main/g/graphviz/libcdt5_2.38.0-12ubuntu2_amd64.deb wget -c http://mirrors.edge.kernel.org/ubuntu/pool/main/g/graphviz/libpathplan4_2.38.0-12ubuntu2_amd64.deb wget -c http://mirrors.edge.kernel.org/ubuntu/pool/main/g/graphviz/libcgraph6_2.38.0-12ubuntu2_amd64.deb wget -c http://mirrors.edge.kernel.org/ubuntu/pool/main/g/graphviz/libgvc6_2.38.0-12ubuntu2_amd64.deb wget -c http://mirrors.edge.kernel.org/ubuntu/pool/main/g/graphviz/libgraphviz-dev_2.38.0-12ubuntu2_amd64.deb # Create a fake root environment mkdir /home/johndoe/env # Extract package files for File in `ls *.deb` do dpkg -x $File /home/johndoe/env done # Provide a path where executable files are located export PATH=$PATH:"/home/johndoe/env/usr/bin" # Provide a path for the loader to search for the dynamic libraries so that it can link them at runtime export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/home/johndoe/env/usr/lib" # Test the executable dot --help # Configure all plugins (PDF, PNG, SVG, etc.) dot -с # Now you can use "dot" to convert your diagrams to image files |
Exporting PATH and LD_LIBRARY_PATH environmental variables to the .bashrc file would allow to permanently allow execution of the graphviz's dot program.