Annotation of loncom/build/parse.pl, revision 1.2

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>