defect 3385 fix string subs in plugins and finish defect 3366 kit version and release subs in addpkgs support
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@15779 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -33,7 +33,7 @@ | ||||
|      cleantar              - deletes the Kit deployment directory and Kit | ||||
|      cleanall               - equivalent to buildkit cleanrepo all and | ||||
|                                             buildkit cleantar | ||||
|      addpkgs -p <packagedir> [--kitversion <version>] [--kitrelease <release>] <kit tarfile> | ||||
|      addpkgs -p <packagedir> [-k|--kitversion <version>] [-r|--kitrelease <release>] <kit tarfile> | ||||
|                            - used by customer to add external product | ||||
|                              packages when they are not built into the  | ||||
|                              shipped kit tar file | ||||
| @@ -317,8 +317,8 @@ if ( | ||||
|                 'v|version'    => \$::VERSION, | ||||
|                 'V|verbose'    => \$::VERBOSE, | ||||
|                 'p|pkgdir=s'   => \$::PKGDIR, | ||||
|                 'kitversion=s' => \$::KITVERSION, | ||||
|                 'kitrelease=s' => \$::KITRELEASE, | ||||
|                 'k|kitversion=s' => \$::KITVERSION, | ||||
|                 'r|kitrelease=s' => \$::KITRELEASE, | ||||
|     ) | ||||
|   ) | ||||
| { | ||||
| @@ -2336,6 +2336,8 @@ sub create_kitconf | ||||
|             } | ||||
|             $::kit_config->{$s}{entries}[$li]->{$a} = $se->{$a}; | ||||
|           } | ||||
|           # cp_to_kitconfig=2 means copy the file to the new kit | ||||
|           # but only do the copy if this is a final kit build | ||||
|           if (( $::buildkit_def{$s}{$a}->{cp_to_kitconfig} eq '2' ) && | ||||
|               ( defined ($se->{$a}) ) && | ||||
|               !$::HAVE_EXTERNAL_PKG && !$::HAVE_NON_NATIVE_PKGS ) { | ||||
| @@ -2346,10 +2348,15 @@ sub create_kitconf | ||||
|                     ($a eq 'genimage_postinstall')) { | ||||
|                     $prefix = "KIT_".$prefix; | ||||
|                 } | ||||
|             } | ||||
|             if ( !($::kit_config->{$s}{entries}[$li]->{$a} =  | ||||
|                 if ( !($::kit_config->{$s}{entries}[$li]->{$a} =  | ||||
|                    &cp_to_builddir($a,$se->{$a},$::workdir.'/'.$::buildkit_def{$s}{$a}->{base_dir},$prefix, $::bldkit_config->{$s}{entries}[$li])) ) { | ||||
|                    return 1; | ||||
|                 } | ||||
|             } else { | ||||
|                 if ( !($::kit_config->{$s}{entries}[$li]->{$a} =  | ||||
|                     &cp_to_builddir($a,$se->{$a},$::workdir.'/'.$::buildkit_def{$s}{$a}->{base_dir},$prefix)) ) { | ||||
|               return 1; | ||||
|                   return 1; | ||||
|                 } | ||||
|             } | ||||
|           } | ||||
|         } | ||||
| @@ -2441,6 +2448,7 @@ sub create_kitconf | ||||
| =head3    cp_to_builddir | ||||
| 	 | ||||
|    Copy specified files into the build directory renaming as indicated | ||||
|    and substituting strings if needed | ||||
|  | ||||
| =cut | ||||
|  | ||||
| @@ -2454,6 +2462,7 @@ sub cp_to_builddir | ||||
|     my $files = shift; | ||||
|     my $from_dir = shift; | ||||
|     my $prefix = shift; | ||||
|     my $kitcomp = shift; | ||||
|  | ||||
|     my $copied_files; | ||||
|     my $other_files = $::deploy_dir."/other_files"; | ||||
| @@ -2467,14 +2476,42 @@ sub cp_to_builddir | ||||
|         my $from_file_base = basename($file);  | ||||
|         my $to_file_base = $prefix."_".$from_file_base; | ||||
|         my $to_file = $other_files."/".$to_file_base; | ||||
|         if ( system("cp -fp $from_file $to_file") ) { | ||||
|             # non-zero return from system call | ||||
|  | ||||
|         # Read in the file | ||||
|         my $FF; | ||||
|         unless ( open( $FF, "<", $from_file ) ) { | ||||
|             print  "The Kit file $from_file could not be read. \n"; | ||||
|             return 1; | ||||
|         } | ||||
|         my @lines = <$FF>; | ||||
|         for (@lines) { | ||||
|             s/<<<buildkit_WILL_INSERT_kit_name_HERE>>>/$::bldkit_config->{kit}{entries}[0]->{kitname}/g; | ||||
|             s/<<<buildkit_WILL_INSERT_kit_basename_HERE>>>/$::bldkit_config->{kit}{entries}[0]->{basename}/g; | ||||
|             s/<<<buildkit_WILL_INSERT_kit_version_HERE>>>/$::bldkit_config->{kit}{entries}[0]->{version}/g; | ||||
|             s/<<<buildkit_WILL_INSERT_kit_release_HERE>>>/$::bldkit_config->{kit}{entries}[0]->{release}/g; | ||||
|             if ( defined ($kitcomp) ) { | ||||
|                 s/<<<buildkit_WILL_INSERT_kitcomponent_name_HERE>>>/$kitcomp->{kitcompname}/g; | ||||
|                 s/<<<buildkit_WILL_INSERT_kitcomponent_basename_HERE>>>/$kitcomp->{basename}/g; | ||||
|                 s/<<<buildkit_WILL_INSERT_kitcomponent_version_HERE>>>/$kitcomp->{version}/g; | ||||
|                 s/<<<buildkit_WILL_INSERT_kitcomponent_release_HERE>>>/$kitcomp->{release}/g; | ||||
|             } | ||||
|         } | ||||
|         # Write the file back out | ||||
|         my $TF; | ||||
|         unless ( open( $TF, ">$to_file" ) ) { | ||||
|             print "Error copying file $from_file to build directory $other_files \n"; | ||||
|             return; | ||||
|          }         | ||||
|             return 1; | ||||
|         } | ||||
|         if ($::VERBOSE) { | ||||
|             print "Copied $from_file to $to_file replacing kit and kitcomponent strings as needed. \n"; | ||||
|         } | ||||
|         print $TF @lines; | ||||
|         close($TF); | ||||
|  | ||||
|         $copied_files .= ",$to_file_base"; | ||||
|   | ||||
|         if ($type eq 'postbootscripts') { | ||||
|         if (($type eq 'postbootscripts') ||   | ||||
|             ($type eq 'genimage_postinstall')) { | ||||
|             system("chmod 755 $to_file"); | ||||
|         } | ||||
|     } | ||||
| @@ -2792,6 +2829,10 @@ sub edit_plugin | ||||
| { | ||||
|     my $file = shift;  | ||||
|     my $kitname = $::bldkit_config->{kit}{entries}[0]->{kitname}; | ||||
|     # convert dashes to underscore since the kitname is used as perl pkg names | ||||
|     # in the plugin and this causes perl syntax errors | ||||
|     $kitname =~ s/\-/\_/g; | ||||
|     $kitname =~ s/\./\_/g; | ||||
|  | ||||
|     # read in the file | ||||
|     my $PF; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user