More parsing

March 19, 2008

After lots of hacking last night I now have a working grammar that generates a useful data structure representing an LCFG schema. For details see the links from yesterday, they point to the latest versions of the script, grammar and output. As well as the work done by the grammar the conversion script modifies the structure in various ways. It lifts tag resources into their taglists so that we can have a proper OO view and it tidies the tree to remove inherited resources which have not been mutated.

I still have some problems, mostly these are related to the odd way in which taglists work with regards to tags and how they can be generated using placeholders. Note the ng_logrotate_truncate resource in the top-level of the parser output. It is actually a specific attribute of the ng_logrotate taglist. It has not been lifted to the right-level so I will need to add some magic to spot these specific entries and move them accordingly.


Parsing Schemas

March 18, 2008

For a while now I’ve been playing with the idea of parsing the LCFG schemas and converting them to a proper object-orientated representation using Moose. The first attempt was rapidly getting out of control so I decided to start again.

The legendary Damian Conway wrote a Perl module for text parsing named Parse::RecDescent, it’s been around a long time but it has never been surpassed. The big advantage here is that the module can be fed a yacc-like grammar but the results can be manipulated with all the power of Perl. The script for my second attempt is noticably smaller, it doesn’t yet do everything that the first script does but the principal code is done. It still needs to store the resulting parse tree and then push it through Template Toolkit rather than just run a load of print statements. All the power is now in the grammar, I don’t claim to be great at writing grammars so this is probably a lot more messy than it could be but it does work. As a simple example, I have parsed the schema for gdm, the output shows what the script has discovered.

This took a few hours of work, mainly this involved getting my head around Parse::RecDescent but it is already much more capable than my previous attempt.


UKUUG Talk

March 17, 2008

I will be talking at the UKUUG Spring Conference in Birmingham. For those interested my slides are available at www.lcfg.org/doc/sysconfig_ukuug_2008.pdf, they are not yet linked from the site, that will happen after the talk. The title is “System Configuration: An end to hacky scripts?“. I’ve tried to make the title mildly provocative to draw out a few more people and given that I am up against “Excel on the Commandline” I hope that means I get a good attendance. It’s on the morning of April 1st so I am in search of a good joke to embed.


Successful projects

March 5, 2008

I’ve recently become aware that Pragmatic Programmers do an excellent set of books on how to run a successful project. Particularly:

I first came across these guys about 10 years ago when they brought out the Pragmatic Programmer book. It’s a superb book which everyone who writes code should read, it became an instant must-have class and it has been widely recognised as a book which really changed how people think about programming.


Moose on SL5

March 3, 2008

I’ve been working through packaging the Moose perl module and its dependencies for SL5. This has now been done and you can now use an LCFG header (currently “develop” only) to include the packages like this:

#include <lcfg/options/perl-moose.h>

I will add the modules for FC6 in next. All the packages which weren’t provided in epel have been built locally and put into the new “world” bucket.

To get the new release tools on the SL5 machine as well you will need this:

!profile.packages    mEXTRA(perl-Data-Structure-Util-0.12-1.inf \
                                              perl-YAML-Syck-0.98-1.el5\
                                              perl-UNIVERSAL-require-0.11-1.el5/noarch\
                                              perl-LCFG-Build-PkgSpec-0.0.5-1/noarch\
                                              perl-LCFG-Build-VCS-0.0.5-1/noarch)