version 1.10, 2001/09/17 18:25:15
|
version 1.16, 2001/11/07 16:53:52
|
Line 5
|
Line 5
|
# May 2001 |
# May 2001 |
# 06/19/2001,06/20,06/24 - Scott Harrison |
# 06/19/2001,06/20,06/24 - Scott Harrison |
# 9/5/2001,9/6,9/7,9/8 - Scott Harrison |
# 9/5/2001,9/6,9/7,9/8 - Scott Harrison |
|
# 9/17,9/18 - Scott Harrison |
|
# 11/4 - Scott Harrison |
|
|
############################################################################### |
############################################################################### |
## ## |
## ## |
Line 14
|
Line 16
|
## 3. First pass through (grab distribution-specific information) ## |
## 3. First pass through (grab distribution-specific information) ## |
## 4. Second pass through (parse out what is not necessary) ## |
## 4. Second pass through (parse out what is not necessary) ## |
## 5. Third pass through (translate markup according to specified mode) ## |
## 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) ## |
## ## |
## ## |
############################################################################### |
############################################################################### |
|
|
Line 220 my $target;
|
Line 224 my $target;
|
my $source; |
my $source; |
my $note; |
my $note; |
my $build; |
my $build; |
|
my $buildlink; |
my $commands; |
my $commands; |
my $command; |
my $command; |
my $status; |
my $status; |
Line 228 my $dependency;
|
Line 233 my $dependency;
|
my @links; |
my @links; |
my %categoryhash; |
my %categoryhash; |
|
|
|
my @buildall; |
|
my @buildinfo; |
|
|
|
my @configall; |
|
|
# Make new parser with distribution specific input |
# Make new parser with distribution specific input |
undef $parser; |
undef $parser; |
$parser = HTML::TokeParser->new(\$cleanstring) or |
$parser = HTML::TokeParser->new(\$cleanstring) or |
Line 272 $parser->{textify}={
|
Line 282 $parser->{textify}={
|
build => \&format_build, |
build => \&format_build, |
status => \&format_status, |
status => \&format_status, |
dependencies => \&format_dependencies, |
dependencies => \&format_dependencies, |
|
buildlink => \&format_buildlink, |
glob => \&format_glob, |
glob => \&format_glob, |
sourcedir => \&format_sourcedir, |
sourcedir => \&format_sourcedir, |
filenames => \&format_filenames, |
filenames => \&format_filenames, |
Line 296 while ($token = $parser->get_tag('lpml')
|
Line 307 while ($token = $parser->get_tag('lpml')
|
} |
} |
exit; |
exit; |
|
|
|
# ---------- Functions (most all just format contents of different markup tags) |
|
|
|
# ------------------------ Final output at end of markup parsing and formatting |
sub end { |
sub end { |
if ($mode eq 'html') { |
if ($mode eq 'html') { |
return "<br />THE END\n"; |
return "<br />THE END\n"; |
Line 324 sub format_lpml {
|
Line 338 sub format_lpml {
|
print ' by Scott Harrison 2001'."\n"; |
print ' by Scott Harrison 2001'."\n"; |
print '# This file was automatically generated on '.`date`; |
print '# This file was automatically generated on '.`date`; |
print "\n".$invocation; |
print "\n".$invocation; |
|
$lpml .= "SHELL=\"/bin/bash\"\n\n"; |
|
} |
|
elsif ($mode eq 'configinstall') { |
|
print '# LPML configuration targets. Linux Packaging Markup Language,'; |
|
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 { |
else { |
return ''; |
return ''; |
Line 340 sub format_targetroot {
|
Line 369 sub format_targetroot {
|
elsif ($mode eq 'install') { |
elsif ($mode eq 'install') { |
return '# TARGET INSTALL LOCATION is "'.$targetroot."\"\n"; |
return '# TARGET INSTALL LOCATION is "'.$targetroot."\"\n"; |
} |
} |
|
elsif ($mode eq 'build') { |
|
return '# TARGET INSTALL LOCATION is "'.$targetroot."\"\n"; |
|
} |
else { |
else { |
return ''; |
return ''; |
} |
} |
Line 355 sub format_sourceroot {
|
Line 387 sub format_sourceroot {
|
elsif ($mode eq 'install') { |
elsif ($mode eq 'install') { |
return '# SOURCE CODE LOCATION IS "'.$sourceroot."\"\n";; |
return '# SOURCE CODE LOCATION IS "'.$sourceroot."\"\n";; |
} |
} |
|
elsif ($mode eq 'build') { |
|
return '# SOURCE CODE LOCATION IS "'.$sourceroot."\"\n";; |
|
} |
else { |
else { |
return ''; |
return ''; |
} |
} |
Line 634 sub format_files {
|
Line 669 sub format_files {
|
return "\n".'files:'."\n".$text. |
return "\n".'files:'."\n".$text. |
"\n".'links:'."\n".join('',@links); |
"\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 { |
else { |
return ''; |
return ''; |
} |
} |
Line 663 sub format_file {
|
Line 749 sub format_file {
|
$file=''; $source=''; $target=''; $categoryname=''; $description=''; |
$file=''; $source=''; $target=''; $categoryname=''; $description=''; |
$note=''; $build=''; $status=''; $dependencies=''; |
$note=''; $build=''; $status=''; $dependencies=''; |
my $text=&trim($parser->get_text('/file')); |
my $text=&trim($parser->get_text('/file')); |
|
my $buildtest; |
if ($source) { |
if ($source) { |
$parser->get_tag('/file'); |
$parser->get_tag('/file'); |
if ($mode eq 'html') { |
if ($mode eq 'html') { |
Line 672 sub format_file {
|
Line 759 sub format_file {
|
"\nEND FILE"); |
"\nEND FILE"); |
} |
} |
elsif ($mode eq 'install' && $categoryname ne 'conf') { |
elsif ($mode eq 'install' && $categoryname ne 'conf') { |
return "\t".'@test -e '.$sourceroot.'/'.$source. |
if ($build) { |
' && install '. |
my $bi=$sourceroot.'/'.$source.';'.$build.';'. |
$categoryhash{$categoryname}.' '. |
$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.=<<END; |
|
ECODE=0; DEP=''; \\ |
|
test -e $command/$dep || (echo '**** WARNING **** cannot evaluate status of dependency $command/$dep (for building ${sourceroot}/${source} with)'); DEP="1"; \\ |
|
[ -n DEP ] && { perl filecompare.pl -B $command/$dep ${targetroot}/${target} || ECODE=\$\$?; } || DEP="1"; \\ |
|
case "\$\$ECODE" in \\ |
|
2) echo "**** WARNING **** dependency $command/$dep is newer than target file ${targetroot}/${target}; you may want to run make build";; \\ |
|
esac; \\ |
|
END |
|
} |
|
chomp $depstring; |
|
$buildtest=<<END; |
|
\@if !(test -e "${sourceroot}/${source}") && !(test -e "${targetroot}/${target}"); then \\ |
|
echo "**** ERROR **** ${sourceroot}/${source} is missing and is also not present at target location ${targetroot}/${target}; you must run make build"; exit; \\ |
|
END |
|
$buildtest.=<<END if $depstring; |
|
elif !(test -e "${sourceroot}/${source}"); then \\ |
|
$depstring |
|
END |
|
$buildtest.=<<END; |
|
fi |
|
END |
|
} |
|
my $bflag='-b'; |
|
$bflag='-g' if $dependencies or $buildlink; |
|
return <<END; |
|
$buildtest \@if !(test -e "${sourceroot}/${source}"); then \\ |
|
echo "**** WARNING **** CVS source file does not exist: ${sourceroot}/${source}"; \\ |
|
else \\ |
|
ECODE=0; \\ |
|
perl filecompare.pl $bflag ${sourceroot}/${source} ${targetroot}/${target} || ECODE=\$\$?; \\ |
|
case "\$\$ECODE" in \\ |
|
1) echo "${targetroot}/${target} is unchanged";; \\ |
|
2) echo "**** WARNING **** target file ${targetroot}/${target} is newer than CVS source; creating ${targetroot}/${target}.lpmlnewfile instead" && install -o www -g www -m 0500 ${sourceroot}/${source} ${targetroot}/${target}.lpmlnewfile;; \\ |
|
0) echo "install -o www -g www -m 0500 ${sourceroot}/${source} ${targetroot}/${target}" && install -o www -g www -m 0500 ${sourceroot}/${source} ${targetroot}/${target};; \\ |
|
esac; \\ |
|
fi |
|
END |
|
# return "\t".'@test -e '.$sourceroot.'/'.$source. |
|
# ' && perl filecompare.pl -b '.$sourceroot.'/'.$source.' '. |
|
# $targetroot.'/'.$target. |
|
# ' && install '. |
|
# $categoryhash{$categoryname}.' '. |
|
# $sourceroot.'/'.$source.' '. |
|
# $targetroot.'/'.$target. |
|
# ' || echo "**** LON-CAPA WARNING '. |
|
# '**** CVS source file does not exist: '.$sourceroot.'/'. |
|
# $source.'"'."\n"; |
|
} |
|
elsif ($mode eq 'configinstall' && $categoryname eq 'conf') { |
|
push @configall,$targetroot.'/'.$target; |
|
return $targetroot.'/'.$target.': alwaysrun'."\n". |
|
"\t".'@echo -n ""; ECODE=0 && { perl filecompare.pl -G '.$sourceroot.'/'.$source.' '.$targetroot.'/'.$target.' || ECODE=$$?; } && { [ $$ECODE != "2" ] || (install '.$categoryhash{$categoryname}.' '. |
$sourceroot.'/'.$source.' '. |
$sourceroot.'/'.$source.' '. |
$targetroot.'/'.$target. |
$targetroot.'/'.$target.'.lpmlnewconf'. |
' || echo "**** LON-CAPA WARNING '. |
' && echo "*** CONFIGURATION FILE CHANGE ***" && echo "'. |
'**** CVS source file does not exist: '.$sourceroot.'/'. |
'You likely need to compare contents of '. |
$source.'"'."\n"; |
''.$targetroot.'/'.$target.' with the new '. |
|
''.$targetroot.'/'.$target.'.lpmlnewconf"'. |
|
"); };\n\n"; |
|
} |
|
elsif ($mode eq 'build' && $build) { |
|
push @buildall,$sourceroot.'/'.$source; |
|
push @buildinfo,$targetroot.'/'.$target.';'.$sourceroot.'/'. |
|
$source.';'.$build.';'. |
|
$dependencies; |
|
# return '# need to build '.$source."; |
} |
} |
else { |
else { |
return ''; |
return ''; |
Line 734 sub format_fileglob {
|
Line 888 sub format_fileglob {
|
elsif ($mode eq 'install') { |
elsif ($mode eq 'install') { |
return "\t".'install '. |
return "\t".'install '. |
$categoryhash{$categoryname}.' '. |
$categoryhash{$categoryname}.' '. |
$sourceroot.'/'.$sourcedir.'[^CVS]'.$glob.' '. |
$sourceroot.'/'.$sourcedir.'[^C][^V][^S]'.$glob.' '. |
$targetroot.'/'.$targetdir.'.'."\n"; |
$targetroot.'/'.$targetdir.'.'."\n"; |
} |
} |
else { |
else { |
Line 795 sub format_build {
|
Line 949 sub format_build {
|
my $text=&trim($parser->get_text('/build')); |
my $text=&trim($parser->get_text('/build')); |
if ($text) { |
if ($text) { |
$parser->get_tag('/build'); |
$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 ''; |
return ''; |
} |
} |
Line 817 sub format_dependencies {
|
Line 982 sub format_dependencies {
|
my $text=&trim($parser->get_text('/dependencies')); |
my $text=&trim($parser->get_text('/dependencies')); |
if ($text) { |
if ($text) { |
$parser->get_tag('/dependencies'); |
$parser->get_tag('/dependencies'); |
$dependencies=$text; |
$dependencies=join(';', |
|
(map {s/^\s*//;s/\s$//;$_} split(/\;/,$text))); |
} |
} |
return ''; |
return ''; |
} |
} |
Line 863 sub htmlsafe {
|
Line 1029 sub htmlsafe {
|
sub trim { |
sub trim { |
my ($s)=@_; $s=~s/^\s*//; $s=~s/\s*$//; return $s; |
my ($s)=@_; $s=~s/^\s*//; $s=~s/\s*$//; return $s; |
} |
} |
|
|
|
# ----------------------------------- POD (plain old documentation, CPAN style) |