Diff for /loncom/build/lpml_parse.pl between versions 1.27 and 1.31

version 1.27, 2001/12/06 00:22:53 version 1.31, 2001/12/13 23:41:26
Line 1 Line 1
 #!/usr/bin/perl  #!/usr/bin/perl
   
 # Scott Harrison  # The LearningOnline Network with CAPA
   # lpml_parse.pl - Linux Packaging Markup Language parser
   #
   # $Id$
   #
   # Written by Scott Harrison, harris41@msu.edu
   #
   # Copyright Michigan State University Board of Trustees
   #
   # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   #
   # LON-CAPA is free software; you can redistribute it and/or modify
   # it under the terms of the GNU General Public License as published by
   # the Free Software Foundation; either version 2 of the License, or
   # (at your option) any later version.
   #
   # LON-CAPA is distributed in the hope that it will be useful,
   # but WITHOUT ANY WARRANTY; without even the implied warranty of
   # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   # GNU General Public License for more details.
   #
   # You should have received a copy of the GNU General Public License
   # along with LON-CAPA; if not, write to the Free Software
   # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   #
   # /home/httpd/html/adm/gpl.txt
   #
   # http://www.lon-capa.org/
   #
 # YEAR=2001  # YEAR=2001
 # May 2001  # May 2001
 # 06/19/2001,06/20,06/24 - Scott Harrison  # 06/19/2001,06/20,06/24 - Scott Harrison
 # 9/5/2001,9/6,9/7,9/8 - Scott Harrison  # 9/5/2001,9/6,9/7,9/8 - Scott Harrison
 # 9/17,9/18 - Scott Harrison  # 9/17,9/18 - Scott Harrison
 # 11/4,11/5,11/6,11/7,11/16,11/17 - Scott Harrison  # 11/4,11/5,11/6,11/7,11/16,11/17 - Scott Harrison
 # 12/2,12/3,12/4,12/5 - Scott Harrison  # 12/2,12/3,12/4,12/5,12/6,12/13 - Scott Harrison
 # $Id$  #
 ###  ###
   
 ###############################################################################  ###############################################################################
Line 197  $cleanstring=~s/\>\s*\n\s*\</\>\</g; Line 225  $cleanstring=~s/\>\s*\n\s*\</\>\</g;
 # storage variables  # storage variables
 my $lpml;  my $lpml;
 my $categories;  my $categories;
   my @categorynamelist;
 my $category;  my $category;
 my $category_att_name;  my $category_att_name;
 my $category_att_type;  my $category_att_type;
Line 244  my @links; Line 273  my @links;
 my %categoryhash;  my %categoryhash;
 my $dpathlength;  my $dpathlength;
 my %fab; # file category abbreviation  my %fab; # file category abbreviation
   my $directory_count;
   my $file_count;
   my $link_count;
   my $fileglob_count;
   my $fileglobnames_count;
   my %categorycount;
   # START TEMP WAY
   #my %bytecount;  # TEMP WAY TO COUNT INFORMATION
   #my %linecount;  # TEMP WAY TO COUNT INFORMATION
   # END TEMP WAY
   
 my @buildall;  my @buildall;
 my @buildinfo;  my @buildinfo;
