Annotation of loncom/build/lpml_parse.pl, revision 1.42

1.1       harris41    1: #!/usr/bin/perl
1.2       albertel    2: 
1.28      harris41    3: # The LearningOnline Network with CAPA
                      4: # lpml_parse.pl - Linux Packaging Markup Language parser
                      5: #
1.42    ! harris41    6: # $Id: lpml_parse.pl,v 1.41 2002/03/22 01:55:04 harris41 Exp $
1.28      harris41    7: #
                      8: # Written by Scott Harrison, harris41@msu.edu
                      9: #
                     10: # Copyright Michigan State University Board of Trustees
                     11: #
                     12: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                     13: #
                     14: # LON-CAPA is free software; you can redistribute it and/or modify
                     15: # it under the terms of the GNU General Public License as published by
                     16: # the Free Software Foundation; either version 2 of the License, or
                     17: # (at your option) any later version.
                     18: #
                     19: # LON-CAPA is distributed in the hope that it will be useful,
                     20: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     21: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     22: # GNU General Public License for more details.
                     23: #
                     24: # You should have received a copy of the GNU General Public License
                     25: # along with LON-CAPA; if not, write to the Free Software
                     26: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     27: #
                     28: # /home/httpd/html/adm/gpl.txt
                     29: #
                     30: # http://www.lon-capa.org/
                     31: #
1.4       harris41   32: # YEAR=2001
1.2       albertel   33: # May 2001
1.3       harris41   34: # 06/19/2001,06/20,06/24 - Scott Harrison
1.5       harris41   35: # 9/5/2001,9/6,9/7,9/8 - Scott Harrison
1.14      harris41   36: # 9/17,9/18 - Scott Harrison
1.21      harris41   37: # 11/4,11/5,11/6,11/7,11/16,11/17 - Scott Harrison
1.35      harris41   38: # 12/2,12/3,12/4,12/5,12/6,12/13,12/19,12/29 - Scott Harrison
                     39: # YEAR=2002
1.41      harris41   40: # 1/8,1/9,1/29,1/31,2/5,3/21 - Scott Harrison
1.18      harris41   41: ###
1.3       harris41   42: 
1.4       harris41   43: ###############################################################################
                     44: ##                                                                           ##
                     45: ## ORGANIZATION OF THIS PERL SCRIPT                                          ##
                     46: ## 1. Notes                                                                  ##
                     47: ## 2. Get command line arguments                                             ##
                     48: ## 3. First pass through (grab distribution-specific information)            ##
                     49: ## 4. Second pass through (parse out what is not necessary)                  ##
                     50: ## 5. Third pass through (translate markup according to specified mode)      ##
1.14      harris41   51: ## 6. Functions (most all just format contents of different markup tags)     ##
                     52: ## 7. POD (plain old documentation, CPAN style)                              ##
1.4       harris41   53: ##                                                                           ##
                     54: ###############################################################################
                     55: 
                     56: # ----------------------------------------------------------------------- Notes
                     57: #
1.3       harris41   58: # I am using a multiple pass-through approach to parsing
                     59: # the lpml file.  This saves memory and makes sure the server
                     60: # will never be overloaded.
1.4       harris41   61: #
                     62: # This is meant to parse files meeting the lpml document type.
                     63: # See lpml.dtd.  LPML=Linux Packaging Markup Language.
1.2       albertel   64: 
1.1       harris41   65: use HTML::TokeParser;
1.2       albertel   66: 
1.3       harris41   67: my $usage=<<END;
                     68: **** ERROR ERROR ERROR ERROR ****
                     69: Usage is for lpml file to come in through standard input.
                     70: 1st argument is the mode of parsing.
1.4       harris41   71: 2nd argument is the category permissions to use (runtime or development)
                     72: 3rd argument is the distribution (default,redhat6.2,debian2.2,redhat7.1,etc).
                     73: 4th argument is to manually specify a sourceroot.
                     74: 5th argument is to manually specify a targetroot.
1.3       harris41   75: 
                     76: Only the 1st argument is mandatory for the program to run.
                     77: 
                     78: Example:
                     79: 
                     80: cat ../../doc/loncapafiles.lpml |\\
1.25      harris41   81: perl lpml_parse.pl html development default /home/sherbert/loncapa /tmp/install
1.3       harris41   82: END
                     83: 
                     84: # ------------------------------------------------- Grab command line arguments
                     85: 
                     86: my $mode;
1.4       harris41   87: if (@ARGV==5) {
1.3       harris41   88:     $mode = shift @ARGV;
                     89: }
                     90: else {
1.4       harris41   91:     @ARGV=();shift @ARGV;
1.3       harris41   92:     while(<>){} # throw away the input to avoid broken pipes
                     93:     print $usage;
                     94:     exit -1; # exit with error status
                     95: }
                     96: 
1.4       harris41   97: my $categorytype;
                     98: if (@ARGV) {
                     99:     $categorytype = shift @ARGV;
                    100: }
                    101: 
1.3       harris41  102: my $dist;
                    103: if (@ARGV) {
                    104:     $dist = shift @ARGV;
                    105: }
1.2       albertel  106: 
1.3       harris41  107: my $targetroot;
                    108: my $sourceroot;
1.27      harris41  109: my $targetrootarg;
                    110: my $sourcerootarg;
1.3       harris41  111: if (@ARGV) {
1.4       harris41  112:     $sourceroot = shift @ARGV;
1.3       harris41  113: }
                    114: if (@ARGV) {
1.4       harris41  115:     $targetroot = shift @ARGV;
1.3       harris41  116: }
1.4       harris41  117: $sourceroot=~s/\/$//;
                    118: $targetroot=~s/\/$//;
1.27      harris41  119: $sourcerootarg=$sourceroot;
                    120: $targetrootarg=$targetroot;
1.3       harris41  121: 
1.19      harris41  122: my $logcmd='| tee -a WARNINGS';
                    123: 
1.5       harris41  124: my $invocation;
                    125: # --------------------------------------------------- Record program invocation
1.17      harris41  126: if ($mode eq 'install' or $mode eq 'configinstall' or $mode eq 'build') {
1.5       harris41  127:     $invocation=(<<END);
                    128: # Invocation: STDINPUT | lpml_parse.pl
                    129: #             1st argument (mode) is: $mode
                    130: #             2nd argument (category type) is: $categorytype
                    131: #             3rd argument (distribution) is: $dist
1.36      harris41  132: #             4th argument (sourceroot) is: described below
                    133: #             5th argument (targetroot) is: described below
1.5       harris41  134: END
                    135: }
                    136: 
1.3       harris41  137: # ---------------------------------------------------- Start first pass through
1.2       albertel  138: my @parsecontents = <>;
                    139: my $parsestring = join('',@parsecontents);
                    140: my $outstring;
                    141: 
1.3       harris41  142: # Need to make a pass through and figure out what defaults are
                    143: # overrided.  Top-down overriding strategy (leaves don't know
                    144: # about distant leaves).
                    145: 
                    146: my @hierarchy;
                    147: $hierarchy[0]=0;
                    148: my $hloc=0;
                    149: my $token;
                    150: $parser = HTML::TokeParser->new(\$parsestring) or
                    151:     die('can\'t create TokeParser object');
                    152: $parser->xml_mode('1');
                    153: my %hash;
                    154: my $key;
                    155: while ($token = $parser->get_token()) {
                    156:     if ($token->[0] eq 'S') {
                    157: 	$hloc++;
                    158: 	$hierarchy[$hloc]++;
                    159: 	$key=$token->[1].join(',',@hierarchy[0..($hloc-1)]);
                    160: 	my $thisdist=' '.$token->[2]{'dist'}.' ';
                    161: 	if ($thisdist eq ' default ') {
                    162: 	    $hash{$key}=1; # there is a default setting for this key
                    163: 	}
                    164: 	elsif ($dist && $hash{$key}==1 && $thisdist=~/\s$dist\s/) {
                    165: 	    $hash{$key}=2; # disregard default setting for this key if
                    166: 	                   # there is a directly requested distribution match
                    167: 	}
                    168:     }
                    169:     if ($token->[0] eq 'E') {
                    170: 	$hloc--;
                    171:     }
                    172: }
                    173: 
                    174: # --------------------------------------------------- Start second pass through
                    175: undef $hloc;
                    176: undef @hierarchy;
                    177: undef $parser;
                    178: $hierarchy[0]=0;
                    179: $parser = HTML::TokeParser->new(\$parsestring) or
                    180:     die('can\'t create TokeParser object');
                    181: $parser->xml_mode('1');
                    182: my $cleanstring;
                    183: while ($token = $parser->get_token()) {
                    184:     if ($token->[0] eq 'S') {
                    185: 	$hloc++;
                    186: 	$hierarchy[$hloc]++;
                    187: 	$key=$token->[1].join(',',@hierarchy[0..($hloc-1)]);
                    188: 	my $thisdist=' '.$token->[2]{'dist'}.' ';
1.4       harris41  189: 	# This conditional clause is set up to ignore two sets
                    190: 	# of invalid conditions before accepting entry into
                    191: 	# the cleanstring.
1.3       harris41  192: 	if ($hash{$key}==2 and
                    193: 	    !($thisdist eq '  ' or $thisdist =~/\s$dist\s/)) {
                    194: 	    if ($token->[4]!~/\/>$/) {
                    195: 		$parser->get_tag('/'.$token->[1]);
                    196: 		$hloc--;
                    197: 	    }
                    198: 	}
                    199: 	elsif ($thisdist ne '  ' and $thisdist!~/\s$dist\s/ and
                    200: 	       !($thisdist eq ' default ' and $hash{$key}!=2)) {
                    201: 	    if ($token->[4]!~/\/>$/) {
                    202: 		$parser->get_tag('/'.$token->[1]);
                    203: 		$hloc--;
                    204: 	    }
                    205: 	}
                    206: 	else {
                    207: 	    $cleanstring.=$token->[4];
                    208: 	}
                    209: 	if ($token->[4]=~/\/>$/) {
1.39      harris41  210: #	    $hloc--;
1.3       harris41  211: 	}
                    212:     }
                    213:     if ($token->[0] eq 'E') {
                    214: 	$cleanstring.=$token->[2];
                    215: 	$hloc--;
                    216:     }
                    217:     if ($token->[0] eq 'T') {
                    218: 	$cleanstring.=$token->[1];
                    219:     }
                    220: }
                    221: $cleanstring=&trim($cleanstring);
