diff --git a/xCAT-buildkit/bin/buildkit b/xCAT-buildkit/bin/buildkit index 70947316d..46ccf1c39 100755 --- a/xCAT-buildkit/bin/buildkit +++ b/xCAT-buildkit/bin/buildkit @@ -33,7 +33,7 @@ cleantar - deletes the Kit deployment directory and Kit cleanall - equivalent to buildkit cleanrepo all and buildkit cleantar - addpkgs -p [--kitversion ] [--kitrelease ] + addpkgs -p [-k|--kitversion ] [-r|--kitrelease ] - 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/<<>>/$::bldkit_config->{kit}{entries}[0]->{kitname}/g; + s/<<>>/$::bldkit_config->{kit}{entries}[0]->{basename}/g; + s/<<>>/$::bldkit_config->{kit}{entries}[0]->{version}/g; + s/<<>>/$::bldkit_config->{kit}{entries}[0]->{release}/g; + if ( defined ($kitcomp) ) { + s/<<>>/$kitcomp->{kitcompname}/g; + s/<<>>/$kitcomp->{basename}/g; + s/<<>>/$kitcomp->{version}/g; + s/<<>>/$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;