Over the last few months the new libraries for handling LCFG profiles have been shaping up nicely. They are finally reaching a point where they match up with my original aims so I thought I’d give a taste of how it all works. Here’s an example of processing an LCFG XML profile into the Berkeley DB and rpmcfg files required by the client:
use LCFG::Profile; my $xml = '/var/lcfg/conf/profile/xml/example.lcfg.org.xml'; my $dbm = '/tmp/example.lcfg.org.DB2.db'; my $dbm_ns = 'example'; my $rpmcfg = '/tmp/example.lcfg.org.rpmcfg'; my $new_profile = LCFG::Profile->new_from_xml($xml); my $update_dbm = 0; if ( -f $dbm ) { my $cur_profile = LCFG::Profile->new_from_bdb($dbm); my $diff = $cur_profile->diff($new_profile); if ( $diff->size > 0 ) { $update_dbm = 1; } } else { $update_dbm = 1; } if ( $update_dbm ) { $new_profile->to_bdb( $dbm, $dbm_ns ); say 'Updated DBM'; } my $pkgs_changed = $new_profile->to_rpmcfg($rpmcfg); if ( $pkgs_changed ) { say 'Updated packages'; }
This is basically what the LCFG client does whenever it processes a new profile but is a lot nicer than the current rdxprof code!