--- loncom/build/lpml_parse.pl 2003/09/11 22:01:48 1.52 +++ loncom/build/lpml_parse.pl 2011/03/25 22:55:06 1.57 @@ -12,7 +12,7 @@ # The LearningOnline Network with CAPA # lpml_parse.pl - Linux Packaging Markup Language parser # -# $Id: lpml_parse.pl,v 1.52 2003/09/11 22:01:48 albertel Exp $ +# $Id: lpml_parse.pl,v 1.57 2011/03/25 22:55:06 raeburn Exp $ # # Written by Scott Harrison, codeharrison@yahoo.com # @@ -86,6 +86,7 @@ Usage is for lpml file to come in throug typical choices: default,redhat6.2,debian2.2,redhat7 4th argument is to manually specify a sourceroot. 5th argument is to manually specify a targetroot. +6th argument is to manually specify a shell. Only the 1st argument is mandatory for the program to run. @@ -100,7 +101,7 @@ END # ------------------------------------------------- Grab command line arguments my $mode=''; -if (@ARGV==5) { +if (@ARGV == 6 || @ARGV == 5) { $mode = shift @ARGV; } else { @@ -135,6 +136,11 @@ $targetroot=~s/\/$//; # remove trailing $sourcerootarg=$sourceroot; $targetrootarg=$targetroot; +my $shell = 'sh'; +if (@ARGV) { + $shell = shift @ARGV; +} + my $logcmd='| tee -a WARNINGS'; my $invocation; # Record how the program was invoked @@ -147,6 +153,7 @@ if ($mode eq 'install' or $mode eq 'conf # 3rd argument (distribution) is: $dist # 4th argument (sourceroot) is: described below # 5th argument (targetroot) is: described below +# 6th argument (shell) is: $shell END } @@ -313,6 +320,7 @@ my $targets; my $target; my $source; my $note; +my $installscript; my $build; my $buildlink; my $commands; @@ -384,6 +392,7 @@ $parser->{textify}={ target => \&format_target, note => \&format_note, build => \&format_build, + installscript => \&format_installscript, status => \&format_status, dependencies => \&format_dependencies, privatedependencies => \&format_privatedependencies, @@ -529,7 +538,7 @@ END print ' by Scott Harrison 2001'."\n"; print '# This file was automatically generated on '.`date`; print "\n".$invocation; - $lpml .= "SHELL=\"/bin/bash\"\n\n"; + $lpml .= "\n"; } elsif ($mode eq 'configinstall') { print '# LPML configuration file targets (configinstall).'."\n"; @@ -537,14 +546,14 @@ END print ' by Scott Harrison 2001'."\n"; print '# This file was automatically generated on '.`date`; print "\n".$invocation; - $lpml .= "SHELL=\"/bin/bash\"\n\n"; + $lpml .= "\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".$invocation; - $lpml .= "SHELL=\"/bin/sh\"\n\n"; + $lpml .= "\n"; } else { return ''; @@ -643,6 +652,8 @@ sub format_category { my ($user,$group)=split(/\:/,$chown); $categoryhash{$category_att_name}='-o '.$user.' -g '.$group. ' -m '.$chmod; + $categoryhash{"chmod.".$category_att_name}=$chmod; + $categoryhash{"chown.".$category_att_name}=$chown; } return ''; } @@ -1147,11 +1158,11 @@ sub format_files { $tword=''; $tword=' alwaysrun' if $trigger eq 'always run'; if ($command!~/\s/) { $command=~s/\/([^\/]*)$//; - $command2="cd $command; sh ./$1;\\"; + $command2="cd $command; $shell ./$1;\\"; } else { $command=~s/(.*?\/)([^\/]+\s+.*)$/$1/; - $command2="cd $command; sh ./$2;\\"; + $command2="cd $command; $shell ./$2;\\"; } my $depstring; my $depstring2="\t\t\@echo '';\\\n"; @@ -1218,7 +1229,7 @@ sub format_links { sub format_file { my @tokeninfo=@_; $file=''; $source=''; $target=''; $categoryname=''; $description=''; - $note=''; $build=''; $status=''; $dependencies=''; + $note=''; $build=''; $status=''; $dependencies=''; $installscript=''; my $text=&trim($parser->get_text('/file')); my $buildtest; $file_count++; @@ -1262,14 +1273,15 @@ sub format_file { # "$build $status $dependencies" . # "\nEND FILE"); } - elsif ($mode eq 'install' && $categoryname ne 'conf') { + elsif (($mode eq 'install') && (($categoryname ne 'conf') && + ($categoryname ne 'www conf'))) { 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;\\"; + $command2="cd $command; $shell ./$1;\\"; my $depstring; foreach my $dep (@deps) { $depstring.=<get_text('/installscript')); + if ($installscript) { + $parser->get_tag('/installscript'); + $installscript=~s/([^\\])\\\s+/$1/g; # allow for lines split onto new lines + } + return ''; +} # -------------------------------------------------------- Format build section sub format_buildlink { my @tokeninfo=@_;