--- loncom/build/lpml_parse.pl 2001/11/07 16:59:51 1.17
+++ loncom/build/lpml_parse.pl 2002/04/08 10:56:16 1.43
@@ -1,12 +1,50 @@
#!/usr/bin/perl
-# Scott Harrison
+# -------------------------------------------------------- Documentation notice
+# Run "perldoc ./lpml_parse.pl" in order to best view the software
+# documentation internalized in this program.
+
+# --------------------------------------------------------- License Information
+# The LearningOnline Network with CAPA
+# lpml_parse.pl - Linux Packaging Markup Language parser
+#
+# $Id: lpml_parse.pl,v 1.43 2002/04/08 10:56:16 harris41 Exp $
+#
+# Written by Scott Harrison, codeharrison@yahoo.com
+#
+# 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 - 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,12/13,12/19,12/29 - Scott Harrison
+# YEAR=2002
+# 1/8,1/9,1/29,1/31,2/5,3/21,4/8 - Scott Harrison
+#
+###
###############################################################################
## ##
@@ -25,7 +63,8 @@
#
# I am using a multiple pass-through approach to parsing
# the lpml file. This saves memory and makes sure the server
-# will never be overloaded.
+# will never be overloaded. At some point, I expect the
+# first two steps will be implemented with my XFML
#
# This is meant to parse files meeting the lpml document type.
# See lpml.dtd. LPML=Linux Packaging Markup Language.
@@ -46,12 +85,12 @@ Only the 1st argument is mandatory for t
Example:
cat ../../doc/loncapafiles.lpml |\\
-perl lpml_parse.pl html default /home/sherbert/loncapa /tmp/install
+perl lpml_parse.pl html development default /home/sherbert/loncapa /tmp/install
END
# ------------------------------------------------- Grab command line arguments
-my $mode;
+my $mode='';
if (@ARGV==5) {
$mode = shift @ARGV;
}
@@ -62,18 +101,20 @@ else {
exit -1; # exit with error status
}
-my $categorytype;
+my $categorytype='';
if (@ARGV) {
$categorytype = shift @ARGV;
}
-my $dist;
+my $dist='';
if (@ARGV) {
$dist = shift @ARGV;
}
-my $targetroot;
-my $sourceroot;
+my $targetroot='';
+my $sourceroot='';
+my $targetrootarg='';
+my $sourcerootarg='';
if (@ARGV) {
$sourceroot = shift @ARGV;
}
@@ -82,6 +123,10 @@ if (@ARGV) {
}
$sourceroot=~s/\/$//;
$targetroot=~s/\/$//;
+$sourcerootarg=$sourceroot;
+$targetrootarg=$targetroot;
+
+my $logcmd='| tee -a WARNINGS';
my $invocation;
# --------------------------------------------------- Record program invocation
@@ -91,15 +136,15 @@ 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
}
# ---------------------------------------------------- Start first pass through
my @parsecontents = <>;
my $parsestring = join('',@parsecontents);
-my $outstring;
+my $outstring='';
# Need to make a pass through and figure out what defaults are
# overrided. Top-down overriding strategy (leaves don't know
@@ -113,7 +158,7 @@ $parser = HTML::TokeParser->new(\$parses
die('can\'t create TokeParser object');
$parser->xml_mode('1');
my %hash;
-my $key;
+my $key='';
while ($token = $parser->get_token()) {
if ($token->[0] eq 'S') {
$hloc++;
@@ -134,9 +179,9 @@ while ($token = $parser->get_token()) {
}
# --------------------------------------------------- Start second pass through
-undef $hloc;
-undef @hierarchy;
-undef $parser;
+undef($hloc);
+undef(@hierarchy);
+undef($parser);
$hierarchy[0]=0;
$parser = HTML::TokeParser->new(\$parsestring) or
die('can\'t create TokeParser object');
@@ -169,7 +214,7 @@ while ($token = $parser->get_token()) {
$cleanstring.=$token->[4];
}
if ($token->[4]=~/\/>$/) {
- $hloc--;
+# $hloc--;
}
}
if ($token->[0] eq 'E') {
@@ -188,11 +233,13 @@ $cleanstring=~s/\>\s*\n\s*\\>\new(\$cleans
$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,
category => \&format_category,
+ abbreviation => \&format_abbreviation,
targetdir => \&format_targetdir,
chown => \&format_chown,
chmod => \&format_chmod,
@@ -266,6 +325,7 @@ $parser->{textify}={
rpmAutoReqProv => \&format_rpmAutoReqProv,
rpmdescription => \&format_rpmdescription,
rpmpre => \&format_rpmpre,
+ rpmRequires => \&format_rpmRequires,
directories => \&format_directories,
directory => \&format_directory,
categoryname => \&format_categoryname,
@@ -312,7 +372,43 @@ exit;
# ------------------------ Final output at end of markup parsing and formatting
sub end {
if ($mode eq 'html') {
- return "
THE END\n";
+ 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." | ".
+ "
".
+ "
".
+ "".
+ "File Category Count".
+ "Icon | Name | Number of Occurrences | ".
+ "Number of Incorrect Counts | ".
+ "
".
+ join("\n",(map {" | ".
+ "$_ | $categorycount{$_} | ".
+ " |
"}
+ @categorynamelist)).
+ "
".
+ "