initial checkin of xCAT-buildkit rpm

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14202 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
mellor 2012-11-01 17:22:53 +00:00
parent f21e2939e0
commit d24431934e
27 changed files with 4096 additions and 1 deletions

View File

@ -174,7 +174,7 @@ if [ "$OSNAME" = "AIX" ]; then
fi
# Build the rest of the noarch rpms
for rpmname in xCAT-client xCAT-server xCAT-IBMhpc xCAT-rmc xCAT-UI xCAT-test; do
for rpmname in xCAT-client xCAT-server xCAT-IBMhpc xCAT-rmc xCAT-UI xCAT-test xCAT-build; do
if $GREP $rpmname $SVNUP || [ "$BUILDALL" == 1 ]; then
UPLOAD=1
if [ "$EMBED" = "zvm" -a "$rpmname" != "xCAT-server" -a "$rpmname" != "xCAT-UI" ]; then continue; fi # for embedded envs only need to build server special

326
xCAT-buildkit/LICENSE.html Normal file
View File

@ -0,0 +1,326 @@
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 9">
<meta name=Originator content="Microsoft Word 9">
<title>Eclipse Public License - Version 1.0</title>
<!--[if gte mso 9]><xml>
<o:DocumentProperties>
<o:Revision>2</o:Revision>
<o:TotalTime>3</o:TotalTime>
<o:Created>2004-03-05T23:03:00Z</o:Created>
<o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
<o:Pages>4</o:Pages>
<o:Words>1626</o:Words>
<o:Characters>9270</o:Characters>
<o:Lines>77</o:Lines>
<o:Paragraphs>18</o:Paragraphs>
<o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
<o:Version>9.4402</o:Version>
</o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:TrackRevisions/>
</w:WordDocument>
</xml><![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:553679495 -2147483648 8 0 66047 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
p
{margin-right:0in;
mso-margin-top-alt:auto;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
p.BalloonText, li.BalloonText, div.BalloonText
{mso-style-name:"Balloon Text";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:8.0pt;
font-family:Tahoma;
mso-fareast-font-family:"Times New Roman";}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
</head>
<body lang=EN-US style='tab-interval:.5in'>
<div class=Section1>
<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
</p>
<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
OF THIS AGREEMENT.</span> </p>
<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
in the case of the initial Contributor, the initial code and documentation
distributed under this Agreement, and<br clear=left>
b) in the case of each subsequent Contributor:</span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
changes to the Program, and</span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
additions to the Program;</span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
such changes and/or additions to the Program originate from and are distributed
by that particular Contributor. A Contribution 'originates' from a Contributor
if it was added to the Program by such Contributor itself or anyone acting on
such Contributor's behalf. Contributions do not include additions to the
Program which: (i) are separate modules of software distributed in conjunction
with the Program under their own license agreement, and (ii) are not derivative
works of the Program. </span></p>
<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
entity that distributes the Program.</span> </p>
<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
claims licensable by a Contributor which are necessarily infringed by the use
or sale of its Contribution alone or when combined with the Program. </span></p>
<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
distributed in accordance with this Agreement.</span> </p>
<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
receives the Program under this Agreement, including all Contributors.</span> </p>
<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
Subject to the terms of this Agreement, each Contributor hereby grants Recipient
a non-exclusive, worldwide, royalty-free copyright license to<span
style='color:red'> </span>reproduce, prepare derivative works of, publicly
display, publicly perform, distribute and sublicense the Contribution of such
Contributor, if any, and such derivative works, in source code and object code
form.</span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
Subject to the terms of this Agreement, each Contributor hereby grants
Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
patent license under Licensed Patents to make, use, sell, offer to sell, import
and otherwise transfer the Contribution of such Contributor, if any, in source
code and object code form. This patent license shall apply to the combination
of the Contribution and the Program if, at the time the Contribution is added
by the Contributor, such addition of the Contribution causes such combination
to be covered by the Licensed Patents. The patent license shall not apply to
any other combinations which include the Contribution. No hardware per se is
licensed hereunder. </span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
Recipient understands that although each Contributor grants the licenses to its
Contributions set forth herein, no assurances are provided by any Contributor
that the Program does not infringe the patent or other intellectual property
rights of any other entity. Each Contributor disclaims any liability to Recipient
for claims brought by any other entity based on infringement of intellectual
property rights or otherwise. As a condition to exercising the rights and
licenses granted hereunder, each Recipient hereby assumes sole responsibility
to secure any other intellectual property rights needed, if any. For example,
if a third party patent license is required to allow Recipient to distribute
the Program, it is Recipient's responsibility to acquire that license before
distributing the Program.</span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
Each Contributor represents that to its knowledge it has sufficient copyright
rights in its Contribution, if any, to grant the copyright license set forth in
this Agreement. </span></p>
<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
Program in object code form under its own license agreement, provided that:</span>
</p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
it complies with the terms and conditions of this Agreement; and</span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
its license agreement:</span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
effectively disclaims on behalf of all Contributors all warranties and
conditions, express and implied, including warranties or conditions of title
and non-infringement, and implied warranties or conditions of merchantability
and fitness for a particular purpose; </span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
effectively excludes on behalf of all Contributors all liability for damages,
including direct, indirect, special, incidental and consequential damages, such
as lost profits; </span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
states that any provisions which differ from this Agreement are offered by that
Contributor alone and not by any other party; and</span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
states that source code for the Program is available from such Contributor, and
informs licensees how to obtain it in a reasonable manner on or through a
medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
<p><span style='font-size:10.0pt'>When the Program is made available in source
code form:</span> </p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
it must be made available under this Agreement; and </span></p>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
copy of this Agreement must be included with each copy of the Program. </span></p>
<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
copyright notices contained within the Program. </span></p>
<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
originator of its Contribution, if any, in a manner that reasonably allows
subsequent Recipients to identify the originator of the Contribution. </span></p>
<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
<p><span style='font-size:10.0pt'>Commercial distributors of software may
accept certain responsibilities with respect to end users, business partners
and the like. While this license is intended to facilitate the commercial use
of the Program, the Contributor who includes the Program in a commercial
product offering should do so in a manner which does not create potential
liability for other Contributors. Therefore, if a Contributor includes the
Program in a commercial product offering, such Contributor (&quot;Commercial
Contributor&quot;) hereby agrees to defend and indemnify every other
Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
legal actions brought by a third party against the Indemnified Contributor to
the extent caused by the acts or omissions of such Commercial Contributor in
connection with its distribution of the Program in a commercial product
offering. The obligations in this section do not apply to any claims or Losses
relating to any actual or alleged intellectual property infringement. In order
to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
Contributor in writing of such claim, and b) allow the Commercial Contributor
to control, and cooperate with the Commercial Contributor in, the defense and
any related settlement negotiations. The Indemnified Contributor may participate
in any such claim at its own expense.</span> </p>
<p><span style='font-size:10.0pt'>For example, a Contributor might include the
Program in a commercial product offering, Product X. That Contributor is then a
Commercial Contributor. If that Commercial Contributor then makes performance
claims, or offers warranties related to Product X, those performance claims and
warranties are such Commercial Contributor's responsibility alone. Under this
section, the Commercial Contributor would have to defend claims against the
other Contributors related to those performance claims and warranties, and if a
court requires any other Contributor to pay any damages as a result, the
Commercial Contributor must pay those damages.</span> </p>
<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
responsible for determining the appropriateness of using and distributing the
Program and assumes all risks associated with its exercise of rights under this
Agreement , including but not limited to the risks and costs of program errors,
compliance with applicable laws, damage to or loss of data, programs or
equipment, and unavailability or interruption of operations. </span></p>
<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
or unenforceable under applicable law, it shall not affect the validity or
enforceability of the remainder of the terms of this Agreement, and without
further action by the parties hereto, such provision shall be reformed to the
minimum extent necessary to make such provision valid and enforceable.</span> </p>
<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
against any entity (including a cross-claim or counterclaim in a lawsuit)
alleging that the Program itself (excluding combinations of the Program with
other software or hardware) infringes such Recipient's patent(s), then such
Recipient's rights granted under Section 2(b) shall terminate as of the date
such litigation is filed. </span></p>
<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
shall terminate if it fails to comply with any of the material terms or
conditions of this Agreement and does not cure such failure in a reasonable
period of time after becoming aware of such noncompliance. If all Recipient's
rights under this Agreement terminate, Recipient agrees to cease use and
distribution of the Program as soon as reasonably practicable. However,
Recipient's obligations under this Agreement and any licenses granted by
Recipient relating to the Program shall continue and survive. </span></p>
<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
copies of this Agreement, but in order to avoid inconsistency the Agreement is
copyrighted and may only be modified in the following manner. The Agreement
Steward reserves the right to publish new versions (including revisions) of
this Agreement from time to time. No one other than the Agreement Steward has
the right to modify this Agreement. The Eclipse Foundation is the initial
Agreement Steward. The Eclipse Foundation may assign the responsibility to
serve as the Agreement Steward to a suitable separate entity. Each new version
of the Agreement will be given a distinguishing version number. The Program
(including Contributions) may always be distributed subject to the version of
the Agreement under which it was received. In addition, after a new version of
the Agreement is published, Contributor may elect to distribute the Program
(including its Contributions) under the new version. Except as expressly stated
in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
the intellectual property of any Contributor under this Agreement, whether
expressly, by implication, estoppel or otherwise. All rights in the Program not
expressly granted under this Agreement are reserved.</span> </p>
<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
State of New York and the intellectual property laws of the United States of
America. No party to this Agreement will bring a legal action under this
Agreement more than one year after the cause of action arose. Each party waives
its rights to a jury trial in any resulting litigation.</span> </p>
<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
</div>
</body>
</html>