1.10      harris41  222: $cleanstring=~s/\>\s*\n\s*\</\>\</g;
                    223: 
1.3       harris41  224: # ---------------------------------------------------- Start final pass through
                    225: 
                    226: # storage variables
                    227: my $lpml;
                    228: my $categories;
1.29      harris41  229: my @categorynamelist;
1.3       harris41  230: my $category;
                    231: my $category_att_name;
                    232: my $category_att_type;
                    233: my $chown;
                    234: my $chmod;
1.25      harris41  235: my $abbreviation; # space-free abbreviation; esp. for image names
1.3       harris41  236: my $rpm;
                    237: my $rpmSummary;
                    238: my $rpmName;
                    239: my $rpmVersion;
                    240: my $rpmRelease;
                    241: my $rpmVendor;
                    242: my $rpmBuildRoot;
                    243: my $rpmCopyright;
                    244: my $rpmGroup;
                    245: my $rpmSource;
                    246: my $rpmAutoReqProv;
                    247: my $rpmdescription;
                    248: my $rpmpre;
                    249: my $directories;
                    250: my $directory;
                    251: my $targetdirs;
                    252: my $targetdir;
                    253: my $categoryname;
                    254: my $description;
                    255: my $files;
                    256: my $fileglobs;
                    257: my $links;
                    258: my $file;
                    259: my $link;
                    260: my $fileglob;
                    261: my $sourcedir;
                    262: my $targets;
                    263: my $target;
                    264: my $source;
                    265: my $note;
                    266: my $build;
1.14      harris41  267: my $buildlink;
1.3       harris41  268: my $commands;
                    269: my $command;
                    270: my $status;
                    271: my $dependencies;
                    272: my $dependency;
1.4       harris41  273: my @links;
                    274: my %categoryhash;
1.26      harris41  275: my $dpathlength;
                    276: my %fab; # file category abbreviation
1.29      harris41  277: my $directory_count;
                    278: my $file_count;
                    279: my $link_count;
                    280: my $fileglob_count;
                    281: my $fileglobnames_count;
                    282: my %categorycount;
1.3       harris41  283: 
1.11      harris41  284: my @buildall;
1.12      harris41  285: my @buildinfo;
                    286: 
                    287: my @configall;
1.11      harris41  288: 
1.3       harris41  289: # Make new parser with distribution specific input
                    290: undef $parser;
                    291: $parser = HTML::TokeParser->new(\$cleanstring) or
                    292:     die('can\'t create TokeParser object');
                    293: $parser->xml_mode('1');
                    294: 
                    295: # Define handling methods for mode-dependent text rendering
1.26      harris41  296: 
1.3       harris41  297: $parser->{textify}={
1.31      harris41  298:     specialnotices => \&format_specialnotices,
                    299:     specialnotice => \&format_specialnotice,
1.3       harris41  300:     targetroot => \&format_targetroot,
                    301:     sourceroot => \&format_sourceroot,
                    302:     categories => \&format_categories,
                    303:     category => \&format_category,
1.25      harris41  304:     abbreviation => \&format_abbreviation,
1.3       harris41  305:     targetdir => \&format_targetdir,
                    306:     chown => \&format_chown,
                    307:     chmod => \&format_chmod,
                    308:     rpm => \&format_rpm,
                    309:     rpmSummary => \&format_rpmSummary,
                    310:     rpmName => \&format_rpmName,
                    311:     rpmVersion => \&format_rpmVersion,
                    312:     rpmRelease => \&format_rpmRelease,
                    313:     rpmVendor => \&format_rpmVendor,
                    314:     rpmBuildRoot => \&format_rpmBuildRoot,
                    315:     rpmCopyright => \&format_rpmCopyright,
                    316:     rpmGroup => \&format_rpmGroup,
                    317:     rpmSource => \&format_rpmSource,
                    318:     rpmAutoReqProv => \&format_rpmAutoReqProv,
                    319:     rpmdescription => \&format_rpmdescription,
                    320:     rpmpre => \&format_rpmpre,
1.35      harris41  321:     rpmRequires => \&format_rpmRequires,
1.3       harris41  322:     directories => \&format_directories,
                    323:     directory => \&format_directory,
                    324:     categoryname => \&format_categoryname,
                    325:     description => \&format_description,
                    326:     files => \&format_files,
                    327:     file => \&format_file,
                    328:     fileglob => \&format_fileglob,
1.4       harris41  329:     links => \&format_links,
1.3       harris41  330:     link => \&format_link,
                    331:     linkto => \&format_linkto,
                    332:     source => \&format_source,
                    333:     target => \&format_target,
                    334:     note => \&format_note,
                    335:     build => \&format_build,
                    336:     status => \&format_status,
                    337:     dependencies => \&format_dependencies,
1.14      harris41  338:     buildlink => \&format_buildlink,
1.3       harris41  339:     glob => \&format_glob,
                    340:     sourcedir => \&format_sourcedir,
                    341:     filenames => \&format_filenames,
                    342:     };
                    343: 
                    344: my $text;
                    345: my $token;
                    346: undef $hloc;
                    347: undef @hierarchy;
                    348: my $hloc;
                    349: my @hierarchy2;
                    350: while ($token = $parser->get_tag('lpml')) {
                    351:     &format_lpml(@{$token});
                    352:     $text = &trim($parser->get_text('/lpml'));
                    353:     $token = $parser->get_tag('/lpml');
                    354:     print $lpml; 
                    355:     print "\n";
1.4       harris41  356: #    $text=~s/\s*\n\s*\n\s*/\n/g;
1.3       harris41  357:     print $text;
                    358:     print "\n";
                    359:     print &end();
                    360: }
                    361: exit;
                    362: 
1.14      harris41  363: # ---------- Functions (most all just format contents of different markup tags)
                    364: 
                    365: # ------------------------ Final output at end of markup parsing and formatting
