File:  [LON-CAPA] / loncom / build / Attic / parse.pl
Revision 1.16: download - view: text, annotated - select for diffs
Thu Dec 14 17:39:57 2000 UTC (23 years, 6 months ago) by harris41
Branches: MAIN
CVS tags: HEAD
implementing the ability to install new configuration files while
making time-stamped backups -Scott

    1: #!/usr/bin/perl
    2: 
    3: # Scott Harrison
    4: # November 2000
    5: 
    6: # Read in loncapa tags and metagroup tags
    7: 
    8: # ---------------------------------------------- Read in command line arguments
    9: my ($file,$mode)=@ARGV;
   10: 
   11: # ---------------------------------------------------- Read in master data file
   12: open IN,"<$file";
   13: my @lines=<IN>;
   14: close IN;
   15: my $info1=join('',@lines);
   16: my $info2=$info1; # value to allow for meta data group retrieval
   17: 
   18: # ------------------------------------------------------- Make default settings
   19: my $distribution="redhat6.2";
   20: my $date=`date +'%B %e, %Y'`; chop $date;
   21: my $buildhost=`hostname`; chop $buildhost;
   22: # file category mappings
   23: my %fcm=(
   24: 	 'conf' => 'configurable',
   25: 	 'graphic file' => 'graphicfile',
   26: 	 'handler' => 'handler',
   27: 	 'interface file' => 'interfacefile',
   28: 	 'symbolic link' => 'link',
   29: 	 'root script' => 'rootscript',
   30: 	 'script' => 'script',
   31: 	 'setuid script' => 'setuid',
   32: 	 'static conf' => 'static',
   33: 	 'system file' => 'systemfile',
   34: 	 );
   35: 
   36: # ---------------------------------------------------- Parse the marked up data
   37: my %info; # big data storage object
   38: while ($info1=~/\<loncapa\s+(.*?)\>/isg) {
   39:     my $keystring=$1;
   40:     # In the parsing of LON-CAPA tags, remove boundary white-space,
   41:     # and handle quotation commands.
   42:     my %hash=map {my ($key,$value)=split(/\=(?!")|\=(?=\s*"[^"]*"[^"]*$)/);
   43:                                    $value=~s/^"//;
   44:  				   $value=~s/"$//;
   45:                                    (uc($key),$value);}
   46:              split(/\s+(?=\w+\s*\=)/,$keystring);
   47:     # Handle the different types of commands
   48:     if (uc($hash{'TYPE'}) eq "OWNERSHIP") {
   49:         $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHMOD'}=$hash{'CHMOD'};
   50:         $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHOWN'}=$hash{'CHOWN'};
   51:     }
   52:     elsif (uc($hash{'TYPE'}) eq "DEVOWNERSHIP") {
   53:         $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHMOD'}=$hash{'CHMOD'};
   54:         $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHOWN'}=$hash{'CHOWN'};
   55:     }
   56:     elsif (uc($hash{'TYPE'}) eq "RPM") {
   57:         $hash{'VALUE'}=~s/\\n/\n/g;
   58:         $info{$hash{'TYPE'}}{$hash{'NAME'}}=$hash{'VALUE'};
   59:     }
   60:     elsif (uc($hash{'TYPE'}) eq "DIRECTORY") {
   61:         $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'CATEGORY'}=
   62:                                                        $hash{'CATEGORY'};
   63:         $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'DESCRIPTION'}=
   64:                                $hash{'DESCRIPTION'} if $hash{'DESCRIPTION'};
   65:     }
   66:     elsif (uc($hash{'TYPE'}) eq "LOCATION") {
   67:         $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'CATEGORY'}=                               $hash{'CATEGORY'};
   68:         $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'LINKTO'}=                               $hash{'LINKTO'};
   69:         $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'SOURCE'}=                                               $hash{'SOURCE'};
   70:         # get surrounding metagroup information
   71:         my $ckeystring=$keystring; $ckeystring=~s/(SOURCE\=\"[^"]*)\*/$1\\\*/g;
   72:         $ckeystring=~s/(TARGET\=\"[^"]*)\*/$1\\\*/g;
   73:         $info2=~/.*\<(?:metagroup|metasupergroup)\>(.*?)\<loncapa\s+$ckeystring\>(.*?)\<\/(?:metagroup|metasupergroup)\>/is;
   74: 	my $data=$1.$2;
   75:         my @meta=('description','build','dependencies','files','note');
   76:         foreach my $m (@meta) {
   77: 	    if ($data=~/\<($m)\>(.*?)\<\/$m\>/sgi) {
   78: 		my ($key,$value)=($1,$2);
   79: 		$info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{uc($key)}=
   80: 		                                                    $value;
   81: 	    }
   82:         }
   83:     }
   84:     else {
   85:         warn("WARNING: this tag text will be ignored since it cannot be understood\n---> $keystring\n");
   86:     }
   87: }
   88: 
   89: my $a;
   90: my @directories;
   91: if ($mode eq "HTML") {
   92:     $a=&begin_description_page;
   93:     print $a;
   94:     $a=&make_rpm_description_block;
   95:     print $a;
   96:     @directories=&determine_directory_structure;
   97:     $a=&make_directory_structure_description_block(\@directories);
   98:     print $a;
   99:     $a=&make_file_type_ownership_and_permissions_description_block;
  100:     print $a;
  101:     $a=&make_directory_and_file_structure_description_block(\@directories);
  102:     print $a;
  103:     $a=&end_description_page;
  104:     print $a;
  105: }
  106: elsif ($mode eq "SPEC") {
  107:     my $out=$info{'RPM'}{'Name'} . '-' . $info{'RPM'}{'Version'} . '.spec';
  108:     open OUT,">$out";
  109:     $a=&make_rpm_spec_block;
  110:     print OUT $a;
  111:     $a=&make_rpm_build_block;
  112:     print OUT $a;
  113:     @directories=&determine_directory_structure;
  114:     $a=&make_directory_structure_spec_block(\@directories);
  115:     print OUT $a;
  116:     $a=&make_directory_and_file_structure_spec_block(\@directories);
  117:     print OUT $a;
  118:     $a=&end_spec_page;
  119:     print OUT $a;
  120:     close OUT;
  121: }
  122: elsif ($mode eq "LCMakefile") {
  123:     @directories=&determine_directory_structure;
  124:     $a=&make_directory_LCMakefile_segment(\@directories);
  125:     print $a;
  126:     $a=&make_files_LCMakefile_segment(\@directories);
  127:     print $a;
  128:     $a=&make_links_LCMakefile_segment(\@directories);
  129:     print $a;
  130: }
  131: elsif ($mode eq "BinaryRoot") {
  132:     mkdir "BinaryRoot",0755;
  133:     open OUT,">Makefile.BinaryRoot";
  134:     @directories=&determine_directory_structure;
  135:     $a=&make_directory_binaryroot_segment(\@directories);
  136:     print OUT $a;
  137:     $a=&make_files_binaryroot_segment(\@directories);
  138:     print OUT $a;
  139:     $a=&make_links_binaryroot_segment(\@directories);
  140:     print OUT $a;
  141:     close OUT;
  142:     print `make -f Makefile.BinaryRoot TARGET='BinaryRoot' SOURCE='../..' directories`;
  143:     print `make -f Makefile.BinaryRoot TARGET='BinaryRoot' SOURCE='../..' files`;
  144:     print `make -f Makefile.BinaryRoot TARGET='BinaryRoot' SOURCE='../..' links`;
  145:     open OUT,">base_file_list.txt";
  146:     $a=&make_file_list(\@directories);
  147:     print OUT $a;
  148:     close OUT;
  149:     
  150: }
  151: elsif ($mode eq "status") {
  152: }
  153: elsif ($mode eq "update") {
  154: }
  155: elsif ($mode eq "configinstall") {
  156:     @directories=&determine_directory_structure;
  157:     $a=&make_files_configinstall_segment(\@directories);
  158:     print $a;
  159: }
  160: elsif ($mode eq "install") {
  161:     @directories=&determine_directory_structure;
  162:     $a=&make_directory_install_segment(\@directories);
  163:     print $a;
  164:     $a=&make_files_install_segment(\@directories);
  165:     print $a;
  166:     $a=&make_links_install_segment(\@directories);
  167:     print $a;
  168: }
  169: elsif ($mode eq "build") {
  170:     @directories=&determine_directory_structure;
  171:     $a=&make_files_build_segment(\@directories);
  172:     print $a;
  173: }
  174: 
  175: # ------------------------------------------------------ a list of file targets
  176: sub make_file_list {
  177:     my ($dirs)=@_;
  178:     my $description;
  179:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
  180:     foreach my $d (@$dirs) {
  181: 	# set other values
  182: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
  183: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
  184: 	# find files that are contained in this directory
  185: 	my @files;
  186: 	my @filesfull;
  187: 	foreach my $f (@allfiles) {
  188: 	    if ($f=~/^$d\/([^\/]+)$/) {
  189: 		push @files,$1;
  190: 		push @filesfull,$f;
  191: 	    }
  192: 	}
  193: 	# render starting HTML formatting elements
  194: 	if (@files) {
  195:         }
  196: 	my $pwd=`pwd`; chop $pwd;
  197: 	if (@files) {
  198:             foreach my $i (0..$#files) {
  199: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
  200: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
  201: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
  202: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
  203: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
  204: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
  205: 		my $rot="/".$filesfull[$i];
  206: 		if ($rot=~/\*/) {
  207: 		    $rot=~s/[^\/]+$// if $rot=~/\*/;
  208: 		    my $listing=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
  209: 		    chop $listing;
  210: 		    my @list=split(/\s+/,$listing);
  211: 		    my $rot2;
  212: 		    foreach my $l (@list) {
  213: 			$l=~s/^\s*//; $l=~s/\s*$//;
  214: 			$rot2.="BinaryRoot$rot$l\n" if length($l);
  215: 		    }
  216: 		    chop $rot2;
  217: 		    $rot=$rot2;
  218: 		}
  219: 		else {
  220: 		    $rot="BinaryRoot$rot";
  221: 		}
  222: 		if ($category eq "conf") {
  223: 		    $rot.=" # config";
  224: 		}
  225: 		$description.=<<END;
  226: $rot
  227: END
  228: 	    }
  229: 	}
  230:     }
  231:     $description.=<<END;
  232: 
  233: END
  234:     return $description;
  235: }
  236: 
  237: # --------------------------------- Commands to make BinaryRoot directories
  238: sub make_directory_binaryroot_segment {
  239:     my ($dirs)=@_;
  240:     my $description=<<END;
  241: directories:
  242: END
  243:     foreach my $d (@$dirs) {
  244: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
  245: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
  246: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
  247: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
  248: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
  249: 	my $own=$devchown; $own=~s/\:/\,/;
  250: 	$description.=<<END;
  251: \tinstall -m $devchmod -d \$(TARGET)/$d
  252: END
  253:     }
  254:     $description.=<<END;
  255: 
  256: END
  257:     return $description;
  258: }
  259: 
  260: # --------------------------------------- Commands to make BinaryRoot files
  261: sub make_files_binaryroot_segment {
  262:     my ($dirs)=@_;
  263:     my $description=<<END;
  264: files:
  265: END
  266:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
  267:     foreach my $d (@$dirs) {
  268: 	# set other values
  269: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
  270: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
  271: 	# find files that are contained in this directory
  272: 	my @files;
  273: 	my @filesfull;
  274: 	foreach my $f (@allfiles) {
  275: 	    if ($f=~/^$d\/([^\/]+)$/) {
  276: 		push @files,$1;
  277: 		push @filesfull,$f;
  278: 	    }
  279: 	}
  280: 	# render starting HTML formatting elements
  281: 	if (@files) {
  282: 	    $description.=<<END;
  283: \t# $d $dirdescription
  284: END
  285:         }
  286: 	if (@files) {
  287:             foreach my $i (0..$#files) {
  288: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
  289: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
  290: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
  291: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
  292: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
  293: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
  294: 		my $rot=$filesfull[$i];
  295: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
  296: 		$description.=<<END if $category ne 'symbolic link';
  297: \tinstall -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
  298: END
  299: 	    }
  300: 	}
  301:     }
  302:     $description.=<<END;
  303: 
  304: END
  305:     return $description;
  306: }
  307: 
  308: # ------------------------------ Commands to make BinaryRoot symbolic links
  309: sub make_links_binaryroot_segment {
  310:     my ($dirs)=@_;
  311:     my $description=<<END;
  312: links:
  313: END
  314:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
  315:     foreach my $d (@$dirs) {
  316: 	# find files that are contained in this directory
  317: 	my @files;
  318: 	my @filesfull;
  319: 	foreach my $f (@allfiles) {
  320: 	    if ($f=~/^$d\/([^\/]+)$/) {
  321: 		push @files,$1;
  322: 		push @filesfull,$f;
  323: 	    }
  324: 	}
  325: 	# render starting HTML formatting elements
  326: 	if (@files) {
  327:             foreach my $i (0..$#files) {
  328: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
  329: 		my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
  330: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
  331: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
  332: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
  333: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
  334: 		$description.=<<END if $category eq 'symbolic link';
  335: \tln -s /$linkto \$(TARGET)/$filesfull[$i]
  336: END
  337: 	    }
  338: 	}
  339:     }
  340:     $description.=<<END;
  341: 
  342: END
  343:     return $description;
  344: }
  345: 
  346: # ------ Installation commands for a Makefile used only by a rpm -ba invocation
  347: sub make_directory_LCMakefile_segment {
  348:     my ($dirs)=@_;
  349:     my $description=<<END;
  350: directories:
  351: END
  352:     foreach my $d (@$dirs) {
  353: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
  354: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
  355: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
  356: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
  357: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
  358: 	my $own=$devchown; $own=~s/\:/\,/;
  359: 	$description.=<<END;
  360: \tinstall -m $devchmod -d \$(SOURCE)/$d \$(ROOT)/$d
  361: END
  362:     }
  363:     $description.=<<END;
  364: 
  365: END
  366:     return $description;
  367: }
  368: 
  369: # ------ Installation commands for a Makefile used only by a rpm -ba invocation
  370: sub make_files_LCMakefile_segment {
  371:     my ($dirs)=@_;
  372:     my $description=<<END;
  373: files:
  374: END
  375:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
  376:     foreach my $d (@$dirs) {
  377: 	# set other values
  378: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
  379: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
  380: 	# find files that are contained in this directory
  381: 	my @files;
  382: 	my @filesfull;
  383: 	foreach my $f (@allfiles) {
  384: 	    if ($f=~/^$d\/([^\/]+)$/) {
  385: 		push @files,$1;
  386: 		push @filesfull,$f;
  387: 	    }
  388: 	}
  389: 	# render starting HTML formatting elements
  390: 	if (@files) {
  391: 	    $description.=<<END;
  392: \t# $d $dirdescription
  393: END
  394:         }
  395: 	if (@files) {
  396:             foreach my $i (0..$#files) {
  397: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
  398: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
  399: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
  400: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
  401: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
  402: 		my $rot=$filesfull[$i];
  403: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
  404: 		$description.=<<END if $category ne 'symbolic link';
  405: \tinstall -m $devchmod \$(SOURCE)/$filesfull[$i] \$(ROOT)/$rot
  406: END
  407: 	    }
  408: 	}
  409:     }
  410:     $description.=<<END;
  411: 
  412: END
  413:     return $description;
  414: }
  415: 
  416: # ------ Installation commands for a Makefile used only by a rpm -ba invocation
  417: sub make_links_LCMakefile_segment {
  418:     my ($dirs)=@_;
  419:     my $description=<<END;
  420: links:
  421: END
  422:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
  423:     foreach my $d (@$dirs) {
  424: 	# find files that are contained in this directory
  425: 	my @files;
  426: 	my @filesfull;
  427: 	foreach my $f (@allfiles) {
  428: 	    if ($f=~/^$d\/([^\/]+)$/) {
  429: 		push @files,$1;
  430: 		push @filesfull,$f;
  431: 	    }
  432: 	}
  433: 	# render starting HTML formatting elements
  434: 	if (@files) {
  435:             foreach my $i (0..$#files) {
  436: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
  437: 		my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
  438: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
  439: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
  440: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
  441: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
  442: 		$description.=<<END if $category eq 'symbolic link';
  443: \tln -s /$linkto \$(ROOT)/$filesfull[$i]
  444: END
  445: 	    }
  446: 	}
  447:     }
  448:     $description.=<<END;
  449: 
  450: END
  451:     return $description;
  452: }
  453: 
  454: # --------------------------------- Installation commands to install directories
  455: sub make_directory_install_segment {
  456:     my ($dirs)=@_;
  457:     my $description=<<END;
  458: directories:
  459: END
  460:     foreach my $d (@$dirs) {
  461: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
  462: 	my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
  463: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
  464: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
  465: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
  466: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
  467: 	my ($owner,$group)=split(/\:/,$devchown);
  468: 	my $own=$devchown; $own=~s/\:/\,/;
  469: 	$description.=<<END;
  470: \tinstall -o $owner -g $group -m $devchmod -d \$(TARGET)/$d
  471: END
  472:     }
  473:     $description.=<<END;
  474: 
  475: END
  476:     return $description;
  477: }
  478: 
  479: # ------------------------------------------------------ Commands to build files
  480: sub make_files_build_segment {
  481:     my ($dirs)=@_;
  482:     my $description;
  483:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
  484:     my $tab="\t";
  485:     my $sources="all: ";
  486:     foreach my $d (@$dirs) {
  487: 	# set other values
  488: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
  489: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
  490: 	# find files that are contained in this directory
  491: 	my @files;
  492: 	my @filesfull;
  493: 	foreach my $f (@allfiles) {
  494: 	    if ($f=~/^$d\/([^\/]+)$/) {
  495: 		push @files,$1;
  496: 		push @filesfull,$f;
  497: 	    }
  498: 	}
  499: 	if (@files) {
  500:             foreach my $i (0..$#files) {
  501: 		# if has build information, output appropriate something
  502: 		my $build=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'BUILD'};
  503: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
  504: 		$build=~s/^\s+//; $build=~s/\s+$//;
  505: 		if ($build) {
  506: 		    my $dependencies=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DEPENDENCIES'};
  507: 		    my $source2=$source;
  508: 		    $source2=~s/^[^\/]+\///;
  509:  		    $source2="../" . $source2;
  510: 		    $sources.="$source2 ";
  511: 		    my $directory=$build;
  512: 		    $directory=~s/^[^\/]+\///;
  513: 		    $directory=~s/([^\/]+)$//;
  514:  		    $directory="../" . $directory;
  515: 		    my $buildfile=$1;
  516: 		    my $sdir=$source;
  517: 		    $sdir=~s/^[^\/]+\///;
  518: 		    $sdir=~s/([^\/]+)$//;
  519:  		    $sdir="../" . $sdir;
  520: 		    $dependencies=~s/\s+$//;
  521: 		    my $depstat="";
  522: 		    if ($dependencies=~s/\s+\[ALWAYS_RUN_BUILD_COMMAND\]//) {
  523: 			$depstat=" alwaysrun";
  524: 		    }
  525: 		    $dependencies=~s/\s+/ $sdir/gs;
  526: 		    $description.=<<END;
  527: $source2: $dependencies$depstat
  528: ${tab}cd $directory; sh ./$buildfile
  529: 
  530: END
  531: 		}
  532: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
  533: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
  534: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
  535: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
  536: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
  537: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
  538: 		my $rot=$filesfull[$i];
  539: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
  540: #		$description.=<<END if $category ne 'symbolic link';
  541: #\tinstall -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
  542: #END
  543: 	    }
  544: 	}
  545:     }
  546:     $description.=<<END;
  547: alwaysrun:
  548: 
  549: END
  550:     $sources.="\n\n";
  551:     return ($sources . $description);
  552: }
  553: 
  554: # --------------------------------------- Installation commands to install files
  555: sub make_files_install_segment {
  556:     my ($dirs)=@_;
  557:     my $description=<<END;
  558: files:
  559: END
  560:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
  561:     foreach my $d (@$dirs) {
  562: 	# set other values
  563: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
  564: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
  565: 	# find files that are contained in this directory
  566: 	my @files;
  567: 	my @filesfull;
  568: 	foreach my $f (@allfiles) {
  569: 	    if ($f=~/^$d\/([^\/]+)$/) {
  570: 		push @files,$1;
  571: 		push @filesfull,$f;
  572: 	    }
  573: 	}
  574: 	# render starting HTML formatting elements
  575: 	if (@files) {
  576: 	    $description.=<<END;
  577: \t# $d $dirdescription
  578: END
  579:         }
  580: 	if (@files) {
  581:             foreach my $i (0..$#files) {
  582: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
  583: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
  584: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
  585: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
  586: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
  587: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
  588: 		my $rot=$filesfull[$i];
  589: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
  590: 		my ($owner,$group)=split(/\:/,$devchown);
  591: 		if ($category ne 'conf') {
  592: 		    $description.=<<END if $category ne 'symbolic link';
  593: \tinstall -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
  594: END
  595:                 }
  596: 	    }
  597: 	}
  598:     }
  599:     $description.=<<END;
  600: 
  601: END
  602:     return $description;
  603: }
  604: 
  605: # ------ Installation commands to install configuration files (and make backups)
  606: sub make_files_configinstall_segment {
  607:     my ($dirs)=@_;
  608:     my $description=<<END;
  609: configfiles:
  610: END
  611:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
  612:     foreach my $d (@$dirs) {
  613: 	# set other values
  614: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
  615: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
  616: 	# find files that are contained in this directory
  617: 	my @files;
  618: 	my @filesfull;
  619: 	foreach my $f (@allfiles) {
  620: 	    if ($f=~/^$d\/([^\/]+)$/) {
  621: 		push @files,$1;
  622: 		push @filesfull,$f;
  623: 	    }
  624: 	}
  625: 	# render starting HTML formatting elements
  626: 	if (@files) {
  627: 	    $description.=<<END;
  628: \t# $d $dirdescription
  629: END
  630:         }
  631: 	if (@files) {
  632:             foreach my $i (0..$#files) {
  633: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
  634: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
  635: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
  636: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
  637: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
  638: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
  639: 		my $rot=$filesfull[$i];
  640: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
  641: 		my ($owner,$group)=split(/\:/,$devchown);
  642: 		if ($category eq 'conf') {
  643: 		    $description.=<<END;
  644: \tinstall -b -S `date +'.\%Y\%m\%d\%H\%M\%S'` -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
  645: END
  646:                 }
  647: 	    }
  648: 	}
  649:     }
  650:     $description.=<<END;
  651: 
  652: END
  653:     return $description;
  654: }
  655: 
  656: # ------------------------------ Installation commands to install symbolic links
  657: sub make_links_install_segment {
  658:     my ($dirs)=@_;
  659:     my $description=<<END;
  660: links:
  661: END
  662:     chop $description;
  663:     my $description2;
  664:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
  665:     foreach my $d (@$dirs) {
  666: 	# find files that are contained in this directory
  667: 	my @files;
  668: 	my @filesfull;
  669: 	foreach my $f (@allfiles) {
  670: 	    if ($f=~/^$d\/([^\/]+)$/) {
  671: 		push @files,$1;
  672: 		push @filesfull,$f;
  673: 	    }
  674: 	}
  675: 	# render starting HTML formatting elements
  676: 	if (@files) {
  677:             foreach my $i (0..$#files) {
  678: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
  679: 		my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
  680: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
  681: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
  682: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
  683: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
  684: 		if ($category eq 'symbolic link') {
  685: 		    $description.=" \$(TARGET)/$filesfull[$i]";
  686: 		    $description2.=<<END;
  687: \$(TARGET)/$filesfull[$i]:
  688: \tln -s /$linkto \$(TARGET)/$filesfull[$i]
  689: 
  690: END
  691:                 }
  692: 	    }
  693: 	}
  694:     }
  695:     $description.=<<END;
  696: 
  697: END
  698:     $description.=$description2;
  699:     return $description;
  700: }
  701: 
  702: # --------------------------------------------------------- Make RPM .spec block
  703: sub make_rpm_spec_block {
  704:     my $pwd=`pwd`; chop $pwd;
  705:     my $buildroot="$pwd/LON-CAPA-BuildRoot";
  706:     my $source=$info{'RPM'}{'Name'} . "-" . $info{'RPM'}{'Version'} . '.tar.gz';
  707:     my $description=<<END;
  708: Summary: $info{'RPM'}{'Summary'}
  709: Name: $info{'RPM'}{'Name'}
  710: Version: $info{'RPM'}{'Version'}
  711: Release: $info{'RPM'}{'Release'}
  712: Vendor: $info{'RPM'}{'Vendor'} 
  713: BuildRoot: $buildroot
  714: Copyright: $info{'RPM'}{'Copyright'}
  715: Group: $info{'RPM'}{'Group'}
  716: Source: $source
  717: AutoReqProv: $info{'RPM'}{'AutoReqProv'}
  718: \%description
  719: $info{'RPM'}{'description'}
  720: 
  721: END
  722:     return $description;
  723: }
  724: 
  725: # --------------------------------------------------- Make RPM build .spec block
  726: sub make_rpm_build_block {
  727:     my $pwd=`pwd`; chop $pwd;
  728:     my $buildroot="$pwd/LON-CAPA-BuildRoot";
  729:     my $sourceroot="$pwd/LON-CAPA-SourceRoot";
  730:     my $description=<<END;
  731: 
  732: \%prep
  733: \%setup
  734: 
  735: \%build
  736: rm -Rf "$buildroot"
  737: 
  738: \%install
  739: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" directories
  740: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" files
  741: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" links
  742: 
  743: \%pre
  744: $info{'RPM'}{'pre'}
  745: 
  746: \%post
  747: \%postun
  748: 
  749: \%files
  750: # \%doc README COPYING ChangeLog LICENSE
  751: END
  752:     return $description;
  753: }
  754: 
  755: # ------------------------------------- Make directory structure RPM .spec block
  756: sub make_directory_structure_spec_block {
  757:     my ($dirs)=@_;
  758:     foreach my $d (@$dirs) {
  759: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
  760: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
  761: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
  762: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
  763: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
  764: 	my $own=$devchown; $own=~s/\:/\,/;
  765: 	$description.=<<END;
  766: \%dir \%attr($devchmod,$own) /$d
  767: END
  768:     }
  769:     return $description;
  770: }
  771: 
  772: # ---------------------------- Make directory and file structure RPM .spec block
  773: sub make_directory_and_file_structure_spec_block {
  774:     my ($dirs)=@_;
  775:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
  776:     foreach my $d (@$dirs) {
  777: 	# set other values
  778: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
  779: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
  780: 	# find files that are contained in this directory
  781: 	my @files;
  782: 	my @filesfull;
  783: 	foreach my $f (@allfiles) {
  784: 	    if ($f=~/^$d\/([^\/]+)$/) {
  785: 		push @files,$1;
  786: 		push @filesfull,$f;
  787: 	    }
  788: 	}
  789: 	# render starting HTML formatting elements
  790: 	if (@files) {
  791: 	    $description.=<<END;
  792: # $d $dirdescription
  793: END
  794:         }
  795: 	if (@files) {
  796:             foreach my $i (0..$#files) {
  797: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
  798: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
  799: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
  800: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
  801: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
  802: 		my $own=$devchown; $own=~s/\:/\,/;
  803: 		my $config="";
  804: 		$config="\%config " if $category eq 'conf';
  805: 		$devchmod='-' if $category eq 'symbolic link';
  806: 		$description.=<<END;
  807: $config\%attr($devchmod,$own) /$filesfull[$i]
  808: END
  809: 	    }
  810: 	}
  811:     }
  812:     return $description;
  813: }
  814: 
  815: # ----------------------------------------------------------- End RPM .spec page
  816: sub end_spec_page {
  817: }
  818: 
  819: # ------------------------------------------------------- Begin description page
  820: sub begin_description_page {
  821:     my $description=<<END;
  822: <HTML>
  823: <HEAD>
  824: <TITLE>LON-CAPA Software Description Page ($distribution, $date)</TITLE>
  825: </HEAD>
  826: <BODY>
  827: <FONT SIZE=+2>LON-CAPA Software Description Page ($distribution, $date)</FONT>
  828: <BR>Michigan State University
  829: <BR>Learning Online with CAPA
  830: <BR>Contact korte\@lon-capa.org
  831: <UL>
  832: <LI>About this file
  833: <LI>Software Package Description
  834: <LI>Directory Structure
  835: <LI>File Type Ownership and Permissions
  836: <LI>File and Directory Structure
  837: </UL>
  838: <FONT SIZE=+2>About this file</FONT>
  839: <P>
  840: This file is generated dynamically by <TT>parse.pl</TT> as
  841: part of a development compilation process.  See 
  842: http://install.lon-capa.org/compile/index.html for more
  843: information.
  844: </P>
  845: END
  846:     return $description;
  847: }
  848: 
  849: # ------------------------------------------------- End description page
  850: sub end_description_page {
  851:     my $description=<<END;
  852: <HR>
  853: <FONT SIZE=-1>LON-CAPA Software Development Team</FONT>
  854: </BODY>
  855: </HTML>
  856: END
  857:     return $description;
  858: }
  859: 
  860: # ------------------------------------------------- Make RPM description block
  861: sub make_rpm_description_block {
  862:     my $description=<<END;
  863: <FONT SIZE=+2>Rolled in a RedHat 6.2 RPM, $date</FONT>
  864: <P>
  865: <TABLE BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=10 CELLSPACING=0>
  866: <TR><TD>
  867: <PRE>
  868: Name        : $info{'RPM'}{'Name'}
  869: Version     : $info{'RPM'}{'Version'}
  870: Vendor      : $info{'RPM'}{'Vendor'} 
  871: Release     : $info{'RPM'}{'Release'}                             
  872: Build Host  : $buildhost
  873: Group       : $info{'RPM'}{'Group'}
  874: License     : $info{'RPM'}{'Copyright'}
  875: Summary     : $info{'RPM'}{'Summary'}
  876: Description : 
  877: $info{'RPM'}{'description'}
  878: </PRE>
  879: </TD></TR>
  880: </TABLE>
  881: </P>
  882: END
  883:     return $description;
  884: }
  885: 
  886: # ----------------------------------------------- Determine directory structure
  887: sub determine_directory_structure {
  888:     my @directories=keys %{$info{'DIRECTORY'}{$distribution}};
  889:     return (sort @directories);
  890: }
  891: 
  892: 
  893: # ---------------------------------- Make directory structure description block
  894: sub make_directory_structure_description_block {
  895:     my ($dirs)=@_;
  896:     my $description=<<END;
  897: <FONT SIZE=+2>Directory Structure Description, $date</FONT>
  898: <P>
  899: The directory structure description below shows only those
  900: directories which either contain LON-CAPA specific files
  901: or normally do not exist on a RedHat Linux system (and
  902: must be generated to allow proper placement of files
  903: during LON-CAPA run-time operation).
  904: </P>
  905: <P>
  906: <TABLE BORDER=1 CELLPADDING=3 CELLSPACING=0>
  907: END
  908:     my $maxcount=0;
  909:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
  910:     my %diraccount; # hash to track which directories are accounted for
  911:     foreach my $file (@allfiles) {
  912: 	$file=~/^(.*)\/([^\/]+)$/;
  913: 	$diraccount{$1}=1;
  914:     }
  915:     foreach my $d (@$dirs) {
  916:         my (@matches)=($d=~/\//g);
  917: 	my $count=scalar(@matches);
  918: 	$maxcount=$count if $count>$maxcount;
  919: 	delete $diraccount{$d};
  920:     }
  921:     $description.=<<END;
  922: <TR>
  923: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Category</TH>
  924: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
  925: <TH ALIGN=LEFT BGCOLOR=#FFFFFF><FONT COLOR=#FF0000>Development<BR>Permissions</FONT></TH>
  926: END
  927:     $description.="<TH ALIGN=LEFT BGCOLOR=#FFFFFF COLSPAN=".($maxcount+1).">Directory Path</TH>\n";
  928:     if (keys %diraccount) {
  929: 	$description.= "<TR><TD ALIGN=LEFT BGCOLOR=#FFFFFF COLSPAN=".($maxcount+4)."><I><PRE>Directories that are unaccounted for: \n";
  930: 	foreach my $d (keys %diraccount) {
  931: 	    $description.="$d\n";
  932: 	}
  933: 	$description.="</PRE></I></TH></TR>\n";
  934:     }
  935:     foreach my $d (@$dirs) {
  936: 	my $dtable=$d;
  937: 	$dtable=~s/\//\<\/TD\>\<TD\>/g;
  938: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
  939: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
  940: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
  941: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
  942: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
  943: 	$description.=<<END;
  944: <TR>
  945: <TD BGCOLOR=#FFFFFF>$category</TD>
  946: <TD BGCOLOR=#FFFFFF><TT>$chmod $chown</TT></TD>
  947: <TD BGCOLOR=#FFFFFF><FONT COLOR=#FF0000><TT>$devchmod $devchown</TT></FONT></TD>
  948: <TD>
  949: $dtable
  950: </TD>
  951: </TR>
  952: END
  953:     }
  954:     $description.=<<END;
  955: </TABLE>
  956: </P>
  957: END
  958:     return $description;
  959: }
  960: 
  961: # ------------------- Make file type ownership and permissions description block
  962: sub make_file_type_ownership_and_permissions_description_block {
  963:     my $description=<<END;
  964: <FONT SIZE=+2>File Type Ownership and Permissions Descriptions, $date</FONT>
  965: <P>
  966: This table shows what permissions and ownership settings correspond
  967: to each kind of file type.
  968: </P>
  969: <P>
  970: <TABLE BORDER=1 CELLPADDING=5 WIDTH=60%>
  971: <TR>
  972: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Icon</TH>
  973: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Type</TH>
  974: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
  975: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Development Permissions</TH>
  976: </TR>
  977: END
  978:     foreach my $type (keys %{$info{'OWNERSHIP'}}) {
  979: 	if (defined($fcm{$type})) {
  980: 	    my $chmod=$info{'OWNERSHIP'}{$type}{'CHMOD'};
  981: 	    my $chown=$info{'OWNERSHIP'}{$type}{'CHOWN'};
  982: 	    my $devchmod=$info{'DEVOWNERSHIP'}{$type}{'CHMOD'};
  983: 	    my $devchown=$info{'DEVOWNERSHIP'}{$type}{'CHOWN'};
  984: 	    $description.=<<END;
  985: <TR>
  986: <TD><IMG SRC="$fcm{$type}.gif" ALT="$type"></TD>
  987: <TD>$type</TD>
  988: <TD><TT>$chmod $chown</TT></TD>
  989: <TD><TT>$devchmod $devchown</TT></TD>
  990: </TR>
  991: END
  992:         }
  993:     }
  994:     $description.=<<END;
  995: </TABLE>
  996: </P>
  997: END
  998: }
  999: 
 1000: # ------------------------- Make directory and file structure description block
 1001: sub make_directory_and_file_structure_description_block {
 1002:     my ($dirs)=@_;
 1003:     my $description=<<END;
 1004: <FONT SIZE=+2>Directory and File Structure Description, $date</FONT>
 1005: <P>
 1006: The icons on the left column correspond to the file type
 1007: specified in the second column.  The last column "Notes" shows compilation,
 1008: dependency, and configuration information.  The CVS location
 1009: shows the location of the binary source file (if applicable) needed to
 1010: be copied to the target.  If the binary source file is not at
 1011: the specified location, then the text is shown in 
 1012: <FONT COLOR=#FF0000>red</FONT>.
 1013: </P>
 1014: <P>
 1015: <TABLE BORDER=1 CELLPADDING=5 WIDTH=500>
 1016: END
 1017:     my $counter=0;
 1018:     my @colorindex=("#80FF80","#80FFFF","#FFFF80");
 1019:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
 1020:     foreach my $d (@$dirs) {
 1021: 	# set color
 1022: 	my $color=$colorindex[$counter%3];
 1023: 	# set other values
 1024: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
 1025: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
 1026: 	# find subdirectories that are contained in this directory
 1027: 	my @subdirs;
 1028: 	foreach my $d2 (@$dirs) {
 1029: 	    if ($d2=~/^$d\/([^\/]+)$/) {
 1030: 		push @subdirs,$1;
 1031: 	    }
 1032: 	}
 1033: 	# find files that are contained in this directory
 1034: 	my @files;
 1035: 	my @filesfull;
 1036: 	foreach my $f (@allfiles) {
 1037: 	    if ($f=~/^$d\/([^\/]+)$/) {
 1038: 		push @files,$1;
 1039: 		push @filesfull,$f;
 1040: 	    }
 1041: 	}
 1042: 	# render starting HTML formatting elements
 1043: 	if (@subdirs || @files) {
 1044: 	    my $subdirstring="<BR>* Relevant subdirectories: " . join(", ",@subdirs) if @subdirs;
 1045: 	    $description.=<<END;
 1046: <TR><TD BGCOLOR=#000000 COLSPAN=6><FONT COLOR=$color><IMG SRC="directory.gif" ALT="directory">DIRECTORY -- $d $dirdescription
 1047: $subdirstring</FONT></TD></TR>
 1048: END
 1049:         }
 1050: 	else {
 1051: 	    $description.=<<END;
 1052: <TR><TD BGCOLOR=#000000 COLSPAN=6><FONT COLOR=$color><IMG SRC="emptydirectory.gif" ALT="empty directory">EMPTY DIRECTORY - $d $dirdescription</FONT></TD></TR>
 1053: END
 1054:         }
 1055: 	if (@files) {
 1056: 	    $description.=<<END;
 1057: <TR>
 1058: <TH BGCOLOR=$color ALIGN=LEFT COLSPAN=2>Type</TH>
 1059: <TH BGCOLOR=$color ALIGN=LEFT>File Name</TH>
 1060: <TH BGCOLOR=$color ALIGN=LEFT>Function</TH>
 1061: <TH BGCOLOR=$color ALIGN=LEFT>CVS Location</TH>
 1062: <TH BGCOLOR=$color ALIGN=LEFT>Notes</TH>
 1063: </TR>
 1064: END
 1065:             foreach my $i (0..$#files) {
 1066: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
 1067: 		my $fdescription=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DESCRIPTION'};
 1068: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
 1069: 		my $note=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'NOTE'};
 1070: 		$note.="<BR>" if $note;
 1071: 		my $listing=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
 1072: 		my @E=split(/\s+/,$listing);
 1073: 		$source=~/(.*)\/[^\/]+$/;
 1074: 		my $sd=$1;
 1075: 		my $eflag=0;
 1076: 		foreach my $e (@E) {
 1077: 		    unless (-e "../../$sd/$e") {
 1078: 			$e="<FONT COLOR=#FF0000>$e</FONT>";
 1079: 			$eflag=1;
 1080: 		    }
 1081: 		}
 1082: 		$listing=join("\n",@E);
 1083: 		$listing="<B>listing</B><BR><FONT SIZE=-2>$listing</FONT>" if $listing;
 1084: 		$listing.="<BR>" if $listing;
 1085: 		my $build=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'BUILD'};
 1086: 		$build="<B>build</B><BR>$build" if $build;
 1087: 		$build.="<BR>" if $build;
 1088: 		my $dependencies=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DEPENDENCIES'};
 1089: 		$dependencies="<B>dependencies</B><BR>$dependencies" if $dependencies;
 1090: 		$dependencies.="<BR>" if $dependencies;
 1091: 		unless (-e "../../$source") {
 1092: 		    $source=~/([^\/]+)$/;
 1093: 		    my $s=$1;
 1094: 		    if ($source!~/\*/) {
 1095: 			$source="<FONT COLOR=#FF0000>$source</FONT>";
 1096: 		    }
 1097: 		    elsif ($eflag) {
 1098: 			$source="<FONT COLOR=#FF0000>$source</FONT>";
 1099: 		    }
 1100: 		}
 1101: 		$description.=<<END;
 1102: <TR>
 1103: <TD BGCOLOR=#A0A0A0><IMG SRC="$fcm{$category}.gif" ALT="$category"></TD>
 1104: <TD BGCOLOR=$color>$category</TD>
 1105: <TD BGCOLOR=$color>$files[$i]</TD>
 1106: <TD BGCOLOR=$color>$fdescription&nbsp;</TD>
 1107: <TD BGCOLOR=$color>$source</TD>
 1108: <TD BGCOLOR=$color>$note$listing$build$dependencies&nbsp;</TD>
 1109: </TR>
 1110: END
 1111: 	    }
 1112: 	}
 1113: 	$counter++;
 1114:     }
 1115:     $description.=<<END;
 1116: </TABLE>
 1117: </P>
 1118: END
 1119:     return $description;
 1120: }

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