| W:\dev\indigoperl\indigoperl/perl/site/lib/IPM_RM.pm |
sub parseppd { my ($PPDfile) = @_; # parse ppd file
my $osname;
if ($^O eq "MSWin32") {
$osname = "MSWin32";
}
else {
$osname = `uname`; chop $osname;
$osname = lc($osname);
$osname =~ s/-//;
$osname =~ s/\///;
}
my $ppddata = ($PPDfile =~ /^http:/) ? get($PPDfile) : ReadFile($PPDfile);
my ($package_name) = $ppddata =~ m/SOFTPKG NAME=\"(.*?)\"/i;
my ($package_version) = $ppddata =~ m/SOFTPKG NAME=\".*?\"\s+VERSION=\"(.*?)\"/i;
while($package_version =~ s/,0$//) { 1; }
$package_version =~ s/,/./g;
my $reltarfile;
foreach ($ppddata =~ m/<IMPLEMENTATION>(.*?)<\/IMPLEMENTATION>/sg) {
($reltarfile) = $_ =~ m/CODEBASE HREF=\"(.*?)\"/is if (m/OS NAME=\"$osname\"/);
}
if (!$reltarfile) {
print "ERROR: PPD does not contain an implementation section for OS=$osname\n";
return undef;
}
my $package_description = "$package_name-$package_version";
my $fulltarfile;
if (-f $reltarfile) { # ppd contain a full path
$fulltarfile = $reltarfile;
}
elsif ($reltarfile =~ /^http:/) {
$fulltarfile = $reltarfile; # ppd contains an abs URL
}
else {
my ($foo, $path) = fileparse($PPDfile);
$fulltarfile = "$path$reltarfile";
}
return ($fulltarfile, $package_version);
}
sub get_cached { my ($url, $cachedir) = @_;
my $local_file = $url;
$local_file =~ s%http://%%;
$local_file =~ s%/|\\|\?|:%_%g;
$local_file = "$cachedir/$local_file";
my $rc = mirror($url, $local_file);
#return is_success($rc) ? ReadFile($local_file) : undef;
return (-e $local_file) ? ReadFile($local_file) : undef;
}
| W:\dev\indigoperl\indigoperl/perl/site/lib/IPM_RM.pm |