diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index d5ea523c0..6e0d18f3f 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -1376,7 +1376,7 @@ kitrepo => { }, }, kitcomponent => { - cols => [qw(kitcompname description kitname kitreponame basename version release serverroles kitpkgdeps driverpacks kitcompdeps postbootscripts genimage_postinstall exlist comments disable)], + cols => [qw(kitcompname description kitname kitreponame basename version release serverroles kitpkgdeps prerequisite driverpacks kitcompdeps postbootscripts genimage_postinstall exlist comments disable)], keys => [qw(kitcompname)], tablespace =>'XCATTBS16K', table_desc => 'This table stores all kit components added to the xCAT cluster.', @@ -1390,6 +1390,7 @@ kitcomponent => { release => 'Kit Component release.', serverroles => 'The types of servers that this Kit Component can install on. Valid types are: mgtnode, servicenode, compute', kitpkgdeps => 'Comma-separated list of packages that this kit component depends on.', + prerequisite => 'Prerequisite for this kit component, the prerequisite includes ospkgdeps,preinstall,preupgrade,preuninstall scripts', driverpacks => 'Comma-separated List of driver package names. These must be full names like: pkg1-1.0-1.x86_64.rpm.', kitcompdeps => 'Comma-separated list of kit components that this kit component depends on.', postbootscripts => 'Comma-separated list of postbootscripts that will run during the node boot.', diff --git a/xCAT-buildkit/bin/buildkit b/xCAT-buildkit/bin/buildkit index 88f370782..8752200b8 100755 --- a/xCAT-buildkit/bin/buildkit +++ b/xCAT-buildkit/bin/buildkit @@ -352,7 +352,7 @@ if ( 'h|help' => \$::HELP, 'v|version' => \$::VERSION, 'V|verbose' => \$::VERBOSE, - 'n|noprerequisite' => \$::NOPREREQUISITE, + 'n|noprerequisite' => \$::PREREQUISITE, 'p|pkgdir=s' => \$::PKGDIR, 'k|kitversion=s' => \$::KITVERSION, 'r|kitrelease=s' => \$::KITRELEASE, @@ -1946,7 +1946,7 @@ sub build_kitcomp # specifically reference it's version-release if ( &update_kitcomp_kitpkgdeps($comp,$repodir) ) { return 1; } - if ( $::NOPREREQUISITE ) { + if ( !$::PREREQUISITE ) { if ( $comp->{ospkgdeps} || $comp->{preinstall} || $comp->{preupgrade} || $comp->{preuninstall} ) { if ( &gen_kitcomp_spec($comp,\%repo, 'PREREQUISITE') ) { return 1; } @@ -2608,7 +2608,7 @@ sub create_kitconf $se->{kitcompname}; $::kit_config->{$s}{entries}[$li]->{kitreponame} = $se->{kitreponame}; - if ( $::NOPREREQUISITE and $se->{ospkgdeps} || $se->{preinstall} || $se->{preupgrade} || $se->{preuninstall} ) { + if ( !$::PREREQUISITE and ($se->{ospkgdeps} || $se->{preinstall} || $se->{preupgrade} || $se->{preuninstall}) ) { $::kit_config->{$s}{entries}[$li]->{prerequisite} = "prep_" . $se->{basename}; } @@ -3165,7 +3165,7 @@ sub kit_addpkgs next; } if ($l =~ /prerequisite/ ) { - $::NOPREREQUISITE = 1; + $::PREREQUISITE = 1; } } diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index bab92e17c..35c1392be 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -748,9 +748,19 @@ sub assign_to_osimage last; } } + if ( $line =~ /^-prep_$basename$/ ) { + $matched = 1; + $changed = 1; + } unless ( $matched ) { push @l, "$line\n"; } + + my $lastline = pop @l; + while ( $lastline =~ /^#NEW_INSTALL_LIST#$/ ) { + $lastline = pop @l; + } + push @l, $lastline if ( $lastline ); } if ( $changed ) { @@ -1967,11 +1977,12 @@ sub rmkitcomp foreach my $kitcomponent (@kitcomponents) { # Check if it is a kitcompname or basename - (my $kitcomptable) = $tabs{kitcomponent}->getAttribs({kitcompname => $kitcomponent}, 'kitname', 'kitpkgdeps', 'postbootscripts', 'genimage_postinstall', 'kitreponame', 'exlist', 'basename', 'driverpacks'); + (my $kitcomptable) = $tabs{kitcomponent}->getAttribs({kitcompname => $kitcomponent}, 'kitname', 'kitpkgdeps', 'prerequisite', 'postbootscripts', 'genimage_postinstall', 'kitreponame', 'exlist', 'basename', 'driverpacks'); if ( $kitcomptable and $kitcomptable->{'kitname'}){ $kitcomps{$kitcomponent}{name} = $kitcomponent; $kitcomps{$kitcomponent}{kitname} = $kitcomptable->{kitname}; $kitcomps{$kitcomponent}{kitpkgdeps} = $kitcomptable->{kitpkgdeps}; + $kitcomps{$kitcomponent}{prerequisite} = $kitcomptable->{prerequisite}; $kitcomps{$kitcomponent}{basename} = $kitcomptable->{basename}; $kitcomps{$kitcomponent}{exlist} = $kitcomptable->{exlist}; $kitcomps{$kitcomponent}{postbootscripts} = $kitcomptable->{postbootscripts}; @@ -1989,9 +2000,10 @@ sub rmkitcomp my $highest = get_highest_version('kitcompname', 'version', 'release', @entries); $kitcomps{$highest}{name} = $highest; - (my $kitcomptable) = $tabs{kitcomponent}->getAttribs({kitcompname => $highest}, 'kitname', 'kitpkgdeps', 'postbootscripts', 'genimage_postinstall', 'kitreponame', 'exlist', 'basename', 'driverpacks'); + (my $kitcomptable) = $tabs{kitcomponent}->getAttribs({kitcompname => $highest}, 'kitname', 'kitpkgdeps', 'prerequisite', 'postbootscripts', 'genimage_postinstall', 'kitreponame', 'exlist', 'basename', 'driverpacks'); $kitcomps{$highest}{kitname} = $kitcomptable->{kitname}; $kitcomps{$highest}{kitpkgdeps} = $kitcomptable->{kitpkgdeps}; + $kitcomps{$highest}{prerequisite} = $kitcomptable->{prerequisite}; $kitcomps{$highest}{basename} = $kitcomptable->{basename}; $kitcomps{$highest}{exlist} = $kitcomptable->{exlist}; $kitcomps{$highest}{postbootscripts} = $kitcomptable->{postbootscripts}; @@ -2358,6 +2370,17 @@ sub rmkitcomp $num = 1; $inlist = 1; } + if ( $kitcomps{$kitcomponent}{prerequisite} ) { + if ( $line =~ /^$kitreponame\/prep_$basename$/ ) { + if ( $inlist ) { + $num--; + foreach ( 1..$num ) { + pop @newlines; + } + } + next; + } + } if ( $line =~ /^$kitreponame\/$basename$/ ) { if ( $inlist ) { $num--; @@ -2423,7 +2446,29 @@ sub rmkitcomp push @kitpkgdeps, $basename; my $update = 0; + + #check if prerequisite rpm is already added to RMPKGS.otherpkgs.pkglist. + my $matched = 0; + foreach my $line ( @lines ) { + chomp $line; + if ( $line =~ /^-prep_$basename$/ ) { + $matched = 1; + last; + } + } + unless ( $matched ) { + # add the prerequisite rpm to #NEW_INSTALL_LIST# session + # so they can be removed in a seperate command + if ( $kitcomps{$kitcomponent}{prerequisite} ) { + push @l, "#NEW_INSTALL_LIST#\n"; + push @l, "-prep_$basename\n"; + } + $update = 1; + } + + my $added_mark = 0; foreach my $kitpkgdep ( @kitpkgdeps ) { + next if ( $kitpkgdep =~ /^$/ ); my $matched = 0; foreach my $line ( @lines ) { chomp $line; @@ -2434,12 +2479,23 @@ sub rmkitcomp } unless ( $matched ) { - push @l, "-$kitpkgdep\n"; + # add the prerequisite rpm to #NEW_INSTALL_LIST# session + # so they can be removed in a seperate command + if ( $kitcomps{$kitcomponent}{prerequisite} ) { + if (!$added_mark) { + push @l, "#NEW_INSTALL_LIST#\n"; + $added_mark = 1; + } + push @l, "-$kitpkgdep\n"; + } else { + unshift @l, "-$kitpkgdep\n"; + } $update = 1; } } + if ( $update and open(RMPKGLIST, ">", "$installdir/osimages/$osimage/kits/KIT_RMPKGS.otherpkgs.pkglist") ) { print RMPKGLIST @l; close(RMPKGLIST);