Annotation of loncom/build/parse.pl, revision 1.1
1.1 ! harris41 1: #!/usr/bin/perl
! 2:
! 3: # Scott Harrison
! 4: # November 2000
! 5:
! 6: # read in loncapa tags and metagroup tags
! 7:
! 8: my ($file,$mode)=@ARGV;
! 9: open IN,"<$file";
! 10: my @lines=<IN>;
! 11: close IN;
! 12: my $info=join('',@lines);
! 13: my $info2=$info; # value to allow for meta data group retrieval
! 14:
! 15: my %ihash; # big data storage object
! 16: while ($info=~/\<loncapa\s+(.*?)\>/isg) {
! 17: my $keystring=$1;
! 18: my %hash=map {my ($key,$value)=split(/\=(?!")|\=(?=\s*"[^"]*"[^"]*$)/); $value=~s/^"//; $value=~s/"$//;(uc($key),$value);} split(/\s+(?=\w+\s*\=)/,$keystring);
! 19: if (uc($hash{'TYPE'}) eq "OWNERSHIP") {
! 20: $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHMOD'}=$hash{'CHMOD'};
! 21: $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHOWN'}=$hash{'CHOWN'};
! 22: }
! 23: elsif (uc($hash{'TYPE'}) eq "DEVOWNERSHIP") {
! 24: $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHMOD'}=$hash{'CHMOD'};
! 25: $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHOWN'}=$hash{'CHOWN'};
! 26: }
! 27: elsif (uc($hash{'TYPE'}) eq "RPM") {
! 28: $hash{'VALUE'}=~s/\\n/\n/g;
! 29: $info{$hash{'TYPE'}}{$hash{'NAME'}}=$hash{'VALUE'};
! 30: }
! 31: elsif (uc($hash{'TYPE'}) eq "DIRECTORY") {
! 32: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'CATEGORY'}=$hash{'CATEGORY'};
! 33: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'DESCRIPTION'}=$hash{'DESCRIPTION'} if $hash{'DESCRIPTION'};
! 34: }
! 35: elsif (uc($hash{'TYPE'}) eq "LOCATION") {
! 36: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'CATEGORY'}=$hash{'CATEGORY'};
! 37: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'SOURCE'}=$hash{'SOURCE'};
! 38: # get surrounding metagroup information
! 39: my $ckeystring=$keystring; $ckeystring=~s/(SOURCE\=\"[^"]*)\*/$1\\\*/g;
! 40: $info2=~/.*\<(?:metagroup|metasupergroup)\>(.*?)\<loncapa\s+$ckeystring\>(.*?)\<\/(?:metagroup|metasupergroup)\>/is;
! 41: my $data=$1.$2;
! 42: my @meta=('description','build','dependencies','files','note');
! 43: foreach my $m (@meta) {
! 44: if ($data=~/\<($m)\>(.*?)\<\/$m\>/sgi) {
! 45: my ($key,$value)=($1,$2);
! 46: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{$key}=$value;
! 47: print "$key\n\n$value\n\n\n\n";
! 48: }
! 49: }
! 50: }
! 51: else {
! 52: warn("WARNING: this tag text will be ignored since it cannot be understood\n---> $keystring\n");
! 53: }
! 54: }
! 55:
! 56:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>