AIX-LPP
view release on metacpan or search on metacpan
LPP/lpp_name.pm view on Meta::CPAN
} while ($line = <$fh>); }
return $self;
}
sub write {
my $self = shift;
my $fh = shift;
print $fh join ' ', $self->{FORMAT}, $self->{PLATFORM}, $self->{TYPE},
$self->{NAME}, "{\n";
foreach my $fileset (keys %{$self->{FILESET}} ) {
print $fh join ' ', $self->{FILESET}{$fileset}{NAME},
$self->{FILESET}{$fileset}{VRMF},
$self->{FILESET}{$fileset}{DISK},
$self->{FILESET}{$fileset}{BOSBOOT},
$self->{FILESET}{$fileset}{CONTENT},
$self->{FILESET}{$fileset}{LANG},
$self->{FILESET}{$fileset}{DESCRIPTION}, "\n[\n";
for my $i ( 0 .. $#{$self->{FILESET}{$fileset}{REQ}} ) {
print $fh join ' ',@{${$self->{FILESET}{$fileset}{REQ}}[$i]},"\n";
}
print $fh "%\n";
foreach my $key (sort keys %{$self->{FILESET}{$fileset}{SIZEINFO}}) {
print $fh join ' ', $key,
$self->{FILESET}{$fileset}{SIZEINFO}{$key}, "\n";
}
print $fh "%\n%\n%\n%\n]\n";
}
print $fh "}";
}
1;
__END__
=head1 NAME
AIX::LPP::lpp_name - Perl module for manipulation of an AIX lpp_name file
=head1 SYNOPSIS
scripts/mkcontrol view on Meta::CPAN
# (note: only creates limited 'control' file)
#
# usage: mkcontrol < lpp_name > control
use AIX::LPP::lpp_name;
# change this to use stdin/stdout
$package = AIX::LPP::lpp_name->read(\*STDIN);
# instead of calling write(), find the data we want and print it to stdout
my ($name,$version,$type,$four,$fs) = $package->lpp();
my ($fsname,$vrmf,$disk,$bboot,$cntnt,$lang,$desc,$cmnt) =
$package->fileset($fs);
print 'NAME=',"$fsname\n";
print 'VERSION=',"$vrmf\n";
print 'DESCRIPTION=',"$desc\n";
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'
######################### We start with some black magic to print on failure.
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
BEGIN { $| = 1; print "1..1\n"; }
END {print "not ok 1\n" unless $loaded;}
use AIX::LPP::lpp_name;
$loaded = 1;
print "ok 1\n";
######################### End of black magic.
# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
use AIX::LPP::lpp_name;
print "1..8\n";
$package = AIX::LPP::lpp_name->new(NAME => 'test.lpp',TYPE => 'I',
PLATFORM => 'R',FORMAT => '4');
print "ok 1\n";
$package->fileset('test.lpp.rte',VRMF => '1.0.0.0',DISK => '01',BOSBOOT => 'N',
CONTENT => 'I',LANG => 'en_US',DESCRIPTION => 'test.lpp description',
COMMENTS => '');
print "ok 2\n";
$package->fileset('test.lpp.adt');
print "ok 3\n";
my @reqs = [ ['*prereq','bos.rte','4.3.3.0'] ];
$package->requisites('test.lpp.adt', \@reqs);
print "ok 4\n";
$package->sizeinfo('test.lpp.adt');
print "ok 5\n";
$package->lpp(FORMAT => 5) && print "ok 6\n";
$package->lpp() && print "ok 7\n";
$package->{FORMAT} && print "ok 8\n";
use AIX::LPP::lpp_name;
print "1..1\n";
open(LPP_NAME,">data/lpp_test.2") or die "Can't open file lpp_name: $!";
$package = AIX::LPP::lpp_name->new(NAME => 'test.lpp',TYPE => 'I',
FORMAT => '4', PLATFORM => 'R');
$package->fileset('test.lpp.rte', VRMF => '01.01.0000.0000',DISK => '01',
BOSBOOT => 'N',CONTENT => 'U', LANG => 'en_US',
DESCRIPTION => 'test package description' );
# $package->requisites();
# $package->sizeinfo();
$package->write(\*LPP_NAME);
print "ok 1\n";
use AIX::LPP::lpp_name;
print "1..1\n";
open(INLPP,"<data/lpp_name") or die "Can't open file lpp_name: $!";
open(OUTLPP,">data/lpp_test.3") or die "Can't open file lpp_name: $!";
$package = AIX::LPP::lpp_name->read(\*INLPP);
$package->write(\*OUTLPP);
print "ok 1\n";
( run in 0.514 second using v1.01-cache-2.11-cpan-de7293f3b23 )