Skip to content

Instantly share code, notes, and snippets.

@fiee
Last active April 3, 2016 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fiee/2156849 to your computer and use it in GitHub Desktop.
Save fiee/2156849 to your computer and use it in GitHub Desktop.
Update script for MacPorts, ConTeXt, Python, LilyPond, Google Fonts and Perl
#!/bin/bash
NO_PORT=0
NO_TEX=0
NO_PYTHON=0
NO_FONTS=0
DO_PERL=0
for PARAM in $*
do
case $PARAM in
help|--help|-h)
echo "parameters:"
echo "noport: don’t update DarwinPorts"
echo "notex: don’t update ConTeXt"
echo "nopy: don’t update Python"
echo "nofonts: don’t update Google Fonts"
echo "doperl: update Perl"
exit 0
;;
noport)
NO_PORT=1
echo "I won’t update DarwinPorts."
;;
notex)
NO_TEX=1
echo "I won’t update ConTeXt."
;;
nopy)
NO_PYTHON=1
echo "I won’t update Python modules."
;;
nofonts)
NO_FONTS=1
echo "I won’t update Google Webfonts."
;;
doperl)
DO_PERL=1
;;
esac
done
PATH=$PATH:/opt/local/bin
PORT='/opt/local/bin/port'
SVNCO='/opt/local/bin/svn checkout'
SVNUP='/opt/local/bin/svn update'
GITUP='/opt/local/bin/git pull -q'
HGUP='/opt/local/bin/hg pull -u'
PIP='/Library/Frameworks/Python.framework/Versions/Current/bin/pip install -Uq'
PYSP='/Library/Frameworks/Python.framework/Versions/Current/lib/python2.7/site-packages'
Utter() {
echo "$1";
terminal-notifier -message "$1" -title "Update"
return 0;
}
UpdateSubdirs() {
OLDDIR=`pwd`;
cd "$1";
for DIR in *
do
if [ -d "$DIR" ]; then
echo "$DIR"
cd "$DIR";
if [ -d ".svn" ]; then
$SVNUP;
else
if [ -d ".git" ]; then
$GITUP;
else
if [ -d ".hg" ]; then
$HGUP;
else
echo "-- nothing to update --";
fi;
fi;
fi;
cd ..;
fi
done;
cd "$OLDDIR";
return 0;
}
if [ $NO_PORT -ne 1 ]; then
Utter "Updating DarwinPorts. Need Password."
cd
sudo port selfupdate
sudo port -puRc upgrade outdated
sudo port -p uninstall inactive
Utter "DarwinPorts is updated."
fi
Utter "Updating LilyPond"
cd ~
lyp install self
if [ $NO_TEX -ne 1 ]; then
Utter "Updating ConTeXt"
cd ~/Library/texmf
source ./tex/setuptex ./tex
./first-setup.sh --extras=all --engine=luatex
mtxrun --selfupdate
luatools --generate
Utter "ConTeXt is updated."
fi
if [ $NO_FONTS -ne 1 ]; then
Utter "Updating Google Web Fonts"
cd ~/fonts/googlefontdirectory && $HGUP && cd
fi
if [ $NO_PYTHON -ne 1 ]; then
Utter "Updating Python"
cd $PYSP
UpdateSubdirs $PYSP
UpdateSubdirs ~/workspace
fi
if [ $DO_PERL -eq 1 ]; then
# My Perl installation is outdated;
# trying to update to module versions that belong to newer Perl versions fails.
Utter "Updating Perl. Need Password."
sudo perl -MCPAN -e"force upgrade"
Utter "Perl is updated."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment