diff --git a/perl-xCAT/xCAT/Yum.pm b/perl-xCAT/xCAT/Yum.pm index 774418634..b8eeb8c02 100644 --- a/perl-xCAT/xCAT/Yum.pm +++ b/perl-xCAT/xCAT/Yum.pm @@ -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 { diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 52c8db034..e4d99e749 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -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 .= " @@ -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.. diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index a2a37be24..90f65cfa7 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -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) { diff --git a/xCAT-server/lib/xcat/plugins/copycds.pm b/xCAT-server/lib/xcat/plugins/copycds.pm index d65c9b8b6..0a4ff32d5 100644 --- a/xCAT-server/lib/xcat/plugins/copycds.pm +++ b/xCAT-server/lib/xcat/plugins/copycds.pm @@ -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) diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index 6197c36df..f663f8161 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -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"