This section will offer workarounds to common problems encountered when packaging Mono-specific applications for Debian.
The official name of the Mono Project is: Mono, mono:: or mono. To keep it unified (more transparent to the user) it should be always called "Mono", not MONO, not mono, not mono:: even no mixing with .NET in it. The explanation of Mono goes into the package long description.
Often times, upstream software developers are not packagers, and vice versa. Developers do not necessarily test their software with packaging issues in mind. The most common problem we see from this are missing dll exceptions.
When Mono code invokes an external library, it usually calls something like [DllImport("foo")]. "foo" is expanded to libfoo.so, and searched for in your library path.
In Debian and some other binary Linux distributions, packages are split into runtime and -dev packages. Since the versioned library libfoo.so.X is usually used at runtime, and .so is a symlink only used at build time, .so is moved to the -dev package.
When packaging an application which uses libfoo, we don't want normal users to need to need the -dev packages just to run the application. As you saw above, however, Mono defaults to looking for the unversioned .so, which is unavailable in the runtime packages.
When the dll map is missing or upstream forgot the dllmap, it will result in a
DllNotFoundException
.
This will stop the execution of the program.
We can fix this by creating a dll map to the exe or dll that is trying to invoke libfoo. If libfoo is invoked by the dll bar.dll, we will create an xml file, bar.dll.config to tell Mono which .so we really want to load at runtime. bar.dll.config should be installed to the same directory as bar.dll.
<configuration> <dllmap dll="foo" target="libfoo.so.0"/> </configuration>
A config file can contain as many dllmap directives as are needed. If the upstream developer already ships a config file, but it is incomplete, you should create a patch against it in your package.
Most Mono software developers are very helpful people, and will readily accept patches to solve this type of bug if you bring it to their attention. Please be sure to inform them of all these changes.
The Mono runtime uses a shared directory, by default ~/.wapi
.
This directory will be created/used when any CLI application is executed (like
the C# compiler mcs).
Here comes 2 problems with it:
/root/.wapi
instead of $HOME/.wapi
).
Means when you don't set MONO_SHARED_DIR explicitly, the package building will fail! Applications will either hang, die with strange Mono runtime errors or segfault (for instance dh_clideps or dh_makeclideps, they use monodis). So change the MONO_SHARED_DIR by calling
export MONO_SHARED_DIR=$(CURDIR)
in the debian/rules file.
The clean target should later remove $(MONO_SHARED_DIR)/.wapi. For more
information what this .wapi directory is used for, please take a look at
mono(1)
.
Debian CLI Policy (DRAFT)
Version 0.2.0meebey@meebey.net
brandon@smarterits.com