With the release of Ubuntu 9.04 aka Jaunty later this month, I thought I’d share how to get a current version of Mono on the latest Ubuntu release.
For a number of reasons, Ubuntu always seems to be just a little behind current with its Mono packages. The largest reason IMO is the difficulty in properly packaging Mono for Debian/Ubuntu. I’ve tried and it is not easy.
- Make our install a tiny developer environment.
sudo apt-get install build-essential subversion autoconf libtool bison gettext pkg-config libglib2.0-dev - Install the old Mono 2.0 C# compiler from jaunty so that we can bootstrap the trunk compiler.
sudo apt-get install mono-mcs
ln –s /usr/bin/mcs1 /usr/bin/mcs
This installs enough mono to let the C# compiler run. We will remove this and all its dependencies later. - Fetch the source from SVN. I use a mono-dev-update script to checkout the first time and keep me updated. The script pulls and installs mono, mcs, xsp to /opt/mono on a default ubuntu server install once step 1 above has been performed. To build more parts of mono such as GTK# and MonoDevelop you will need more gtk+ library dependencies.
sudo mkdir –p /opt/mono/src
sudo chown $USER /opt/mono /opt/mono/src
./mono-dev-update - Remove the bootstrap mcs
sudo apt-get 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
The real work is done by the mono-dev-update script. Its a mess of bash script which has served me well for a couple of years now.
I’ll paste the current version of it here, but I’ll also try to keep it up to date for download here.
#!/bin/bash #mono-dev-update #Jay R. Wren <jrwren@xmtp.net> #usage: # -s skip svn 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. 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 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 SVNDIRS="mcs mono xsp monodevelop gtk-sharp gtkmozembed-sharp type-reflector debugger banshee-sample-plugin olive mono-tools" CVSDIRS="banshee" MAKEDIRS="mono xsp debugger mono-tools monodevelop gtkmozembed-sharp " BANSCHEEPLUGINS="banshee-sample-plugin" level=0 skipsvn=0 optCount=0; while getopts :xvfsnd:t:cl: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 transform="$OPTARG" ; optCount=$((optCount+2)) ; 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" ; optCount=$((optCount+2));fi done if [[ $optCount != $((OPTIND-1)) ]] ; then echo "optcount($optCount) not equal to OPTIND($OPTIND)";fi echo "using makedirs $MAKEDIRS" echo "using prefix $MONO_PREFIX" if [[ 1 > $skipsvn ]]; then for i in $SVNDIRS do echo -e "\e[1;31m pushd $i \e[m" if [[ -d $i ]];then pushd $i if [[ ! -d .svn ]];then pushd .. ; svn co http://anonsvn.mono-project.com/source/trunk/$i ;popd; 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 echo svn up nice -n 20 svn up if [ $? != 0 ]; then echo "ERROR: $?" ;popd ; break; fi pwd popd fi done else echo "-s detected, skipping svn update" fi #mono, xsp, MD, GTK# etc function autogenAndMake () { echo "running for $*" for i in $* do if [[ -d $i ]]; then echo -e "\e[1;31m pushd $i \e[m" pushd $i if [[ -f "autogen.sh" ]];then PROG=./autogen.sh else PROG=./configure fi if [[ "true" != $forceAGen ]]; then nice -n 20 make && nice -n 20 make install fi if [[ "true" != $noautoretry && $? != 0 || "true" == $forceAGen ]]; then echo -e "\e[1;31m " echo 'make clean ; $PROG --prefix=$MONO_PREFIX --enable-aspnet --enable-aspnetedit --with-preview --with-moonlight && nice -n 20 make && nice -n 20 make install' echo -e "\e[m" if [[ -f Makefile ]]; then make clean; fi $PROG --prefix=$MONO_PREFIX --enable-aspnet --enable-aspnetedit --with-preview --with-moonlight && nice -n 20 make && nice -n 20 make install || break fi popd fi done } #-l not speced or even means build all - odd means build only banshee & olive if [[ $((level % 2)) == 0 ]]; then autogenAndMake $MAKEDIRS fi if [[ $level > 1 ]]; then i=gtk-sharp echo -e "\e[1;31m pushd $i \e[m" pushd $i echo -e "\e[1;31m " echo 'make clean ; ./bootstrap-2.12 --prefix=$MONO_PREFIX && nice -n 20 make && nice -n 20 make install' echo -e "\e[m" if [[ -f Makefile ]]; then make clean ; fi ./bootstrap-2.12 --prefix=$MONO_PREFIX && nice -n 20 make && nice -n 20 make install || break popd fi if [[ $level > 1 ]];then #olive for i in olive do if [[ -d $i ]] ; then echo -e "\e[1;31m pushd $i \e[m" pushd $i echo -e "\e[1;31m " echo 'make clean ; ./configure --prefix=$MONO_PREFIX && nice -n 20 make && nice -n 20 make install' echo -e "\e[m" if [[ -f Makefile ]]; then make clean ; fi ./configure --prefix=$MONO_PREFIX && nice -n 20 make && nice -n 20 make install || break popd fi done fi if [[ $level > 1 ]];then #banshee if [[ -d banshee ]];then pushd banshee cvs up ./configure --prefix=$MONO_PREFIX --disable-helix && nice -n 20 make && nice -n 20 make install || break popd autogenAndMake $BANSCHEEPLUGINS fi fi popd
JR, it a bit confuse at first hand it better if you can reformat the text as
– minimum configuration (pre-package install etc)
– script usage
Jay, can you wrap this up in a NANT script for me?
No, I cannot wrap it into a nant script. I don’t know nant.
But you are welcome to turn this into a nant script.
Hi,
Im using ubuntu Desktop
is this an issue?
when i run the script, it checks out the source code (ran on desktop)
and then im getting the following error
running for boo
mono-dev-update: line 163: pushd: boo: No such file or directory
NAnt 0.85 (Build 0.85.2478.0; release; 14/10/2006)
Copyright (C) 2001-2006 Gerry Shaw
http://nant.sourceforge.net
BUILD FAILED
Could not find a ‘*.build’ file in ‘/opt/mono/src/mod_mono’
For more information regarding the cause of the build failure, run the build again in debug mode.
Try ‘nant -help’ for more information
/opt/mono/src ~/Desktop
./Desktop
boo
gtk-sharp
mod_mono
mono-dev-update
gnome-sharp
mono
mono-tools
xsp
mono-addins
debugger
gtkmozembed-sharp
mcs
monodevelop
olive
type-reflector
Jay, can you wrap this up in a NANT script for me?