version 1.52, 2003/09/11 22:01:48
|
version 1.62, 2020/10/07 19:55:39
|
Line 86 Usage is for lpml file to come in throug
|
Line 86 Usage is for lpml file to come in throug
|
typical choices: default,redhat6.2,debian2.2,redhat7 |
typical choices: default,redhat6.2,debian2.2,redhat7 |
4th argument is to manually specify a sourceroot. |
4th argument is to manually specify a sourceroot. |
5th argument is to manually specify a targetroot. |
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. |
Only the 1st argument is mandatory for the program to run. |
|
|
Line 100 END
|
Line 101 END
|
# ------------------------------------------------- Grab command line arguments |
# ------------------------------------------------- Grab command line arguments |
|
|
my $mode=''; |
my $mode=''; |
if (@ARGV==5) { |
if (@ARGV == 6 || @ARGV == 5) { |
$mode = shift @ARGV; |
$mode = shift @ARGV; |
} |
} |
else { |
else { |
Line 135 $targetroot=~s/\/$//; # remove trailing
|
Line 136 $targetroot=~s/\/$//; # remove trailing
|
$sourcerootarg=$sourceroot; |
$sourcerootarg=$sourceroot; |
$targetrootarg=$targetroot; |
$targetrootarg=$targetroot; |
|
|
|
my $shell = 'sh'; |
|
if (@ARGV) { |
|
$shell = shift @ARGV; |
|
} |
|
|
my $logcmd='| tee -a WARNINGS'; |
my $logcmd='| tee -a WARNINGS'; |
|
|
my $invocation; # Record how the program was invoked |
my $invocation; # Record how the program was invoked |
Line 147 if ($mode eq 'install' or $mode eq 'conf
|
Line 153 if ($mode eq 'install' or $mode eq 'conf
|
# 3rd argument (distribution) is: $dist |
# 3rd argument (distribution) is: $dist |
# 4th argument (sourceroot) is: described below |
# 4th argument (sourceroot) is: described below |
# 5th argument (targetroot) is: described below |
# 5th argument (targetroot) is: described below |
|
# 6th argument (shell) is: $shell |
END |
END |
} |
} |
|
|
Line 313 my $targets;
|
Line 320 my $targets;
|
my $target; |
my $target; |
my $source; |
my $source; |
my $note; |
my $note; |
|
my $installscript; |
my $build; |
my $build; |
my $buildlink; |
my $buildlink; |
my $commands; |
my $commands; |
Line 384 $parser->{textify}={
|
Line 392 $parser->{textify}={
|
target => \&format_target, |
target => \&format_target, |
note => \&format_note, |
note => \&format_note, |
build => \&format_build, |
build => \&format_build, |
|
installscript => \&format_installscript, |
status => \&format_status, |
status => \&format_status, |
dependencies => \&format_dependencies, |
dependencies => \&format_dependencies, |
privatedependencies => \&format_privatedependencies, |
privatedependencies => \&format_privatedependencies, |
Line 529 END
|
Line 538 END
|
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"; |
$lpml .= "\n"; |
} |
} |
elsif ($mode eq 'configinstall') { |
elsif ($mode eq 'configinstall') { |
print '# LPML configuration file targets (configinstall).'."\n"; |
print '# LPML configuration file targets (configinstall).'."\n"; |
Line 537 END
|
Line 546 END
|
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"; |
$lpml .= "\n"; |
} |
} |
elsif ($mode eq 'build') { |
elsif ($mode eq 'build') { |
$lpml = "# LPML build targets. Linux Packaging Markup Language,"; |
$lpml = "# LPML build targets. Linux Packaging Markup Language,"; |
$lpml .= ' by Scott Harrison 2001'."\n"; |
$lpml .= ' by Scott Harrison 2001'."\n"; |
$lpml .= '# This file was automatically generated on '.`date`; |
$lpml .= '# This file was automatically generated on '.`date`; |
$lpml .= "\n".$invocation; |
$lpml .= "\n".$invocation; |
$lpml .= "SHELL=\"/bin/sh\"\n\n"; |
$lpml .= "\n"; |
} |
} |
else { |
else { |
return ''; |
return ''; |
Line 643 sub format_category {
|
Line 652 sub format_category {
|
my ($user,$group)=split(/\:/,$chown); |
my ($user,$group)=split(/\:/,$chown); |
$categoryhash{$category_att_name}='-o '.$user.' -g '.$group. |
$categoryhash{$category_att_name}='-o '.$user.' -g '.$group. |
' -m '.$chmod; |
' -m '.$chmod; |
|
$categoryhash{"chmod.".$category_att_name}=$chmod; |
|
$categoryhash{"chown.".$category_att_name}=$chown; |
} |
} |
return ''; |
return ''; |
} |
} |
Line 1147 sub format_files {
|
Line 1158 sub format_files {
|
$tword=''; $tword=' alwaysrun' if $trigger eq 'always run'; |
$tword=''; $tword=' alwaysrun' if $trigger eq 'always run'; |
if ($command!~/\s/) { |
if ($command!~/\s/) { |
$command=~s/\/([^\/]*)$//; |
$command=~s/\/([^\/]*)$//; |
$command2="cd $command; sh ./$1;\\"; |
$command2="cd $command; $shell ./$1;\\"; |
} |
} |
else { |
else { |
$command=~s/(.*?\/)([^\/]+\s+.*)$/$1/; |
$command=~s/(.*?\/)([^\/]+\s+.*)$/$1/; |
$command2="cd $command; sh ./$2;\\"; |
$command2="cd $command; $shell ./$2;\\"; |
} |
} |
my $depstring; |
my $depstring; |
my $depstring2="\t\t\@echo '';\\\n"; |
my $depstring2="\t\t\@echo '';\\\n"; |
Line 1218 sub format_links {
|
Line 1229 sub format_links {
|
sub format_file { |
sub format_file { |
my @tokeninfo=@_; |
my @tokeninfo=@_; |
$file=''; $source=''; $target=''; $categoryname=''; $description=''; |
$file=''; $source=''; $target=''; $categoryname=''; $description=''; |
$note=''; $build=''; $status=''; $dependencies=''; |
$note=''; $build=''; $status=''; $dependencies=''; $installscript=''; |
|
$buildlink = ''; |
my $text=&trim($parser->get_text('/file')); |
my $text=&trim($parser->get_text('/file')); |
my $buildtest; |
my $buildtest; |
$file_count++; |
$file_count++; |
Line 1262 sub format_file {
|
Line 1274 sub format_file {
|
# "$build $status $dependencies" . |
# "$build $status $dependencies" . |
# "\nEND FILE"); |
# "\nEND FILE"); |
} |
} |
elsif ($mode eq 'install' && $categoryname ne 'conf') { |
elsif (($mode eq 'install') && (($categoryname ne 'conf') && |
|
($categoryname ne 'www conf'))) { |
if ($build) { |
if ($build) { |
my $bi=$sourceroot.'/'.$source.';'.$build.';'. |
my $bi=$sourceroot.'/'.$source.';'.$build.';'. |
$dependencies; |
$dependencies; |
my ($source2,$command,$trigger,@deps)=split(/\;/,$bi); |
my ($source2,$command,$trigger,@deps)=split(/\;/,$bi); |
$tword=''; $tword=' alwaysrun' if $trigger eq 'always run'; |
$tword=''; $tword=' alwaysrun' if $trigger eq 'always run'; |
$command=~s/\/([^\/]*)$//; |
$command=~s/\/([^\/]*)$//; |
$command2="cd $command; sh ./$1;\\"; |
$command2="cd $command; $shell ./$1;\\"; |
my $depstring; |
my $depstring; |
foreach my $dep (@deps) { |
foreach my $dep (@deps) { |
$depstring.=<<END; |
$depstring.=<<END; |
Line 1293 END
|
Line 1306 END
|
$buildtest.=<<END; |
$buildtest.=<<END; |
fi |
fi |
END |
END |
|
} |
|
if ($installscript) { |
|
my $dir = $sourceroot.'/'.$source; |
|
$dir =~ s|/([^/]*)$||; |
|
my $result =" |
|
$buildtest cd $dir ; $shell $installscript"; |
|
if ($categoryname |
|
&& exists($categoryhash{"chmod.$categoryname"}) ) { |
|
$result .="\\\n"; |
|
$result .=<<"END" |
|
chmod -R $categoryhash{"chmod.$categoryname"} ${targetroot}/${target} \\ |
|
chown -R $categoryhash{"chown.$categoryname"} ${targetroot}/${target} |
|
END |
|
} else { |
|
$result.="\n"; |
|
} |
|
return $result; |
|
} |
|
my $testtarget = $target; |
|
if ($categoryname eq 'setuid script') { |
|
my ($path,$filename) = ($target =~ /^(.*\/)([^\/]+)$/); |
|
my $alttarget = $path.'.'.$filename; |
|
if ((-e "$targetroot/$target") && (-B "$targetroot/$target") && |
|
(-e "$targetroot/$alttarget") && (-T "$targetroot/$alttarget")) { |
|
$testtarget = $alttarget; |
|
} |
} |
} |
my $bflag='-b1'; |
my $bflag='-b5'; |
$bflag='-b3' if $dependencies or $buildlink; |
$bflag='-b3' if ($buildlink); |
return <<END; |
$bflag='-b6' if (($dependencies) or |
|
($categoryname eq 'pdf manual')); |
|
if ($tokeninfo[2]{type} eq 'private') { |
|
return <<END; |
|
$buildtest \@if (test -e "${sourceroot}/${source}") && (test -e "${targetroot}/${target}"); then \\ |
|
ECODE=0; \\ |
|
perl filecompare.pl $bflag ${sourceroot}/${source} ${targetroot}/${testtarget} || ECODE=\$\$?; \\ |
|
case "\$\$ECODE" in \\ |
|
1) echo "${targetroot}/${target} is unchanged";; \\ |
|
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 -p $categoryhash{$categoryname} ${sourceroot}/${source} ${targetroot}/${target};; \\ |
|
0) echo "install -p $categoryhash{$categoryname} ${sourceroot}/${source} ${targetroot}/${target}" && install -p $categoryhash{$categoryname} ${sourceroot}/${source} ${targetroot}/${target};; \\ |
|
esac; \\ |
|
elif (test -e "${sourceroot}/${source}") && !(test -e "${targetroot}/${target}"); then\\ |
|
echo "install -p $categoryhash{$categoryname} ${sourceroot}/${source} ${targetroot}/${target}" && install -p $categoryhash{$categoryname} ${sourceroot}/${source} ${targetroot}/${target}; \\ |
|
fi |
|
\@if (test -e "${targetroot}/${target}"); then \\ |
|
perl verifymodown.pl ${targetroot}/${target} "$categoryhash{$categoryname}"$logcmd; \\ |
|
fi |
|
END |
|
} else { |
|
return <<END; |
$buildtest \@if !(test -e "${sourceroot}/${source}") && !(test -e "${targetroot}/${target}"); then \\ |
$buildtest \@if !(test -e "${sourceroot}/${source}") && !(test -e "${targetroot}/${target}"); then \\ |
echo "**** ERROR **** CVS source file does not exist: ${sourceroot}/${source} and neither does target: ${targetroot}/${target}"$logcmd; \\ |
echo "**** ERROR **** CVS source file does not exist: ${sourceroot}/${source} and neither does target: ${targetroot}/${target}"$logcmd; \\ |
elif !(test -e "${sourceroot}/${source}"); then \\ |
elif !(test -e "${sourceroot}/${source}"); then \\ |
echo "**** WARNING **** CVS source file does not exist: ${sourceroot}/${source}"$logcmd; \\ |
echo "**** WARNING **** CVS source file does not exist: ${sourceroot}/${source}"$logcmd; \\ |
perl verifymodown.pl ${targetroot}/${target} "$categoryhash{$categoryname}"$logcmd; \\ |
perl verifymodown.pl ${targetroot}/${target} "$categoryhash{$categoryname}"$logcmd; \\ |
|
elif !(test -e "${targetroot}/${target}"); then \\ |
|
echo "install -p $categoryhash{$categoryname} ${sourceroot}/${source} ${targetroot}/${target}" && install -p $categoryhash{$categoryname} ${sourceroot}/${source} ${targetroot}/${target}; \\ |
else \\ |
else \\ |
ECODE=0; \\ |
ECODE=0; \\ |
perl filecompare.pl $bflag ${sourceroot}/${source} ${targetroot}/${target} || ECODE=\$\$?; \\ |
perl filecompare.pl $bflag ${sourceroot}/${source} ${targetroot}/${testtarget} || ECODE=\$\$?; \\ |
case "\$\$ECODE" in \\ |
case "\$\$ECODE" in \\ |
1) echo "${targetroot}/${target} is unchanged";; \\ |
1) echo "${targetroot}/${target} is unchanged";; \\ |
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};; \\ |
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 -p $categoryhash{$categoryname} ${sourceroot}/${source} ${targetroot}/${target};; \\ |
0) echo "install $categoryhash{$categoryname} ${sourceroot}/${source} ${targetroot}/${target}" && install $categoryhash{$categoryname} ${sourceroot}/${source} ${targetroot}/${target};; \\ |
0) echo "install -p $categoryhash{$categoryname} ${sourceroot}/${source} ${targetroot}/${target}" && install -p $categoryhash{$categoryname} ${sourceroot}/${source} ${targetroot}/${target};; \\ |
esac; \\ |
esac; \\ |
perl verifymodown.pl ${targetroot}/${target} "$categoryhash{$categoryname}"$logcmd; \\ |
perl verifymodown.pl ${targetroot}/${target} "$categoryhash{$categoryname}"$logcmd; \\ |
fi |
fi |
END |
END |
|
} |
} |
} |
elsif ($mode eq 'configinstall' && $categoryname eq 'conf') { |
elsif ($mode eq 'configinstall' && (($categoryname eq 'conf') || |
|
($categoryname eq 'www conf'))) { |
push @configall,$targetroot.'/'.$target; |
push @configall,$targetroot.'/'.$target; |
return $targetroot.'/'.$target.': alwaysrun'."\n". |
return $targetroot.'/'.$target.': alwaysrun'."\n". |
"\t".'@# Compare source with target and intelligently respond'. |
"\t".'@# Compare source with target and intelligently respond'. |
Line 1503 sub format_fileglob {
|
Line 1566 sub format_fileglob {
|
if ($glob eq '*') { |
if ($glob eq '*') { |
$eglob='[^C][^V][^S]'.$glob; |
$eglob='[^C][^V][^S]'.$glob; |
} |
} |
return "\t".'install '. |
return "\t".'install -p '. |
$categoryhash{$categoryname}.' '. |
$categoryhash{$categoryname}.' '. |
$sourceroot.'/'.$sourcedir.$eglob.' '. |
$sourceroot.'/'.$sourcedir.$eglob.' '. |
$targetroot.'/'.$targetdir.'.'."\n"; |
$targetroot.'/'.$targetdir.'.'."\n"; |
Line 1597 sub format_build {
|
Line 1660 sub format_build {
|
} |
} |
return ''; |
return ''; |
} |
} |
|
# ------------------------------------------------ Format installscript section |
|
sub format_installscript { |
|
my @tokeninfo=@_; |
|
$installscript= &trim($parser->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 |
# -------------------------------------------------------- Format build section |
sub format_buildlink { |
sub format_buildlink { |
my @tokeninfo=@_; |
my @tokeninfo=@_; |
$buildlink=''; |
|
my $text=&trim($parser->get_text('/buildlink')); |
my $text=&trim($parser->get_text('/buildlink')); |
if ($text) { |
if ($text) { |
$parser->get_tag('/buildlink'); |
$parser->get_tag('/buildlink'); |
$buildlink=$sourceroot.'/'.$text; |
$buildlink=$sourceroot.'/'.$text; |
|
} else { |
|
$buildlink=''; |
} |
} |
return ''; |
return ''; |
} |
} |
Line 1622 sub format_status {
|
Line 1696 sub format_status {
|
# ------------------------------------------------- Format dependencies section |
# ------------------------------------------------- Format dependencies section |
sub format_dependencies { |
sub format_dependencies { |
my @tokeninfo=@_; |
my @tokeninfo=@_; |
#$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=join(';',((map {s/^\s*//;s/\s$//;$_} split(/\;/,$text)),$dependencies)); |
$dependencies=join(';',((map {s/^\s*//;s/\s$//;$_} split(/\;/,$text)),$dependencies)); |
$dependencies=~s/;$//; |
$dependencies=~s/;$//; |
|
} else { |
|
$dependencies=''; |
} |
} |
return ''; |
return ''; |
} |
} |