#!/bin/bash #mono-dev-update #Jay R. Wren #usage: # -s skip svn and git operations. don't try to pull updates. # -f force autogen.sh or configure to run. # -l n set build level to value of 'n'. This controls optional package # builds. Not used much # -n no auto retry. if make fails, do not try to ./configure and # make again. #required packages include: #for mono/mcs:build-essential subversion autoconf libtool bison gettext pkg-config libglib2.0-dev #for the first time mcs bootstrap: mono-mcs # ln .s /usr/bin/mcs1 /usr/bin/mcs # After the first time bootstrap you may remove: binfmt-support cli-common libmono-corlib1.0-cil libmono-corlib2.0-cil libmono-i18n1.0-cil libmono-i18n2.0-cil libmono-security2.0-cil libmono-system1.0-cil libmono-system2.0-cil libmono0 mono-2.0-gac mono-2.0-runtime mono-common mono-gac mono-jit mono-mcs mono-runtime #required packages for mod_mono: apache2-prefork-dev #required packages for debugger: libncurses5-dev #required packages for gtk-sharp: libgtk2.0-dev libgconf2-dev (23MB to dl,98MB disk) #optional required for gtk-sharp glade support: libglade2-dev #mono-tools(profiler, gendarme,etc) requires gtk-sharp gnome-sharp webkit-sharp #required packages for webkit-sharp: libwebkit-dev #required packages for gnome-sharp: libgnomecanvas2-dev libgnomeui-dev #monodevelop requires gnome-sharp boo, gio-sharp and gtksourceviewsharp-2.0...not gtksourviewsharp2 #required packages for mono-tools: #required packages for boo: openjdk-6-jre-headless libgtksourceview-dev # yes, boo requires a java runtime to build. I prefer the openjdk-jre MONO_PREFIX=/opt/mono #GNOME_PREFIX=/opt/gnome GNOME_PREFIX=/usr export LD_LIBRARY_PATH=$MONO_PREFIX/lib:$LD_LIBRARY_PATH export C_INCLUDE_PATH=$MONO_PREFIX/include:$GNOME_PREFIX/include export ACLOCAL_PATH=$MONO_PREFIX/share/aclocal export PKG_CONFIG_PATH=$MONO_PREFIX/lib/pkgconfig:$GNOME_PREFIX/lib/pkgconfig export PATH=$MONO_PREFIX/bin:$PATH export MANPATH=$MANPATH:$MONO_PREFIX/share/man if [[ ! -d $MONO_PREFIX/src ]];then mkdir $MONO_PREFIX/src; fi pushd $MONO_PREFIX/src #sanity checks if [[ -z `which curl` ]] ; then echo this script requires curl to be installed. apt-get install curl if you can ; exit ; fi if [[ ! -d /opt/mono ]] ; then echo this script requires /opt/mono to exist and be owned by you ; exit ; fi if [[ ! -x /usr/bin/svn ]] ; then echo this script requires svn to be installed. apt-get install svn if you can; exit ; fi if [[ ! -x /usr/bin/git ]] ; then echo this script requires git to be installed. apt-get install git if you can; exit ; fi if [[ ! -x /usr/bin/autoconf ]] ; then echo this script requires autoconf to be installed. apt-get install autoconf if you can; exit ; fi if [[ ! -x /usr/bin/libtool ]] ; then echo this script requires libtool to be installed. apt-get install libtool if you can; exit ; fi if [[ ! -r /usr/lib/libgthread-2.0.so && ! -r /usr/lib/x86_64-linux-gnu/libgthread-2.0.so ]] ; then echo this script requires libglib2.0-dev to be installed. apt-get install libglib2.0-dev if you can; exit ; fi if [[ ! -x `which gmcs` ]] ; then echo this script requires a gmcs to bootstrap the mono csharp compiler; echo try installing mono-gmcs package with apt-get install mono-gmcs ; exit ; fi if [[ ! -x `which apxs2` ]] ; then echo; echo this script requires apache2-prefork-dev package to be installed for mod_mono to be installed. \(needs apxs2\) run apt-get install apache2-prefork-dev if you can ; sleep 5 ; fi SRCDIRS="mono xsp mod_mono gtk-sharp gtkmozembed-sharp debugger mono-addins olive gnome-sharp webkit-sharp mono-tools boo gio-sharp monodevelop gtksourceview-sharp fsharp fsharpbinding" MAKEDIRS="mono xsp mod_mono debugger gtk-sharp gtkmozembed-sharp mono-addins gnome-sharp boo gtksourceview-sharp gio-sharp monodevelop webkit-sharp mono-tools olive fsharp fsharpbinding" level=0 skipsvn=0 optCount=0; while getopts :xvfsnd:tcl:m: OPTS ;do if [[ $OPTS == "x" ]]; then outputStyle=xml ; optCount=$((optCount+1)) ; fi if [[ $OPTS == "v" ]]; then action=view ; optCount=$((optCount+1)) ; fi if [[ $OPTS == "f" ]]; then forceAGen="true" ; optCount=$((optCount+1)) ; fi if [[ $OPTS == "s" ]]; then skipsvn=1 ; optCount=$((optCount+1)) ; fi if [[ $OPTS == "n" ]]; then noautoretry="true" ; optCount=$((optCount+1)) ; fi if [[ $OPTS == "d" ]]; then DEBUG="$OPTARG" ; optCount=$((optCount+2)) ; fi if [[ $OPTS == "t" ]]; then tryDeps="true" ; optCount=$((optCount+1)) ; fi if [[ $OPTS == "c" ]]; then for i in $MAKEDIRS;do pushd $i ; make clean ; popd ; done ;exit ; optCount=$((optCount+1)) ; fi if [[ $OPTS == "l" ]]; then level="$OPTARG" ; optCount=$((optCount+2)) ; fi if [[ $OPTS == "m" ]]; then MAKEDIRS="$OPTARG" SRCDIRS="$OPTARG" ; optCount=$((optCount+2));fi done if [[ $optCount != $((OPTIND-1)) ]] ; then echo "optcount($optCount) not equal to OPTIND($OPTIND)";fi if [[ $tryDeps == "true" ]]; then read -t 5 -p "Do you want to sudo apt-get install all required packages? (y/n) " doit if [[ $doit == 'y' ]]; then sudo apt-get install build-essential subversion autoconf libtool bison gettext pkg-config libglib2.0-dev apache2-prefork-dev libncurses5-dev libgnomecanvas2-dev libgnomeui-dev libgtk2.0-dev libgconf2-dev libglade2-dev libgtksourceview-dev libwebkit-dev fi fi echo "using makedirs $MAKEDIRS" echo "using prefix $MONO_PREFIX" function gtksourceviewpatch() { if grep -q Sample Makefile.am ; then echo ' Index: sample/Makefile.am =================================================================== --- sample/Makefile.am (revision 132921) +++ sample/Makefile.am (working copy) @@ -1,14 +1,10 @@ TEST = SourceViewTest.exe -PRINT = PrintSample.exe -EXTRA_DIST = SourceViewTest.cs PrintSample.cs -CLEANFILES = $(TEST) $(TEST).mdb $(PRINT) $(PRINT).mdb +EXTRA_DIST = SourceViewTest.cs +CLEANFILES = $(TEST) $(TEST).mdb -all: $(TEST) $(PRINT) +all: $(TEST) $(TEST): $(srcdir)/SourceViewTest.cs $(CSC) -out:$@ $(srcdir)/SourceViewTest.cs -r:../gtksourceview/gtksourceview-sharp.dll -pkg:gtk-sharp-2.0 -$(PRINT): $(srcdir)/PrintSample.cs - $(CSC) -out:$@ $(srcdir)/PrintSample.cs -r:../gtksourceview/gtksourceview-sharp.dll -pkg:gtk-sharp-2.0 -pkg:gnome-sharp-2.0 - ' | patch -p0 fi } if [[ 1 > $skipsvn ]]; then for i in $SRCDIRS do if [[ ! -d $i ]];then echo directory now found for $i, trying to checkout or clone via svn or git respectively if [[ $i == "boo" ]]; then echo svn co http://svn.codehaus.org/boo/boo/trunk boo svn co http://svn.codehaus.org/boo/boo/trunk boo elif [[ $i == "gtksourceview-sharp" ]]; then echo git clone http://github.com/mono/gtksourceview-sharp.git git clone http://github.com/mono/gtksourceview-sharp.git if [ $? != 0 ]; then echo "ERROR: $?" ;popd ; break; fi pushd gtksourceview-sharp git branch gtksourceview-sharp-0.x origin/remote/gtksourceview-sharp-0.x if [ $? != 0 ]; then echo "ERROR: $?" ;popd ; break; fi git checkout gtksourceview-sharp-0.x if [ $? != 0 ]; then echo "ERROR: $?" ;popd ; break; fi popd elif [[ $i == "gtk-sharp" ]]; then echo git clone http://github.com/mono/$i.git git clone http://github.com/mono/$i.git if [ $? != 0 ]; then echo "ERROR: $?" ;popd ; break; fi git branch gtk-sharp-2-12-branch remotes/origin/gtk-sharp-2-12-branch if [ $? != 0 ]; then echo "ERROR: $?" ;popd ; break; fi git checkout gtk-sharp-2-12-branch if [ $? != 0 ]; then echo "ERROR: $?" ;popd ; break; fi elif [[ $i == "fsharp" || $i == "fsharpbinding" ]]; then echo git clone http://github.com/fsharp/$i.git git clone http://github.com/fsharp/$i.git echo git checkout remotes/origin/2.4 git checkout remotes/origin/2.4 elif [[ $i == "monodevelop" ]]; then echo git clone http://github.com/mono/$i.git git clone http://github.com/mono/$i.git else echo git clone http://github.com/mono/$i.git git clone http://github.com/mono/$i.git if [ $? != 0 ]; then echo "ERROR: $?" ;popd ; break; fi fi fi echo -e "\e[1;31m pushd $i \e[m" pushd $i if [[ $? != 0 ]]; then break; fi #echo -e "\e[1;31m svn info" #svn info #echo 'svn log -r `svn info|grep Revision|cut -f2 -d' '`:HEAD' #echo -e "\e[m" #svn log -r `svn info|grep Revision|cut -f2 -d' '`:HEAD if [[ $i == "boo" ]]; then echo svn up svn up else echo git pull git pull if [[ $i == "gtksourceview-sharp-0.x" ]]; then gtksourceviewpatch ; fi if [ $? != 0 ]; then echo "ERROR: $?" ;popd ; break; fi fi pwd popd done else echo "-s detected, skipping git " fi #mono, xsp, MD, GTK# etc function autogenAndMake () { echo "running for $*" for i in $* do if [[ "boo" == $i ]]; then nantbuild boo continue fi if [[ -d $i ]]; then echo -e "\e[1;31m pushd $i \e[m" pushd $i MAKEARGS="prefix=$MONO_PREFIX" if [[ "true" != $forceAGen ]]; then echo -e "\e[1;31m nice -n 20 make $MAKEARGS \e[m" make $MAKEARGS if [[ $? == 0 && "mod_mono" == $i ]] ; then echo "mod_mono must be installed as root so that the apache module can be installed" read -t 5 -p "Do you want to sudo make install mod_mono? (y/n) " doit if [[ $doit == 'y' ]]; then sudo env PATH=$PATH nice -n 20 make install $MAKEARGS fi else echo -e "\e[1;31m nice -n 20 make install $MAKEARGS \e[m" nice -n 20 make install $MAKEARGS fi fi if [[ "true" != $noautoretry && $? != 0 || "true" == $forceAGen ]]; then #if [[ "monodevelop" == $i ]]; then grep -v Gecko profiles/all > profiles/custom;CONFIGARGS="--profile=custom";fi # if [[ "mono" == $i ]]; then CONFIGARGS="--with-preview --with-moonlight";fi if [[ -f Makefile ]]; then echo -e "\e[1;31m " echo make clean echo -e "\e[m" make clean else echo "no makefile" fi echo -e "\e[1;31m " if [[ $i == "fsharp" ]]; then autoreconf fi if [[ $i == "gtk-sharp" ]];then PROG=./bootstrap-2.12 elif [[ $i == "gnome-sharp" ]];then PROG=./bootstrap-2.24 elif [[ $i == "gio-sharp" ]];then PROG=./autogen-2.22.sh elif [[ -x "autogen.sh" ]];then PROG=./autogen.sh else PROG=./configure fi echo "$PROG --prefix=$MONO_PREFIX $CONFIGARGS && nice -n 20 make " echo -e "\e[m" #sleep to let me read the "YES/NO" status of detected config options $PROG --prefix=$MONO_PREFIX $CONFIGARGS && sleep 2 && nice -n 20 make if [[ $? != 0 ]]; then echo -e "\e[1;31m make failed $? \e[m" && popd && break ;fi if [[ "mod_mono" == $i ]] ; then echo "mod_mono must be installed as root so that the apache module can be installed" read -t 5 -p "Do you want to sudo make install mod_mono? (y/n) " doit if [[ $doit == 'y' ]]; then sudo env PATH=$PATH nice -n 20 make install $MAKEARGS fi elif [[ "gtksourceview-sharp-0.x" = $i ]];then echo "gtksourceview-sharp must be installed as root - it updates some lang files owned by ubuntu gtksourceview-common package" read -t 5 -p "Do you want to sudo make install ? (y/n) " doit if [[ $doit == 'y' ]]; then sudo env PATH=$PATH nice -n 20 make install $MAKEARGS fi else echo -e "\e[1;31m nice -n 20 make install $MAKEARGS \e[m" nice -n 20 make install $MAKEARGS || (echo -e "\e[1;31m make failed $? \e[m" && popd && break) fi fi popd fi done } function nantbuild () { nant=`which nant` if [[ ! -x "$nant" ]]; then if [[ ! -d "nant-0.86-beta1" ]];then echo -e "\e[1;31m " echo could not find dir nant-0.86-beta1 echo -e "\e[m" curl -C - -O "http://voxel.dl.sourceforge.net/sourceforge/nant/nant-0.86-beta1-src.tar.gz" tar zxvf nant-0.86-beta1-src.tar.gz fi pushd nant-0.86-beta1 make install prefix=$MONO_PREFIX popd fi echo "running for $*" for i in $*; do pushd $i if [[ $i == "boo" ]]; then if grep -q /usr/local default.build ; then perl -pi.orig -e "s@/usr/local@$MONO_PREFIX@" default.build fi #echo "boo must be installed as root so that mime-info and gtksourceview lang can be installed" read -t 5 -p "Do you want to touch and chown /usr/share/mime-info/boo.mime and boo.keys and /usr/share/gtksourceview-1.0/language-specs/boo.lang for boo? (y/n) " doit if [[ $doit == 'y' ]]; then sudo touch /usr/share/mime-info/boo.mime /usr/share/mime-info/boo.keys /usr/share/gtksourceview-1.0/language-specs/boo.lang /usr/share/mime/packages/boo-mime-info.xml sudo chown $USER /usr/share/mime-info/boo.mime /usr/share/mime-info/boo.keys /usr/share/gtksourceview-1.0/language-specs/boo.lang /usr/share/mime/packages/boo-mime-info.xml fi nant -D:install.prefix=$MONO_PREFIX all nant -D:install.prefix=$MONO_PREFIX install else nant install fi popd done } autogenAndMake $MAKEDIRS popd