Doing .NET the "hard" way

One of my favorite tools for .NET development is the dependency injection framework StructureMap from Jeremy D. Miller. It’s free and it’s Open Source, but it’s only available in the Windows world. Compared to Castle Windsor, StructureMap is much more lightweight and compact, but with the recent enhancements in the upcoming release just as powerful.

So I thought, it couldn’t be so hard, to make StructureMap work with Mono and package it for Debian, but actually, it’s not THAT easy.

The heavy usage of .NET 3.5 features, like lambdas, requires a recent development version of Mono. Took me 2-3 hours to have Mono and Monodevelop compiled from SVN and installed in parallel to my old Mono packages to /opt/mono. But that’s working fine now.

The StructureMap VS2008 solution loads fine in Monodevelop, which makes life a lot easier. The only 3’rd party-dependency that StructureMap has, is Rhino.Mocks (another of my favorite development tools). The Rhino.Mocks assembly seems to work with Mono, but compiling it from source is probably much harder, because of it’s dependency to DynamicProxy, so I decided to leave that by side for now, skip StructureMap.Automocking and concentrate on the core parts of StructureMap.

After working about a week on this, I already found three bugs in the Mono C# compiler, but the good news is, that StructureMap now compiles fine with some small patches (that Jeremy hopefully will include in the upcoming release).

Luckily, StructureMap is very well covered with unit tests, which makes testing it on Mono much easier. The state of affairs is, that most of the tests go green. I have about 70 failures within more then 600 tests and I’m pretty confident, that I can solve the remaining issues as well.

Tags , , ,

Posted in , | Posted on 21 Aug 2008 01:19by Tobi | no comments

VDR plug-in dependencies

In the past, when upgrading Debian VDR and VDR plug-in packages, it could happen, that one or more plug-ins were not updated (maybe because they haven’t been uploaded yet or haven’t migrated to testing). This could be problematic, because the new VDR might have a changed ABI (Application Binary Interface), causing any old plug-ins to be unloadable due to their ABI incompatibility. Such an ABI incompatibility could also happen, when the VDR package was built with any optional patches, but the plug-in wasn’t compiled against the patched VDR headers.

To avoid crashes with such incompatible plug-ins, the wrapper script that starts VDR checked at runtime, if a plug-in matches the “patchlevel” (a string identifier in a custom control field of the Debian package, listing the names of the applied optional patches) and if the plug-in was loadable at all. This check was pretty slow, because it relied on getting the pachtlevel information via dpkg, so we recently introduced some kind of caching, which made the VDR start up procedure even more complicated.

When this topic came up again recently with bug report #489914, I had the idea to replace the weak runtime compatibility test with install time dependency checks using Debians virtual package / “Provides” feature. It’s a pretty simple solution and I’m wondering, why I haven’t thought about this before.

This is how it works: The VDR-Package has a ”Provides: vdr-abi-1.6.0-debian” entry in it’s control file and the VDR plug-ins just have a dependency on ”vdr-abi-1.6.0-debian”. This way you can’t install a plug-in without having a compatible VDR installed and vice versa. Any changes in VDR’s ABI must be reflected in the virtual package name like ”vdr-abi-1.6.0-debian-1” when having added a patch to the Debian package or ”vdr-abi-1.6.1-debian” when a new upstream version introduces a new ABI.

Under the hood, there’s happening a little bit more. With the VDR header package vdr-dev, /usr/share/vdr-dev/abi-version will be installed, which contains the ABI version name used in the Provides-field. It also installs /usr/share/vdr-dev/dependencies.sh which plug-ins may use to create a ${vdr:Depends) substitution variable, that will hold the correct ABI version name. So everything a plug-in has to do, is to have a ”Depends: ${vdr:Depends)” in its control file and to to call dependencies.sh during the build process.

The ABI version name, that the VDR package will use, is specified in debian/abi-version and from there finds it’s way to the “Provides”-field in the control file via the ${vdr:Provides} substition variable. It’s the package maintainers responsibility to change the ABI version name with every ABI changes that might be introduced in a new package release. The C++ ABI compatibility is well documented by the KDE team in “Policies/Binary Compatibility Issues With C++”

As a small safety network, the VDR package will check at build-time, if any of the applied patches (debian/patches) has been modified, by keeping a list of MD5 sums of all patches in debian/.vdr-patches. If a patch changes, the build will break until the md5 sums are manually updated with debian/rules accept-patches. Before doing this, the package maintainer should check, if any of the changed patches may affect the ABI-version and in this case has to modify the ABI version name in debian/abi-version.

This mechanism also supports building VDR in different “patch flavours”. By setting the environment variable “PATCHVARIANT”, a different set of patches from debian/patches can be selected. e.g.;

PATCHVARIANT=multipatch dpkg-buildpackage -tc -uc -us -rfakeroot

This will use the patches listed in debian/patches/00list.multipatch and it will use debian/abi-version.multipatch and debian/.vdr-patches.multipatch. The ABI version of such a patch variant should differ from the “vanilla” ABI version and all other patch variants, e.g.; “vdr-abi-1.6.0-multipatch-2008-07-26”.