1.3       harris41  366: sub end {
                    367:     if ($mode eq 'html') {
1.29      harris41  368: 	return "<br />&nbsp;<br />".
                    369: 	    "<a name='summary' /><font size='+2'>Summary of Source Repository".
                    370: 	    "</font>".
                    371: 	    "<br />&nbsp;<br />".
                    372: 	    "<table border='1' cellpadding='5'>".
                    373: 	    "<caption>Files, Directories, and Symbolic Links</caption>".
                    374: 	    "<tr><td>Files (not referenced by globs)</td><td>$file_count</td>".
                    375: 	    "</tr>".
                    376: 	    "<tr><td>Files (referenced by globs)</td>".
                    377: 	    "<td>$fileglobnames_count</td>".
                    378: 	    "</tr>".
                    379: 	    "<tr><td>Total Files</td>".
                    380: 	    "<td>".($fileglobnames_count+$file_count)."</td>".
                    381: 	    "</tr>".
                    382: 	    "<tr><td>File globs</td>".
                    383: 	    "<td>".$fileglob_count."</td>".
                    384: 	    "</tr>".
                    385: 	    "<tr><td>Directories</td>".
                    386: 	    "<td>".$directory_count."</td>".
                    387: 	    "</tr>".
                    388: 	    "<tr><td>Symbolic links</td>".
                    389: 	    "<td>".$link_count."</td>".
                    390: 	    "</tr>".
                    391: 	    "</table>".
                    392: 	    "<table border='1' cellpadding='5'>".
                    393: 	    "<caption>File Category Count</caption>".
                    394: 	    "<tr><th>Icon</th><th>Name</th><th>Number of Occurrences</th>".
1.32      harris41  395: 	    "<th>Number of Incorrect Counts</th>".
                    396: 	    "</tr>".
1.29      harris41  397: 	    join("\n",(map {"<tr><td><img src='$fab{$_}.gif' ".
                    398: 		 "alt='$_ icon' /></td>".
1.32      harris41  399:  	         "<td>$_</td><td>$categorycount{$_}</td>".
                    400: 		 "<td><!-- POSTEVALINLINE $_ --></td></tr>"}
1.29      harris41  401: 		@categorynamelist)).
                    402: 	    "</table>".
                    403: 	    "</body></html>\n";
                    404: 
1.3       harris41  405:     }
1.4       harris41  406:     if ($mode eq 'install') {
                    407: 	return '';
                    408:     }
1.3       harris41  409: }
                    410: 
                    411: # ----------------------- Take in string to parse and the separation expression
                    412: sub extract_array {
                    413:     my ($stringtoparse,$sepexp) = @_;
                    414:     my @a=split(/$sepexp/,$stringtoparse);
                    415:     return \@a;
                    416: }
                    417: 
                    418: # --------------------------------------------------------- Format lpml section
                    419: sub format_lpml {
                    420:     my (@tokeninfo)=@_;
                    421:     my $date=`date`; chop $date;
                    422:     if ($mode eq 'html') {
1.24      harris41  423: 	$lpml=<<END;
                    424: <html>
                    425: <head>
1.25      harris41  426: <title>LPML Description Page
                    427: (dist=$dist, categorytype=$categorytype, $date)</title>
1.24      harris41  428: </head>
                    429: <body>
                    430: END
                    431: 	$lpml .= "<br /><font size='+2'>LPML Description Page (dist=$dist, ".
1.25      harris41  432: 	    "categorytype=$categorytype, $date)".
1.23      harris41  433: 	    "</font>";
                    434: 	$lpml .=<<END;
                    435: <ul>
1.24      harris41  436: <li><a href='#about'>About this file</a></li>
                    437: <li><a href='#ownperms'>File Type Ownership and Permissions
                    438: Descriptions</a></li>
                    439: <li><a href='#package'>Software Package Description</a></li>
                    440: <li><a href='#directories'>Directory Structure</a></li>
1.26      harris41  441: <li><a href='#files'>Files</a></li>
1.29      harris41  442: <li><a href='#summary'>Summary of Source Repository</a></li>
1.23      harris41  443: </ul>
                    444: END
                    445:         $lpml .=<<END;
1.24      harris41  446: <br />&nbsp;<br /><a name='about' />
1.23      harris41  447: <font size='+2'>About this file</font>
                    448: <p>
                    449: This file is generated dynamically by <tt>lpml_parse.pl</tt> as
1.28      harris41  450: part of a development compilation process.</p>
                    451: <p>LPML written by Scott Harrison (harris41\@msu.edu).
1.23      harris41  452: </p>
                    453: END
                    454:     }
                    455:     elsif ($mode eq 'text') {
                    456: 	$lpml = "LPML Description Page (dist=$dist, $date)";
                    457: 	$lpml .=<<END;
                    458: 
                    459: * About this file
                    460: * Software Package Description
                    461: * Directory Structure
                    462: * File Type Ownership and Permissions
1.26      harris41  463: * Files
1.23      harris41  464: END
                    465:         $lpml .=<<END;
                    466: 
                    467: About this file
                    468: 
                    469: This file is generated dynamically by lpml_parse.pl as
                    470: part of a development compilation process.  Author: Scott
                    471: Harrison (harris41\@msu.edu).
                    472: 
                    473: END
1.3       harris41  474:     }
1.4       harris41  475:     elsif ($mode eq 'install') {
                    476: 	print '# LPML install targets. Linux Packaging Markup Language,';
                    477: 	print ' by Scott Harrison 2001'."\n";
                    478: 	print '# This file was automatically generated on '.`date`;
1.5       harris41  479: 	print "\n".$invocation;
1.14      harris41  480: 	$lpml .= "SHELL=\"/bin/bash\"\n\n";
1.4       harris41  481:     }
1.16      harris41  482:     elsif ($mode eq 'configinstall') {
1.17      harris41  483: 	print '# LPML configuration file targets (configinstall).'."\n";
                    484: 	print '# Linux Packaging Markup Language,';
1.16      harris41  485: 	print ' by Scott Harrison 2001'."\n";
                    486: 	print '# This file was automatically generated on '.`date`;
                    487: 	print "\n".$invocation;
                    488: 	$lpml .= "SHELL=\"/bin/bash\"\n\n";
                    489:     }
1.11      harris41  490:     elsif ($mode eq 'build') {
1.14      harris41  491: 	$lpml = "# LPML build targets. Linux Packaging Markup Language,";
                    492: 	$lpml .= ' by Scott Harrison 2001'."\n";
1.11      harris41  493: 	$lpml .= '# This file was automatically generated on '.`date`;
1.17      harris41  494: 	$lpml .= "\n".$invocation;
1.11      harris41  495: 	$lpml .= "SHELL=\"/bin/sh\"\n\n";
                    496:     }
1.4       harris41  497:     else {
                    498: 	return '';
                    499:     }
1.3       harris41  500: }
                    501: # --------------------------------------------------- Format targetroot section
                    502: sub format_targetroot {
                    503:     my $text=&trim($parser->get_text('/targetroot'));
                    504:     $text=$targetroot if $targetroot;
                    505:     $parser->get_tag('/targetroot');
                    506:     if ($mode eq 'html') {
1.10      harris41  507: 	return $targetroot="\n<br />TARGETROOT: $text";
1.3       harris41  508:     }
1.17      harris41  509:     elsif ($mode eq 'install' or $mode eq 'build' or
                    510: 	   $mode eq 'configinstall') {
1.11      harris41  511: 	return '# TARGET INSTALL LOCATION is "'.$targetroot."\"\n";
                    512:     }
1.3       harris41  513:     else {
                    514: 	return '';
                    515:     }
                    516: }
                    517: # --------------------------------------------------- Format sourceroot section
                    518: sub format_sourceroot {
                    519:     my $text=&trim($parser->get_text('/sourceroot'));
                    520:     $text=$sourceroot if $sourceroot;
                    521:     $parser->get_tag('/sourceroot');
                    522:     if ($mode eq 'html') {
1.10      harris41  523: 	return $sourceroot="\n<br />SOURCEROOT: $text";
1.3       harris41  524:     }
1.17      harris41  525:     elsif ($mode eq 'install' or $mode eq 'build' or
                    526: 	   $mode eq 'configinstall') {
1.11      harris41  527: 	return '# SOURCE CODE LOCATION IS "'.$sourceroot."\"\n";;
                    528:     }
1.3       harris41  529:     else {
                    530: 	return '';
                    531:     }
                    532: }
                    533: # --------------------------------------------------- Format categories section
                    534: sub format_categories {
                    535:     my $text=&trim($parser->get_text('/categories'));
                    536:     $parser->get_tag('/categories');
                    537:     if ($mode eq 'html') {
1.24      harris41  538: 	return $categories="\n<br />&nbsp;<br />".
                    539: 	    "\n<a name='ownperms'>".
                    540: 	    "\n<font size='+2'>File Type Ownership and Permissions".
                    541: 	    " Descriptions</font>".
1.25      harris41  542: 	    "\n<p>This table shows what permissions and ownership settings ".
                    543: 	    "correspond to each category.</p>".
                    544: 	    "\n<table border='1' cellpadding='5' width='60%'>\n".
                    545: 	    "<tr>".
                    546: 	    "<th align='left' bgcolor='#ffffff'>Icon</th>".
                    547: 	    "<th align='left' bgcolor='#ffffff'>Category Name</th>".
                    548: 	    "<th align='left' bgcolor='#ffffff'>Permissions ".
                    549: 	    "($categorytype)</th>".
                    550: 	    "</tr>".
                    551: 	    "\n$text\n".
1.24      harris41  552: 	    "</table>\n";
                    553:     }
                    554:     elsif ($mode eq 'text') {
                    555: 	return $categories="\n".
                    556: 	    "\nFile Type Ownership and Permissions".
                    557: 	    " Descriptions".
1.25      harris41  558: 	    "\n$text".
1.24      harris41  559: 	    "\n";
1.3       harris41  560:     }
                    561:     else {
                    562: 	return '';
                    563:     }
                    564: }
                    565: # --------------------------------------------------- Format categories section
                    566: sub format_category {
                    567:     my (@tokeninfo)=@_;
                    568:     $category_att_name=$tokeninfo[2]->{'name'};
                    569:     $category_att_type=$tokeninfo[2]->{'type'};
1.25      harris41  570:     $abbreviation=''; $chmod='';$chown='';
1.3       harris41  571:     $parser->get_text('/category');
                    572:     $parser->get_tag('/category');
1.26      harris41  573:     $fab{$category_att_name}=$abbreviation;
1.3       harris41  574:     if ($mode eq 'html') {
1.25      harris41  575: 	if ($category_att_type eq $categorytype) {
1.29      harris41  576: 	    push @categorynamelist,$category_att_name;
1.27      harris41  577: 	    $categoryhash{$category_att_name}="$chmod $chown";
1.25      harris41  578: 	    return $category="<tr>".
                    579: 		"<td><img src='$abbreviation.gif' ".
                    580:    	        "alt='${category_att_name}' /></td>\n".
                    581: 		"<td>${category_att_name}</td>\n".
                    582: 		"<td>$chmod $chown</td>\n".
                    583: 		"</tr>".
                    584: 		"\n";
                    585: #	return $category="\n<br />CATEGORY $category_att_name ".
                    586: #	    "$category_att_type $chmod $chown";
                    587: 	}
1.3       harris41  588:     }
                    589:     else {
1.4       harris41  590: 	if ($category_att_type eq $categorytype) {
                    591: 	    my ($user,$group)=split(/\:/,$chown);
                    592: 	    $categoryhash{$category_att_name}='-o '.$user.' -g '.$group.
                    593: 		' -m '.$chmod;
                    594: 	}
1.3       harris41  595: 	return '';
                    596:     }
                    597: }
1.25      harris41  598: # --------------------------------------------------- Format categories section
                    599: sub format_abbreviation {
                    600:     my @tokeninfo=@_;
                    601:     $abbreviation='';
                    602:     my $text=&trim($parser->get_text('/abbreviation'));
                    603:     if ($text) {
                    604: 	$parser->get_tag('/abbreviation');
                    605: 	$abbreviation=$text;
                    606:     }
                    607:     return '';
                    608: }