Line 259  $parser->xml_mode('1'); Line 298  $parser->xml_mode('1');
 # Define handling methods for mode-dependent text rendering  # Define handling methods for mode-dependent text rendering
   
 $parser->{textify}={  $parser->{textify}={
       specialnotices => \&format_specialnotices,
       specialnotice => \&format_specialnotice,
     targetroot => \&format_targetroot,      targetroot => \&format_targetroot,
     sourceroot => \&format_sourceroot,      sourceroot => \&format_sourceroot,
     categories => \&format_categories,      categories => \&format_categories,
Line 326  exit; Line 367  exit;
 # ------------------------ Final output at end of markup parsing and formatting  # ------------------------ Final output at end of markup parsing and formatting
 sub end {  sub end {
     if ($mode eq 'html') {      if ($mode eq 'html') {
  return "</body></html>\n";   # START TEMP WAY
   # my $totallinecount;
   # my $totalbytecount;
   # map {$totallinecount+=$linecount{$_};
   #     $totalbytecount+=$bytecount{$_}}
   #  @categorynamelist;
           # END TEMP WAY
    return "<br />&nbsp;<br />".
       "<a name='summary' /><font size='+2'>Summary of Source Repository".
       "</font>".
       "<br />&nbsp;<br />".
       "<table border='1' cellpadding='5'>".
       "<caption>Files, Directories, and Symbolic Links</caption>".
       "<tr><td>Files (not referenced by globs)</td><td>$file_count</td>".
       "</tr>".
       "<tr><td>Files (referenced by globs)</td>".
       "<td>$fileglobnames_count</td>".
       "</tr>".
       "<tr><td>Total Files</td>".
       "<td>".($fileglobnames_count+$file_count)."</td>".
       "</tr>".
       "<tr><td>File globs</td>".
       "<td>".$fileglob_count."</td>".
       "</tr>".
       "<tr><td>Directories</td>".
       "<td>".$directory_count."</td>".
       "</tr>".
       "<tr><td>Symbolic links</td>".
       "<td>".$link_count."</td>".
       "</tr>".
       "</table>".
       "<table border='1' cellpadding='5'>".
       "<caption>File Category Count</caption>".
       "<tr><th>Icon</th><th>Name</th><th>Number of Occurrences</th>".
       join("\n",(map {"<tr><td><img src='$fab{$_}.gif' ".
    "alt='$_ icon' /></td>".
             "<td>$_</td><td>$categorycount{$_}</td></tr>"}
    @categorynamelist)).
       "</table>".
       "</body></html>\n";
   
   # START TEMP WAY
   #    join("\n",(map {"<tr><td><img src='$fab{$_}.gif' ".
   # "alt='$_ icon' /></td>".
   #         "<td>$_</td><td>$categorycount{$_}</td><td>$linecount{$_}</td><td>$bytecount{$_}</td></tr>"}
   # @categorynamelist)).
   #    "<br />&nbsp;<br />".
   #    "Total Lines of Code: $totallinecount".
   #    "<br />&nbsp;<br />".
   #    "Total Bytes: $totalbytecount".
   # END TEMP WAY
     }      }
     if ($mode eq 'install') {      if ($mode eq 'install') {
  return '';   return '';
Line 364  Descriptions</a></li> Line 455  Descriptions</a></li>
 <li><a href='#package'>Software Package Description</a></li>  <li><a href='#package'>Software Package Description</a></li>
 <li><a href='#directories'>Directory Structure</a></li>  <li><a href='#directories'>Directory Structure</a></li>
 <li><a href='#files'>Files</a></li>  <li><a href='#files'>Files</a></li>
   <li><a href='#summary'>Summary of Source Repository</a></li>
 </ul>  </ul>
 END  END
         $lpml .=<<END;          $lpml .=<<END;
Line 371  END Line 463  END
 <font size='+2'>About this file</font>  <font size='+2'>About this file</font>
 <p>  <p>
 This file is generated dynamically by <tt>lpml_parse.pl</tt> as  This file is generated dynamically by <tt>lpml_parse.pl</tt> as
 part of a development compilation process.  Author: Scott  part of a development compilation process.</p>
 Harrison (harris41\@msu.edu).  <p>LPML written by Scott Harrison (harris41\@msu.edu).
 </p>  </p>
 END  END
     }      }
Line 497  sub format_category { Line 589  sub format_category {
     $fab{$category_att_name}=$abbreviation;      $fab{$category_att_name}=$abbreviation;
     if ($mode eq 'html') {      if ($mode eq 'html') {
  if ($category_att_type eq $categorytype) {   if ($category_att_type eq $categorytype) {
       push @categorynamelist,$category_att_name;
     $categoryhash{$category_att_name}="$chmod $chown";      $categoryhash{$category_att_name}="$chmod $chown";
     return $category="<tr>".      return $category="<tr>".
  "<td><img src='$abbreviation.gif' ".   "<td><img src='$abbreviation.gif' ".
Line 784  sub format_directory { Line 877  sub format_directory {
     $targetdir='';$categoryname='';$description='';      $targetdir='';$categoryname='';$description='';
     $parser->get_text('/directory');      $parser->get_text('/directory');
     $parser->get_tag('/directory');      $parser->get_tag('/directory');
       $directory_count++;
       $categorycount{$categoryname}++;
     if ($mode eq 'html') {      if ($mode eq 'html') {
  my @a;   my @a;
  @a=($targetdir=~/\//g);   @a=($targetdir=~/\//g);
Line 791  sub format_directory { Line 886  sub format_directory {
  $dpathlength=$d if $d>$dpathlength;   $dpathlength=$d if $d>$dpathlength;
  my $thtml=$targetdir;   my $thtml=$targetdir;
  $thtml=~s/\//\<\/td\>\<td bgcolor='#ffffff'\>/g;   $thtml=~s/\//\<\/td\>\<td bgcolor='#ffffff'\>/g;
    my ($chmod,$chown)=split(/\s/,$categoryhash{$categoryname});
  return $directory="\n<tr><td rowspan='2' bgcolor='#ffffff'>".   return $directory="\n<tr><td rowspan='2' bgcolor='#ffffff'>".
     "$categoryname</td>".      "$categoryname</td>".
     "<td rowspan='2' bgcolor='#ffffff'><!-- POSTEVAL: -->&nbsp;</td>".      "<td rowspan='2' bgcolor='#ffffff'><!-- POSTEVAL verify.pl directory /$targetdir $categoryhash{$categoryname} -->&nbsp;</td>".
     "<td rowspan='2' bgcolor='#ffffff'>$chmod<br />$chown</td>".      "<td rowspan='2' bgcolor='#ffffff'>$chmod<br />$chown</td>".
     "<td bgcolor='#ffffff'>$thtml</td></tr>".      "<td bgcolor='#ffffff'>$thtml</td></tr>".
     "<tr><td bgcolor='#ffffff' colspan='[{{{{{DPATHLENGTH}}}}}]'>".      "<tr><td bgcolor='#ffffff' colspan='[{{{{{DPATHLENGTH}}}}}]'>".
Line 953  sub format_file { Line 1049  sub format_file {
     $note=''; $build=''; $status=''; $dependencies='';      $note=''; $build=''; $status=''; $dependencies='';
     my $text=&trim($parser->get_text('/file'));      my $text=&trim($parser->get_text('/file'));
     my $buildtest;      my $buildtest;
       $file_count++;
       $categorycount{$categoryname}++;
       # START TEMP WAY
   #    if (-T "$sourcerootarg/$source") {
   # $linecount{$categoryname}+=`wc -l $sourcerootarg/$source`;
   #    }
   #    my $bytesize=(-s "$sourcerootarg/$source");
   #    $bytecount{$categoryname}+=$bytesize;
       # END TEMP WAY
     if ($source) {      if ($source) {
  $parser->get_tag('/file');   $parser->get_tag('/file');
  if ($mode eq 'html') {   if ($mode eq 'html') {
     return ($file="\n<!-- FILESORT:$target -->".      return ($file="\n<!-- FILESORT:$target -->".
     "<tr>".      "<tr>".
     "<td><!-- POSTEVAL -->&nbsp;</td><td>".      "<td><!-- POSTEVAL verify.pl file '$sourcerootarg' ".
       "'$targetrootarg' ".
       "'$source' '$target' ".
       "$categoryhash{$categoryname} -->&nbsp;</td><td>".
     "<img src='$fab{$categoryname}.gif' ".      "<img src='$fab{$categoryname}.gif' ".
     "alt='$categoryname icon' /></td>".      "alt='$categoryname icon' /></td>".
     "<td>$categoryname<br /><font size='-1'>".      "<td>$categoryname<br /><font size='-1'>".
Line 1076  sub format_link { Line 1184  sub format_link {
     $link=''; $linkto=''; $source=''; $target=''; $categoryname='';       $link=''; $linkto=''; $source=''; $target=''; $categoryname=''; 
     $description=''; $note=''; $build=''; $status=''; $dependencies='';      $description=''; $note=''; $build=''; $status=''; $dependencies='';
     my $text=&trim($parser->get_text('/link'));      my $text=&trim($parser->get_text('/link'));
       my @links;
     if ($linkto) {      if ($linkto) {
  $parser->get_tag('/link');   $parser->get_tag('/link');
  if ($mode eq 'html') {   if ($mode eq 'html') {
     my @targets=map {s/^\s*//;s/\s$//;$_} split(/\;/,$target);      my @targets=map {s/^\s*//;s/\s$//;$_} split(/\;/,$target);
       $link_count+=scalar(@targets);
     foreach my $tgt (@targets) {      foreach my $tgt (@targets) {
    $categorycount{$categoryname}++;
  push @links,("\n<!-- FILESORT:$tgt -->".   push @links,("\n<!-- FILESORT:$tgt -->".
     "<tr>".      "<tr>".
     "<td><!-- POSTEVAL -->&nbsp;</td><td>".      "<td><!-- POSTEVAL verify.pl link ".
       "'/$targetrootarg$linkto' '/$targetrootarg$tgt' ".
       "$categoryhash{$categoryname} -->&nbsp;</td><td>".
     "<img src='$fab{$categoryname}.gif' ".      "<img src='$fab{$categoryname}.gif' ".
     "alt='$categoryname icon' /></td>".      "alt='$categoryname icon' /></td>".
     "<td><font size='-1'>$categoryname</font></td>".      "<td><font size='-1'>$categoryname</font></td>".
Line 1132  sub format_fileglob { Line 1245  sub format_fileglob {
     $filenames='';      $filenames='';
     my $text=&trim($parser->get_text('/fileglob'));      my $text=&trim($parser->get_text('/fileglob'));
     my $filenames2=$filenames;$filenames2=~s/\s//g;      my $filenames2=$filenames;$filenames2=~s/\s//g;
       $fileglob_count++;
       my @semi=($filenames2=~/(\;)/g);
       $fileglobnames_count+=scalar(@semi)+1;
       $categorycount{$categoryname}+=scalar(@semi)+1;
       # START TEMP WAY
   #    for my $f (split(/\;/,$filenames2)) {
   # if (-T "$sourcerootarg/$sourcedir/$f") {
   #    $linecount{$categoryname}+=`wc -l $sourcerootarg/$sourcedir/$f`;
   #    open OUT,">>/tmp/junk123";
   #    print OUT "$linecount{$categoryname} $categoryname $sourcerootarg/$sourcedir/$f\n";
   #    close OUT;
   # }
   # my $bytesize=(-s "$sourcerootarg/$sourcedir/$f");
   # $bytecount{$categoryname}+=$bytesize;
   #    }
       # END TEMP WAY
     if ($sourcedir) {      if ($sourcedir) {
  $parser->get_tag('/fileglob');   $parser->get_tag('/fileglob');
  if ($mode eq 'html') {   if ($mode eq 'html') {
     return $fileglob="\n<tr>".      return $fileglob="\n<tr>".
  "<td><!-- POSTEVAL2 verify.pl fileglob '$sourcerootarg' ".   "<td><!-- POSTEVAL verify.pl fileglob '$sourcerootarg' ".
  "'$targetrootarg' ".   "'$targetrootarg' ".
  "'$glob' '$sourcedir' '$filenames2' '$targetdir' ".   "'$glob' '$sourcedir' '$filenames2' '$targetdir' ".
  "$categoryhash{$categoryname} -->&nbsp;</td>".   "$categoryhash{$categoryname} -->&nbsp;</td>".
Line 1158  sub format_fileglob { Line 1287  sub format_fileglob {
 # "\nEND FILEGLOB</td></tr>";  # "\nEND FILEGLOB</td></tr>";
  }   }
  elsif ($mode eq 'install') {   elsif ($mode eq 'install') {
       my $eglob=$glob;
       if ($glob eq '*') {
    $eglob='[^C][^V][^S]'.$glob;
       }
     return "\t".'install '.      return "\t".'install '.
  $categoryhash{$categoryname}.' '.   $categoryhash{$categoryname}.' '.
  $sourceroot.'/'.$sourcedir.'[^C][^V][^S]'.$glob.' '.   $sourceroot.'/'.$sourcedir.$eglob.' '.
  $targetroot.'/'.$targetdir.'.'."\n";   $targetroot.'/'.$targetdir.'.'."\n";
  }   }
  else {   else {
Line 1296  sub format_filenames { Line 1429  sub format_filenames {
     }      }
     return '';      return '';
 }  }
   # ------------------------------------------------ Format specialnotice section
   sub format_specialnotices {
       $parser->get_tag('/specialnotices');
       return '';
   }
   # ------------------------------------------------ Format specialnotice section
   sub format_specialnotice {
       $parser->get_tag('/specialnotice');
       return '';
   }
 # ------------------------------------------------------- Format linkto section  # ------------------------------------------------------- Format linkto section
 sub format_linkto {  sub format_linkto {
     my @tokeninfo=@_;      my @tokeninfo=@_;

Removed from v.1.27  
changed lines
  Added in v.1.31


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