--- loncom/build/lpml_parse.pl 2001/12/06 00:22:53 1.27 +++ loncom/build/lpml_parse.pl 2002/01/09 22:18:16 1.35 @@ -1,14 +1,44 @@ #!/usr/bin/perl -# Scott Harrison +# The LearningOnline Network with CAPA +# lpml_parse.pl - Linux Packaging Markup Language parser +# +# $Id: lpml_parse.pl,v 1.35 2002/01/09 22:18:16 harris41 Exp $ +# +# 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 # May 2001 # 06/19/2001,06/20,06/24 - Scott Harrison # 9/5/2001,9/6,9/7,9/8 - Scott Harrison # 9/17,9/18 - 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 -# $Id: lpml_parse.pl,v 1.27 2001/12/06 00:22:53 harris41 Exp $ +# 12/2,12/3,12/4,12/5,12/6,12/13,12/19,12/29 - Scott Harrison +# YEAR=2002 +# 1/8,1/9 - Scott Harrison +# ### ############################################################################### @@ -197,6 +227,7 @@ $cleanstring=~s/\>\s*\n\s*\\xml_mode('1'); # Define handling methods for mode-dependent text rendering $parser->{textify}={ + specialnotices => \&format_specialnotices, + specialnotice => \&format_specialnotice, targetroot => \&format_targetroot, sourceroot => \&format_sourceroot, categories => \&format_categories, @@ -280,6 +323,7 @@ $parser->{textify}={ rpmAutoReqProv => \&format_rpmAutoReqProv, rpmdescription => \&format_rpmdescription, rpmpre => \&format_rpmpre, + rpmRequires => \&format_rpmRequires, directories => \&format_directories, directory => \&format_directory, categoryname => \&format_categoryname, @@ -326,7 +370,60 @@ exit; # ------------------------ Final output at end of markup parsing and formatting sub end { if ($mode eq 'html') { - return "\n"; + # START TEMP WAY +# my $totallinecount; +# my $totalbytecount; +# map {$totallinecount+=$linecount{$_}; +# $totalbytecount+=$bytecount{$_}} +# @categorynamelist; + # END TEMP WAY + return "
 
". + "Summary of Source Repository". + "". + "
 
". + "". + "". + "". + "". + "". + "". + "". + "". + "". + "". + "". + "". + "". + "". + "". + "". + "". + "". + "". + "
Files, Directories, and Symbolic Links
Files (not referenced by globs)$file_count
Files (referenced by globs)$fileglobnames_count
Total Files".($fileglobnames_count+$file_count)."
File globs".$fileglob_count."
Directories".$directory_count."
Symbolic links".$link_count."
". + "". + "". + "". + "". + "". + join("\n",(map {"". + "". + ""} + @categorynamelist)). + "
File Category Count
IconNameNumber of OccurrencesNumber of Incorrect Counts
$_$categorycount{$_}
". + "\n"; + +# START TEMP WAY +# join("\n",(map {"". +# "$_$categorycount{$_}$linecount{$_}$bytecount{$_}"} +# @categorynamelist)). +# "
 
". +# "Total Lines of Code: $totallinecount". +# "
 
