--- loncom/build/lpml_parse.pl 2001/12/12 23:20:47 1.30 +++ loncom/build/lpml_parse.pl 2002/03/22 02:09:41 1.42 @@ -3,7 +3,7 @@ # The LearningOnline Network with CAPA # lpml_parse.pl - Linux Packaging Markup Language parser # -# $Id: lpml_parse.pl,v 1.30 2001/12/12 23:20:47 harris41 Exp $ +# $Id: lpml_parse.pl,v 1.42 2002/03/22 02:09:41 harris41 Exp $ # # Written by Scott Harrison, harris41@msu.edu # @@ -35,8 +35,9 @@ # 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,12/6 - Scott Harrison -# +# 12/2,12/3,12/4,12/5,12/6,12/13,12/19,12/29 - Scott Harrison +# YEAR=2002 +# 1/8,1/9,1/29,1/31,2/5,3/21 - Scott Harrison ### ############################################################################### @@ -128,8 +129,8 @@ if ($mode eq 'install' or $mode eq 'conf # 1st argument (mode) is: $mode # 2nd argument (category type) is: $categorytype # 3rd argument (distribution) is: $dist -# 4th argument (targetroot) is: described below -# 5th argument (sourceroot) is: described below +# 4th argument (sourceroot) is: described below +# 5th argument (targetroot) is: described below END } @@ -206,7 +207,7 @@ while ($token = $parser->get_token()) { $cleanstring.=$token->[4]; } if ($token->[4]=~/\/>$/) { - $hloc--; +# $hloc--; } } if ($token->[0] eq 'E') { @@ -279,10 +280,6 @@ 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 @buildinfo; @@ -298,6 +295,8 @@ $parser->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, @@ -319,6 +318,7 @@ $parser->{textify}={ rpmAutoReqProv => \&format_rpmAutoReqProv, rpmdescription => \&format_rpmdescription, rpmpre => \&format_rpmpre, + rpmRequires => \&format_rpmRequires, directories => \&format_directories, directory => \&format_directory, categoryname => \&format_categoryname, @@ -365,13 +365,6 @@ exit; # ------------------------ Final output at end of markup parsing and formatting sub end { if ($mode eq 'html') { - # START TEMP WAY -# my $totallinecount; -# my $totalbytecount; -# map {$totallinecount+=$linecount{$_}; -# $totalbytecount+=$bytecount{$_}} -# @categorynamelist; - # END TEMP WAY return "
 
". "Summary of Source Repository". "". @@ -399,23 +392,16 @@ sub end { "". "". "". + "". + "". join("\n",(map {"". - ""} + "". + ""} @categorynamelist)). "
File Category Count
IconNameNumber of OccurrencesNumber of Incorrect Counts
$_$categorycount{$_}
$_$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 ''; @@ -659,6 +645,9 @@ $text END } + elsif ($mode eq 'make_rpm') { + return $text; + } elsif ($mode eq 'text') { return $rpm=<$text +END + } else { return ''; } @@ -694,6 +688,11 @@ sub format_rpmName { elsif ($mode eq 'text') { return $rpmName="\nName : $text"; } + elsif ($mode eq 'make_rpm') { + return <$text +END + } else { return ''; } @@ -736,6 +735,11 @@ sub format_rpmVendor { elsif ($mode eq 'text') { return $rpmVendor="\nVendor : $text"; } + elsif ($mode eq 'make_rpm') { + return <$text +END + } else { return ''; } @@ -764,6 +768,11 @@ sub format_rpmCopyright { elsif ($mode eq 'text') { return $rpmCopyright="\nLicense : $text"; } + elsif ($mode eq 'make_rpm') { + return <$text +END + } else { return ''; } @@ -778,6 +787,11 @@ sub format_rpmGroup { elsif ($mode eq 'text') { return $rpmGroup="\nGroup : $text"; } + elsif ($mode eq 'make_rpm') { + return <Utilities/System +END + } else { return ''; } @@ -803,9 +817,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 ''; } @@ -824,6 +843,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 ''; } @@ -836,10 +862,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'); @@ -864,7 +922,10 @@ sub format_directories { } elsif ($mode eq 'install') { return "\n".'directories:'."\n".$text; - } + } + elsif ($mode eq 'rpm_file_list') { + return $text; + } else { return ''; } @@ -887,7 +948,9 @@ sub format_directory { my ($chmod,$chown)=split(/\s/,$categoryhash{$categoryname}); return $directory="\n". "$categoryname". - " ". + "". + " ". "$chmod
$chown". "$thtml". "". @@ -901,6 +964,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 ''; } @@ -980,8 +1046,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; @@ -1017,6 +1089,9 @@ sub format_files { $binfo."\n". "alwaysrun:\n\n"; } + elsif ($mode eq 'rpm_file_list') { + return $text; + } else { return ''; } @@ -1049,19 +1124,12 @@ sub format_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". "". - " ". @@ -1090,10 +1158,10 @@ sub format_file { foreach my $dep (@deps) { $depstring.=<get_text('/link')); - my @links; if ($linkto) { $parser->get_tag('/link'); if ($mode eq 'html') { @@ -1192,7 +1271,7 @@ sub format_link { $categorycount{$categoryname}++; push @links,("\n". "". - " ". ">/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". - " ". @@ -1294,6 +1370,16 @@ sub format_fileglob { $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 ''; } @@ -1369,6 +1455,7 @@ sub format_build { if ($text) { $parser->get_tag('/build'); $build=$sourceroot.'/'.$text.';'.$tokeninfo[2]{'trigger'}; + $build=~s/([^\\])\\\s+/$1/g; # allow for lines split onto new lines } return ''; } @@ -1427,6 +1514,16 @@ sub format_filenames { } return ''; } +# ----------------------------------------------- Format specialnotices 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=@_;