Revision 7722b6b5774238a1a89964c36f3778979e35ac72 authored by a1ex on 06 August 2014, 08:43:29 UTC, committed by a1ex on 06 August 2014, 08:43:29 UTC
1 parent 45a3fed
MLTools
#!/bin/bash
# UNDER DEVELOPMENT, pre-alpha version
# MLTools is a script to prepare your mac for use all Magic Lantern features
# more info on Magic lantern: http://www.magiclantern.fm
# on MLTools: http://www.magiclantern.fm/forum/index.php?topic=1019.0
#SETTINGS=~/.MacOSX/environment.plist
#PLIST=/usr/libexec/PlistBuddy
# if the file doesn't exist, try to create folder
#if [ ! -f $SETTINGS ]
#then
# mkdir -p ~/.MLTools
#fi
# then just add entries (file will be created if it doesn't exist)
#$PLIST -c "Add :MLsource string '~/magic-lantern'" $SETTINGS
#$PLIST -c "Add :arm_fldr string '~/arm-toolchain'" $SETTINGS
#$PLIST -c "Add :EOS_CARD string '/Volumes/EOS_DIGITAL/'" $SETTINGS
#$PLIST -c "Add :files_fldr string '"$EOS_CARD"DCIM/100CANON'" $SETTINGS
#$PLIST -c "Add :ML_FLDR string '/ML'" $SETTINGS
#$PLIST -c "Add :BIN string 'autoexec.bin'" $SETTINGS
#########################################################################################
# OSX FUNCTIONS
#########################################################################################
setvar() {
echo "*******************************************"
echo "* Checking Start Options: *"
echo "*******************************************"
# CHANGE THIS IF YOU WANT
MLsource=~/magic-lantern # folder with magic lanter sources
arm_fldr=~/arm-toolchain462 # summon-arm toolchain location
EOS_CARD=/Volumes/EOS_DIGITAL/ # ML installed card address
files_fldr="$EOS_CARD"DCIM/ # folder to check for file to conver on camera
ML_FLDR=ML/ # Ml folder on card
BIN=autoexec.bin # ML bin name
# List of things to install
BREW_MLdev="
binutils
gmp
mpfr
libmpc
mercurial
wget
imagemagick
ufraw
mplayer
poppler
gfortran
pkg-config"
PIP_MLdev="
numpy
PIL
matplotlib
docutils
scipy
ipython==0.10
sympy
pydot
yappi
Cheetah
profilestats
ahocorasick
pyprof2calltree
pyparsing
"
BREW_MLbase="
mercurial
imagemagick
wget
ufraw
mplayer"
PIP_MLbase="
numpy
PIL"
CONVERT_422_MSG="CONVERT_422_MSG"
HDR_MERGE_MSG="HDR_MERGE_MSG"
FST_MERGE_MSG="FST_MERGE_MSG"
CONVERT_RAW_MSG="CONVERT_RAW_MSG"
}
cd ~/
help() {
echo ""
echo "Usage: MLTools [option]"
echo ""
echo "At first start this script will check if there are the file"
echo "needed to perform all conversion, if not here it will install"
echo "what needed."
echo ""
echo "If there is no option set it will try to find and convert"
echo "all that there is on ML card"
echo "If there is no ML card it will try to install ML on the "
echo "eventually available EOS__DIGITAL card mounted and make bootable"
echo "or it will ask for a folder to search something to convert"
echo ""
echo "Options:"
echo "[folder] :used for searching something to convert"
echo "[file] :used for converting that file"
echo "h or help :shows this help"
echo "i or install :installs base system andd clone Unified repo"
echo "d or dev :install all the dependencies for the arm"
echo " toolchain and starts the summon-arm script"
echo "remove or r :uninstall all the dependencies previously installed"
echo " it will ask for confirmation"
exit 0
}
checkBrewPIP() {
echo "*******************************************"
echo "* Checking for Homebrew and PIP... *"
echo "*******************************************"
if [ $(which brew) ]; then
echo "Homebrew already installed"
else
echo "Installing Homebrew..."
/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
echo "Done"
brew doctor
fi
echo "Updating Homebrew..."
brew update
echo "Done"
if [ $(which pip) ]; then
echo "pip already installed"
else
echo "Installing pip..."
sudo easy_install pip
echo "Done"
fi
echo "Updating pip..."
sudo pip install -U pip
echo "Done"
}
checkMLs() {
if [ ! -d "$MLsource" ];then
hg clone -r unified https://bitbucket.org/hudson/magic-lantern/
fi
}
installBase() {
checkBrewPIP
echo "*******************************************"
echo "* Installing Base tools: *"
echo "*******************************************"
for f in $BREW_ML; do
if [ ! $(brew list | grep "$f") ]; then
echo "$f Installation (brew)"
brew install "$f"
else
echo "$f already installed (brew)"
fi
done
for f in $PIP_ML; do
if [ ! $(pip freeze | grep "$f") ]; then
echo "$f Installation (pip)"
sudo pip install "$f"
else
echo "$f already installed (pip)"
fi
done
if [ ! $(which enfuse) ] || [ ! -f /usr/bin/enfuse ]; then
echo "Downloading hugin"
wget http://panorama.dyndns.org/download.php?id=476
echo "hugin installation (dmg)"
hdiutil attach hugin-mac-2011.5.0.5833_db2f378e1c08.dmg
cp /Volumes/hugin-mac-2011.5.0.5833_db2f378e1c08/hugin-mac-2011.5.0.5833/Hugin.app /Applications
cp /Volumes/hugin-mac-2011.5.0.5833_db2f378e1c08/hugin-mac-2011.5.0.5833/HuginTools /Applications
printf "%b\n" 'export PATH="/Applications/HuginTools:$PATH"'
hdiutil detach hugin-mac-2011.5.0.5833_db2f378e1c08
rm -f hugin-mac-2011.5.0.5833_db2f378e1c08.dmg
else
echo "hugin already installed"
fi
checkMLs
}
installDev() {
installBase
echo "*******************************************"
echo "* Installing Dev dipendencies: *"
echo "*******************************************"
if [ ! -d ~/.matplotlib ]; then
mkdir -p ~/.matplotlib
printf "%b\n" "backend : WXAgg # Use wxpython as the plotting backend." >> ~/.matplotlib/matplotlibrc
fi
if [ ! $(pip freeze | grep wxPython=) ]; then
Dw=http://downloads.sourceforge.net/wxpython/
FL=wxPython2.8-osx-unicode-2.8.12.1-universal-py2.7.dmg
wget $Dw$FL
echo "wxPython Installation"
hdiutil attach $FL
sudo installer -pkg /Volumes/${FL%.*}/${FL%.*}.pkg -target /
hdiutil detach /Volumes/${FL%.*}
rm -f $FL
else
echo "wxPython already installed"
fi
if [ ! $(pip freeze | grep scipy) ]; then
Dw=http://www.graphviz.org/pub/graphviz/stable/macos/lion/
FL=graphviz-2.28.0.pkg
wget $Dw$FL
echo "graphviz Installation"
sudo installer -pkg $FL -target /
rm -f $FL
sudo pip install pygraphviz
else
echo "graphviz already installed"
fi
if [ ! $(pip freeze | grep easygui) ]; then
echo "Downloading easygui"
Dw=http://sourceforge.net/projects/easygui/files/0.96/
FL=easygui-0.96.tar.gz
wget $Dw$FL
tar xvfz $FL
rm -f $FL
echo "easygui Installation"
sudo python setup.py install
rm -f easygui.py
rm -f setup.py
else
echo "easygui already installed"
fi
if [ ! $(which libusb-config) ]; then
echo "Downloading libusb.pkg"
Dw=http://www.ellert.se/PKGS/libusb-2011-10-29/10.7/
FL=libusb.pkg.tar.gz
wget $Dw$FL
tar xvfz $FL
rm -f $FL
echo "libusb.pkg Installation"
sudo installer -pkg libusb.pkg -target /
rm -f libusb.pkg
else
echo "libusb already installed"
fi
if [ ! $(which pandoc) ] ; then
echo "pandoc Installation (pkg)"
wget http://pandoc.googlecode.com/files/pandoc-1.9.4.1.dmg
hdiutil attach pandoc-1.9.4.1.dmg
sudo installer -pkg /Volumes/pandoc\ 1.9.4.1/pandoc-1.9.4.1.pkg -target /
hdiutil detach /Volumes/pandoc\ 1.9.4.1
rm -f pandoc-1.9.4.1.dmg
else
echo "pandoc already installed"
fi
if [ ! $(which tex) ]; then
echo
echo "To be able to compile docs"
echo "YOU NEED TO INSTALL MacTeX"
echo "http://www.tug.org/mactex/"
echo "Searching Installer..."
echo
mactex=$(mdfind MacTeX-2011.mpkg | grep MacTeX-2011.mpkg)
if [ ! $mactex ]; then
echo "Downloading MacTeX"
wget http://mirror.ctan.org/systems/mac/mactex/MacTeX.mpkg.zip
unzip MacTeX.mpkg.zip
rm -f MacTeX.mpkg.zip
open MacTeX-2011.mpkg
else
open $mactex
fi
else
echo "tex already installed (dmg)"
fi
}
installArm() {
installDev
cp -r "$MLsource"/toolchain/patches .
sudo bash "$MLsource"/toolchain/summon-arm
printf "%b\n" '\nexport PATH="$HOME/arm-toolchain462/bin:$HOME/arm-toolchain462/tools:$PATH\n' >> .bash_profile
sudo rm -dR build
sudo rm -dR patches
sudo rm -dR sources
sudo rm -dR stamps
}
remove() {
echo "Are you sure to remove all thing installed? Y or N"
read install
if [ "$install" == Y ] || [ "$install" == y ]; then
BREW_ML=$"BREW_MLdev"
for f in $BREW_ML; do
echo "brew uninstall $f"
# brew uninstall "$f"
done
for f in $PIP_ML; do
echo "pip uninstall $f"
# pip uninstall "$f"
done
fi
exit 0
}
########-FILES-CONVERSION-###############################################
checkRAW() {
list_file=${z:$cut}
echo $list_file
for img in $list_file; do
if [ -f $files_fldr$d/${img%.*}.CR2 ] && [ ! -f $files_fldr$d/${img%.*}.JPG ]; then
echo "Converting ${img%.*}.CR2 to ${img%.*}.JPG..."
/usr/local/bin/convert cr2:"$files_fldr$d"/"${img%.*}".CR2 "$files_fldr$d"/"${img%.*}".JPG
fi
done
cd "$files_fldr$d"
bash "$file_is"
}
checkFILE() {
if [ "${file_is: -4}" == ".422" ]; then
echo "CONVERTING $files_fldr$d/$file_is"
python $MLsource/src/422-JPG.py "$files_fldr$d/$file_is"
elif [ "${file_is: -3}" == ".SH" ]; then
echo SCRIPT_Found
if [ "${file_is:0:4}" == "HDR_" ]; then
a=$(cat "$files_fldr$d/$file_is" | grep align_image_stack)
e=$(cat "$files_fldr$d/$file_is" | grep enfuse)
if [ "${a:0:17}" == "align_image_stack" ]; then
echo HDR_Aligned
z=$a
cut=37
checkRAW
else
echo HDR_Base
z=$e
cut=35
checkRAW
fi
elif [ "${file_is:0:4}" == "FST_" ]; then
echo FST
z=$e
cut=104
checkRAW
else
echo "nothing to convert"
fi
fi
}
checkFLDR() {
for d in $(ls $files_fldr); do
echo "SEARCHING: $files_fldr$d"
for f in $(ls $files_fldr$d) ; do
file_is="$f"
checkFILE
done
done
}
checkML() {
echo -ne "Magic Lantern on $EOS_CARD:"
if [ -d $EOS_CARD ]; then
if [ -f $EOS_CARD$BIN ]; then
echo "FOUND"
elif [ -d "$arm_fldr" ];then
echo "NOT FOUND"
echo "Installing ML on card"
echo "Type Y to continue N to abort, just enter to skip"
read inst
inst=N
if [ "$inst" == Y ] || [ "$inst" == y ];then
installDev
cd "$MLsource"
make clean
make install
bash "$MLsource"/src/make_bootable.sh
exit 0
fi
fi
else
echo ""
echo "NO CARD FOUND! FORMAT IT FROM"
echo " CAMERA BEFORE USING WITH ML"
echo ""
echo "Select a folder with ML generated files…"
read files_fldr
fi
}
import() {
echo "Not yet ready"
}
########################################################################
# START SCRIPT PROCESSES
########################################################################
OSXprocess() {
setvar
#options check
if [ ! "$1" ]; then
checkML
elif [ "$1" == r ] || [ "$1" == remove ]; then
remove
elif [ "$1" == h ] || [ "$1" == help ]; then
help
elif [ ! -d "$MLsource" ] || [ "$1" == i ] || [ "$1" == install ]; then
BREW_ML="$BREW_MLbase"
PIP_ML="$PIP_MLbase"
installBase
exit 0
elif [ "$1" == d ] || [ "$1" == dev ]; then
BREW_ML="$BREW_MLdev"
PIP_ML="$PIP_MLdev"
installDev
exit 0
elif [ "$1" == sa ] || [ "$1" == summonarm ]; then
installArm
exit 0
elif [ -f "$1" ];then
# if the option is a a file use it as source for the script
file_is=$(basename "$1")
file_dir=$(dirname "$1")
echo "file: $file_is"
d=$(dirname "$1")
d=/$(basename "$d")
files_fldr=$(dirname "$file_dir")
if [ "${file_is: -4}" == ".CR2" ]; then
echo "$CONVERT_RAW_MSG $file_is"
/usr/local/bin/convert cr2:$files_fldr$d/$file_is $files_fldr$d/${file_is:0:8}.JPG
echo "Done"
exit 0
fi
echo "FILE SOURCE: $file_dir/$file_is"
checkFILE
exit 0
elif [ -d "$1" ]; then
files_fldr="$1"
fi
echo "SEARCHING: $files_fldr"
checkFLDR
}
LINUXprocess() {
echo "installing dev dependencies"
sudo apt-get install flex bison libgmp3-dev libmpfr-dev libncurses5-dev libmpc-dev autoconf texinfo build-essential git-core mercurial zlibc zlib1g-dev
echo "installing docs dependencies"
sudo apt-get install python-matplotlib python-matplotlib-data python-matplotlib-doc python-matplotlib-dbg texlive-luatex python-docutils texlive-latex-base texlive-latex-recommended texlive-fonts-extra dvi2ps texlive-math-extra pandoc texlive-latex-extra ruby-full poppler-utils imagemagick
}
cd ~/
#(from summon-arm code)#######################################################
# OS and Tooldetection section - Detects which tools and flags to use
##############################################################################
case "$(uname)" in
Linux)
echo "Found Linux OS."
LINUXprocess
;;
Darwin)
echo "Found Darwin OS."
OSXprocess "$1"
;;
CYGWIN*)
echo "Found CygWin that means Windows most likely."
echo "nothing to do."
;;
*)
echo "Found unknown OS. Aborting!"
exit 1
;;
esac
echo FINISHED
exit 0
Computing file changes ...