". +# "Total Bytes: $totalbytecount". +# END TEMP WAY } if ($mode eq 'install') { return ''; @@ -364,6 +461,7 @@ Descriptions
  • Software Package Description
  • Directory Structure
  • Files
  • +
  • Summary of Source Repository
  • END $lpml .=<About this file

    This file is generated dynamically by lpml_parse.pl as -part of a development compilation process. Author: Scott -Harrison (harris41\@msu.edu). +part of a development compilation process.

    +

    LPML written by Scott Harrison (harris41\@msu.edu).

    END } @@ -497,6 +595,7 @@ sub format_category { $fab{$category_att_name}=$abbreviation; if ($mode eq 'html') { if ($category_att_type eq $categorytype) { + push @categorynamelist,$category_att_name; $categoryhash{$category_att_name}="$chmod $chown"; return $category="". " END } + elsif ($mode eq 'make_rpm') { + return $text; + } elsif ($mode eq 'text') { return $rpm=<$text +END + } else { return ''; } @@ -603,6 +710,11 @@ sub format_rpmName { elsif ($mode eq 'text') { return $rpmName="\nName : $text"; } + elsif ($mode eq 'make_rpm') { + return <$text +END + } else { return ''; } @@ -645,6 +757,11 @@ sub format_rpmVendor { elsif ($mode eq 'text') { return $rpmVendor="\nVendor : $text"; } + elsif ($mode eq 'make_rpm') { + return <$text +END + } else { return ''; } @@ -673,6 +790,11 @@ sub format_rpmCopyright { elsif ($mode eq 'text') { return $rpmCopyright="\nLicense : $text"; } + elsif ($mode eq 'make_rpm') { + return <$text +END + } else { return ''; } @@ -687,6 +809,11 @@ sub format_rpmGroup { elsif ($mode eq 'text') { return $rpmGroup="\nGroup : $text"; } + elsif ($mode eq 'make_rpm') { + return <Utilities/System +END + } else { return ''; } @@ -712,9 +839,14 @@ sub format_rpmAutoReqProv { if ($mode eq 'html') { return $rpmAutoReqProv="\nAutoReqProv : $text"; } - if ($mode eq 'text') { + elsif ($mode eq 'text') { return $rpmAutoReqProv="\nAutoReqProv : $text"; } + elsif ($mode eq 'make_rpm') { + return <$text +END + } else { return ''; } @@ -733,6 +865,13 @@ sub format_rpmdescription { $text=~s/\\n/\n/g; return $rpmdescription="\nDescription : $text"; } + elsif ($mode eq 'make_rpm') { + $text=~s/\n//g; + $text=~s/\\n/\n/g; + return <$text +END + } else { return ''; } @@ -745,10 +884,42 @@ sub format_rpmpre { # return $rpmpre="\n
    RPMPRE $text"; return ''; } + elsif ($mode eq 'make_rpm') { + return <$text +END + } else { return ''; } } +# -------------------------------------------------- Format requires section +sub format_rpmRequires { + my @tokeninfo=@_; + my $aref; + my $text; + if ($mode eq 'make_rpm') { + while ($aref=$parser->get_token()) { + if ($aref->[0] eq 'E' && $aref->[1] eq 'rpmRequires') { + last; + } + elsif ($aref->[0] eq 'S') { + $text.=$aref->[4]; + } + elsif ($aref->[0] eq 'E') { + $text.=$aref->[2]; + } + else { + $text.=$aref->[1]; + } + } + } + else { + $parser->get_tag('/rpmRequires'); + return ''; + } + return ''.$text.''; +} # -------------------------------------------------- Format directories section sub format_directories { my $text=$parser->get_text('/directories'); @@ -773,7 +944,10 @@ sub format_directories { } elsif ($mode eq 'install') { return "\n".'directories:'."\n".$text; - } + } + elsif ($mode eq 'rpm_file_list') { + return $text; + } else { return ''; } @@ -784,6 +958,8 @@ sub format_directory { $targetdir='';$categoryname='';$description=''; $parser->get_text('/directory'); $parser->get_tag('/directory'); + $directory_count++; + $categorycount{$categoryname}++; if ($mode eq 'html') { my @a; @a=($targetdir=~/\//g); @@ -791,9 +967,10 @@ sub format_directory { $dpathlength=$d if $d>$dpathlength; my $thtml=$targetdir; $thtml=~s/\//\<\/td\>\/g; + my ($chmod,$chown)=split(/\s/,$categoryhash{$categoryname}); return $directory="\n". "$categoryname". - " ". + " ". "$chmod
    $chown". "$thtml". "". @@ -807,6 +984,9 @@ sub format_directory { return "\t".'install '.$categoryhash{$categoryname}.' -d '. $targetroot.'/'.$targetdir."\n"; } + elsif ($mode eq 'rpm_file_list') { + return $targetroot.'/'.$targetdir."\n"; + } else { return ''; } @@ -886,8 +1066,14 @@ sub format_files { foreach my $bi (@buildinfo) { my ($target,$source,$command,$trigger,@deps)=split(/\;/,$bi); $tword=''; $tword=' alwaysrun' if $trigger eq 'always run'; - $command=~s/\/([^\/]*)$//; - $command2="cd $command; sh ./$1;\\"; + if ($command!~/\s/) { + $command=~s/\/([^\/]*)$//; + $command2="cd $command; sh ./$1;\\"; + } + else { + $command=~s/(.*?\/)([^\/]+\s+.*)$/$1/; + $command2="cd $command; sh ./$2;\\"; + } my $depstring; my $depstring2="\t\t\@echo '';\\\n"; my $olddep; @@ -923,6 +1109,9 @@ sub format_files { $binfo."\n". "alwaysrun:\n\n"; } + elsif ($mode eq 'rpm_file_list') { + return $text; + } else { return ''; } @@ -953,12 +1142,24 @@ sub format_file { $note=''; $build=''; $status=''; $dependencies=''; my $text=&trim($parser->get_text('/file')); 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) { $parser->get_tag('/file'); if ($mode eq 'html') { return ($file="\n". "". - " ". + " ". "". "$categoryname
    ". @@ -984,10 +1185,10 @@ sub format_file { foreach my $dep (@deps) { $depstring.=<get_tag('/link'); if ($mode eq 'html') { my @targets=map {s/^\s*//;s/\s$//;$_} split(/\;/,$target); + $link_count+=scalar(@targets); foreach my $tgt (@targets) { + $categorycount{$categoryname}++; push @links,("\n". "". - " ". + " ". "". "$categoryname". @@ -1112,11 +1328,20 @@ sub format_link { elsif ($mode eq 'install') { my @targets=map {s/^\s*//;s/\s$//;$_} split(/\;/,$target); foreach my $tgt (@targets) { - push @links,"\t".'ln -fs /'.$linkto.' /'.$targetroot.$tgt. + push @links,"\t".'ln -fs /'.$linkto.' '.$targetroot.'/'.$tgt. "\n"; } +# return join('',@links); return ''; } + elsif ($mode eq 'rpm_file_list') { + my @linklocs; + my @targets=map {s/^\s*//;s/\s$//;$_} split(/\;/,$target); + foreach my $tgt (@targets) { + push @linklocs,''.$targetroot.'/'.$tgt."\n"; + } + return join('',@linklocs); + } else { return ''; } @@ -1132,11 +1357,27 @@ sub format_fileglob { $filenames=''; my $text=&trim($parser->get_text('/fileglob')); 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) { $parser->get_tag('/fileglob'); if ($mode eq 'html') { return $fileglob="\n". - " ". @@ -1158,11 +1399,25 @@ sub format_fileglob { # "\nEND FILEGLOB"; } elsif ($mode eq 'install') { + my $eglob=$glob; + if ($glob eq '*') { + $eglob='[^C][^V][^S]'.$glob; + } return "\t".'install '. $categoryhash{$categoryname}.' '. - $sourceroot.'/'.$sourcedir.'[^C][^V][^S]'.$glob.' '. + $sourceroot.'/'.$sourcedir.$eglob.' '. $targetroot.'/'.$targetdir.'.'."\n"; } + elsif ($mode eq 'rpm_file_list') { + my $eglob=$glob; + if ($glob eq '*') { + $eglob='[^C][^V][^S]'.$glob; + } + my $targetdir2=$targetdir;$targetdir2=~s/\/$//; + my @gfiles=map {s/^.*\///;"$targetroot/$targetdir2/$_\n"} + glob("$sourceroot/$sourcedir/$eglob"); + return join('',@gfiles); + } else { return ''; } @@ -1296,6 +1551,16 @@ sub format_filenames { } 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 sub format_linkto { my @tokeninfo=@_;