The patch variants included in the packages available at e-tobi.net are “multipatch” and “extensions”. The official Debian VDR package will only contain the “multipatch” variant (but only a vanilla VDR is available as binary packages in Debian!).

To build your own patch variant, you have to:

  1. copy debian/patches/00list (or 00list.extensions) to debian/patches.00list.mypatchvariant
  2. enable the patches you would like to use in debian/patches.00list.mypatchvariant by uncommenting/commenting them (keep in mind, that some patches depend on each other and therefore some combination might lead to rejects, that you have to resolve yourself)
  3. PATCHVARIANT=mypatchvariant debian/rules accept-patches
  4. PATCHVARIANT=mypatchvariant dpkg-buildpackage -tc -uc -us -rfakeroot
  5. install the new vdr-dev
  6. build ALL the plug-ins you would like to use

Tags , , ,

Posted in , | Posted on 27 Jul 2008 08:33by Tobi | no comments

VDR 1.5.14 packages are online now

As announced earlier I’ve updated the vdr-experimental repository with the VDR 1.5.14 packages.

The following plug-ins have been dropped due to lack of upstream support:

  • autotimeredit (Letzte Version von 11/2005)
  • console (Letzte Version von 09/2004)
  • mediamvp (Letzte Version von 04/2005)

The subtitles plug-in isn’t necessary anymore. DVB subtitles are now directly supported in VDR.

The following plug-ins don’t work at the moment:

  • channelscan
  • reelchannelscan

To use the pvr350 plug-in with Etch, you need to update the Kernel. The kernel packages available at backports.org will work.

All packages are available for the i386 and the amd64 architecture.

An update to VDR 1.5.14, which was released today, will follow soon.

Tobias

Posted in , | Posted on 17 Feb 2008 17:54by Tobi | no comments

Spring-cleaning the e-tobi.net Debian repository

There hasn’t been very much happening in the repository lately, so I decided to do some early spring-cleaning. The VDR 1.4.7-packages in the vdr-experimental repository seem to be pretty stable, so I will move the Etch packages from vdr-experimental to vdr-testing. In vdr-testing there will only be minor updates like important bug fixes in the future. So whoever is currently running happily on vdr-experimental / Etch, should update his sources.list to point to vdr-testing:

#
# e-Tobi's Testing Etch VDR Repository
#
deb http://e-tobi.net/vdr-testing etch base backports addons vdr-standard
#deb http://e-tobi.net/vdr-testing etch base backports addons vdr-multipatch
#deb http://e-tobi.net/vdr-testing etch base backports addons vdr-extensions

vdr-experimental will soon be updated to VDR 1.5.x / VDR 1.6. To stay up-to-date with the latest VDR and plug-in version, use this repository entry:

#
# e-Tobi's Experimental Etch VDR Repository
#
deb http://e-tobi.net/vdr-experimental etch base backports addons vdr-standard
#deb http://e-tobi.net/vdr-experimental etch base backports addons vdr-multipatch
#deb http://e-tobi.net/vdr-experimental etch base backports addons vdr-extensions

vdr-experimental also provides packages for Debian Sid:

#
# e-Tobi's Experimental Sid VDR Repository
#
deb http://e-tobi.net/vdr-experimental sid base backports addons vdr-standard
#deb http://e-tobi.net/vdr-experimental sid base backports addons vdr-multipatch
#deb http://e-tobi.net/vdr-experimental sid base backports addons vdr-extensions

The old Sarge packages (VDR 1.2.6, 1.4.4 and 1.4.6) are not maintained anymore, so I moved them to vdr-deprecated:

#
# e-Tobi's Old Sarge VDR Repository (will soon be dropped!)
#
deb http://e-tobi.net/vdr-deprecated/vdr-stable sarge base backports addons vdr-standard
#deb http://e-tobi.net/vdr-deprecated/vdr-stable sarge base backports addons vdr-multipatch
#deb http://e-tobi.net/vdr-deprecated/vdr-testing sarge base backports addons vdr-standard
#deb http://e-tobi.net/vdr-deprecated/vdr-testing sarge base backports addons vdr-multipatch
#deb http://e-tobi.net/vdr-deprecated/vdr-experimental sarge base backports addons vdr-standard
#deb http://e-tobi.net/vdr-deprecated/vdr-experimental sarge base backports addons vdr-multipatch

Posted in , | Posted on 05 Feb 2008 23:43by Tobi | 8 comments

VDR-Pakete mit Unterschrift

Unterschrift

Ab sofort sind die VDR-Pakete im e-tobi.net-Repository auch signiert. Damit die Signatur überprüft werden kann, müsst ihr meinen öffentlichen Schlüssel importieren:

gpg --keyserver hkp://wwwkeys.eu.pgp.net --recv-keys DB90D8FC306B6783
gpg --armor --export DB90D8FC306B6783 | apt-key add -

Der erste Befehl importiert den Schlüssel vom keyserver, der zweite teilt APT mit, dass dieser Key vertrauenswürdig ist.

Damit sollte die Meldung "WARNUNG: Die folgenden Pakete können nicht authentifiziert werden!" passé sein.

(Bild: aboutpixel.de © Petra Hager)

Tags , , , , , ,

Posted in , | Posted on 25 Mar 2007 23:27by Tobi | 2 comments