Diff for /loncom/build/lpml_parse.pl between versions 1.48 and 1.56

version 1.48, 2002/05/19 17:46:19 version 1.56, 2011/01/10 21:24:36
Line 47 Line 47
 # 12/2,12/3,12/4,12/5,12/6,12/13,12/19,12/29 - Scott Harrison  # 12/2,12/3,12/4,12/5,12/6,12/13,12/19,12/29 - Scott Harrison
 # YEAR=2002  # YEAR=2002
 # 1/8,1/9,1/29,1/31,2/5,3/21,4/8,4/12 - Scott Harrison  # 1/8,1/9,1/29,1/31,2/5,3/21,4/8,4/12 - Scott Harrison
   # 4/21,4/26,5/19,5/23,10/13 - Scott Harrison
 #  #
 ###  ###
   
Line 298  my $directories; Line 299  my $directories;
 my $directory;  my $directory;
 my $targetdirs;  my $targetdirs;
 my $targetdir;  my $targetdir;
   my $protectionlevel;
 my $categoryname;  my $categoryname;
 my $description;  my $description;
 my $files;  my $files;
Line 311  my $targets; Line 313  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 351  $parser->{textify}={ Line 354  $parser->{textify}={
     category => \&format_category,      category => \&format_category,
     abbreviation => \&format_abbreviation,      abbreviation => \&format_abbreviation,
     targetdir => \&format_targetdir,      targetdir => \&format_targetdir,
       protectionlevel => \&format_protectionlevel,
     chown => \&format_chown,      chown => \&format_chown,
     chmod => \&format_chmod,      chmod => \&format_chmod,
     rpm => \&format_rpm,      rpm => \&format_rpm,
Line 381  $parser->{textify}={ Line 385  $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,
     buildlink => \&format_buildlink,      buildlink => \&format_buildlink,
     glob => \&format_glob,      glob => \&format_glob,
     sourcedir => \&format_sourcedir,      sourcedir => \&format_sourcedir,
Line 525  END Line 531  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 533  END Line 539  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 639  sub format_category { Line 645  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 974  sub format_directories { Line 982  sub format_directories {
     elsif ($mode eq 'rpm_file_list') {      elsif ($mode eq 'rpm_file_list') {
  return $text;   return $text;
     }      }
       elsif ($mode eq 'uninstall_shell_commands') {
    return $text;
       }
     else {      else {
  return '';   return '';
     }      }
Line 981  sub format_directories { Line 992  sub format_directories {
 # ---------------------------------------------------- Format directory section  # ---------------------------------------------------- Format directory section
 sub format_directory {  sub format_directory {
     my (@tokeninfo)=@_;      my (@tokeninfo)=@_;
     $targetdir='';$categoryname='';$description='';      $targetdir='';$categoryname='';$description='';$protectionlevel='';
     $parser->get_text('/directory');      $parser->get_text('/directory');
     $parser->get_tag('/directory');      $parser->get_tag('/directory');
     $directory_count++;      $directory_count++;
Line 1015  sub format_directory { Line 1026  sub format_directory {
     elsif ($mode eq 'rpm_file_list') {      elsif ($mode eq 'rpm_file_list') {
  return $targetroot.'/'.$targetdir."\n";   return $targetroot.'/'.$targetdir."\n";
     }      }
       elsif ($mode eq 'uninstall_shell_commands') {
    if ($protectionlevel eq 'never_delete') {
       return 'echo "LEAVING BEHIND '.$targetroot.'/'.$targetdir.
    ' which may have important data worth saving"'."\n";
    }
    elsif ($protectionlevel eq 'weak_delete') {
       if ($targetdir!~/\w/) {
    die("targetdir=\"$targetdir\"! NEVER EVER DELETE THE WHOLE ".
       "FILESYSTEM"."\n");
       }
       return 'rm -Rvf -i '.$targetroot.'/'.$targetdir."\n";
    }
    elsif ($protectionlevel =~ /never/) {
       die("CONFUSING PROTECTION LEVEL \"$protectionlevel\" FOUND ".
    "FOR directory $targetdir"."\n");
    }
    elsif ($protectionlevel !~
       /^never_delete|weak_delete|modest_delete|strong_delete|absolute_delete$/) {
       die("CONFUSING OR MISSING PROTECTION LEVEL \"$protectionlevel\" ".
    "FOUND FOR directory $targetdir\n");
    }
    else {
       if ($targetdir!~/\w/) {
    die("targetdir=\"$targetdir\"! NEVER EVER DELETE THE WHOLE ".
       "FILESYSTEM"."\n");
       }
       return 'rm -Rvf '.$targetroot.'/'.$targetdir.
    "| grep 'removed directory'"."\n";
    }
       }
     else {      else {
  return '';   return '';
     }      }
Line 1030  sub format_targetdir { Line 1071  sub format_targetdir {
     }      }
     return '';      return '';
 }  }
   # ---------------------------------------------- Format protectionlevel section
   sub format_protectionlevel {
       my @tokeninfo=@_;
       $protectionlevel='';
       my $text=&trim($parser->get_text('/protectionlevel'));
       if ($text) {
    $parser->get_tag('/protectionlevel');
    $protectionlevel=$text;
       }
       return '';
   }
 # ------------------------------------------------- Format categoryname section  # ------------------------------------------------- Format categoryname section
 sub format_categoryname {  sub format_categoryname {
     my @tokeninfo=@_;      my @tokeninfo=@_;
Line 1170  sub format_links { Line 1222  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='';
     my $text=&trim($parser->get_text('/file'));      my $text=&trim($parser->get_text('/file'));
     my $buildtest;      my $buildtest;
     $file_count++;      $file_count++;
Line 1189  sub format_file { Line 1241  sub format_file {
     my (@deps)=split(/\;/,$dependencies);      my (@deps)=split(/\;/,$dependencies);
     my $retval=join("\n",($source,      my $retval=join("\n",($source,
        (map {"$command$_"} @deps)));         (map {"$command$_"} @deps)));
       if ($tokeninfo[2]{type} eq 'private') {
    return "\n";
       }
     return $retval."\n";      return $retval."\n";
  }   }
  elsif ($mode eq 'html') {   elsif ($mode eq 'html') {
Line 1211  sub format_file { Line 1266  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;
Line 1242  END Line 1298  END
                 $buildtest.=<<END;                  $buildtest.=<<END;
  fi   fi
 END  END
               }
       if ($installscript) {
    my $dir = $sourceroot.'/'.$source;
    $dir =~ s|/([^/]*)$||;
    my $result =" 
   $buildtest cd $dir ; sh $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 $bflag='-b1';              my $bflag='-b1';
             $bflag='-b3' if $dependencies or $buildlink;              $bflag='-b3' if $dependencies or $buildlink;
Line 1263  $buildtest \@if !(test -e "${sourceroot} Line 1336  $buildtest \@if !(test -e "${sourceroot}
  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 1283  END Line 1357  END
  ' && echo "**** NOTE: CONFIGURATION FILE CHANGE ****"'.   ' && echo "**** NOTE: CONFIGURATION FILE CHANGE ****"'.
  " \\\n\t\t".$logcmd.' && '." \\\n\t\t"."echo -n \"".   " \\\n\t\t".$logcmd.' && '." \\\n\t\t"."echo -n \"".
  'You likely need to compare contents of "'."\\\n\t\t\t".   'You likely need to compare contents of "'."\\\n\t\t\t".
  'echo -n "'.$targetroot.'/'.$target.'"'."\\\n\t\t".   '&& echo -n "'.$targetroot.'/'.$target.'"'."\\\n\t\t".
  'echo -n "with the new "'."\\\n\t\t\t".   '&& echo -n " with the new "'."\\\n\t\t\t".
                 'echo "'.$targetroot.'/'.$target.'.lpmlnew"'."\\\n\t\t".                  '&& echo "'.$targetroot.'/'.$target.'.lpmlnew"'."\\\n\t\t".
  "$logcmd); } && "." \\\n\t"."\\\n\t"."\\\n\t".   "$logcmd); } && "." \\\n\t"."\\\n\t"."\\\n\t".
   
   
Line 1298  END Line 1372  END
  "\\\n\t\t".$logcmd.' && '."\\\n\t\t".   "\\\n\t\t".$logcmd.' && '."\\\n\t\t".
  'echo -n "'.   'echo -n "'.
  'You likely need to review the contents of "'."\\\n\t\t\t".   'You likely need to review the contents of "'."\\\n\t\t\t".
  'echo -n "'.   '&& echo -n "'.
  $targetroot.'/'.$target.'"'."\\\n\t\t\t".   $targetroot.'/'.$target.'"'."\\\n\t\t\t".
  'echo -n "'.   '&& echo -n "'.
  'to make sure its "'."\\\n\t\t".   ' to make sure its "'."\\\n\t\t".
  'echo "'.   '&& echo "'.
                 'settings are compatible with your overall system"'."\\\n\t\t".                  'settings are compatible with your overall system"'."\\\n\t\t".
  "$logcmd); } && "."\\\n\t"."\\\n\t"."\\\n\t".   "$logcmd); } && "."\\\n\t"."\\\n\t"."\\\n\t".
   
Line 1310  END Line 1384  END
  '{ [ $$ECODE != "1" ] || ('."\\\n\t\t".   '{ [ $$ECODE != "1" ] || ('."\\\n\t\t".
  'echo "**** ERROR ****"'.$logcmd.' && '."\\\n\t\t".'echo -n "'.   'echo "**** ERROR ****"'.$logcmd.' && '."\\\n\t\t".'echo -n "'.
  'Configuration source file does not exist "'."\\\n\t\t".   'Configuration source file does not exist "'."\\\n\t\t".
  'echo -n "'.$sourceroot.'/'.$source.'"'."\\\n\t\t".   '&& echo -n "'.$sourceroot.'/'.$source.'"'."\\\n\t\t".
  "$logcmd); } && "."\\\n\t\t".   "$logcmd); } && "."\\\n\t\t".
  "perl verifymodown.pl ${targetroot}/${target} "."\\\n\t\t\t".   "perl verifymodown.pl ${targetroot}/${target} "."\\\n\t\t\t".
  "\"$categoryhash{$categoryname}\""."\\\n\t\t\t".   "\"$categoryhash{$categoryname}\""."\\\n\t\t\t".
Line 1546  sub format_build { Line 1620  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=@_;
Line 1571  sub format_status { Line 1655  sub format_status {
 # ------------------------------------------------- Format dependencies section  # ------------------------------------------------- Format dependencies section
 sub format_dependencies {  sub format_dependencies {
     my @tokeninfo=@_;      my @tokeninfo=@_;
     $dependencies='';      #$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(';',   $dependencies=join(';',((map {s/^\s*//;s/\s$//;$_} split(/\;/,$text)),$dependencies));
       (map {s/^\s*//;s/\s$//;$_} split(/\;/,$text)));   $dependencies=~s/;$//;
       }
       return '';
   }
   sub format_privatedependencies {
       my @tokeninfo=@_;
       #$dependencies='';
       my $text=&trim($parser->get_text('/privatedependencies'));
       if ($text) {
    $parser->get_tag('/privatedependencies');
    if ($mode eq 'MANIFEST') { return ''; }
    $dependencies=join(';',((map {s/^\s*//;s/\s$//;$_} split(/\;/,$text)),$dependencies));
    $dependencies=~s/;$//;
     }      }
     return '';      return '';
 }  }

Removed from v.1.48  
changed lines
  Added in v.1.56


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