[wpkg-users] Perl Modules for backend management

Nicholas Young nich at aurema.com
Wed Dec 7 06:46:17 CET 2005


In an attempt to write up some scripts to allow simple management of the
various XML files, I think the easiest way, for me, is to use perl.

At the moment the vague plan is
WPKG.pm
 -> WPKG::Hosts.pm
 -> WPKG::Packages.pm
 -> WPKG::Profiles.pm

The client management code, ie cgi page will call WPKG.pm which will
open the xml files using the other three modules. A skeleton of
WPKG::Profiles is included below for a brief idea of what I am thinking.
The client code will essentially run

$wpkg = new WPKG("Directory");
$wpkg->add_host("foobar", "custom");
$wpkg->add_profile_package("custom", "msoffice");

The modules then will do all the magic in ensuring that "msoffice"
exists and that "custom" is a valid profile-id.

Or direct addressing if required in:
$wpkg->{packages}->{wpkg1}->{name} = "Windows Packager sample 1";

The main aim is to make writing a web interface "easy" as it is all
calls against perl modules which should strip requirements for worrying
about concistency/XML formatting/...

Any problems, suggestions before I go further with writing this?

-- 
Nich

-- WPKG::Profiles
package WPKG::Profiles;

use 5.008005;
use strict;
use warnings;

require Exporter;

use XML::Simple;
use Carp;

our @ISA = qw(Exporter);

our %EXPORT_TAGS = ( 'all' => [ qw(

) ] );

our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );

our @EXPORT = qw(
);

our $VERSION = '1.00';

sub new
{
    my ($class) = shift;
    my $self = {};
    my $file = 'profiles.xml';

    my @argv = @_;
    if ( $#argv == 0 ) {
        $file = shift;
    }

    if ( ! -f $file || ! -r $file || ! -w $file) {
        croak("$class: File $file is not a valid file or cannot be
              read/written to");
    }

    my $x = XMLin($file);

    $self -> {profile} = $x;
    $self -> {file} = $file;

    bless($self, $class);
    return $self;
}

sub save
{
    my ($self) = shift;

    XMLout($self->{profile},
                 RootName => "profiles",
                 OutputFile => $self->{file}
                );
}

sub add_profile
{
    my ($self) = shift;
    my ($name) = shift;
}

sub rm_profile
{
    my ($self) = shift;
    my ($name) = shift;
}

sub add_depend
{
    my ($self) = shift;
    my ($name, $depend) = @_;
}

sub rm_depend
{
    my ($self) = shift;
    my ($name, $depend) = @_;
}

sub add_package
{
    my ($self) = shift;
    my ($name, $package) = @_;
}

sub rm_package
{
    my ($self) = shift;
    my ($name, $package) = @_;
}

1;



wpkg-users mailing list
wpkg-users at lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/wpkg-users




More information about the wpkg-users mailing list