2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-22 03:32:04 +00:00

fix issue when using copycds -p, stateful install has yum point to the wrong repository. #1852

This commit is contained in:
immarvin 2016-10-29 23:18:43 -04:00
parent 1b51602577
commit 1e6714a99d
5 changed files with 32 additions and 43 deletions

View File

@ -11,29 +11,23 @@ my $installpfx;
sub localize_yumrepo {
my $self = shift;
my $installroot = shift;
$distname = shift;
$arch = shift;
$installpfx = "$installroot/$distname/$arch";
mkpath("$installroot/postscripts/repos/$distname/$arch/");
open($yumrepofile, ">", "$installroot/postscripts/repos/$distname/$arch/local-repository.tmpl");
my $pkgdir = shift;
$distname=shift;
$arch=shift;
open($yumrepofile, ">", "$pkgdir/local-repository.tmpl");
my %options = (
wanted => \&check_tofix,
follow_fast => 1
);
find(\%options, $installpfx);
find(\%options, $pkgdir);
close($yumrepofile);
}
sub remove_yumrepo {
my $self = shift;
my $installroot = shift;
$distname = shift;
$arch = shift;
rmtree("$installroot/postscripts/repos/$distname/$arch/");
my $pkgdir = shift;
rmtree("$pkgdir/local-repository.tmpl");
}
sub check_tofix {
@ -57,14 +51,13 @@ sub generate_repo
my @dircomps = File::Spec->splitdir($dirlocation);
pop(@dircomps);
my $yumurl = File::Spec->catdir(@dircomps);
$yumurl =~ s!$installpfx!http://#INSTSERVER#/install/$distname/$arch/!;
my $reponame = $dircomps[$#dircomps];
print $yumrepofile "[local-$distname-$arch-$reponame]\n";
print $yumrepofile "name=xCAT configured yum repository for $distname/$arch/$reponame\n";
print $yumrepofile "name=xCAT configured yum repository for $yumurl\n";
print $yumrepofile "baseurl=$yumurl\n";
print $yumrepofile "enabled=1\n";
print $yumrepofile "gpgcheck=0\n\n";
}
}
sub fix_directory {

View File

@ -288,11 +288,11 @@ sub subvars {
@pkgdirs = split(",", $media_dir);
my $source;
my $source_in_pre;
my $writerepo;
my $c = 0;
foreach my $pkgdir (@pkgdirs) {
if ($platform =~ /^(rh|SL|centos|fedora)$/) {
if ($c == 0) {
# After some tests, if we put the repo in pre scripts in the kickstart like for rhels6.x
# the rhels5.9 will not be installed successfully. So put in kickstart directly.
$source_in_pre .= "echo 'url --url http://'\$nextserver'/$pkgdir' >> /tmp/repos";
@ -301,6 +301,18 @@ sub subvars {
$source_in_pre .= "\necho 'repo --name=pkg$c --baseurl=http://'\$nextserver'/$pkgdir' >> /tmp/repos";
$source .= "repo --name=pkg$c --baseurl=http://#TABLE:noderes:\$NODE:nfsserver#/$pkgdir\n"; #for rhels5.9
}
if( -f "$pkgdir/local-repository.tmpl"){
my $repofd;
my $repo_in_post;
local $/=undef;
open($repofd,"<","$pkgdir/local-repository.tmpl");
$repo_in_post = <$repofd>;
close($repofd);
$repo_in_post =~ s#baseurl=#baseurl=http://$master/#g;
$writerepo .= "\ncat >/etc/yum.repos.d/local-repository-$c.repo << 'EOF'\n";
$writerepo .="$repo_in_post\n";
$writerepo .="EOF\n";
}
} elsif ($platform =~ /^(sles|suse)/) {
my $http = "http://#TABLE:noderes:\$NODE:nfsserver#$pkgdir";
$source .= " <listentry>
@ -320,6 +332,7 @@ sub subvars {
if (("ubuntu" eq $platform) || ("debian" eq $platform)) {
$inc =~ s/#INCLUDE_OSIMAGE_PKGDIR#/$pkgdirs[-1]/;
}
$inc =~ s/#WRITEREPO#/$writerepo/g;
}
#ok, now do everything else..

View File

@ -2464,30 +2464,8 @@ sub copycd
}
unless ($path =~ /^($defaultpath)/)
{
mkpath($defaultpath);
if (-d $defaultpath)
{
rmtree($defaultpath);
}
else
{
unlink($defaultpath);
}
my $hassymlink = eval { symlink("", ""); 1 };
if ($hassymlink) {
symlink($path, $defaultpath);
} else
{
link($path, $defaultpath);
}
}
require xCAT::Yum;
xCAT::Yum->localize_yumrepo($installroot, $distname, $arch);
xCAT::Yum->localize_yumrepo($path, $distname, $arch);
if ($rc != 0)
{

View File

@ -145,6 +145,10 @@ sub process_request {
if ($path)
{
$path=Cwd::realpath($path);
unless(substr($path,0,length("/install")) eq "/install"){
$callback->({ warning => "copycds: the specified path \"$path\" is not a subdirectory under /install. Make sure this path is configured for httpd/apache, otherwise, the provisioning with this iso will fail!" });
}
push @{ $newreq->{arg} }, ("-p", $path);
}
if ($specific)

View File

@ -396,9 +396,10 @@ chmod 755 /xcatpost/mypostscript
export ARCH=#TABLE:nodetype:THISNODE:arch#
export CONSOLEPORT=#TABLEBLANKOKAY:nodehm:THISNODE:serialport#
if [[ $OSVER != ubuntu* ]]; then
addsiteyum
fi
#for redhat:
##place-holder for the code to save the repo info on compute node,pointing to the "pkgdir" of the osimage
##so that the provisioned node
##WRITEREPO#
if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
msgutil_r "$MASTER_IP" "info" "running mypostscript" "/var/log/xcat/xcat.log"