1.3       harris41  609: # -------------------------------------------------------- Format chown section
                    610: sub format_chown {
                    611:     my @tokeninfo=@_;
                    612:     $chown='';
                    613:     my $text=&trim($parser->get_text('/chown'));
                    614:     if ($text) {
                    615: 	$parser->get_tag('/chown');
                    616: 	$chown=$text;
                    617:     }
                    618:     return '';
                    619: }
                    620: # -------------------------------------------------------- Format chmod section
                    621: sub format_chmod {
                    622:     my @tokeninfo=@_;
                    623:     $chmod='';
                    624:     my $text=&trim($parser->get_text('/chmod'));
                    625:     if ($text) {
                    626: 	$parser->get_tag('/chmod');
                    627: 	$chmod=$text;
                    628:     }
                    629:     return '';
                    630: }
                    631: # ---------------------------------------------------------- Format rpm section
                    632: sub format_rpm {
                    633:     my $text=&trim($parser->get_text('/rpm'));
                    634:     $parser->get_tag('/rpm');
                    635:     if ($mode eq 'html') {
1.23      harris41  636: 	return $rpm=<<END;
1.24      harris41  637: <br />&nbsp;<br />
                    638: <a name='package' />
1.23      harris41  639: <font size='+2'>Software Package Description</font>
                    640: <p>
                    641: <table bgcolor='#ffffff' border='0' cellpadding='10' cellspacing='0'>
                    642: <tr><td><pre>
                    643: $text
                    644: </pre></td></tr>
                    645: </table>
                    646: END
                    647:     }
1.35      harris41  648:     elsif ($mode eq 'make_rpm') {
                    649: 	return $text;
                    650:     }
1.23      harris41  651:     elsif ($mode eq 'text') {
                    652: 	return $rpm=<<END;
                    653: Software Package Description
                    654: 
                    655: $text
                    656: END
1.3       harris41  657:     }
                    658:     else {
                    659: 	return '';
                    660:     }
                    661: }
                    662: # --------------------------------------------------- Format rpmSummary section
                    663: sub format_rpmSummary {
                    664:     my $text=&trim($parser->get_text('/rpmSummary'));
                    665:     $parser->get_tag('/rpmSummary');
                    666:     if ($mode eq 'html') {
1.23      harris41  667: 	return $rpmSummary="\nSummary     : $text";
                    668:     }
                    669:     elsif ($mode eq 'text') {
                    670: 	return $rpmSummary="\nSummary     : $text";
1.3       harris41  671:     }
1.35      harris41  672:     elsif ($mode eq 'make_rpm') {
                    673: 	return <<END;
                    674: <summary>$text</summary>
                    675: END
                    676:     }
1.3       harris41  677:     else {
                    678: 	return '';
                    679:     }
                    680: }
                    681: # ------------------------------------------------------ Format rpmName section
                    682: sub format_rpmName {
                    683:     my $text=&trim($parser->get_text('/rpmName'));
                    684:     $parser->get_tag('/rpmName');
                    685:     if ($mode eq 'html') {
1.24      harris41  686: 	return $rpmName="\nName        : $text";
                    687:     }
                    688:     elsif ($mode eq 'text') {
                    689: 	return $rpmName="\nName        : $text";
1.3       harris41  690:     }
1.35      harris41  691:     elsif ($mode eq 'make_rpm') {
                    692: 	return <<END;
                    693: <name>$text</name>
                    694: END
                    695:     }
1.3       harris41  696:     else {
                    697: 	return '';
                    698:     }
                    699: }
                    700: # --------------------------------------------------- Format rpmVersion section
                    701: sub format_rpmVersion {
                    702:     my $text=$parser->get_text('/rpmVersion');
                    703:     $parser->get_tag('/rpmVersion');
                    704:     if ($mode eq 'html') {
1.24      harris41  705: 	return $rpmVersion="\nVersion     : $text";
                    706:     }
                    707:     elsif ($mode eq 'text') {
                    708: 	return $rpmVersion="\nVersion     : $text";
1.3       harris41  709:     }
                    710:     else {
                    711: 	return '';
                    712:     }
                    713: }
                    714: # --------------------------------------------------- Format rpmRelease section
                    715: sub format_rpmRelease {
                    716:     my $text=$parser->get_text('/rpmRelease');
                    717:     $parser->get_tag('/rpmRelease');
                    718:     if ($mode eq 'html') {
1.24      harris41  719: 	return $rpmRelease="\nRelease     : $text";
                    720:     }
                    721:     elsif ($mode eq 'text') {
                    722: 	return $rpmRelease="\nRelease     : $text";
1.3       harris41  723:     }
                    724:     else {
                    725: 	return '';
                    726:     }
                    727: }
                    728: # ---------------------------------------------------- Format rpmVendor section
                    729: sub format_rpmVendor {
                    730:     my $text=$parser->get_text('/rpmVendor');
                    731:     $parser->get_tag('/rpmVendor');
                    732:     if ($mode eq 'html') {
1.24      harris41  733: 	return $rpmVendor="\nVendor      : $text";
                    734:     }
                    735:     elsif ($mode eq 'text') {
                    736: 	return $rpmVendor="\nVendor      : $text";
1.3       harris41  737:     }
1.35      harris41  738:     elsif ($mode eq 'make_rpm') {
                    739: 	return <<END;
                    740: <vendor>$text</vendor>
                    741: END
                    742:     }
1.3       harris41  743:     else {
                    744: 	return '';
                    745:     }
                    746: }
                    747: # ------------------------------------------------- Format rpmBuildRoot section
                    748: sub format_rpmBuildRoot {
                    749:     my $text=$parser->get_text('/rpmBuildRoot');
                    750:     $parser->get_tag('/rpmBuildRoot');
                    751:     if ($mode eq 'html') {
1.24      harris41  752: 	return $rpmBuildRoot="\nBuild Root  : $text";
                    753:     }
                    754:     elsif ($mode eq 'text') {
                    755: 	return $rpmBuildRoot="\nBuild Root  : $text";
1.3       harris41  756:     }
                    757:     else {
                    758: 	return '';
                    759:     }
                    760: }
                    761: # ------------------------------------------------- Format rpmCopyright section
                    762: sub format_rpmCopyright {
                    763:     my $text=$parser->get_text('/rpmCopyright');
                    764:     $parser->get_tag('/rpmCopyright');
                    765:     if ($mode eq 'html') {
1.24      harris41  766: 	return $rpmCopyright="\nLicense     : $text";
                    767:     }
                    768:     elsif ($mode eq 'text') {
                    769: 	return $rpmCopyright="\nLicense     : $text";
1.3       harris41  770:     }
1.35      harris41  771:     elsif ($mode eq 'make_rpm') {
                    772: 	return <<END;
                    773: <copyright>$text</copyright>
                    774: END
                    775:     }
1.3       harris41  776:     else {
                    777: 	return '';
                    778:     }
                    779: }
                    780: # ----------------------------------------------------- Format rpmGroup section
                    781: sub format_rpmGroup {
                    782:     my $text=$parser->get_text('/rpmGroup');
                    783:     $parser->get_tag('/rpmGroup');
                    784:     if ($mode eq 'html') {
1.24      harris41  785: 	return $rpmGroup="\nGroup       : $text";
                    786:     }
                    787:     elsif ($mode eq 'text') {
                    788: 	return $rpmGroup="\nGroup       : $text";
1.3       harris41  789:     }
1.35      harris41  790:     elsif ($mode eq 'make_rpm') {
                    791: 	return <<END;
                    792: <group>Utilities/System</group>
                    793: END
                    794:     }
1.3       harris41  795:     else {
                    796: 	return '';
                    797:     }
                    798: }
                    799: # ---------------------------------------------------- Format rpmSource section
                    800: sub format_rpmSource {
                    801:     my $text=$parser->get_text('/rpmSource');
                    802:     $parser->get_tag('/rpmSource');
                    803:     if ($mode eq 'html') {
1.24      harris41  804: 	return $rpmSource="\nSource      : $text";
                    805:     }
                    806:     elsif ($mode eq 'text') {
                    807: 	return $rpmSource="\nSource      : $text";
1.3       harris41  808:     }
                    809:     else {
                    810: 	return '';
                    811:     }
                    812: }
                    813: # ----------------------------------------------- Format rpmAutoReqProv section
                    814: sub format_rpmAutoReqProv {
                    815:     my $text=$parser->get_text('/rpmAutoReqProv');
                    816:     $parser->get_tag('/rpmAutoReqProv');
                    817:     if ($mode eq 'html') {
1.24      harris41  818: 	return $rpmAutoReqProv="\nAutoReqProv : $text";
                    819:     }
1.35      harris41  820:     elsif ($mode eq 'text') {
1.24      harris41  821: 	return $rpmAutoReqProv="\nAutoReqProv : $text";
1.3       harris41  822:     }
1.35      harris41  823:     elsif ($mode eq 'make_rpm') {
                    824: 	return <<END;
                    825: <AutoReqProv>$text</AutoReqProv>
                    826: END
                    827:     }
1.3       harris41  828:     else {
                    829: 	return '';
                    830:     }
                    831: }
                    832: # ----------------------------------------------- Format rpmdescription section
                    833: sub format_rpmdescription {
                    834:     my $text=$parser->get_text('/rpmdescription');
                    835:     $parser->get_tag('/rpmdescription');
                    836:     if ($mode eq 'html') {
1.25      harris41  837: 	$text=~s/\n//g;
                    838: 	$text=~s/\\n/\n/g;
1.24      harris41  839: 	return $rpmdescription="\nDescription : $text";
                    840:     }
                    841:     elsif ($mode eq 'text') {
1.25      harris41  842: 	$text=~s/\n//g;
                    843: 	$text=~s/\\n/\n/g;
1.24      harris41  844: 	return $rpmdescription="\nDescription : $text";
1.3       harris41  845:     }
1.35      harris41  846:     elsif ($mode eq 'make_rpm') {
                    847: 	$text=~s/\n//g;
                    848: 	$text=~s/\\n/\n/g;
                    849: 	return <<END;
                    850: <description>$text</description>
                    851: END
                    852:     }
1.3       harris41  853:     else {
                    854: 	return '';
                    855:     }
                    856: }
                    857: # ------------------------------------------------------- Format rpmpre section
                    858: sub format_rpmpre {
                    859:     my $text=$parser->get_text('/rpmpre');
                    860:     $parser->get_tag('/rpmpre');
                    861:     if ($mode eq 'html') {
1.24      harris41  862: #	return $rpmpre="\n<br />RPMPRE $text";
                    863: 	return '';
1.3       harris41  864:     }
1.35      harris41  865:     elsif ($mode eq 'make_rpm') {
                    866: 	return <<END;
                    867: <pre>$text</pre>
                    868: END
                    869:     }
1.3       harris41  870:     else {
                    871: 	return '';
                    872:     }
                    873: }
