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

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

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