more on installing extra packages

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2111 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
linggao 2008-09-09 21:08:48 +00:00
parent c185b7fddc
commit 2f4f7acab5
7 changed files with 117 additions and 37 deletions

View File

@ -225,28 +225,28 @@ sub makescript {
if (($nodesetstate) && ($nodesetstate eq "netboot")) { $stat="netboot";}
my $pathtofiles="$::XCATROOT/share/xcat/$stat/$platform";
my $pkglist;
if (-r "$pathtofiles/$profile.$os.$arch.otherrpms.pkglist") {
$pkglist = "$pathtofiles/$profile.$os.$arch.otherrpms.pkglist";
} elsif (-r "$pathtofiles/$profile.$arch.otherrpms.pkglist") {
$pkglist = "$pathtofiles/$profile.$arch.otherrpms.pkglist";
} elsif (-r "$pathtofiles/$profile.$os.otherrpms.pkglist") {
$pkglist = "$pathtofiles/$profile.$os.otherrpms.pkglist";
} elsif (-r "$pathtofiles/$profile.otherrpms.pkglist") {
$pkglist = "$pathtofiles/$profile.otherrpms.pkglist";
if (-r "$pathtofiles/$profile.$os.$arch.otherpkgs.pkglist") {
$pkglist = "$pathtofiles/$profile.$os.$arch.otherpkgs.pkglist";
} elsif (-r "$pathtofiles/$profile.$arch.otherpkgs.pkglist") {
$pkglist = "$pathtofiles/$profile.$arch.otherpkgs.pkglist";
} elsif (-r "$pathtofiles/$profile.$os.otherpkgs.pkglist") {
$pkglist = "$pathtofiles/$profile.$os.otherpkgs.pkglist";
} elsif (-r "$pathtofiles/$profile.otherpkgs.pkglist") {
$pkglist = "$pathtofiles/$profile.otherpkgs.pkglist";
}
if ($pkglist) {
my @otherrpms=();
my @otherpkgs=();
if (open(FILE1, "<$pkglist")) {
while (readline(FILE1)) {
chomp($_);
push(@otherrpms,$_);
push(@otherpkgs,$_);
}
close(FILE1);
}
if ( @otherrpms > 0) {
push @scriptd, "OTHERRPMS=". join(',',@otherrpms) . " \n";
push @scriptd, "export OTHERRPMS\n";
if ( @otherpkgs > 0) {
push @scriptd, "OTHERPKGS=". join(',',@otherpkgs) . " \n";
push @scriptd, "export OTHERPKGS\n";
}
}
}
@ -255,13 +255,11 @@ sub makescript {
###Please do not remove or modify this line of code!!! xcatdsklspost depends on it
push @scriptd, "# postscripts-start-here\n";
my $hasotherrpms=0;
# get the xcatdefaults entry in the postscripts table
my $et = $posttab->getAttribs({node=>"xcatdefaults"},'postscripts');
my $defscripts = $et->{'postscripts'};
if ($defscripts) {
foreach my $n (split(/,/, $defscripts)) {
if ((!$hasotherrpms) && ($n eq "otherrpms")) { $hasotherrpms =1;}
push @scriptd, $n."\n";
}
}
@ -271,12 +269,10 @@ sub makescript {
$ps = $et->{'postscripts'};
if ($ps) {
foreach my $n (split(/,/, $ps)) {
if ((!$hasotherrpms) && ($n eq "otherrpms")) { $hasotherrpms =1;}
push @scriptd, $n."\n";
}
}
if (!$hasotherrpms) { push @scriptd, "otherrpms\n";}
###Please do not remove or modify this line of code!!! xcatdsklspost depends on it
push @scriptd, "# postscripts-end-here\n";

View File

@ -661,7 +661,7 @@ if ((!-r "/etc/xcat/postscripts.sqlite") || $::FORCE)
else
{
$chtabcmds =
"$::XCATROOT/sbin/chtab node=xcatdefaults postscripts.postscripts='syslog,remoteshell';";
"$::XCATROOT/sbin/chtab node=xcatdefaults postscripts.postscripts='syslog,remoteshell,otherpkgs';";
}
$chtabcmds .=

View File

@ -70,6 +70,7 @@ foreach (split /,/,$netdriver) {
unless ($onlyinitrd) {
my $srcdir = "$installroot/$osver/$arch";
my $srcdir_otherpkgs = "$installroot/post/otherpkgs/$osver/$arch";
@yumdirs=();
find(\&isyumdir, <$installroot/$osver/$arch/>);
unless (scalar(@yumdirs)) {
@ -85,6 +86,8 @@ unless ($onlyinitrd) {
$repnum += 1;
}
$repnum-=1;
#add the section for other packages
print $yumconfig "[$osver-$arch-otherpkgs]\nname=$osver-$arch-otherpkgs\nbaseurl=file://$srcdir_otherpkgs\ngpgpcheck=0\n\n";
close($yumconfig);
mkpath "$installroot/netboot/$osver/$arch/$profile/rootimg/etc";
my $fd;
@ -93,10 +96,13 @@ unless ($onlyinitrd) {
close($fd);
my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$installroot/netboot/$osver/$arch/$profile/rootimg/ --disablerepo=* ";
foreach (0..$repnum) {
$yumcmd .= "--enablerepo=$osver-$arch-$_ "
$yumcmd .= "--enablerepo=$osver-$arch-$_ ";
}
$yumcmd .= "--enablerepo=$osver-$arch-otherpkgs ";
$yumcmd .= "install ";
mkpath("$installroot/netboot/$osver/$arch/$profile/rootimg/var/lib/yum");
my $pkglist;
if (-r "$pathtofiles/$profile.$osver.$arch.pkglist") {
$pkglist = "$pathtofiles/$profile.$osver.$arch.pkglist";
@ -115,7 +121,31 @@ unless ($onlyinitrd) {
chomp;
$yumcmd .= $_ . " ";
}
close($yumconfig);
#get otherpackage list into yum command
my $otherpkglist;
if (-r "$pathtofiles/$profile.$osver.$arch.otherpkgs.pkglist") {
$otherpkglist = "$pathtofiles/$profile.$osver.$arch.otherpkgs.pkglist";
} elsif (-r "$pathtofiles/$profile.$arch.otherpkgs.pkglist") {
$otherpkglist = "$pathtofiles/$profile.$arch.otherpkgs.pkglist";
} elsif (-r "$pathtofiles/$profile.$osver.otherpkgs.pkglist") {
$otherpkglist = "$pathtofiles/$profile.$osver.otherpkgs.pkglist";
} elsif (-r "$pathtofiles/$profile.otherpkgs.pkglist") {
$otherpkglist = "$pathtofiles/$profile.otherpkgs.pkglist";
}
if ($otherpkglist) {
open($yumconfig,"<","$otherpkglist");
while (<$yumconfig>) {
chomp;
$yumcmd .= $_ . " ";
}
close($yumconfig);
}
$yumcmd =~ s/ $/\n/;
# print "yumcmd=$yumcmd\n";
# `cat /tmp/genimage.$$.yum.conf`;
my $rc = system($yumcmd);
if ($rc) {
print "yum invocation failed\n";
@ -281,7 +311,7 @@ if [ "\$NFS" = "1" ]; then
mount --move /ro /sysroot/ro
mount --move /rw /sysroot/rw
cp /etc/resolv.conf /sysroot/etc/
echo xcatfs / aufs rw,_netdev 0 0 >> /sysroot/etc/fstab
echo xcatfs / aufs rw,_netdev 0 0 >> /sysroot/etc/fstab
elif [ -r /rootimg.sfs ]; then
echo Setting up squashfs with ram overlay.
mknod /dev/loop0 b 7 0
@ -522,3 +552,5 @@ sub generic_post { #This function is meant to leave the image in a state approxi
rename(<$installroot/netboot/$osver/$arch/$profile/rootimg/boot/vmlinuz*>,"$installroot/netboot/$osver/$arch/$profile/kernel");
}

View File

@ -89,6 +89,7 @@ unless (grep /af_packet/,@ndrivers) {
unless ($onlyinitrd) {
my $srcdir = "$installroot/$osver/$arch/1";
my $srcdir_otherpkgs = "$installroot/post/otherpkgs/$osver/$arch/1";
mkpath "$installroot/netboot/$osver/$arch/$profile/rootimg/etc";
mkpath "$installroot/netboot/$osver/$arch/$profile/rootimg/dev";
#system "mount -o bind /dev $installroot/netboot/$osver/$arch/$profile/rootimg/dev";
@ -97,6 +98,7 @@ unless ($onlyinitrd) {
print $fd "#Dummy fstab for rpm postscripts to see\n";
close($fd);
system("zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ sa file:$srcdir");
system("zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ sa file:$srcdir_otherpkgs");
#my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$installroot/netboot/$osver/$arch/$profile/rootimg/ --disablerepo=* ";
#$yumcmd .= "install ";
#mkpath("$installroot/netboot/$osver/$arch/$profile/rootimg/var/lib/yum");
@ -119,6 +121,28 @@ unless ($onlyinitrd) {
chomp;
$yumcmd .= $_ . " ";
}
close($yumconfig);
#get otherpackage list into yum command
my $otherpkglist;
if (-r "$pathtofiles/$profile.$osver.$arch.otherpkgs.pkglist") {
$otherpkglist = "$pathtofiles/$profile.$osver.$arch.otherpkgs.pkglist";
} elsif (-r "$pathtofiles/$profile.$arch.otherpkgs.pkglist") {
$otherpkglist = "$pathtofiles/$profile.$arch.otherpkgs.pkglist";
} elsif (-r "$pathtofiles/$profile.$osver.otherpkgs.pkglist") {
$otherpkglist = "$pathtofiles/$profile.$osver.otherpkgs.pkglist";
} elsif (-r "$pathtofiles/$profile.otherpkgs.pkglist") {
$otherpkglist = "$pathtofiles/$profile.otherpkgs.pkglist";
}
if ($otherpkglist) {
open($yumconfig,"<","$otherpkglist");
while (<$yumconfig>) {
chomp;
$yumcmd .= $_ . " ";
}
close($yumconfig);
}
$yumcmd =~ s/ $/\n/;
my $rc = system($yumcmd);
if ($rc) {

View File

@ -90,6 +90,7 @@ unless (grep /af_packet/,@ndrivers) {
unless ($onlyinitrd) {
my $srcdir = "$installroot/$osver/$arch/1";
my $srcdir_otherpkgs = "$installroot/post/otherpkgs/$osver/$arch/1";
find(\&isyumdir, <$srcdir/>);
print Dumper(@yumdirs);
unless (scalar(@yumdirs)) {
@ -105,7 +106,10 @@ unless ($onlyinitrd) {
$repnum += 1;
}
$repnum-=1;
#add the section for other packages
print $yumconfig "[$osver-$arch-otherpkgs]\nname=$osver-$arch-otherpkgs\nbaseurl=file://$srcdir_otherpkgs\ngpgpcheck=0\n\n";
close($yumconfig);
mkpath "$installroot/netboot/$osver/$arch/$profile/rootimg/etc";
mkpath "$installroot/netboot/$osver/$arch/$profile/rootimg/dev";
#system "mount -o bind /dev $installroot/netboot/$osver/$arch/$profile/rootimg/dev";
@ -118,6 +122,7 @@ unless ($onlyinitrd) {
$yumcmd .= "install ";
mkpath("$installroot/netboot/$osver/$arch/$profile/rootimg/var/lib/yum");
#my $yumcmd = "zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ install -y ";
my $pkglist;
if (-r "$pathtofiles/$profile.$osver.$arch.pkglist") {
$pkglist = "$pathtofiles/$profile.$osver.$arch.pkglist";
@ -136,6 +141,29 @@ unless ($onlyinitrd) {
chomp;
$yumcmd .= $_ . " ";
}
close($yumconfig);
#get otherpackage list into yum command
my $otherpkglist;
if (-r "$pathtofiles/$profile.$osver.$arch.otherpkgs.pkglist") {
$otherpkglist = "$pathtofiles/$profile.$osver.$arch.otherpkgs.pkglist";
} elsif (-r "$pathtofiles/$profile.$arch.otherpkgs.pkglist") {
$otherpkglist = "$pathtofiles/$profile.$arch.otherpkgs.pkglist";
} elsif (-r "$pathtofiles/$profile.$osver.otherpkgs.pkglist") {
$otherpkglist = "$pathtofiles/$profile.$osver.otherpkgs.pkglist";
} elsif (-r "$pathtofiles/$profile.otherpkgs.pkglist") {
$otherpkglist = "$pathtofiles/$profile.otherpkgs.pkglist";
}
if ($otherpkglist) {
open($yumconfig,"<","$otherpkglist");
while (<$yumconfig>) {
chomp;
$yumcmd .= $_ . " ";
}
close($yumconfig);
}
$yumcmd =~ s/ $/\n/;
my $rc = system($yumcmd);
if ($rc) {

View File

@ -2,28 +2,28 @@
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
#-------------------------------------------------------------------------------
#=head1 otherrpms
#=head1 otherpkgs
#=head2 It gets the extra rpms and install/update them.
# The environment variable OTHERRPMS contains the rpms to be installed/updated.
# The environment variable OTHERPKGS contains the rpms to be installed/updated.
# On MN, You need to:
# 1. put rpms under /install/post/otherrpms/os/arch directory where 'os' and 'arch'
# 1. put rpms under /install/post/otherpkgs/os/arch directory where 'os' and 'arch'
# can be found in the nodetype table.
# 2. put the name of the packages to /opt/xcat/share/xcat/netboot(install)/platform
# directory. The file name is one of the following:
# profile.os.arch.otherrpms.pkglist
# profile.os.otherrpms.pkglist
# profile.arch.otherrpms.pkglist
# profile.otherrpms.pkglist
# profile.os.arch.otherpkgs.pkglist
# profile.os.otherpkgs.pkglist
# profile.arch.otherpkgs.pkglist
# profile.otherpkgs.pkglist
# The install/deployment process will pick up the rpms and install them on the nodes.
# However, if the nodes have already installed and up and running, you can run the following
# command to have the extra rpms installed:
# updatenode noderange otherrpms
# updatenode noderange otherpkgs
#
#=cut
#-------------------------------------------------------------------------------
#echo "OTHERRPMS=$OTHERRPMS"
if [[ -z "$OTHERRPMS" ]]; then
#echo "OTHERPKGS=$OTHERPKGS"
if [[ -z "$OTHERPKGS" ]]; then
echo "$0: no extra rpms to install"
exit 0
fi
@ -32,21 +32,21 @@ SIP=`grep -h dhcp-server-identifier /var/lib/dhclient/dhclient-*.leases|tail -n
if [ -z "$SIP" ]; then
SIP=`grep -h DHCPSID /var/lib/dhcpcd/*.info|awk -F= '{print $2}'|tail -n 1`
fi
mkdir -p /xcatpost/post/otherrpms;
mkdir -p /xcatpost/post/otherpkgs;
mkdir -p /tmp/postage/
rm -f -R /xcatpost/post/otherrpms/*
rm -f -R /xcatpost/post/otherpkgs/*
rm -f -R /tmp/postage/*
cd /tmp/postage
for x in `echo "$OTHERRPMS" | tr "," "\n"`
for x in `echo "$OTHERPKGS" | tr "," "\n"`
do
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$SIP/post/otherrpms/$OSVER/$ARCH/$x-* 2> /tmp/wget.log
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$SIP/post/otherpkgs/$OSVER/$ARCH/$x-* 2> /tmp/wget.log
done
mv $SIP/post/otherrpms/* /xcatpost/post/otherrpms;
mv $SIP/post/otherpkgs/* /xcatpost/post/otherpkgs;
rm -rf $SIP
cd /xcatpost/post/otherrpms/$OSVER/$ARCH
cd /xcatpost/post/otherpkgs/$OSVER/$ARCH
rpm -Uvh *
exit 0

View File

@ -154,7 +154,7 @@ if [ "$1" = "1" ]; then #Only if installing for the fist time..
XCATROOT=$RPM_INSTALL_PREFIX0 $RPM_INSTALL_PREFIX0/sbin/chtab key=timezone site.value=`grep ^ZONE /etc/sysconfig/clock|cut -d= -f 2|sed -e 's/"//g'`
fi
if [ ! -r /etc/xcat/postscripts.sqlite ]; then
XCATROOT=$RPM_INSTALL_PREFIX0 $RPM_INSTALL_PREFIX0/sbin/chtab node=xcatdefaults postscripts.postscripts='syslog,remoteshell'
XCATROOT=$RPM_INSTALL_PREFIX0 $RPM_INSTALL_PREFIX0/sbin/chtab node=xcatdefaults postscripts.postscripts='syslog,remoteshell,otherpkgs'
XCATROOT=$RPM_INSTALL_PREFIX0 $RPM_INSTALL_PREFIX0/sbin/chtab node=service postscripts.postscripts='servicenode'
fi
if [ ! -r /etc/xcat/policy.sqlite ]; then