version 1.37, 2002/01/31 15:04:46
|
version 1.44, 2002/04/08 12:51:03
|
Line 1
|
Line 1
|
#!/usr/bin/perl |
#!/usr/bin/perl |
|
|
|
# -------------------------------------------------------- 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 |
# The LearningOnline Network with CAPA |
# lpml_parse.pl - Linux Packaging Markup Language parser |
# lpml_parse.pl - Linux Packaging Markup Language parser |
# |
# |
# $Id$ |
# $Id$ |
# |
# |
# Written by Scott Harrison, harris41@msu.edu |
# Written by Scott Harrison, codeharrison@yahoo.com |
# |
# |
# Copyright Michigan State University Board of Trustees |
# Copyright Michigan State University Board of Trustees |
# |
# |
Line 37
|
Line 42
|
# 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,12/6,12/13,12/19,12/29 - Scott Harrison |
# 12/2,12/3,12/4,12/5,12/6,12/13,12/19,12/29 - Scott Harrison |
# YEAR=2002 |
# YEAR=2002 |
# 1/8,1/9 - Scott Harrison |
# 1/8,1/9,1/29,1/31,2/5,3/21,4/8 - Scott Harrison |
# |
# |
### |
### |
|
|
Line 58
|
Line 63
|
# |
# |
# I am using a multiple pass-through approach to parsing |
# I am using a multiple pass-through approach to parsing |
# the lpml file. This saves memory and makes sure the server |
# 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. |
# This is meant to parse files meeting the lpml document type. |
# See lpml.dtd. LPML=Linux Packaging Markup Language. |
# See lpml.dtd. LPML=Linux Packaging Markup Language. |
Line 84 END
|
Line 90 END
|
|
|
# ------------------------------------------------- Grab command line arguments |
# ------------------------------------------------- Grab command line arguments |
|
|
my $mode; |
my $mode=''; |
if (@ARGV==5) { |
if (@ARGV==5) { |
$mode = shift @ARGV; |
$mode = shift @ARGV; |
} |
} |
Line 95 else {
|
Line 101 else {
|
exit -1; # exit with error status |
exit -1; # exit with error status |
} |
} |
|
|
my $categorytype; |
my $categorytype=''; |
if (@ARGV) { |
if (@ARGV) { |
$categorytype = shift @ARGV; |
$categorytype = shift @ARGV; |
} |
} |
|
|
my $dist; |
my $dist=''; |
if (@ARGV) { |
if (@ARGV) { |
$dist = shift @ARGV; |
$dist = shift @ARGV; |
} |
} |
|
|
my $targetroot; |
my $targetroot=''; |
my $sourceroot; |
my $sourceroot=''; |
my $targetrootarg; |
my $targetrootarg=''; |
my $sourcerootarg; |
my $sourcerootarg=''; |
if (@ARGV) { |
if (@ARGV) { |
$sourceroot = shift @ARGV; |
$sourceroot = shift @ARGV; |
} |
} |
Line 138 END
|
Line 144 END
|
# ---------------------------------------------------- Start first pass through |
# ---------------------------------------------------- Start first pass through |
my @parsecontents = <>; |
my @parsecontents = <>; |
my $parsestring = join('',@parsecontents); |
my $parsestring = join('',@parsecontents); |
my $outstring; |
my $outstring=''; |
|
|
# Need to make a pass through and figure out what defaults are |
# Need to make a pass through and figure out what defaults are |
# overrided. Top-down overriding strategy (leaves don't know |
# overrided. Top-down overriding strategy (leaves don't know |
Line 152 $parser = HTML::TokeParser->new(\$parses
|
Line 158 $parser = HTML::TokeParser->new(\$parses
|
die('can\'t create TokeParser object'); |
die('can\'t create TokeParser object'); |
$parser->xml_mode('1'); |
$parser->xml_mode('1'); |
my %hash; |
my %hash; |
my $key; |
my $key=''; |
while ($token = $parser->get_token()) { |
while ($token = $parser->get_token()) { |
if ($token->[0] eq 'S') { |
if ($token->[0] eq 'S') { |
$hloc++; |
$hloc++; |
Line 173 while ($token = $parser->get_token()) {
|
Line 179 while ($token = $parser->get_token()) {
|
} |
} |
|
|
# --------------------------------------------------- Start second pass through |
# --------------------------------------------------- Start second pass through |
undef $hloc; |
undef($hloc); |
undef @hierarchy; |
undef(@hierarchy); |
undef $parser; |
undef($parser); |
$hierarchy[0]=0; |
$hierarchy[0]=0; |
$parser = HTML::TokeParser->new(\$parsestring) or |
$parser = HTML::TokeParser->new(\$parsestring) or |
die('can\'t create TokeParser object'); |
die('can\'t create TokeParser object'); |
Line 208 while ($token = $parser->get_token()) {
|
Line 214 while ($token = $parser->get_token()) {
|
$cleanstring.=$token->[4]; |
$cleanstring.=$token->[4]; |
} |
} |
if ($token->[4]=~/\/>$/) { |
if ($token->[4]=~/\/>$/) { |
$hloc--; |
# $hloc--; |
} |
} |
} |
} |
if ($token->[0] eq 'E') { |
if ($token->[0] eq 'E') { |
Line 949 sub format_directory {
|
Line 955 sub format_directory {
|
my ($chmod,$chown)=split(/\s/,$categoryhash{$categoryname}); |
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 [$categoryname] verify.pl directory /$targetdir $categoryhash{$categoryname} --> </td>". |
"<td rowspan='2' bgcolor='#ffffff'><!-- POSTEVAL [$categoryname] ". |
|
"verify.pl directory /$targetdir $categoryhash{$categoryname} -->". |
|
" </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 1128 sub format_file {
|
Line 1136 sub format_file {
|
if ($mode eq 'html') { |
if ($mode eq 'html') { |
return ($file="\n<!-- FILESORT:$target -->". |
return ($file="\n<!-- FILESORT:$target -->". |
"<tr>". |
"<tr>". |
"<td><!-- POSTEVAL [$categoryname] verify.pl file '$sourcerootarg' ". |
"<td><!-- POSTEVAL [$categoryname] verify.pl file '$sourcerootarg' ". |
"'$targetrootarg' ". |
"'$targetrootarg' ". |
"'$source' '$target' ". |
"'$source' '$target' ". |
"$categoryhash{$categoryname} --> </td><td>". |
"$categoryhash{$categoryname} --> </td><td>". |
Line 1228 END
|
Line 1236 END
|
$logcmd.' && echo "'. |
$logcmd.' && echo "'. |
'Configuration source file does not exist '. |
'Configuration source file does not exist '. |
''.$sourceroot.'/'.$source.'"'. |
''.$sourceroot.'/'.$source.'"'. |
"$logcmd); } && perl verifymodown.pl ${targetroot}/${target} \"$categoryhash{$categoryname}\"$logcmd;\n\n"; |
"$logcmd); } && perl verifymodown.pl ${targetroot}/${target} \"". |
|
"$categoryhash{$categoryname}\"$logcmd;\n\n"; |
} |
} |
elsif ($mode eq 'build' && $build) { |
elsif ($mode eq 'build' && $build) { |
push @buildall,$sourceroot.'/'.$source; |
push @buildall,$sourceroot.'/'.$source; |
Line 1337 sub format_fileglob {
|
Line 1346 sub format_fileglob {
|
$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><!-- POSTEVAL [$categoryname] verify.pl fileglob '$sourcerootarg' ". |
"<td><!-- POSTEVAL [$categoryname] verify.pl fileglob '$sourcerootarg' ". |
"'$targetrootarg' ". |
"'$targetrootarg' ". |
"'$glob' '$sourcedir' '$filenames2' '$targetdir' ". |
"'$glob' '$sourcedir' '$filenames2' '$targetdir' ". |
"$categoryhash{$categoryname} --> </td>". |
"$categoryhash{$categoryname} --> </td>". |
Line 1453 sub format_build {
|
Line 1462 sub format_build {
|
if ($text) { |
if ($text) { |
$parser->get_tag('/build'); |
$parser->get_tag('/build'); |
$build=$sourceroot.'/'.$text.';'.$tokeninfo[2]{'trigger'}; |
$build=$sourceroot.'/'.$text.';'.$tokeninfo[2]{'trigger'}; |
|
$build=~s/([^\\])\\\s+/$1/g; # allow for lines split onto new lines |
} |
} |
return ''; |
return ''; |
} |
} |
Line 1511 sub format_filenames {
|
Line 1521 sub format_filenames {
|
} |
} |
return ''; |
return ''; |
} |
} |
# ------------------------------------------------ Format specialnotice section |
# ----------------------------------------------- Format specialnotices section |
sub format_specialnotices { |
sub format_specialnotices { |
$parser->get_tag('/specialnotices'); |
$parser->get_tag('/specialnotices'); |
return ''; |
return ''; |
Line 1545 sub trim {
|
Line 1555 sub trim {
|
|
|
# ----------------------------------- POD (plain old documentation, CPAN style) |
# ----------------------------------- POD (plain old documentation, CPAN style) |
|
|
|
=pod |
|
|
=head1 NAME |
=head1 NAME |
|
|
lpml_parse.pl - This is meant to parse files meeting the lpml document type. |
lpml_parse.pl - This is meant to parse LPML files (Linux Packaging Markup Language) |
See lpml.dtd. LPML=Linux Packaging Markup Language. |
|
|
|
=head1 SYNOPSIS |
=head1 SYNOPSIS |
|
|
Line 1612 linux
|
Line 1623 linux
|
|
|
Packaging/Administrative |
Packaging/Administrative |
|
|
|
=head1 AUTHOR |
|
|
|
Scott Harrison |
|
codeharrison@yahoo.com |
|
|
|
Please let me know how/if you are finding this script useful and |
|
any/all suggestions. -Scott |
|
|
=cut |
=cut |