[Mono-devel-list] Re: [Gtk-sharp-list] kernel support.

Jonathan Pryor jonpryor at vt.edu
Tue Jun 17 16:45:38 EDT 2003


There's one problem with your proposed shell wrapper: it doesn't work
correctly in the presence of symbolic links, since when invoking the
symbolic link "$0" will be the name of the symbolic link, not the name
of the *target* of the symbolic link.

MCS has a solution, but it depends on autoconf (mono's scripts/mcs.in
file is processed, including the full path to mcs).  As such, it may be
undesirable.

So, here's my attempted solution.  It checks for the presence of
symlinks, and looks up the target of the symlink (using readlink) if
necessary, before passing off the program to mono:

    #!/bin/sh
    # Starts a CIL program whose name is patterned after the filename of
    # this script.  The CIL program executed is "$0".exe.

    file=$0

    # If file is a symlink, find where it's pointing to
    if [ -L $file ] ; then
      if ! (readlink -f "$file") > /dev/null 2>&1; then
        echo `basename "$0"` ": missing required program readlink!"
        exit -1
      fi
      file=`readlink -f "$file"`
    fi

    exec mono "$file.exe" "$@"

Thoughts?

 - Jon

On Tue, 2003-06-17 at 12:51, Dag Wieers wrote:
> On 16 Jun 2003, George Farris wrote:
> 
> > Does anyone know what the plans are for kernel support of mono
> > binaries?  Right now a binary mono file shows as:
> > 
> > MS Windows PE 32-bit Intel 80386 console executable
> > 
> > This of course, is totally unacceptable on a Linux machine.  I want to
> > be able to run my binaries directly instead of through a shell script.
> 
> This issue is dear to me too.
> 
> The Debian Mono page indicates there is a workaround. A third binary that 
> does a more conclusive check and then starts either mono or wine.
> 
> Which would mean that the kernel binfmt support has short-comings that can 
> only be overcome by doing it in userspace. My first thought is that the 
> binfmt_misc kernel-support should be fixed to be more useful.
> 
> Since there will not be a good solution soon, I would propose the 
> following standard (and I took the liberty to add it to the Developer FAQ 
> page in the Wiki already).
> 
> The proposal is to have a shell wrapper with the same name as the .Net 
> binary, with the '.exe' part and would consist of the following 2 lines:
> 
> 	#!/bin/sh
> 	exec mono "$0".exe $@
> 
> Ofcourse we could verify some things in this script (check if mono can be 
> called, if the executable exists, etc...) But I would keep it as simple as 
> possible, I've tested the output in various circumstances and the 
> error-output was in each case very clear about the problem.
> 
> Kind regards,
> --   dag wieers,  dag at wieers.com,  http://dag.wieers.com/   --
> [Any errors in spelling, tact or fact are transmission errors]
> 
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list




More information about the Mono-devel-list mailing list