1.35      harris41  874: # -------------------------------------------------- Format requires section
                    875: sub format_rpmRequires {
                    876:     my @tokeninfo=@_;
                    877:     my $aref;
                    878:     my $text;
                    879:     if ($mode eq 'make_rpm') {
                    880: 	while ($aref=$parser->get_token()) {
                    881: 	    if ($aref->[0] eq 'E' && $aref->[1] eq 'rpmRequires') {
                    882: 		last;
                    883: 	    }
                    884: 	    elsif ($aref->[0] eq 'S') {
                    885: 		$text.=$aref->[4];
                    886: 	    }
                    887: 	    elsif ($aref->[0] eq 'E') {
                    888: 		$text.=$aref->[2];
                    889: 	    }
                    890: 	    else {
                    891: 		$text.=$aref->[1];
                    892: 	    }
                    893: 	}
                    894:     }
                    895:     else {
                    896: 	$parser->get_tag('/rpmRequires');
                    897: 	return '';
                    898:     }
                    899:     return '<rpmRequires>'.$text.'</rpmRequires>';
                    900: }
1.3       harris41  901: # -------------------------------------------------- Format directories section
                    902: sub format_directories {
1.4       harris41  903:     my $text=$parser->get_text('/directories');
1.3       harris41  904:     $parser->get_tag('/directories');
                    905:     if ($mode eq 'html') {
1.26      harris41  906: 	$text=~s/\[\{\{\{\{\{DPATHLENGTH\}\}\}\}\}\]/$dpathlength/g;
1.24      harris41  907: 	return $directories="\n<br />&nbsp;<br />".
                    908: 	    "<a name='directories' />".
                    909: 	    "<font size='+2'>Directory Structure</font>".
1.26      harris41  910: 	    "\n<br />&nbsp;<br />".
                    911: 	    "<table border='1' cellpadding='3' cellspacing='0'>\n".
                    912: 	    "<tr><th bgcolor='#ffffff'>Category</th>".
                    913: 	    "<th bgcolor='#ffffff'>Status</th>\n".
                    914: 	    "<th bgcolor='#ffffff'>Expected Permissions & Ownership</th>\n".
                    915: 	    "<th bgcolor='#ffffff' colspan='$dpathlength'>Target Directory ".
                    916: 	    "Path</th></tr>\n".
                    917:  	    "\n$text\n</table><br />"."\n";
1.24      harris41  918:     }
                    919:     elsif ($mode eq 'text') {
                    920: 	return $directories="\nDirectory Structure\n$text\n".
                    921: 	    "\n";
1.3       harris41  922:     }
1.4       harris41  923:     elsif ($mode eq 'install') {
                    924: 	return "\n".'directories:'."\n".$text;
1.35      harris41  925:     }
                    926:     elsif ($mode eq 'rpm_file_list') {
                    927: 	return $text;
                    928:     }
1.3       harris41  929:     else {
                    930: 	return '';
                    931:     }
                    932: }
                    933: # ---------------------------------------------------- Format directory section
                    934: sub format_directory {
                    935:     my (@tokeninfo)=@_;
                    936:     $targetdir='';$categoryname='';$description='';
                    937:     $parser->get_text('/directory');
                    938:     $parser->get_tag('/directory');
1.29      harris41  939:     $directory_count++;
                    940:     $categorycount{$categoryname}++;
1.3       harris41  941:     if ($mode eq 'html') {
1.26      harris41  942: 	my @a;
                    943: 	@a=($targetdir=~/\//g);
                    944: 	my $d=scalar(@a)+1;
                    945: 	$dpathlength=$d if $d>$dpathlength;
                    946: 	my $thtml=$targetdir;
                    947: 	$thtml=~s/\//\<\/td\>\<td bgcolor='#ffffff'\>/g;
1.28      harris41  948: 	my ($chmod,$chown)=split(/\s/,$categoryhash{$categoryname});
1.26      harris41  949: 	return $directory="\n<tr><td rowspan='2' bgcolor='#ffffff'>".
                    950: 	    "$categoryname</td>".
1.41      harris41  951: 	    "<td rowspan='2' bgcolor='#ffffff'><!-- POSTEVAL [$categoryname] ".
                    952: 	    "verify.pl directory /$targetdir $categoryhash{$categoryname} -->".
                    953: 	    "&nbsp;</td>".
1.26      harris41  954: 	    "<td rowspan='2' bgcolor='#ffffff'>$chmod<br />$chown</td>".
                    955: 	    "<td bgcolor='#ffffff'>$thtml</td></tr>".
                    956: 	    "<tr><td bgcolor='#ffffff' colspan='[{{{{{DPATHLENGTH}}}}}]'>".
                    957: 	    "$description</td></tr>";
                    958:     }
                    959:     if ($mode eq 'text') {
                    960: 	return $directory="\nDIRECTORY $targetdir $categoryname ".
1.10      harris41  961: 	    "$description";
1.3       harris41  962:     }
1.4       harris41  963:     elsif ($mode eq 'install') {
1.8       harris41  964: 	return "\t".'install '.$categoryhash{$categoryname}.' -d '.
                    965: 	    $targetroot.'/'.$targetdir."\n";
1.4       harris41  966:     }
1.35      harris41  967:     elsif ($mode eq 'rpm_file_list') {
                    968: 	return $targetroot.'/'.$targetdir."\n";
                    969:     }
1.3       harris41  970:     else {
                    971: 	return '';
                    972:     }
                    973: }
                    974: # ---------------------------------------------------- Format targetdir section
                    975: sub format_targetdir {
                    976:     my @tokeninfo=@_;
                    977:     $targetdir='';
                    978:     my $text=&trim($parser->get_text('/targetdir'));
                    979:     if ($text) {
                    980: 	$parser->get_tag('/targetdir');
                    981: 	$targetdir=$text;
                    982:     }
                    983:     return '';
                    984: }
                    985: # ------------------------------------------------- Format categoryname section
                    986: sub format_categoryname {
                    987:     my @tokeninfo=@_;
                    988:     $categoryname='';
                    989:     my $text=&trim($parser->get_text('/categoryname'));
                    990:     if ($text) {
                    991: 	$parser->get_tag('/categoryname');
                    992: 	$categoryname=$text;
                    993:     }
                    994:     return '';
                    995: }
                    996: # -------------------------------------------------- Format description section
                    997: sub format_description {
                    998:     my @tokeninfo=@_;
                    999:     $description='';
1.10      harris41 1000:     my $text=&htmlsafe(&trim($parser->get_text('/description')));
1.3       harris41 1001:     if ($text) {
                   1002: 	$parser->get_tag('/description');
                   1003: 	$description=$text;
                   1004:     }
                   1005:     return '';
                   1006: }
                   1007: # -------------------------------------------------------- Format files section
                   1008: sub format_files {
1.4       harris41 1009:     my $text=$parser->get_text('/files');
1.3       harris41 1010:     $parser->get_tag('/files');
                   1011:     if ($mode eq 'html') {
1.24      harris41 1012: 	return $directories="\n<br />&nbsp;<br />".
                   1013: 	    "<a name='files' />".
1.26      harris41 1014: 	    "<font size='+2'>Files</font><br />&nbsp;<br />".
                   1015: 	    "<p>All source and target locations are relative to the ".
                   1016: 	    "sourceroot and targetroot values at the beginning of this ".
                   1017: 	    "document.</p>".
                   1018: 	    "\n<table border='1' cellpadding='5'>".
                   1019: 	    "<tr><th>Status</th><th colspan='2'>Category</th>".
                   1020: 	    "<th>Name/Location</th>".
                   1021: 	    "<th>Description</th><th>Notes</th></tr>".
                   1022: 	    "$text</table>\n".
1.24      harris41 1023: 	    "\n";
                   1024:     }
                   1025:     elsif ($mode eq 'text') {
                   1026: 	return $directories="\n".
                   1027: 	    "File and Directory Structure".
                   1028: 	    "\n$text\n".
                   1029: 	    "\n";
1.3       harris41 1030:     }
1.4       harris41 1031:     elsif ($mode eq 'install') {
                   1032: 	return "\n".'files:'."\n".$text.
                   1033: 	    "\n".'links:'."\n".join('',@links);
                   1034:     }
1.12      harris41 1035:     elsif ($mode eq 'configinstall') {
                   1036: 	return "\n".'configfiles: '.
                   1037: 	join(' ',@configall).
1.14      harris41 1038: 	"\n\n".$text.
                   1039: 	"\n\nalwaysrun:\n\n";
1.12      harris41 1040:     }
1.11      harris41 1041:     elsif ($mode eq 'build') {
                   1042: 	my $binfo;
                   1043: 	my $tword;
                   1044: 	my $command2;
                   1045: 	my @deps;
                   1046: 	foreach my $bi (@buildinfo) {
1.14      harris41 1047: 	    my ($target,$source,$command,$trigger,@deps)=split(/\;/,$bi);
1.11      harris41 1048: 	    $tword=''; $tword=' alwaysrun' if $trigger eq 'always run'; 
1.33      harris41 1049: 	    if ($command!~/\s/) {
                   1050: 		$command=~s/\/([^\/]*)$//;
                   1051: 		$command2="cd $command; sh ./$1;\\";
                   1052: 	    }
                   1053: 	    else {
                   1054: 		$command=~s/(.*?\/)([^\/]+\s+.*)$/$1/;
                   1055: 		$command2="cd $command; sh ./$2;\\";
                   1056: 	    }
1.11      harris41 1057: 	    my $depstring;
1.14      harris41 1058: 	    my $depstring2="\t\t\@echo '';\\\n";
                   1059: 	    my $olddep;
1.11      harris41 1060: 	    foreach my $dep (@deps) {
1.14      harris41 1061: 		unless ($olddep) {
                   1062: 		    $olddep=$deps[$#deps];
                   1063: 		}
1.11      harris41 1064: 		$depstring.="\telif !(test -r $command/$dep);\\\n";
                   1065: 		$depstring.="\t\tthen echo ".
1.14      harris41 1066: 		"\"**** WARNING **** missing the file: ".
1.19      harris41 1067:  	        "$command/$dep\"$logcmd;\\\n";
1.14      harris41 1068: 		$depstring.="\t\ttest -e $source || test -e $target || echo ".
                   1069: 		    "'**** ERROR **** neither source=$source nor target=".
1.19      harris41 1070: 		    "$target exist and they cannot be built'$logcmd;\\\n";
1.14      harris41 1071: 		$depstring.="\t\tmake -f Makefile.build ${source}___DEPS;\\\n";
                   1072: 		if ($olddep) {
                   1073: 		    $depstring2.="\t\tECODE=0;\\\n";
                   1074: 		    $depstring2.="\t\t! test -e $source && test -r $command/$olddep &&".
1.19      harris41 1075: 			" { perl filecompare.pl -b2 $command/$olddep $target ||  ECODE=\$\$?; } && { [ \$\$ECODE != \"2\" ] || echo \"**** WARNING **** dependency $command/$olddep is newer than target file $target; SOMETHING MAY BE WRONG\"$logcmd; };\\\n";
1.14      harris41 1076: 		}
                   1077: 		$olddep=$dep;
1.11      harris41 1078: 	    }
                   1079: 	    $binfo.="$source: $tword\n".
                   1080: 		"\t\@if !(echo \"\");\\\n\t\tthen echo ".
1.14      harris41 1081: 		"\"**** WARNING **** Strange shell. ".
1.19      harris41 1082:  	        "Check your path settings.\"$logcmd;\\\n".
1.11      harris41 1083: 		$depstring.
                   1084: 		"\telse \\\n\t\t$command2\n\tfi\n\n";
1.14      harris41 1085: 	    $binfo.="${source}___DEPS:\n".$depstring2."\t\tECODE=0;\n\n";
1.11      harris41 1086: 	}
                   1087: 	return 'all: '.join(' ',@buildall)."\n\n".
                   1088:   	        $text.
                   1089: 		$binfo."\n".
                   1090: 		"alwaysrun:\n\n";
                   1091:     }
1.35      harris41 1092:     elsif ($mode eq 'rpm_file_list') {
                   1093: 	return $text;
                   1094:     }
1.3       harris41 1095:     else {
                   1096: 	return '';
                   1097:     }
                   1098: }
                   1099: # ---------------------------------------------------- Format fileglobs section
                   1100: sub format_fileglobs {
                   1101: 
                   1102: }
                   1103: # -------------------------------------------------------- Format links section
1.4       harris41 1104: # deprecated.. currently <link></link>'s are included in <files></files>
1.3       harris41 1105: sub format_links {
1.4       harris41 1106:     my $text=$parser->get_text('/links');
                   1107:     $parser->get_tag('/links');
                   1108:     if ($mode eq 'html') {
1.10      harris41 1109: 	return $links="\n<br />BEGIN LINKS\n$text\n<br />END LINKS\n";
1.4       harris41 1110:     }
                   1111:     elsif ($mode eq 'install') {
                   1112: 	return "\n".'links:'."\n\t".$text;
                   1113:     }
                   1114:     else {
                   1115: 	return '';
                   1116:     }
1.1       harris41 1117: }
1.3       harris41 1118: # --------------------------------------------------------- Format file section
                   1119: sub format_file {
                   1120:     my @tokeninfo=@_;
                   1121:     $file=''; $source=''; $target=''; $categoryname=''; $description='';
                   1122:     $note=''; $build=''; $status=''; $dependencies='';
                   1123:     my $text=&trim($parser->get_text('/file'));
1.14      harris41 1124:     my $buildtest;
1.29      harris41 1125:     $file_count++;
                   1126:     $categorycount{$categoryname}++;
1.3       harris41 1127:     if ($source) {
                   1128: 	$parser->get_tag('/file');
                   1129: 	if ($mode eq 'html') {
1.26      harris41 1130: 	    return ($file="\n<!-- FILESORT:$target -->".
                   1131: 		    "<tr>".
1.41      harris41 1132:           "<td><!-- POSTEVAL [$categoryname] verify.pl file '$sourcerootarg' ".
1.28      harris41 1133: 		    "'$targetrootarg' ".
                   1134: 		    "'$source' '$target' ".
                   1135: 		    "$categoryhash{$categoryname} -->&nbsp;</td><td>".
1.27      harris41 1136: 		    "<img src='$fab{$categoryname}.gif' ".
1.26      harris41 1137: 		    "alt='$categoryname icon' /></td>".
1.27      harris41 1138: 		    "<td>$categoryname<br /><font size='-1'>".
                   1139: 		    $categoryhash{$categoryname}."</font></td>".
1.26      harris41 1140: 		    "<td>SOURCE: $source<br />TARGET: $target</td>".
                   1141: 		    "<td>$description</td>".
                   1142: 		    "<td>$note</td>".
                   1143: 		    "</tr>");
                   1144: #	    return ($file="\n<br />BEGIN FILE\n".
                   1145: #		"$source $target $categoryname $description $note " .
                   1146: #		"$build $status $dependencies" .
                   1147: #		"\nEND FILE");
1.3       harris41 1148: 	}
1.5       harris41 1149: 	elsif ($mode eq 'install' && $categoryname ne 'conf') {
1.14      harris41 1150: 	    if ($build) {
                   1151: 		my $bi=$sourceroot.'/'.$source.';'.$build.';'.
                   1152: 		    $dependencies;
                   1153: 		my ($source2,$command,$trigger,@deps)=split(/\;/,$bi);
                   1154: 		$tword=''; $tword=' alwaysrun' if $trigger eq 'always run'; 
                   1155: 		$command=~s/\/([^\/]*)$//;
                   1156: 		$command2="cd $command; sh ./$1;\\";
                   1157: 		my $depstring;
                   1158: 		foreach my $dep (@deps) {
                   1159: 		    $depstring.=<<END;
                   1160: 		ECODE=0; DEP=''; \\
1.34      harris41 1161: 		test -e $dep || (echo '**** WARNING **** cannot evaluate status of dependency $dep (for building ${sourceroot}/${source} with)'$logcmd); DEP="1"; \\
                   1162: 		[ -n DEP ] && { perl filecompare.pl -b2 $dep ${targetroot}/${target} || ECODE=\$\$?; } || DEP="1"; \\
1.14      harris41 1163: 		case "\$\$ECODE" in \\
1.34      harris41 1164: 			2) echo "**** WARNING **** dependency $dep is newer than target file ${targetroot}/${target}; you may want to run make build"$logcmd;; \\
1.14      harris41 1165: 		esac; \\
                   1166: END
                   1167: 		}
                   1168:                 chomp $depstring;
                   1169: 		$buildtest=<<END;
                   1170: 	\@if !(test -e "${sourceroot}/${source}") && !(test -e "${targetroot}/${target}"); then \\
1.19      harris41 1171: 		echo "**** ERROR **** ${sourceroot}/${source} is missing and is also not present at target location ${targetroot}/${target}; you must run make build"$logcmd; exit; \\
1.14      harris41 1172: END
                   1173:                 $buildtest.=<<END if $depstring;
                   1174: 	elif !(test -e "${sourceroot}/${source}"); then \\
                   1175: $depstring
                   1176: END
                   1177:                 $buildtest.=<<END;
                   1178: 	fi
                   1179: END
                   1180: 	    }
1.18      harris41 1181:             my $bflag='-b1';
                   1182:             $bflag='-b3' if $dependencies or $buildlink;
1.14      harris41 1183: 	    return <<END;
1.19      harris41 1184: $buildtest	\@if !(test -e "${sourceroot}/${source}") && !(test -e "${targetroot}/${target}"); then \\
                   1185: 		echo "**** ERROR **** CVS source file does not exist: ${sourceroot}/${source} and neither does target: ${targetroot}/${target}"$logcmd; \\
                   1186: 	elif !(test -e "${sourceroot}/${source}"); then \\
                   1187: 		echo "**** WARNING **** CVS source file does not exist: ${sourceroot}/${source}"$logcmd; \\
1.21      harris41 1188: 		perl verifymodown.pl ${targetroot}/${target} "$categoryhash{$categoryname}"$logcmd; \\
1.14      harris41 1189: 	else \\
                   1190: 		ECODE=0; \\
                   1191: 		perl filecompare.pl $bflag ${sourceroot}/${source} ${targetroot}/${target} || ECODE=\$\$?; \\
                   1192: 		case "\$\$ECODE" in \\
                   1193: 			1) echo "${targetroot}/${target} is unchanged";; \\
1.21      harris41 1194: 			2) echo "**** WARNING **** target file ${targetroot}/${target} is newer than CVS source; saving current (old) target file to ${targetroot}/${target}.lpmlsave and then overwriting"$logcmd && install -o www -g www -m 0600 ${targetroot}/${target} ${targetroot}/${target}.lpmlsave && install $categoryhash{$categoryname} ${sourceroot}/${source} ${targetroot}/${target};; \\
1.27      harris41 1195: 			0) echo "install $categoryhash{$categoryname} ${sourceroot}/${source} ${targetroot}/${target}" && install $categoryhash{$categoryname} ${sourceroot}/${source} ${targetroot}/${target};; \\
1.14      harris41 1196: 		esac; \\
1.21      harris41 1197: 		perl verifymodown.pl ${targetroot}/${target} "$categoryhash{$categoryname}"$logcmd; \\
1.14      harris41 1198: 	fi
                   1199: END
1.12      harris41 1200: 	}
                   1201: 	elsif ($mode eq 'configinstall' && $categoryname eq 'conf') {
                   1202: 	    push @configall,$targetroot.'/'.$target;
1.14      harris41 1203: 	    return $targetroot.'/'.$target.': alwaysrun'."\n".
1.20      harris41 1204: 		"\t".'@echo -n ""; ECODE=0 && { perl filecompare.pl -b4 '.
                   1205: 		$sourceroot.'/'.$source.' '.$targetroot.'/'.$target.
                   1206: 		' || ECODE=$$?; } && '.
                   1207: 		'{ [ $$ECODE != "2" ] || (install '.
                   1208:                 $categoryhash{$categoryname}.' '.
1.12      harris41 1209: 		$sourceroot.'/'.$source.' '.
1.21      harris41 1210: 		$targetroot.'/'.$target.'.lpmlnew'.
1.19      harris41 1211: 		' && echo "**** NOTE: CONFIGURATION FILE CHANGE ****"'.
                   1212: 		$logcmd.' && echo "'.
1.14      harris41 1213: 		'You likely need to compare contents of '.
                   1214: 		''.$targetroot.'/'.$target.' with the new '.
1.21      harris41 1215:                 ''.$targetroot.'/'.$target.'.lpmlnew"'.
1.20      harris41 1216: 		"$logcmd); } && ".
                   1217: 		'{ [ $$ECODE != "3" ] || (install '.
                   1218:                 $categoryhash{$categoryname}.' '.
                   1219: 		$sourceroot.'/'.$source.' '.
                   1220: 		$targetroot.'/'.$target.''.
                   1221: 		' && echo "**** WARNING: NEW CONFIGURATION FILE ADDED ****"'.
                   1222: 		$logcmd.' && echo "'.
                   1223: 		'You likely need to review the contents of '.
                   1224: 		''.$targetroot.'/'.$target.' to make sure its '.
                   1225:                 'settings are compatible with your overall system"'.
                   1226: 		"$logcmd); } && ".
                   1227: 		'{ [ $$ECODE != "1" ] || ('.
                   1228: 		'echo "**** ERROR ****"'.
                   1229: 		$logcmd.' && echo "'.
                   1230: 		'Configuration source file does not exist '.
                   1231: 		''.$sourceroot.'/'.$source.'"'.
1.41      harris41 1232: 	      "$logcmd); } && perl verifymodown.pl ${targetroot}/${target} \"".
                   1233: 		"$categoryhash{$categoryname}\"$logcmd;\n\n";
1.4       harris41 1234: 	}
1.11      harris41 1235: 	elsif ($mode eq 'build' && $build) {
                   1236: 	    push @buildall,$sourceroot.'/'.$source;
1.14      harris41 1237: 	    push @buildinfo,$targetroot.'/'.$target.';'.$sourceroot.'/'.
                   1238: 		$source.';'.$build.';'.
1.11      harris41 1239: 		$dependencies;
                   1240: #	    return '# need to build '.$source.";
                   1241: 	}