1996
xCAT-buildkit/bin/buildkit Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,752 @@
#!/usr/bin/env perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
package xCAT::BuildKitUtils;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
}
# if AIX - make sure we include perl 5.8.2 in INC path.
# Needed to find perl dependencies shipped in deps tarball.
if ($^O =~ /^aix/i) {
unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2));
}
use lib "$::XCATROOT/lib/perl";
use POSIX qw(ceil);
use File::Path;
use Socket;
use strict;
use Symbol;
my $sha1support = eval {
require Digest::SHA1;
1;
};
use IPC::Open3;
use IO::Select;
use xCAT::GlobalDef;
eval {
require xCAT::RemoteShellExp;
};
use warnings "all";
require xCAT::InstUtils;
#require xCAT::NetworkUtils;
require xCAT::Schema;
#require Data::Dumper;
require xCAT::NodeRange;
require xCAT::Version;
require DBI;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(genpassword runcmd3);
#--------------------------------------------------------------------------------
=head1 xCAT::BuildKitUtils
=head2 Package Description
This program module file, is a set of utilities used by xCAT buildkit command
=cut
#-------------------------------------------------------------
#-------------------------------------------------------------------------------
=head3 isAIX
returns 1 if localHost is AIX
Arguments:
none
Returns:
1 - localHost is AIX
0 - localHost is some other platform
Globals:
none
Error:
none
Example:
if (xCAT::BuildKitUtils->isAIX()) { blah; }
Comments:
none
=cut
#-------------------------------------------------------------------------------
sub isAIX
{
if ($^O =~ /^aix/i) { return 1; }
else { return 0; }
}
#-------------------------------------------------------------------------------
=head3 get_OS_VRMF
Arguments:
none
Returns:
v.r.m.f - if success
undef - if error
Example:
my $osversion = xCAT::BuildKitUtils->get_OS_VRMF();
Comments:
Only implemented for AIX for now
=cut
#-------------------------------------------------------------------------------
sub get_OS_VRMF
{
my $version;
if (xCAT::BuildKitUtils->isAIX()) {
my $cmd = "/usr/bin/lslpp -cLq bos.rte";
my $output = `$cmd`;
chomp($output);
# The third field in the lslpp output is the VRMF
$version = (split(/:/, $output))[2];
# not sure if the field would ever contain more than 4 parts?
my ($v1, $v2, $v3, $v4, $rest) = split(/\./, $version);
$version = join(".", $v1, $v2, $v3, $v4);
}
return (length($version) ? $version : undef);
}
#----------------------------------------------------------------------------
=head3 testversion
Compare version1 and version2 according to the operator and
return True or False.
Arguments:
$version1
$operator
$version2
$release1
$release2
Returns:
True or False
Example:
if (BuildKitUtils->testversion ( $ins_ver,
"<",
$req_ver,
$ins_rel,
$req_rel)){ blah; }
Comments:
=cut
#-------------------------------------------------------------------------------
sub testversion
{
my ($class, $version1, $operator, $version2, $release1, $release2) = @_;
my @a1 = split(/\./, $version1);
my @a2 = split(/\./, $version2);
my $len = (scalar(@a1) > scalar(@a2) ? scalar(@a1) : scalar(@a2));
$#a1 = $len - 1; # make the arrays the same length before appending release
$#a2 = $len - 1;
push @a1, split(/\./, $release1);
push @a2, split(/\./, $release2);
$len = (scalar(@a1) > scalar(@a2) ? scalar(@a1) : scalar(@a2));
my $num1 = '';
my $num2 = '';
for (my $i = 0 ; $i < $len ; $i++)
{
my ($d1) = $a1[$i] =~ /^(\d*)/; # remove any non-numbers on the end
my ($d2) = $a2[$i] =~ /^(\d*)/;
my $diff = length($d1) - length($d2);
if ($diff > 0) # pad d2
{
$num1 .= $d1;
$num2 .= ('0' x $diff) . $d2;
}
elsif ($diff < 0) # pad d1
{
$num1 .= ('0' x abs($diff)) . $d1;
$num2 .= $d2;
}
else # they are the same length
{
$num1 .= $d1;
$num2 .= $d2;
}
}
# Remove the leading 0s or perl will interpret the numbers as octal
$num1 =~ s/^0+//;
$num2 =~ s/^0+//;
#SLES Changes ??
# if $num1="", the "eval '$num1 $operator $num2'" will fail.
# So MUST BE be sure that $num1 is not a "".
if (length($num1) == 0) { $num1 = 0; }
if (length($num2) == 0) { $num2 = 0; }
#End of SLES Changes
if ($operator eq '=') { $operator = '=='; }
my $bool = eval "$num1 $operator $num2";
if (length($@))
{
# error msg ?
}
return $bool;
}
#-------------------------------------------------------------------------------
=head3 isLinux
returns 1 if localHost is Linux
Arguments:
none
Returns:
1 - localHost is Linux
0 - localHost is some other platform
Globals:
none
Error:
none
Example:
if (xCAT::BuildKitUtils->isLinux()) { blah; }
Comments:
none
=cut
#-------------------------------------------------------------------------------
sub isLinux
{
if ($^O =~ /^linux/i) { return 1; }
else { return 0; }
}
#--------------------------------------------------------------------------------
=head3 CreateRandomName
Create a random file name.
Arguments:
Prefix of name
Returns:
Prefix with 8 random letters appended
Error:
none
Example:
$file = xCAT::BuildKitUtils->CreateRandomName($namePrefix);
Comments:
None
=cut
#-------------------------------------------------------------------------------
sub CreateRandomName
{
my ($class, $name) = @_;
my $nI;
for ($nI = 0 ; $nI < 8 ; $nI++)
{
my $char = ('a' .. 'z', 'A' .. 'Z')[int(rand(52)) + 1];
$name .= $char;
}
$name;
}
#-----------------------------------------------------------------------
=head3
close_delete_file.
Arguments:
file handle,filename
Returns:
none
Globals:
none
Error:
undef
Example:
xCAT::BuildKitUtils->close_delete_file($file_handle, $file_name);
Comments:
none
=cut
#------------------------------------------------------------------------
sub close_delete_file
{
my ($class, $file_handle, $file_name) = @_;
close $file_handle;
unlink($file_name);
}
#-------------------------------------------------------------------------------
=head3 runcmd3
Run the specified command with optional input and return stderr, stdout, and exit code
Arguments:
command=>[] - Array reference of command to run
input=>[] or string - Data to send to stdin of process like piping input
Returns:
{ exitcode => number, output=> $string, errors => string }
=cut
sub runcmd3 { #a proper runcmd that indpendently returns stdout, stderr, pid and accepts a stdin
my %args = @_;
my @indata;
my $output;
my $errors;
if ($args{input}) {
if (ref $args{input}) { #array ref
@indata = @{$args{input}};
} else { #just a string
@indata=($args{input});
}
}
my @cmd;
if (ref $args{command}) {
@cmd = @{$args{command}};
} else {
@cmd = ($args{command});
}
my $cmdin;
my $cmdout;
my $cmderr = gensym;
my $cmdpid = open3($cmdin,$cmdout,$cmderr,@cmd);
my $cmdsel = IO::Select->new($cmdout,$cmderr);
foreach (@indata) {
print $cmdin $_;
}
close($cmdin);
my @handles;
while ($cmdsel->count()) {
@handles = $cmdsel->can_read();
foreach (@handles) {
my $line;
my $done = sysread $_,$line,180;
if ($done) {
if ($_ eq $cmdout) {
$output .= $line;
} else {
$errors .= $line;
}
} else {
$cmdsel->remove($_);
close($_);
}
}
}
waitpid($cmdpid,0);
my $exitcode = $? >> 8;
return { 'exitcode' => $exitcode, 'output' => $output, 'errors' => $errors }
}
#-------------------------------------------------------------------------------
=head3 runcmd
Run the given cmd and return the output in an array (already chopped).
Alternately, if this function is used in a scalar context, the output
is joined into a single string with the newlines separating the lines.
Arguments:
command, exitcode, reference to output, streaming mode
Returns:
see below
Globals:
$::RUNCMD_RC , $::CALLBACK
Error:
Normally, if there is an error running the cmd,it will display the
error and exit with the cmds exit code, unless exitcode
is given one of the following values:
0: display error msg, DO NOT exit on error, but set
$::RUNCMD_RC to the exit code.
-1: DO NOT display error msg and DO NOT exit on error, but set
$::RUNCMD_RC to the exit code.
-2: DO the default behavior (display error msg and exit with cmds
exit code.
number > 0: Display error msg and exit with the given code
Example:
my $outref = xCAT::BuildKitUtils->runcmd($cmd, -2, 1);
$::CALLBACK= your callback (required for streaming from plugins)
my $outref = xCAT::BuildKitUtils->runcmd($cmd,-2, 1, 1); streaming
Comments:
If refoutput is true, then the output will be returned as a
reference to an array for efficiency.
=cut
#-------------------------------------------------------------------------------
sub runcmd
{
my ($class, $cmd, $exitcode, $refoutput, $stream) = @_;
$::RUNCMD_RC = 0;
# redirect stderr to stdout
if (!($cmd =~ /2>&1$/)) { $cmd .= ' 2>&1'; }
my $outref = [];
if (!defined($stream) || (length($stream) == 0)) { # do not stream
@$outref = `$cmd`;
} else { # streaming mode
my @cmd;
push @cmd,$cmd;
my $rsp = {};
my $output;
my $errout;
open (PIPE, "$cmd |");
while (<PIPE>) {
if ($::CALLBACK){
$rsp->{data}->[0] = $_;
$::CALLBACK->($rsp);
} else {
xCAT::MsgUtils->message("D", "$_");
}
$output .= $_;
}
# store the return string
push @$outref,$output;
}
# now if not streaming process errors
if (($?) && (!defined($stream)))
{
$::RUNCMD_RC = $? >> 8;
my $displayerror = 1;
my $rc;
if (defined($exitcode) && length($exitcode) && $exitcode != -2)
{
if ($exitcode > 0)
{
$rc = $exitcode;
} # if not zero, exit with specified code
elsif ($exitcode <= 0)
{
$rc = ''; # if zero or negative, do not exit
if ($exitcode < 0) { $displayerror = 0; }
}
}
else
{
$rc = $::RUNCMD_RC;
} # if exitcode not specified, use cmd exit code
if ($displayerror)
{
my $rsp = {};
my $errmsg = '';
if (xCAT::BuildKitUtils->isLinux() && $::RUNCMD_RC == 139)
{
$errmsg = "Segmentation fault $errmsg";
}
else
{
$errmsg = join('', @$outref);
chomp $errmsg;
}
if ($::CALLBACK)
{
$rsp->{data}->[0] =
"Command failed: $cmd. Error message: $errmsg.\n";
xCAT::MsgUtils->message("E", $rsp, $::CALLBACK);
}
else
{
xCAT::MsgUtils->message("E",
"Command failed: $cmd. Error message: $errmsg.\n");
}
$xCAT::BuildKitUtils::errno = 29;
}
}
if ($refoutput)
{
chomp(@$outref);
return $outref;
}
elsif (wantarray)
{
chomp(@$outref);
return @$outref;
}
else
{
my $line = join('', @$outref);
chomp $line;
return $line;
}
}
#-------------------------------------------------------------------------------
=head3 CheckVersion
Checks the two versions numbers to see which one is greater.
Arguments:
ver_a the version number in format of d.d.d.d...
ver_b the version number in format of d.d.d.d...
Returns:
1 if ver_a is greater than ver_b
0 if ver_a is eaqual to ver_b
-1 if ver_a is smaller than ver_b
=cut
#-------------------------------------------------------------------------------
sub CheckVersion
{
my $ver_a = shift;
if ($ver_a =~ /xCAT::BuildKitUtils/)
{
$ver_a = shift;
}
my $ver_b = shift;
my @a = split(/\./, $ver_a);
my @b = split(/\./, $ver_b);
my $len_a = @a;
my $len_b = @b;
my $index = 0;
my $max_index = ($len_a > $len_b) ? $len_a : $len_b;
for ($index = 0 ; $index <= $max_index ; $index++)
{
my $val_a = ($len_a < $index) ? 0 : $a[$index];
my $val_b = ($len_b < $index) ? 0 : $b[$index];
if ($val_a > $val_b) { return 1; }
if ($val_a < $val_b) { return -1; }
}
return 0;
}
#-------------------------------------------------------------------------------
=head3 osver
Returns the os and version of the System you are running on
Arguments:
none
Returns:
0 - ok
Globals:
none
Error:
1 error
Example:
my $os=(xCAT::BuildKitUtils->osver{ ...}
Comments:
none
=cut
#-------------------------------------------------------------------------------
sub osver
{
my $osver = "unknown";
my $os = '';
my $ver = '';
my $line = '';
my @lines;
my $relfile;
if (-f "/etc/redhat-release")
{
open($relfile,"<","/etc/redhat-release");
$line = <$relfile>;
close($relfile);
chomp($line);
$os = "rh";
$ver=$line;
# $ver=~ s/\.//;
$ver =~ s/[^0-9]*([0-9.]+).*/$1/;
if ($line =~ /AS/) { $os = 'rhas' }
elsif ($line =~ /ES/) { $os = 'rhes' }
elsif ($line =~ /WS/) { $os = 'rhws' }
elsif ($line =~ /Server/) { $os = 'rhels' }
elsif ($line =~ /Client/) { $os = 'rhel' }
elsif (-f "/etc/fedora-release") { $os = 'rhfc' }
}
elsif (-f "/etc/SuSE-release")
{
open($relfile,"<","/etc/SuSE-release");
@lines = <$relfile>;
close($relfile);
chomp(@lines);
if (grep /SLES|Enterprise Server/, @lines) { $os = "sles" }
if (grep /SLEC/, @lines) { $os = "slec" }
$ver = $lines[0];
$ver =~ s/\.//;
$ver =~ s/[^0-9]*([0-9]+).*/$1/;
#print "ver: $ver\n";
}
elsif (-f "/etc/UnitedLinux-release")
{
$os = "ul";
open($relfile,"<","/etc/UnitedLinux-release");
$ver = <$relfile>;
close($relfile);
$ver =~ tr/\.//;
$ver =~ s/[^0-9]*([0-9]+).*/$1/;
}
elsif (-f "/etc/lsb-release") # Possibly Ubuntu
{
if (open($relfile,"<","/etc/lsb-release")) {
my @text = <$relfile>;
close($relfile);
chomp(@text);
my $distrib_id = '';
my $distrib_rel = '';
foreach (@text) {
if ( $_ =~ /^\s*DISTRIB_ID=(.*)$/ ) {
$distrib_id = $1; # last DISTRIB_ID value in file used
} elsif ( $_ =~ /^\s*DISTRIB_RELEASE=(.*)$/ ) {
$distrib_rel = $1; # last DISTRIB_RELEASE value in file used
}
}
if ( $distrib_id =~ /^(Ubuntu|"Ubuntu")\s*$/ ) {
$os = "ubuntu";
if ( $distrib_rel =~ /^(.*?)\s*$/ ) { # eliminate trailing blanks, if any
$distrib_rel = $1;
}
if ( $distrib_rel =~ /^"(.*?)"$/ ) { # eliminate enclosing quotes, if any
$distrib_rel = $1;
}
$ver = $distrib_rel;
}
}
}
$os = "$os" . "," . "$ver";
return ($os);
}
#-----------------------------------------------------------------------------
=head3 acquire_lock
Get a lock on an arbirtrary named resource. For now, this is only across the scope of one service node/master node, an argument may be added later if/when 'global' locks are supported. This call will block until the lock is free.
Arguments:
A string name for the lock to acquire
Returns:
false on failure
A reference for the lock being held.
=cut
sub acquire_lock {
my $lock_name = shift;
use File::Path;
mkpath("/var/lock/xcat/");
use Fcntl ":flock";
my $tlock;
$tlock->{path}="/var/lock/xcat/".$lock_name;
open($tlock->{fd},">",$tlock->{path}) or return undef;
unless ($tlock->{fd}) { return undef; }
flock($tlock->{fd},LOCK_EX) or return undef;
return $tlock;
}
#---------------------
=head3 release_lock
Release an acquired lock
Arguments:
reference to lock
Returns:
false on failure, true on success
=cut
sub release_lock {
my $tlock = shift;
unlink($tlock->{path});
flock($tlock->{fd},LOCK_UN);
close($tlock->{fd});
}
#-------------------------------------------------------------------------------
=head3 get_unique_members
Description:
Return an array which have unique members
Arguments:
origarray: the original array to be treated
Returns:
Return an array, which contains unique members.
Globals:
none
Error:
none
Example:
my @new_array = xCAT::BuildKitUtils::get_unique_members(@orig_array);
Comments:
=cut
#-------------------------------------------------------------------------------
sub get_unique_members
{
my @orig_array = @_;
my %tmp_hash = ();
for my $ent (@orig_array)
{
$tmp_hash{$ent} = 1;
}
return keys %tmp_hash;
}
#-------------------------------------------------------------------------------
=head3 full_path
Description:
Convert the relative path to full path.
Arguments:
relpath: relative path
cwdir: current working directory, use the cwd() if not specified
Returns:
Return the full path
NULL - Failed to get the full path.
Globals:
none
Error:
none
Example:
my $fp = xCAT::BuildKitUtils::full_path('./test', '/home/guest');
Comments:
=cut
#-------------------------------------------------------------------------------
sub full_path
{
my ($class, $relpath, $cwdir) = @_;
my $fullpath;
if (!$cwdir) { #cwdir is not specified
$fullpath = Cwd::abs_path($relpath);
} else {
$fullpath = $cwdir . "/$relpath";
}
return $fullpath;
}
1;

View File

@ -0,0 +1,189 @@
# Kit Build File
#
# This file was initially auto-generated by the buildkit CLI command.
# To create a new kit, the user should modify this file accordingly.
# Refer to the buildkit manpage for further details.
#
# kit: This section defines general info for the Kit.
# There must be exactly one kit section in a kit build file.
#
# kit attributes:
# basename (mandatory) Kit base name. e.g., kit-lsf
# desc (optional) Kit description.
# version (mandatory) Kit version. e.g., 1.0
# ostype (mandatory) Kit OS type. Must be Linux.
# AIX is currently not supported.
# isinternal (optional) PCM use only.
# Indicate if Kit is for internal use.
# Use 1 for yes, 0 for no. Default: 0
# kitdeployparams (optional) Filename containing a list of kit deployment
# parameters, relative to
# <Kit Build Directory>/other_files
kit:
basename=<<<INSERT_kitbasename_HERE>>>
desc=description for <<<INSERT_kitbasename_HERE>>>
version=1.0
ostype=Linux
kitdeployparams=sample/kitdeployparams.lst
# kitrepo: This section defines a Kit Package Repository.
# There must be at least one kitrepo section in a kit build file.
# If you want to support multiple OSes, you should create a separate
# repo for each OS. Also, no two repos can be defined with the same
# OS name, major/minor version and arch. For example, you cannot have
# two repos for RHEL 6.2 x86_64 in the same kit.
#
# kitrepo attributes:
# kitrepoid (mandatory) Kit package repository ID.
# Must be unique within this file.
# osbasename (mandatory) OS distro base name. e.g., rhels.
# osmajorversion (mandatory) OS major version. e.g., 6
# osminorversion (optional) OS minor version.
# osarch (mandatory) OS architecture. e.g., x86_64
# compat_osbasenames (optional) Comma-separated list of compatible
# OS distro base names. e.g., centos
kitrepo:
kitrepoid=<<<INSERT_kitrepoid_HERE>>>
osbasename=<<<INSERT_osbasename_HERE>>>
osmajorversion=<<<INSERT_osmajorversion_HERE>>>
osminorversion=<<<INSERT_osminorversion_HERE>>>
osarch=<<<INSERT_osarch_HERE>>>
#compat_osbasenames=
# kitcomponent: This section defines one Kit Component.
# There can be zero or more kitcomponent sections.
# If you want to build a component which supports multiple OSes,
# you should create one kitcomponent section for each OS.
# Also, no two components in a kit can be defined with the same
# base name.
#
# kitcomponent attributes:
# basename (mandatory) Kit component base name
# desc (optional) Kit component description
# version (mandatory) Kit component version
# release (mandatory) Kit component release
# serverroles (mandatory) Comma-separated list of servers that this
# component can install on. Valid values:
# mgtnode,servicenode,compute,loginnode,storagenode
# kitrepoid (mandatory) The ID of the kit package repository this
# component belongs to
# kitcompdeps (optional) Comma-separated list of kit component
# dependencies. These kit components can be included in
# this kit or in other kits.
# ospkgdeps (optional) Comma-separated list of OS package dependencies
# These packages must be shipped with the OS distro.
# kitpkgdeps (optional) Comma-separated list of kit package names that
# will be listed as "REQUIRES" when building this kit
# component. Each package must be defined in a separate
# kitpackage section. Each package must be in the same
# kitrepo as this kit component.
# non_native_pkgs (optional) TBD -- NOT SUPPORTED YET!
# Comma-separated list of non-native package
# paths that will be included as files in this kit
# component. All filenames are relative to
# <Kit Build Directory>/source_packages
# Kit component deployment scripts must be specified
# to manage these files.
# driverpacks (optional) Comma-separated list of driver package filenames
# Each driverpack must be defined in a separate kitpackage
# section.
# exlist (optional) Exclude list file for stateless image, relative
# to <Kit Build Directory>/other_files
# Kit component deployment scripts (optional) Each attribute specifies
# script path relative to <Kit Build Directory>/scripts
# Script attributes:
# preinstall, postinstall, preuninstall, postuninstall,
# preupgrade, postupgrade, postbootscripts
kitcomponent:
basename=<<<INSERT_kitcomponent_basename_HERE>>>
desc=description for component <<<INSERT_kitcomponent_basename_HERE>>>
version=1.0
release=1
serverroles=compute
kitrepoid=<<<INSERT_kitrepoid_HERE>>>
#kitcompdeps=
#ospkgdeps=
kitpkgdeps=pkg1
#kitpkgdeps=pkg1,pkg2,pkg2,pkg4
#non_native_pkgs=
#driverpacks=
exlist=sample/exclude.lst
preinstall=sample/pre.sh
postinstall=sample/post.sh
preuninstall=sample/preun.sh
postuninstall=sample/postun.sh
preupgrade=sample/preup.sh
postupgrade=sample/postup.sh
postbootscripts=sample/postboot.sh
# kitpackage: This section defines one Kit Package, and how to build it.
# There can be zero or more kitpackage sections.
# All filenames should be relative paths to
# <Kit Build Directory>/source_packages
# If you want to build a package which can run on multiple OSes,
# you have two options:
# 1. Build a separate package for each OS you want to support.
# For this option, you need to define one kitpackage section
# per supported OS.
# 2. Build one package that can run on multiple OSes.
# If you are building an RPM package, you are responsible for
# creating an RPM spec file that can run on multiple OSes.
# For this option, you need to define one kitpackage section
# which contains multiple kitrepoid lines.
#
# kitpackage attributes:
# filename (mandatory) Package filename
# kitrepoid (mandatory) The repo(s) this package belongs to.
# If multiple repos are defined, the package will be built for
# the first repo only. For the other repos, a symlink is created
# to the package built for the first repo.
# Package build methods (optional)
# Define how to build the packages.
# If you don't specify a build method, the default behavior is
# to assume the package is pre-built under
# <Kit Build Directory>/source_packages
# All files in this section are relative to
# <Kit Build Directory>/source_packages
# There are four methods to build packages.
# 1. Use pre-built RPM package
# rpm_prebuiltdir: Path to directory containing pre-built
# RPM package
# 2. Build RPM from spec + src dir
# rpm_spec: Path to spec file.
# rpm_srcdir: Path to source directory.
# 3. Build RPM from spec + src tarball
# rpm_spec: Path to spec file.
# rpm_srctarball: Path to source tarball.
# 4. Build RPM from source RPM
# rpm_srpm: Path to source RPM package.
kitpackage:
filename=pkg1-1-1.noarch.rpm
kitrepoid=<<<INSERT_kitrepoid_HERE>>>
# Method 1: Use pre-built RPM package
rpm_prebuiltdir=sample/pkg1
#kitpackage:
# filename=pkg2-1-1.noarch.rpm
# kitrepoid=<<<INSERT_kitrepoid_HERE>>>
# # Method 2: Build RPM from spec + src dir
# rpm_spec=sample/pkg2/pkg2.spec
# rpm_srcdir=sample/pkg2/pkg2
#
#kitpackage:
# filename=pkg3-1-1.noarch.rpm
# kitrepoid=<<<INSERT_kitrepoid_HERE>>>
# # Method 3: Build RPM from spec + src tarball
# rpm_spec=sample/pkg3/pkg3.spec
# rpm_srctarball=sample/pkg3/pkg3.tar.gz
#
#kitpackage:
# filename=pkg4-1-1.noarch.rpm
# kitrepoid=<<<INSERT_kitrepoid_HERE>>>
# # Method 4: Build RPM from source RPM
# rpm_srpm=sample/pkg4/pkg4-1-1.src.rpm
#

View File

@ -0,0 +1,175 @@
package xCAT_plugin::<<<buildkit_WILL_INSERT_kitname_HERE>>>_imageprofile;
use strict;
use warnings;
require xCAT::Utils;
require xCAT::Table;
require xCAT::KitPluginUtils;
# buildkit Processing
# In order to avoid collisions with other plugins, the package
# name for this plugin must contain the full kit name.
# The buildkit buildtar command will copy this file from your plugins
# directory to the the kit build directory, renaming the file with the
# correct kit name. All strings in this file of the form
# <<<buildkit_WILL_INSERT_kitname_HERE>>>
# will be replaced with the full kit name. In order for buildkit to
# correctly edit this file, do not remove these strings.
# Global Variables
# This is the full name of the kit which this plugin belongs
# to. The kit name is used by some code in process_request()
# to determine if the plugin should run. When you are testing
# your plugin the kit name should be set to "TESTMODE" to
# bypass the plugin check in process_request().
our ($PLUGIN_KITNAME);
#$PLUGIN_KITNAME = "TESTMODE";
$PLUGIN_KITNAME = "<<<buildkit_WILL_INSERT_kitname_HERE>>>";
#-------------------------------------------------------
=head1
Image Profile Kit Plugin
This plugin contains commands to run custom actions
during image profile operations.
=cut
#-------------------------------------------------------
#-------------------------------------------------------
=head3 handled_commands
Return list of kit plugin commands handled by this plugin
=cut
#-------------------------------------------------------
sub handled_commands {
return {
kitimagevalidatecomps => '<<<buildkit_WILL_INSERT_kitname_HERE>>>_imageprofile',
kitimageimport => '<<<buildkit_WILL_INSERT_kitname_HERE>>>_imageprofile',
};
}
#-------------------------------------------------------
=head3 process_request
Process the kit plugin command.
=cut
#-------------------------------------------------------
sub process_request {
my $request = shift;
my $callback = shift;
# This kit plugin is passed the name of an image profile.
# We need to determine which kits is used by this
# image profile to decide if this plugin should run or not.
my $imgprofilename = $request->{arg}->[0];
my $kitdata = $request->{kitdata};
if (! defined($kitdata)) {
$kitdata = xCAT::KitPluginUtils->get_kits_used_by_image_profiles([$imgprofilename]);
$request->{kitdata} = $kitdata;
}
if ($PLUGIN_KITNAME ne "TESTMODE" && ! exists($kitdata->{$PLUGIN_KITNAME})) {
return;
}
# Name of command and node list
my $command = $request->{command}->[0];
my $args = $request->{arg};
if($command eq 'kitimagevalidatecomps') {
kitimagevalidatecomps($callback, $args);
}
elsif ($command eq 'kitimageimport') {
kitimageimport($callback, $args);
} else {
my $rsp;
$rsp->{data}->[0] = "Command is not supported";
xCAT::MsgUtils->message("E", $rsp, $callback);
}
}
#-------------------------------------------------------
=head3 kitimagevalidatecomps
This command is called to validate new changes to an
image profile's kit component list before the changes
are committed.
=cut
#-------------------------------------------------------
sub kitimagevalidatecomps {
my $callback = shift;
my $args = shift;
my $rsp;
# Parameters
my $imgprofilename = $args->[0];
my $newcomplist = $args->[1];
my @newcomplist = ();
if (defined($newcomplist)) {
@newcomplist = split(/,/, $newcomplist);
}
my $newosdistro = $args->[2];
my $newosdistroupdate = $args->[3];
$rsp->{data}->[0] = "Running kitimagevalidatecomps";
xCAT::MsgUtils->message("I", $rsp, $callback);
# TODO
# ... ADD YOUR CODE HERE
}
#-------------------------------------------------------
=head3 kitimageimport
This command is called after changes to an image profile
have been committed.
=cut
#-------------------------------------------------------
sub kitimageimport {
my $callback = shift;
my $args = shift;
my $rsp;
# Parameters
my $imgprofilename = $args->[0];
$rsp->{data}->[0] = "Running kitimageimport";
xCAT::MsgUtils->message("I", $rsp, $callback);
# TODO
# ... ADD YOUR CODE HERE
}

View File

@ -0,0 +1,251 @@
package xCAT_plugin::<<<buildkit_WILL_INSERT_kitname_HERE>>>_nodemgmt;
use strict;
use warnings;
require xCAT::Utils;
require xCAT::Table;
require xCAT::KitPluginUtils;
# buildkit Processing
# In order to avoid collisions with other plugins, the package
# name for this plugin must contain the full kit name.
# The buildkit buildtar command will copy this file from your plugins
# directory to the the kit build directory, renaming the file with the
# correct kit name. All strings in this file of the form
# <<<buildkit_WILL_INSERT_kitname_HERE>>>
# will be replaced with the full kit name. In order for buildkit to
# correctly edit this file, do not remove these strings.
# Global Variables
# This is the full name of the kit which this plugin belongs
# to. The kit name is used by some code in process_request()
# to determine if the plugin should run. When you are testing
# your plugin the kit name should be set to "TESTMODE" to
# bypass the plugin check in process_request().
our ($PLUGIN_KITNAME);
#$PLUGIN_KITNAME = "TESTMODE";
$PLUGIN_KITNAME = "<<<buildkit_WILL_INSERT_kitname_HERE>>>";
#-------------------------------------------------------
=head1
Node Management Kit Plugin
This plugin contains commands to run custom actions
during node management operations.
=cut
#-------------------------------------------------------
#-------------------------------------------------------
=head3 handled_commands
Return list of kit plugin commands handled by this plugin
=cut
#-------------------------------------------------------
sub handled_commands {
return {
kitnodeadd => '<<<buildkit_WILL_INSERT_kitname_HERE>>>_nodemgmt',
kitnoderemove => '<<<buildkit_WILL_INSERT_kitname_HERE>>>_nodemgmt',
kitnodeupdate => '<<<buildkit_WILL_INSERT_kitname_HERE>>>_nodemgmt',
kitnoderefresh => '<<<buildkit_WILL_INSERT_kitname_HERE>>>_nodemgmt',
kitnodefinished => '<<<buildkit_WILL_INSERT_kitname_HERE>>>_nodemgmt',
};
}
#-------------------------------------------------------
=head3 process_request
Process the kit plugin command.
=cut
#-------------------------------------------------------
sub process_request {
my $request = shift;
my $callback = shift;
# Name of command and node list
my $command = $request->{command}->[0];
my $nodes = $request->{node};
# This kit plugin is passed a list of node names.
# We need to determine which kits are used by these
# nodes to decide if this plugin should run or not.
my $kitdata = $request->{kitdata};
if (! defined($kitdata)) {
$kitdata = xCAT::KitPluginUtils->get_kits_used_by_nodes($nodes);
$request->{kitdata} = $kitdata;
}
if ($PLUGIN_KITNAME ne "TESTMODE" && ! exists($kitdata->{$PLUGIN_KITNAME})) {
return;
}
# Get the nodes using this plugin's kit
$nodes = $kitdata->{$PLUGIN_KITNAME};
if($command eq 'kitnodeadd') {
kitnodeadd($callback, $nodes);
}
elsif ($command eq 'kitnoderemove') {
kitnoderemove($callback, $nodes);
}
elsif ($command eq 'kitnodeupdate') {
kitnodeupdate($callback, $nodes);
}
elsif ($command eq 'kitnoderefresh') {
kitnoderefresh($callback, $nodes);
}
elsif ($command eq 'kitnodefinished') {
kitnodefinished($callback);
} else {
my $rsp;
$rsp->{data}->[0] = "Command is not supported";
xCAT::MsgUtils->message("E", $rsp, $callback);
}
}
#-------------------------------------------------------
=head3 kitnodeadd
This command is called when one or more nodes are added
to the cluster.
=cut
#-------------------------------------------------------
sub kitnodeadd {
my $callback = shift;
my $rsp;
# Parameters
my $nodes = shift;
$rsp->{data}->[0] = "Running kitnodeadd";
xCAT::MsgUtils->message("I", $rsp, $callback);
# TODO
# ... ADD YOUR CODE HERE
}
#-------------------------------------------------------
=head3 kitnoderemove
This command is called when one or more nodes are
removed from the cluster.
=cut
#-------------------------------------------------------
sub kitnoderemove {
my $callback = shift;
my $rsp;
# Parameters
my $nodes = shift;
$rsp->{data}->[0] = "Running kitnoderemove";
xCAT::MsgUtils->message("I", $rsp, $callback);
# TODO
# ... ADD YOUR CODE HERE
}
#-------------------------------------------------------
=head3 kitnodeupdate
This command is called when the configuration of one
or more nodes are updated.
=cut
#-------------------------------------------------------
sub kitnodeupdate {
my $callback = shift;
my $rsp;
# Parameters
my $nodes = shift;
$rsp->{data}->[0] = "Running kitnodeupdate";
xCAT::MsgUtils->message("I", $rsp, $callback);
# TODO
# ... ADD YOUR CODE HERE
}
#-------------------------------------------------------
=head3 kitnoderefresh
This command is called when node-related configuration
files are updated.
=cut
#-------------------------------------------------------
sub kitnoderefresh {
my $callback = shift;
my $rsp;
# Parameters
my $nodes = shift;
$rsp->{data}->[0] = "Running kitnoderefresh";
xCAT::MsgUtils->message("I", $rsp, $callback);
# TODO
# ... ADD YOUR CODE HERE
}
#-------------------------------------------------------
=head3 kitnodefinished
This command is called at the end of a node management
operation.
=cut
#-------------------------------------------------------
sub kitnodefinished {
my $callback = shift;
my $rsp;
$rsp->{data}->[0] = "Running kitnodefinished";
xCAT::MsgUtils->message("I", $rsp, $callback);
# TODO
# ... ADD YOUR CODE HERE
}

View File

@ -0,0 +1,3 @@
echo "running sample-comp1 post script"

View File

@ -0,0 +1,3 @@
#!/bin/sh
echo "running sample-comp1 postboot script"

View File

@ -0,0 +1,3 @@
echo "running sample-comp1 postun script"

View File

@ -0,0 +1,3 @@
echo "running sample-comp1 postup script"

View File

@ -0,0 +1,3 @@
echo "running sample-comp1 pre script"

View File

@ -0,0 +1,3 @@
echo "running sample-comp1 preun script"

View File

@ -0,0 +1,3 @@
echo "running sample-comp1 preup script"

View File

@ -0,0 +1,76 @@
Summary: Pkg2 for Sample Kit
Name: pkg2
Version: 1
Release: 1
Epoch: 1
License: EPL
Group: Applications/System
Source: pkg2.tar.gz
Packager: IBM Corp.
Vendor: IBM Corp.
Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}}
Prefix: /opt/xcat-kitsample
BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root
%ifos linux
BuildArch: noarch
#Requires:
%endif
Provides: pkg2 = %{epoch}:%{version}
%description
Testing package builds for xCAT Sample Kit
%prep
%setup -q -n pkg2
%build
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{prefix}/%{name}/files
mkdir -p $RPM_BUILD_ROOT/etc/%{name}
set +x
%ifos linux
cp -a files/* $RPM_BUILD_ROOT/%{prefix}/%{name}/files/
chmod -R 755 $RPM_BUILD_ROOT/%{prefix}/%{name}/files/*
cp -a cfg/* $RPM_BUILD_ROOT/etc/%{name}/
chmod -R 644 $RPM_BUILD_ROOT/etc/%{name}/*
%endif
set -x
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%{prefix}
/etc/%{name}
%changelog
%pre
if [ "$1" = "1" ] ; then
echo "running pkg2 rpm pre section"
elif [ "$1" = "2" ] ; then
echo "running pkg2 rpm preup section"
fi
%post
if [ "$1" = "1" ] ; then
echo "running pkg2 rpm post section"
elif [ "$1" = "2" ] ; then
echo "running pkg2 rpm postup section"
fi
%preun
echo "running pkg2 rpm preun section"
%postun
echo "running pkg2 rpm postun section"

View File

@ -0,0 +1,3 @@
#
#
# a config file for pkg2

View File

@ -0,0 +1,76 @@
Summary: Pkg3 for Sample Kit
Name: pkg3
Version: 1
Release: 1
Epoch: 1
License: EPL
Group: Applications/System
Source: pkg3.tar.gz
Packager: IBM Corp.
Vendor: IBM Corp.
Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}}
Prefix: /opt/xcat-kitsample
BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root
%ifos linux
BuildArch: noarch
#Requires:
%endif
Provides: pkg3 = %{epoch}:%{version}
%description
Testing package builds for xCAT Sample Kit
%prep
%setup -q -n pkg3
%build
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{prefix}/%{name}/files
mkdir -p $RPM_BUILD_ROOT/etc/%{name}
set +x
%ifos linux
cp -a files/* $RPM_BUILD_ROOT/%{prefix}/%{name}/files/
chmod -R 755 $RPM_BUILD_ROOT/%{prefix}/%{name}/files/*
cp -a cfg/* $RPM_BUILD_ROOT/etc/%{name}/
chmod -R 644 $RPM_BUILD_ROOT/etc/%{name}/*
%endif
set -x
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%{prefix}
/etc/%{name}
%changelog
%pre
if [ "$1" = "1" ] ; then
echo "running pkg3 rpm pre section"
elif [ "$1" = "2" ] ; then
echo "running pkg3 rpm preup section"
fi
%post
if [ "$1" = "1" ] ; then
echo "running pkg3 rpm post section"
elif [ "$1" = "2" ] ; then
echo "running pkg3 rpm postup section"
fi
%preun
echo "running pkg3 rpm preun section"
%postun
echo "running pkg3 rpm postun section"

View File

@ -0,0 +1,48 @@
Summary: Kit <<<INSERT_kitbasename_HERE>>> Component <<<INSERT_kitcomponent_basename_HERE>>> metapackage
Name: <<<INSERT_kitcomponent_basename_HERE>>>
Version: <<<INSERT_kitcomponent_version_HERE>>>
Release: <<<INSERT_kitcomponent_release_HERE>>>
License: EPL
BuildArch: noarch
Requires: <<<INSERT_kitcomponent_ospkgdeps_HERE>>>,<<<INSERT_kitcomponent_kitpkgdeps_HERE>>>,<<<INSERT_kitcomponent_kitcompdeps_HERE>>>
%description
<<<INSERT_kitcomponent_desc_HERE>>>
%prep
%build
%install
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%changelog
%pre
if [ "$1" = "1" ] ; then
<<<INSERT_kitcomponent_preinstall_script_HERE>>>
elif [ "$1" = "2" ] ; then
<<<INSERT_kitcomponent_preupgrade_script_HERE>>>
fi
%post
if [ "$1" = "1" ] ; then
<<<INSERT_kitcomponent_postinstall_script_HERE>>>
elif [ "$1" = "2" ] ; then
<<<INSERT_kitcomponent_postupgrade_script_HERE>>>
fi
%preun
<<<INSERT_kitcomponent_preuninstall_script_HERE>>>
%postun
<<<INSERT_kitcomponent_postuninstall_script_HERE>>>

View File

@ -0,0 +1,93 @@
Summary: xCAT buildkit tools and sample kit
Name: xCAT-buildkit
Version: %(cat Version)
Release: snap%(date +"%Y%m%d%H%M")
Epoch: 4
License: EPL
Group: Applications/System
Source: xCAT-buildkit-%(cat Version).tar.gz
Packager: IBM Corp.
Vendor: IBM Corp.
Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}}
Prefix: /opt/xcat
BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root
#%ifnos linux
AutoReqProv: no
#%endif
# AIX will build with an arch of "ppc"
# also need to fix Requires for AIX
%ifos linux
BuildArch: noarch
#Requires:
%endif
# No dependencies on any other xCAT rpms
# so that this rpm can be installed in a separate build server
Requires: rpm-build
Provides: xCAT-buildkit = %{epoch}:%{version}
%description
xCAT-buildkit provides the buildkit tool and sample kit files to build an xCAT kit.
%prep
%setup -q -n xCAT-buildkit
%build
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/kits
mkdir -p $RPM_BUILD_ROOT/%{prefix}/bin
mkdir -p $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT
%ifos linux
cp -aR share/xcat/kits/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/kits/
chmod -R 644 $RPM_BUILD_ROOT/%{prefix}/share/xcat/kits/*
cp -a lib/perl/xCAT/* $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT
chmod -R 644 $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT/*
cp -a bin/* $RPM_BUILD_ROOT/%{prefix}/bin/
chmod -R 755 $RPM_BUILD_ROOT/%{prefix}/bin/*
%else
cp -hpR share/xcat/kits/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/kits/
chmod -R 644 $RPM_BUILD_ROOT/%{prefix}/share/xcat/kits/*
cp -hpR lib/perl/xCAT/* $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT/
chmod -R 755 $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT/*
cp -hpR bin/* $RPM_BUILD_ROOT/%{prefix}/bin/
chmod -R 755 $RPM_BUILD_ROOT/%{prefix}/bin/*
%endif
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-buildkit
cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-buildkit
chmod 644 $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-buildkit/*
echo $RPM_BUILD_ROOT %{prefix}
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
#%doc LICENSE.html
%{prefix}
%changelog
%pre
# only need to check on AIX
%ifnos linux
if [ -x /usr/sbin/emgr ]; then # Check for emgr cmd
/usr/sbin/emgr -l 2>&1 | grep -i xCAT # Test for any xcat ifixes - msg and exit if found
if [ $? = 0 ]; then
echo "Error: One or more xCAT emgr ifixes are installed. You must use the /usr/sbin/emgr command to uninstall each xCAT emgr ifix prior to RPM installation."
exit 2
fi
fi
%endif
%post
%preun

View File

@ -0,0 +1,86 @@
Summary: xCAT buildkit tools and sample kit
Name: xCAT-buildkit
Version: %(cat Version)
Release: snap%(date +"%Y%m%d%H%M")
Epoch: 4
License: EPL
Group: Applications/System
Source: xCAT-buildkit-%(cat Version).tar.gz
Packager: IBM Corp.
Vendor: IBM Corp.
Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}}
Prefix: /opt/xcat
BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root
%ifnos linux
AutoReqProv: no
%endif
# AIX will build with an arch of "ppc"
# also need to fix Requires for AIX
%ifos linux
BuildArch: noarch
#Requires:
%endif
# No dependencies on any other xCAT rpms
# so that this rpm can be installed in a separate build server
Requires: rpm-build
Provides: xCAT-buildkit = %{epoch}:%{version}
%description
xCAT-buildkit provides the buildkit tool and sample kit files to build an xCAT kit.
%prep
%setup -q -n xCAT-buildkit
%build
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/kits
mkdir -p $RPM_BUILD_ROOT/%{prefix}/bin
%ifos linux
cp -aR share/xcat/kits/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/kits/
chmod -R 644 $RPM_BUILD_ROOT/%{prefix}/share/xcat/kits/*
cp -a bin/* $RPM_BUILD_ROOT/%{prefix}/bin/
chmod -R 755 $RPM_BUILD_ROOT/%{prefix}/bin/*
%else
cp -hpR share/xcat/kits/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/kits/
chmod -R 755 $RPM_BUILD_ROOT/%{prefix}/share/xcat/kits/*
%endif
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-buildkit
cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-buildkit
chmod 644 $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-buildkit/*
echo $RPM_BUILD_ROOT %{prefix}
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
#%doc LICENSE.html
%{prefix}
%changelog
%pre
# only need to check on AIX
%ifnos linux
if [ -x /usr/sbin/emgr ]; then # Check for emgr cmd
/usr/sbin/emgr -l 2>&1 | grep -i xCAT # Test for any xcat ifixes - msg and exit if found
if [ $? = 0 ]; then
echo "Error: One or more xCAT emgr ifixes are installed. You must use the /usr/sbin/emgr command to uninstall each xCAT emgr ifix prior to RPM installation."
exit 2
fi
fi
%endif
%post
%preun