--- loncom/build/lpml_parse.pl 2001/09/17 18:25:15 1.10 +++ loncom/build/lpml_parse.pl 2001/11/05 02:57:21 1.14 @@ -5,6 +5,8 @@ # May 2001 # 06/19/2001,06/20,06/24 - Scott Harrison # 9/5/2001,9/6,9/7,9/8 - Scott Harrison +# 9/17,9/18 - Scott Harrison +# 11/4 - Scott Harrison ############################################################################### ## ## @@ -14,6 +16,8 @@ ## 3. First pass through (grab distribution-specific information) ## ## 4. Second pass through (parse out what is not necessary) ## ## 5. Third pass through (translate markup according to specified mode) ## +## 6. Functions (most all just format contents of different markup tags) ## +## 7. POD (plain old documentation, CPAN style) ## ## ## ############################################################################### @@ -220,6 +224,7 @@ my $target; my $source; my $note; my $build; +my $buildlink; my $commands; my $command; my $status; @@ -228,6 +233,11 @@ my $dependency; my @links; my %categoryhash; +my @buildall; +my @buildinfo; + +my @configall; + # Make new parser with distribution specific input undef $parser; $parser = HTML::TokeParser->new(\$cleanstring) or @@ -272,6 +282,7 @@ $parser->{textify}={ build => \&format_build, status => \&format_status, dependencies => \&format_dependencies, + buildlink => \&format_buildlink, glob => \&format_glob, sourcedir => \&format_sourcedir, filenames => \&format_filenames, @@ -296,6 +307,9 @@ while ($token = $parser->get_tag('lpml') } exit; +# ---------- Functions (most all just format contents of different markup tags) + +# ------------------------ Final output at end of markup parsing and formatting sub end { if ($mode eq 'html') { return "
THE END\n"; @@ -324,6 +338,14 @@ sub format_lpml { print ' by Scott Harrison 2001'."\n"; print '# This file was automatically generated on '.`date`; print "\n".$invocation; + $lpml .= "SHELL=\"/bin/bash\"\n\n"; + } + elsif ($mode eq 'build') { + $lpml = "# LPML build targets. Linux Packaging Markup Language,"; + $lpml .= ' by Scott Harrison 2001'."\n"; + $lpml .= '# This file was automatically generated on '.`date`; + $lpml .= "\n"; + $lpml .= "SHELL=\"/bin/sh\"\n\n"; } else { return ''; @@ -340,6 +362,9 @@ sub format_targetroot { elsif ($mode eq 'install') { return '# TARGET INSTALL LOCATION is "'.$targetroot."\"\n"; } + elsif ($mode eq 'build') { + return '# TARGET INSTALL LOCATION is "'.$targetroot."\"\n"; + } else { return ''; } @@ -355,6 +380,9 @@ sub format_sourceroot { elsif ($mode eq 'install') { return '# SOURCE CODE LOCATION IS "'.$sourceroot."\"\n";; } + elsif ($mode eq 'build') { + return '# SOURCE CODE LOCATION IS "'.$sourceroot."\"\n";; + } else { return ''; } @@ -634,6 +662,57 @@ sub format_files { return "\n".'files:'."\n".$text. "\n".'links:'."\n".join('',@links); } + elsif ($mode eq 'configinstall') { + return "\n".'configfiles: '. + join(' ',@configall). + "\n\n".$text. + "\n\nalwaysrun:\n\n"; + } + elsif ($mode eq 'build') { + my $binfo; + my $tword; + my $command2; + my @deps; + foreach my $bi (@buildinfo) { + my ($target,$source,$command,$trigger,@deps)=split(/\;/,$bi); + $tword=''; $tword=' alwaysrun' if $trigger eq 'always run'; + $command=~s/\/([^\/]*)$//; + $command2="cd $command; sh ./$1;\\"; + my $depstring; + my $depstring2="\t\t\@echo '';\\\n"; + my $olddep; + foreach my $dep (@deps) { + unless ($olddep) { + $olddep=$deps[$#deps]; + } + $depstring.="\telif !(test -r $command/$dep);\\\n"; + $depstring.="\t\tthen echo ". + "\"**** WARNING **** missing the file: ". + "$command/$dep\";\\\n"; + $depstring.="\t\ttest -e $source || test -e $target || echo ". + "'**** ERROR **** neither source=$source nor target=". + "$target exist and they cannot be built';\\\n"; + $depstring.="\t\tmake -f Makefile.build ${source}___DEPS;\\\n"; + if ($olddep) { + $depstring2.="\t\tECODE=0;\\\n"; + $depstring2.="\t\t! test -e $source && test -r $command/$olddep &&". + " { perl filecompare.pl -B $command/$olddep $target || ECODE=\$\$?; } && { [ \$\$ECODE != \"2\" ] || echo \"**** WARNING **** dependency $command/$olddep is newer than target file $target; SOMETHING MAY BE WRONG\"; };\\\n"; + } + $olddep=$dep; + } + $binfo.="$source: $tword\n". + "\t\@if !(echo \"\");\\\n\t\tthen echo ". + "\"**** WARNING **** Strange shell. ". + "Check your path settings.\";\\\n". + $depstring. + "\telse \\\n\t\t$command2\n\tfi\n\n"; + $binfo.="${source}___DEPS:\n".$depstring2."\t\tECODE=0;\n\n"; + } + return 'all: '.join(' ',@buildall)."\n\n". + $text. + $binfo."\n". + "alwaysrun:\n\n"; + } else { return ''; } @@ -663,6 +742,7 @@ sub format_file { $file=''; $source=''; $target=''; $categoryname=''; $description=''; $note=''; $build=''; $status=''; $dependencies=''; my $text=&trim($parser->get_text('/file')); + my $buildtest; if ($source) { $parser->get_tag('/file'); if ($mode eq 'html') { @@ -672,14 +752,81 @@ sub format_file { "\nEND FILE"); } elsif ($mode eq 'install' && $categoryname ne 'conf') { - return "\t".'@test -e '.$sourceroot.'/'.$source. - ' && install '. - $categoryhash{$categoryname}.' '. + if ($build) { + my $bi=$sourceroot.'/'.$source.';'.$build.';'. + $dependencies; + my ($source2,$command,$trigger,@deps)=split(/\;/,$bi); + $tword=''; $tword=' alwaysrun' if $trigger eq 'always run'; + $command=~s/\/([^\/]*)$//; + $command2="cd $command; sh ./$1;\\"; + my $depstring; + foreach my $dep (@deps) { + $depstring.=<get_text('/build')); if ($text) { $parser->get_tag('/build'); - $build=$text; + $build=$sourceroot.'/'.$text.';'.$tokeninfo[2]{'trigger'}; + } + return ''; +} +# -------------------------------------------------------- Format build section +sub format_buildlink { + my @tokeninfo=@_; + $buildlink=''; + my $text=&trim($parser->get_text('/buildlink')); + if ($text) { + $parser->get_tag('/buildlink'); + $buildlink=$sourceroot.'/'.$text; } return ''; } @@ -817,7 +975,8 @@ sub format_dependencies { my $text=&trim($parser->get_text('/dependencies')); if ($text) { $parser->get_tag('/dependencies'); - $dependencies=$text; + $dependencies=join(';', + (map {s/^\s*//;s/\s$//;$_} split(/\;/,$text))); } return ''; } @@ -863,3 +1022,5 @@ sub htmlsafe { sub trim { my ($s)=@_; $s=~s/^\s*//; $s=~s/\s*$//; return $s; } + +# ----------------------------------- POD (plain old documentation, CPAN style)