1.35      harris41 1242:         elsif ($mode eq 'rpm_file_list') {
                   1243: 	    if ($categoryname eq 'doc') {
                   1244: 		return $targetroot.'/'.$target.' # doc'."\n";
                   1245: 	    }
                   1246: 	    elsif ($categoryname eq 'conf') {
                   1247: 		return $targetroot.'/'.$target.' # config'."\n";
                   1248: 	    }
                   1249: 	    else {
                   1250: 		return $targetroot.'/'.$target."\n";
                   1251: 	    }
                   1252: 	}
1.3       harris41 1253: 	else {
                   1254: 	    return '';
                   1255: 	}
                   1256:     }
                   1257:     return '';
                   1258: }
                   1259: # --------------------------------------------------------- Format link section
                   1260: sub format_link {
                   1261:     my @tokeninfo=@_;
1.27      harris41 1262:     $link=''; $linkto=''; $source=''; $target=''; $categoryname=''; 
                   1263:     $description=''; $note=''; $build=''; $status=''; $dependencies='';
1.3       harris41 1264:     my $text=&trim($parser->get_text('/link'));
                   1265:     if ($linkto) {
                   1266: 	$parser->get_tag('/link');
                   1267: 	if ($mode eq 'html') {
1.27      harris41 1268: 	    my @targets=map {s/^\s*//;s/\s$//;$_} split(/\;/,$target);
1.29      harris41 1269: 	    $link_count+=scalar(@targets);
1.27      harris41 1270: 	    foreach my $tgt (@targets) {
1.29      harris41 1271: 		$categorycount{$categoryname}++;
1.27      harris41 1272: 		push @links,("\n<!-- FILESORT:$tgt -->".
                   1273: 		    "<tr>".
1.32      harris41 1274: 		    "<td><!-- POSTEVAL [$categoryname] verify.pl link ".
1.28      harris41 1275: 		    "'/$targetrootarg$linkto' '/$targetrootarg$tgt' ".
                   1276: 		    "$categoryhash{$categoryname} -->&nbsp;</td><td>".
1.27      harris41 1277: 		    "<img src='$fab{$categoryname}.gif' ".
                   1278: 		    "alt='$categoryname icon' /></td>".
                   1279: 		    "<td><font size='-1'>$categoryname</font></td>".
                   1280: 		    "<td>LINKTO: $linkto<br />TARGET: $tgt</td>".
                   1281: 		    "<td>$description</td>".
                   1282: 		    "<td>$note</td>".
                   1283: 		    "</tr>");
                   1284: #		push @links,"\t".'ln -fs /'.$linkto.' /'.$targetroot.$tgt.
                   1285: #		    "\n";
                   1286: 	    }
                   1287: 	    return join('',@links);
                   1288: #	    return ($link="\n<!-- FILESORT:$target -->".
                   1289: #		    "<tr>".
                   1290: #		    "<td>&nbsp;</td><td><img src='$fab{$categoryname}.gif' ".
                   1291: #		    "alt='$categoryname icon' /></td>".
                   1292: #		    "<td>$categoryname</td>".
                   1293: #		    "<td>LINKTO: $linkto<br />TARGET: $target</td>".
                   1294: #		    "<td>$description</td>".
                   1295: #		    "<td>$note</td>".
                   1296: #		    "</tr>");
                   1297: #	    return $link="\n<tr><td colspan='6'>BEGIN LINK\n".
                   1298: #		"$linkto $target $categoryname $description $note " .
                   1299: #		"$build $status $dependencies" .
                   1300: #		    "\nEND LINK</td></tr>";
1.4       harris41 1301: 	}
                   1302: 	elsif ($mode eq 'install') {
1.10      harris41 1303: 	    my @targets=map {s/^\s*//;s/\s$//;$_} split(/\;/,$target);
1.5       harris41 1304: 	    foreach my $tgt (@targets) {
1.35      harris41 1305: 		push @links,"\t".'ln -fs /'.$linkto.' '.$targetroot.'/'.$tgt.
1.5       harris41 1306: 		    "\n";
                   1307: 	    }
1.35      harris41 1308: #	    return join('',@links);
1.4       harris41 1309: 	    return '';
1.3       harris41 1310: 	}
1.35      harris41 1311: 	elsif ($mode eq 'rpm_file_list') {
                   1312: 	    my @linklocs;
                   1313: 	    my @targets=map {s/^\s*//;s/\s$//;$_} split(/\;/,$target);
                   1314: 	    foreach my $tgt (@targets) {
                   1315: 		push @linklocs,''.$targetroot.'/'.$tgt."\n";
                   1316: 	    }
                   1317: 	    return join('',@linklocs);
                   1318: 	}
1.3       harris41 1319: 	else {
                   1320: 	    return '';
                   1321: 	}
                   1322:     }
                   1323:     return '';
                   1324: }
                   1325: # ----------------------------------------------------- Format fileglob section
                   1326: sub format_fileglob {
                   1327:     my @tokeninfo=@_;
                   1328:     $fileglob=''; $glob=''; $sourcedir='';
                   1329:     $targetdir=''; $categoryname=''; $description='';
                   1330:     $note=''; $build=''; $status=''; $dependencies='';
                   1331:     $filenames='';
                   1332:     my $text=&trim($parser->get_text('/fileglob'));
1.27      harris41 1333:     my $filenames2=$filenames;$filenames2=~s/\s//g;
1.29      harris41 1334:     $fileglob_count++;
                   1335:     my @semi=($filenames2=~/(\;)/g);
                   1336:     $fileglobnames_count+=scalar(@semi)+1;
                   1337:     $categorycount{$categoryname}+=scalar(@semi)+1;
1.3       harris41 1338:     if ($sourcedir) {
                   1339: 	$parser->get_tag('/fileglob');
                   1340: 	if ($mode eq 'html') {
1.27      harris41 1341: 	    return $fileglob="\n<tr>".
1.41      harris41 1342:       "<td><!-- POSTEVAL [$categoryname] verify.pl fileglob '$sourcerootarg' ".
1.27      harris41 1343: 		"'$targetrootarg' ".
                   1344: 		"'$glob' '$sourcedir' '$filenames2' '$targetdir' ".
                   1345: 		"$categoryhash{$categoryname} -->&nbsp;</td>".
                   1346: 		"<td>"."<img src='$fab{$categoryname}.gif' ".
                   1347: 	        "alt='$categoryname icon' /></td>".
                   1348: 		"<td>$categoryname<br />".
                   1349: 		"<font size='-1'>".$categoryhash{$categoryname}."</font></td>".
                   1350: 		"<td>SOURCEDIR: $sourcedir<br />".
                   1351: 		"TARGETDIR: $targetdir<br />".
                   1352:                 "GLOB: $glob<br />".
                   1353:                 "FILENAMES: $filenames".
                   1354: 		"</td>".
                   1355: 		"<td>$description</td>".
                   1356: 		"<td>$note</td>".
                   1357: 		"</tr>";
                   1358: #	    return $fileglob="\n<tr><td colspan='6'>BEGIN FILEGLOB\n".
                   1359: #		"$glob sourcedir $targetdir $categoryname $description $note ".
                   1360: #		"$build $status $dependencies $filenames" .
                   1361: #		"\nEND FILEGLOB</td></tr>";
1.3       harris41 1362: 	}
1.5       harris41 1363: 	elsif ($mode eq 'install') {
1.30      harris41 1364: 	    my $eglob=$glob;
                   1365: 	    if ($glob eq '*') {
                   1366: 		$eglob='[^C][^V][^S]'.$glob;
                   1367: 	    }
1.5       harris41 1368: 	    return "\t".'install '.
                   1369: 		$categoryhash{$categoryname}.' '.
1.30      harris41 1370: 		$sourceroot.'/'.$sourcedir.$eglob.' '.
1.5       harris41 1371: 		$targetroot.'/'.$targetdir.'.'."\n";
1.35      harris41 1372: 	}
                   1373: 	elsif ($mode eq 'rpm_file_list') {
                   1374: 	    my $eglob=$glob;
                   1375: 	    if ($glob eq '*') {
                   1376: 		$eglob='[^C][^V][^S]'.$glob;
                   1377: 	    }
                   1378: 	    my $targetdir2=$targetdir;$targetdir2=~s/\/$//;
                   1379: 	    my @gfiles=map {s/^.*\///;"$targetroot/$targetdir2/$_\n"}
                   1380: 	               glob("$sourceroot/$sourcedir/$eglob");
                   1381: 	    return join('',@gfiles);
1.5       harris41 1382: 	}
1.3       harris41 1383: 	else {
                   1384: 	    return '';
                   1385: 	}
                   1386:     }
                   1387:     return '';
                   1388: }
                   1389: # ---------------------------------------------------- Format sourcedir section
                   1390: sub format_sourcedir {
                   1391:     my @tokeninfo=@_;
                   1392:     $sourcedir='';
                   1393:     my $text=&trim($parser->get_text('/sourcedir'));
                   1394:     if ($text) {
                   1395: 	$parser->get_tag('/sourcedir');
                   1396: 	$sourcedir=$text;
                   1397:     }
                   1398:     return '';
                   1399: }
                   1400: # ------------------------------------------------------- Format target section
                   1401: sub format_target {
                   1402:     my @tokeninfo=@_;
                   1403:     $target='';
                   1404:     my $text=&trim($parser->get_text('/target'));
                   1405:     if ($text) {
                   1406: 	$parser->get_tag('/target');
                   1407: 	$target=$text;
                   1408:     }
                   1409:     return '';
                   1410: }
                   1411: # ------------------------------------------------------- Format source section
                   1412: sub format_source {
                   1413:     my @tokeninfo=@_;
                   1414:     $source='';
                   1415:     my $text=&trim($parser->get_text('/source'));
                   1416:     if ($text) {
                   1417: 	$parser->get_tag('/source');
                   1418: 	$source=$text;
                   1419:     }
                   1420:     return '';
                   1421: }
                   1422: # --------------------------------------------------------- Format note section
                   1423: sub format_note {
                   1424:     my @tokeninfo=@_;
                   1425:     $note='';
1.26      harris41 1426: #    my $text=&trim($parser->get_text('/note'));
                   1427:     my $aref;
                   1428:     my $text;
                   1429:     while ($aref=$parser->get_token()) {
                   1430: 	if ($aref->[0] eq 'E' && $aref->[1] eq 'note') {
                   1431: 	    last;
                   1432: 	}
                   1433: 	elsif ($aref->[0] eq 'S') {
                   1434: 	    $text.=$aref->[4];
                   1435: 	}
                   1436: 	elsif ($aref->[0] eq 'E') {
                   1437: 	    $text.=$aref->[2];
                   1438: 	}
                   1439: 	else {
                   1440: 	    $text.=$aref->[1];
                   1441: 	}
                   1442:     }
1.3       harris41 1443:     if ($text) {
1.26      harris41 1444: #	$parser->get_tag('/note');
1.3       harris41 1445: 	$note=$text;
                   1446:     }
                   1447:     return '';
                   1448: 
                   1449: }
                   1450: # -------------------------------------------------------- Format build section
                   1451: sub format_build {
                   1452:     my @tokeninfo=@_;
                   1453:     $build='';
                   1454:     my $text=&trim($parser->get_text('/build'));
                   1455:     if ($text) {
                   1456: 	$parser->get_tag('/build');
1.11      harris41 1457: 	$build=$sourceroot.'/'.$text.';'.$tokeninfo[2]{'trigger'};
1.42    ! harris41 1458: 	$build=~s/([^\\])\\\s+/$1/g; # allow for lines split onto new lines
1.3       harris41 1459:     }
                   1460:     return '';
                   1461: }
1.14      harris41 1462: # -------------------------------------------------------- Format build section
                   1463: sub format_buildlink {
                   1464:     my @tokeninfo=@_;
                   1465:     $buildlink='';
                   1466:     my $text=&trim($parser->get_text('/buildlink'));
                   1467:     if ($text) {
                   1468: 	$parser->get_tag('/buildlink');
                   1469: 	$buildlink=$sourceroot.'/'.$text;
                   1470:     }
                   1471:     return '';
                   1472: }
1.3       harris41 1473: # ------------------------------------------------------- Format status section
                   1474: sub format_status {
                   1475:     my @tokeninfo=@_;
                   1476:     $status='';
                   1477:     my $text=&trim($parser->get_text('/status'));
                   1478:     if ($text) {
                   1479: 	$parser->get_tag('/status');
                   1480: 	$status=$text;
                   1481:     }
                   1482:     return '';
                   1483: }
                   1484: # ------------------------------------------------- Format dependencies section
                   1485: sub format_dependencies {
                   1486:     my @tokeninfo=@_;
                   1487:     $dependencies='';
                   1488:     my $text=&trim($parser->get_text('/dependencies'));
                   1489:     if ($text) {
                   1490: 	$parser->get_tag('/dependencies');
1.11      harris41 1491: 	$dependencies=join(';',
                   1492: 			      (map {s/^\s*//;s/\s$//;$_} split(/\;/,$text)));
1.3       harris41 1493:     }
                   1494:     return '';
                   1495: }
                   1496: # --------------------------------------------------------- Format glob section
                   1497: sub format_glob {
                   1498:     my @tokeninfo=@_;
                   1499:     $glob='';
                   1500:     my $text=&trim($parser->get_text('/glob'));
                   1501:     if ($text) {
                   1502: 	$parser->get_tag('/glob');
                   1503: 	$glob=$text;
                   1504:     }
                   1505:     return '';
                   1506: }
                   1507: # ---------------------------------------------------- Format filenames section
                   1508: sub format_filenames {
                   1509:     my @tokeninfo=@_;
                   1510:     my $text=&trim($parser->get_text('/filenames'));
                   1511:     if ($text) {
                   1512: 	$parser->get_tag('/filenames');
                   1513: 	$filenames=$text;
                   1514:     }
1.31      harris41 1515:     return '';
                   1516: }
1.38      harris41 1517: # ----------------------------------------------- Format specialnotices section
1.31      harris41 1518: sub format_specialnotices {
                   1519:     $parser->get_tag('/specialnotices');
                   1520:     return '';
                   1521: }
                   1522: # ------------------------------------------------ Format specialnotice section
                   1523: sub format_specialnotice {
                   1524:     $parser->get_tag('/specialnotice');
1.3       harris41 1525:     return '';
                   1526: }
                   1527: # ------------------------------------------------------- Format linkto section
                   1528: sub format_linkto {
                   1529:     my @tokeninfo=@_;
                   1530:     my $text=&trim($parser->get_text('/linkto'));
                   1531:     if ($text) {
                   1532: 	$parser->get_tag('/linkto');
                   1533: 	$linkto=$text;
                   1534:     }
                   1535:     return '';
1.10      harris41 1536: }
                   1537: # ------------------------------------- Render less-than and greater-than signs
                   1538: sub htmlsafe {
                   1539:     my $text=@_[0];
                   1540:     $text =~ s/</&lt;/g;
                   1541:     $text =~ s/>/&gt;/g;
                   1542:     return $text;
1.3       harris41 1543: }
                   1544: # --------------------------------------- remove starting and ending whitespace
                   1545: sub trim {
                   1546:     my ($s)=@_; $s=~s/^\s*//; $s=~s/\s*$//; return $s;
                   1547: } 
1.14      harris41 1548: 
                   1549: # ----------------------------------- POD (plain old documentation, CPAN style)
1.18      harris41 1550: 
                   1551: =head1 NAME
                   1552: 
                   1553: lpml_parse.pl - This is meant to parse files meeting the lpml document type.
                   1554: See lpml.dtd.  LPML=Linux Packaging Markup Language.
                   1555: 
                   1556: =head1 SYNOPSIS
                   1557: 
                   1558: Usage is for lpml file to come in through standard input.
                   1559: 
                   1560: =over 4
                   1561: 
                   1562: =item *
                   1563: 
                   1564: 1st argument is the mode of parsing.
                   1565: 
                   1566: =item * 
                   1567: 
                   1568: 2nd argument is the category permissions to use (runtime or development)
                   1569: 
                   1570: =item *
                   1571: 
                   1572: 3rd argument is the distribution
                   1573: (default,redhat6.2,debian2.2,redhat7.1,etc).
                   1574: 
                   1575: =item *
                   1576: 
                   1577: 4th argument is to manually specify a sourceroot.
                   1578: 
                   1579: =item *
                   1580: 
                   1581: 5th argument is to manually specify a targetroot.
                   1582: 
                   1583: =back
                   1584: 
                   1585: Only the 1st argument is mandatory for the program to run.
                   1586: 
                   1587: Example:
                   1588: 
                   1589: cat ../../doc/loncapafiles.lpml |\\
                   1590: perl lpml_parse.pl html default /home/sherbert/loncapa /tmp/install
                   1591: 
                   1592: =head1 DESCRIPTION
                   1593: 
                   1594: I am using a multiple pass-through approach to parsing
                   1595: the lpml file.  This saves memory and makes sure the server
                   1596: will never be overloaded.
                   1597: 
                   1598: =head1 README
                   1599: 
                   1600: I am using a multiple pass-through approach to parsing
                   1601: the lpml file.  This saves memory and makes sure the server
                   1602: will never be overloaded.
                   1603: 
                   1604: =head1 PREREQUISITES
                   1605: 
                   1606: HTML::TokeParser
                   1607: 
                   1608: =head1 COREQUISITES
                   1609: 
                   1610: =head1 OSNAMES
                   1611: 
                   1612: linux
                   1613: 
                   1614: =head1 SCRIPT CATEGORIES
                   1615: 
                   1616: Packaging/Administrative
                   1617: 
                   1618: =cut

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