#!/usr/bin/perl
# Scott Harrison
# November 2000
# read in loncapa tags and metagroup tags
my ($file,$mode)=@ARGV;
open IN,"<$file";
my @lines=<IN>;
close IN;
my $info=join('',@lines);
my $info2=$info; # value to allow for meta data group retrieval
my %ihash; # big data storage object
while ($info=~/\<loncapa\s+(.*?)\>/isg) {
my $keystring=$1;
my %hash=map {my ($key,$value)=split(/\=(?!")|\=(?=\s*"[^"]*"[^"]*$)/); $value=~s/^"//; $value=~s/"$//;(uc($key),$value);} split(/\s+(?=\w+\s*\=)/,$keystring);
if (uc($hash{'TYPE'}) eq "OWNERSHIP") {
$info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHMOD'}=$hash{'CHMOD'};
$info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHOWN'}=$hash{'CHOWN'};
}
elsif (uc($hash{'TYPE'}) eq "DEVOWNERSHIP") {
$info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHMOD'}=$hash{'CHMOD'};
$info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHOWN'}=$hash{'CHOWN'};
}
elsif (uc($hash{'TYPE'}) eq "RPM") {
$hash{'VALUE'}=~s/\\n/\n/g;
$info{$hash{'TYPE'}}{$hash{'NAME'}}=$hash{'VALUE'};
}
elsif (uc($hash{'TYPE'}) eq "DIRECTORY") {
$info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'CATEGORY'}=$hash{'CATEGORY'};
$info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'DESCRIPTION'}=$hash{'DESCRIPTION'} if $hash{'DESCRIPTION'};
}
elsif (uc($hash{'TYPE'}) eq "LOCATION") {
$info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'CATEGORY'}=$hash{'CATEGORY'};
$info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'SOURCE'}=$hash{'SOURCE'};
# get surrounding metagroup information
my $ckeystring=$keystring; $ckeystring=~s/(SOURCE\=\"[^"]*)\*/$1\\\*/g;
$info2=~/.*\<(?:metagroup|metasupergroup)\>(.*?)\<loncapa\s+$ckeystring\>(.*?)\<\/(?:metagroup|metasupergroup)\>/is;
my $data=$1.$2;
my @meta=('description','build','dependencies','files','note');
foreach my $m (@meta) {
if ($data=~/\<($m)\>(.*?)\<\/$m\>/sgi) {
my ($key,$value)=($1,$2);
$info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{$key}=$value;
print "$key\n\n$value\n\n\n\n";
}
}
}
else {
warn("WARNING: this tag text will be ignored since it cannot be understood\n---> $keystring\n");
}
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>