home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2000 May
/
Chip_2000-05_cd1.bin
/
zkuste
/
Perl
/
ActivePerl-5.6.0.613.msi
/
䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥
/
_77dafebc175a4a2f515756c827ab29dc
< prev
next >
Wrap
Text File
|
2000-03-23
|
3KB
|
108 lines
###############################################################################
#
# Script: configPPM.pl
# Author: Michael Smith
# Description: Setup 'ppm.xml' for first use by inserting path strings
# consistent with the installation we are performing.
#
# Copyright ⌐ 1999, ActiveState Tool Corp.
#
###############################################################################
BEGIN {
$tmp = $ENV{'TEMP'} || $ENV{'tmp'} ||
($Config{'osname'} eq 'MSWin32' ? 'c:/temp' : '/tmp');
open(STDERR, ">> $tmp/ActivePerlInstall.log");
}
use Config;
use XML::PPMConfig;
use XML::Parser;
my $ppmConfigFile = $ARGV[0];
my $srcDir = $ARGV[1];
my $oldConfig = $ARGV[2];
my $sitelib = $Config{'sitelib'};
my $perldir = $Config{'prefix'};
my $osname = $Config{'osname'};
my @ppmConfig;
my $osversion = join ",", (split (/\./, $Config{'osvers'}), (0) x 4) [0 .. 3];
print "Configuring PPM ...\n";
chmod($ppmConfigFile, '0600');
if(open(FILE, "+<$ppmConfigFile")) {
while(<FILE>) {
s/%SITELIB%/$sitelib/g;
s/%PERLDIR%/$perldir/g;
s/%SRCDIR%/$srcDir/g;
s/%OSNAME%/$osname/g;
s/%OSVERSION%/$osversion/g;
s/%TEMP%/$tmp/g;
push(@ppmConfig, $_);
}
seek(FILE, 0, 0);
truncate(FILE, 0);
foreach my $line (@ppmConfig) {
print FILE $line;
}
close(FILE);
sleep(1);
}
else {
print "$ppmConfigFile : $!\n";
print "Press [Enter] to continue\n";
<STDIN>;
}
if(-f $oldConfig) {
mergePPMConfig($oldConfig, $ppmConfigFile);
}
###############################################################################
#
###############################################################################
sub mergePPMConfig {
my $file1 = shift;
my $file2 = shift;
my $parser = new XML::Parser(Style => 'Objects', Pkg => 'XML::PPMConfig');
my $Config1 = $parser->parsefile($file1);
my $Config2 = $parser->parsefile($file2);
my $i = 0;
foreach my $elem (@{$Config1->[0]->{Kids}}) {
if((ref $elem) =~ /.*::PACKAGE$/) {
if (! existsInConfig('PACKAGE', $elem->{NAME}, $Config2)) {
splice(@{$Config2->[0]->{Kids}}, $i, 0, $elem);
}
}
++$i;
}
open(FILE, ">$file2")
|| return "Error: Could not open $file2 : $!";
select(FILE);
my $Config_ref = bless($Config2->[0], "XML::PPMConfig::PPMCONFIG");
$Config_ref->output();
close(FILE);
return;
}
###############################################################################
#
###############################################################################
sub existsInConfig {
my $element = shift;
my $name = shift;
my $config = shift;
foreach my $elem (@{$config->[0]->{Kids}}) {
return 1
if ((ref $elem) =~ /.*::$element$/ && $elem->{NAME} eq $name);
}
return 0;
}