diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index d5e855f69..64c61d00a 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -1,5 +1,10 @@ # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html package xCAT_plugin::anaconda; +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} +use lib "$::XCATROOT/lib/perl"; use Storable qw(dclone); use Sys::Syslog; use Thread qw(yield); @@ -424,26 +429,18 @@ sub mkinstall $genos =~ s/\..*//; if ($genos =~ /rh.s(\d*)/) { - unless (-r $::XCATROOT - . "/share/xcat/install/$platform/$profile.$genos.$arch.tmpl" - or -r $::XCATROOT - . "/share/xcat/install/$platform/$profile.$genos.tmpl") + unless (-r "$installroot/custom/install/$platform/$profile.$genos.$arch.tmpl" + or -r "/install/custom/install/$platform/$profile.$genos.tmpl" + or -r "$::XCATROOT/share/xcat/install/$platform/$profile.$genos.$arch.tmpl" + or -r "$::XCATROOT/share/xcat/install/$platform/$profile.$genos.tmpl") { $genos = "rhel$1"; } } - - unless (-r $::XCATROOT . "/share/xcat/install/$platform/$profile.tmpl" - or -r $::XCATROOT - . "/share/xcat/install/$platform/$profile.$arch.tmpl" - or -r $::XCATROOT - . "/share/xcat/install/$platform/$profile.$os.tmpl" - or -r $::XCATROOT - . "/share/xcat/install/$platform/$profile.$genos.tmpl" - or -r $::XCATROOT - . "/share/xcat/install/$platform/$profile.$os.$arch.tmpl" - or -r $::XCATROOT - . "/share/xcat/install/$platform/$profile.$genos.$arch.tmpl") + + my $tmplfile=get_tmpl_file_name("$installroot/custom/install/$platform", $profile, $os, $arch, $genos); + if (! $tmplfile) { $tmplfile=get_tmpl_file_name("$::XCATROOT/share/xcat/install/$platform", $profile, $os, $arch, $genos); } + unless ( -r "$tmplfile") { $callback->( { @@ -459,69 +456,17 @@ sub mkinstall #Call the Template class to do substitution to produce a kickstart file in the autoinst dir my $tmperr = - "Unable to find template in $::XCATROOT/share/xcat/install/$platform (for $profile/$os/$arc combination)"; - if (-r $::XCATROOT - . "/share/xcat/install/$platform/$profile.$os.$arch.tmpl") + "Unable to find template in /install/custom/install/$platform or $::XCATROOT/share/xcat/install/$platform (for $profile/$os/$arch combination)"; + if (-r "$tmplfile") { $tmperr = xCAT::Template->subvars( - $::XCATROOT - . "/share/xcat/install/$platform/$profile.$os.$arch.tmpl", + $tmplfile, "/$installroot/autoinst/" . $node, $node ); } - elsif (-r $::XCATROOT - . "/share/xcat/install/$platform/$profile.$genos.$arch.tmpl") - { - $tmperr = - xCAT::Template->subvars( - $::XCATROOT - . "/share/xcat/install/$platform/$profile.$genos.$arch.tmpl", - "/$installroot/autoinst/" . $node, - $node - ); - } - elsif (-r $::XCATROOT - . "/share/xcat/install/$platform/$profile.$arch.tmpl") - { - $tmperr = - xCAT::Template->subvars( - $::XCATROOT - . "/share/xcat/install/$platform/$profile.$arch.tmpl", - "/$installroot/autoinst/" . $node, - $node - ); - } - elsif ( - -r $::XCATROOT . "/share/xcat/install/$platform/$profile.$os.tmpl") - { - $tmperr = - xCAT::Template->subvars( - $::XCATROOT - . "/share/xcat/install/$platform/$profile.$os.tmpl", - "/$installroot/autoinst/" . $node, - $node - ); - } - elsif (-r $::XCATROOT - . "/share/xcat/install/$platform/$profile.$genos.tmpl") - { - $tmperr = - xCAT::Template->subvars( - $::XCATROOT - . "/share/xcat/install/$platform/$profile.$genos.tmpl", - "/$installroot/autoinst/" . $node, - $node - ); - } - elsif (-r $::XCATROOT . "/share/xcat/install/$platform/$profile.tmpl") - { - $tmperr = - xCAT::Template->subvars( - $::XCATROOT . "/share/xcat/install/$platform/$profile.tmpl", - "/$installroot/autoinst/" . $node, $node); - } + if ($tmperr) { $callback->( @@ -862,4 +807,34 @@ sub copycd } } +sub get_tmpl_file_name { + my $base=shift; + my $profile=shift; + my $os=shift; + my $arch=shift; + my $genos=shift; + + if (-r "$base/$profile.$os.$arch.tmpl") { + return "base/$profile.$os.$arch.tmpl"; + } + elsif (-r "$base/$profile.$genos.$arch.tmpl") { + return "$base/$profile.$genos.$arch.tmpl"; + } + elsif (-r "$base/$profile.$arch.tmpl") { + return "$base/$profile.$arch.tmpl"; + } + elsif ( -r "$base/$profile.$os.tmpl") { + return "$base/$profile.$os.tmpl"; + } + elsif (-r "$base/$profile.$genos.tmpl") { + return "$base/$profile.$genos.tmpl"; + } + elsif (-r "$base/$profile.tmpl") { + return "$base/$profile.tmpl"; + } + + return ""; +} + + 1; diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index 1b2a7bf99..d57fe7e81 100644 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -61,19 +61,15 @@ sub process_request { return; } my $oldpath=cwd(); - my $exlistloc; - if (-r "$::XCATROOT/share/xcat/netboot/$distname/$profile.$osver.$arch.exlist") { - $exlistloc = "$::XCATROOT/share/xcat/netboot/$distname/$profile.$osver.$arch.exlist"; - } elsif (-r "$::XCATROOT/share/xcat/netboot/$distname/$profile.$arch.exlist") { - $exlistloc = "$::XCATROOT/share/xcat/netboot/$distname/$profile.$arch.exlist"; - } elsif (-r "$::XCATROOT/share/xcat/netboot/$distname/$profile.$osver.exlist") { - $exlistloc = "$::XCATROOT/share/xcat/netboot/$distname/$profile.$osver.exlist"; - } elsif (-r "$::XCATROOT/share/xcat/netboot/$distname/$profile.exlist") { - $exlistloc = "$::XCATROOT/share/xcat/netboot/$distname/$profile.exlist"; - } else { - $callback->({error=>["Unable to finde file exclusion list under $::XCATROOT/share/xcat/netboot/$distname/ for $profile/$arch/$osver"],errorcode=>[1]}); + my $exlistloc=get_exlist_file_name("$installroot/custom/netboot/$distname", $profile, $osver, $arch); + if (!$exlistloc) { $exlistloc=get_exlist_file_name("$::XCATROOT/share/xcat/netboot/$distname", $profile, $osver, $arch); } + + if (!$exlistloc) + { + $callback->({error=>["Unable to finde file exclusion list under $installroot/custom/netboot/$distname or $::XCATROOT/share/xcat/netboot/$distname/ for $profile/$arch/$osver"],errorcode=>[1]}); next; } + #print "exlistloc=$exlistloc\n"; my $exlist; open($exlist,"<",$exlistloc); my $excludestr = "find . "; @@ -238,3 +234,21 @@ sub copybootscript { return 0; } +sub get_exlist_file_name { + my $base=shift; + my $profile=shift; + my $osver=shift; + my $arch=shift; + + my $exlistloc=""; + if (-r "$base/$profile.$osver.$arch.exlist") { + $exlistloc = "$base/$profile.$osver.$arch.exlist"; + } elsif (-r "$base/$profile.$arch.exlist") { + $exlistloc = "$base/$profile.$arch.exlist"; + } elsif (-r "$base/$profile.$osver.exlist") { + $exlistloc = "$base/$profile.$osver.exlist"; + } elsif (-r "$base/$profile.exlist") { + $exlistloc = "$base/$profile.exlist"; + } + return $exlistloc; +} diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index 29ee72077..f3bab6d64 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -1,5 +1,10 @@ # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html package xCAT_plugin::sles; +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} +use lib "$::XCATROOT/lib/perl"; use Storable qw(dclone); use Sys::Syslog; use File::Temp qw/tempdir/; @@ -272,11 +277,9 @@ sub mkinstall my $os = $ent->{os}; my $arch = $ent->{arch}; my $profile = $ent->{profile}; - unless ( -r $::XCATROOT . "/share/xcat/install/sles/$profile.tmpl" - or -r $::XCATROOT . "/share/xcat/install/sles/$profile.$arch.tmpl" - or -r $::XCATROOT . "/share/xcat/install/sles/$profile.$os.tmpl" - or -r $::XCATROOT - . "/share/xcat/install/sles/$profile.$os.$arch.tmpl") + my $tmplfile=get_tmpl_file_name("/install/custom/install/sles", $profile, $os, $arch); + if (! $tmplfile) { $tmplfile=get_tmpl_file_name("$::XCATROOT/share/xcat/install/sles", $profile, $os, $arch); } + unless ( -r "$tmplfile") { $callback->( { @@ -290,37 +293,16 @@ sub mkinstall #Call the Template class to do substitution to produce a kickstart file in the autoinst dir my $tmperr; - if (-r $::XCATROOT . "/share/xcat/install/sles/$profile.$os.$arch.tmpl") + if (-r "$tmplfile") { $tmperr = xCAT::Template->subvars( - $::XCATROOT - . "/share/xcat/install/sles/$profile.$os.$arch.tmpl", + $tmplfile, "/install/autoinst/$node", $node ); } - elsif (-r $::XCATROOT . "/share/xcat/install/sles/$profile.$arch.tmpl") - { - $tmperr = - xCAT::Template->subvars( - $::XCATROOT . "/share/xcat/install/sles/$profile.$arch.tmpl", - "/install/autoinst/$node", $node); - } - elsif (-r $::XCATROOT . "/share/xcat/install/sles/$profile.$os.tmpl") - { - $tmperr = - xCAT::Template->subvars( - $::XCATROOT . "/share/xcat/install/sles/$profile.$os.tmpl", - "/install/autoinst/$node", $node); - } - elsif (-r $::XCATROOT . "/share/xcat/install/sles/$profile.tmpl") - { - $tmperr = - xCAT::Template->subvars( - $::XCATROOT . "/share/xcat/install/sles/$profile.tmpl", - "/install/autoinst/$node", $node); - } + if ($tmperr) { $callback->( @@ -712,4 +694,25 @@ sub copycd } } +sub get_tmpl_file_name { + my $base=shift; + my $profile=shift; + my $os=shift; + my $arch=shift; + if (-r "$base/$profile.$os.$arch.tmpl") { + return "$base/$profile.$os.$arch.tmpl"; + } + elsif (-r "$base/$profile.$arch.tmpl") { + return "$base/$profile.$arch.tmpl"; + } + elsif (-r "$base/$profile.$os.tmpl") { + return "$base/$profile.$os.tmpl"; + } + elsif (-r "$base/$profile.tmpl") { + return "$base/$profile.tmpl"; + } + + return ""; +} + 1; diff --git a/xCAT-server/lib/xcat/plugins/windows.pm b/xCAT-server/lib/xcat/plugins/windows.pm index fa0d1c773..a8b91aa2b 100644 --- a/xCAT-server/lib/xcat/plugins/windows.pm +++ b/xCAT-server/lib/xcat/plugins/windows.pm @@ -1,5 +1,10 @@ # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html package xCAT_plugin::windows; +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} +use lib "$::XCATROOT/lib/perl"; use Storable qw(dclone); use Sys::Syslog; use File::Temp qw/tempdir/; @@ -76,11 +81,9 @@ sub mkinstall my $os = $ent->{os}; my $arch = $ent->{arch}; my $profile = $ent->{profile}; - unless ( -r $::XCATROOT . "/share/xcat/install/windows/$profile.tmpl" - or -r $::XCATROOT . "/share/xcat/install/windows/$profile.$arch.tmpl" - or -r $::XCATROOT . "/share/xcat/install/windows/$profile.$os.tmpl" - or -r $::XCATROOT - . "/share/xcat/install/windows/$profile.$os.$arch.tmpl") + my $tmplfile=get_tmpl_file_name("$installroot/custom/install/windows", $profile, $os, $arch); + if (! $tmplfile) { $tmplfile=get_tmpl_file_name("$::XCATROOT/share/xcat/install/windows", $profile, $os, $arch); } + unless ( -r "$tmplfile") { $callback->( { @@ -94,37 +97,16 @@ sub mkinstall #Call the Template class to do substitution to produce an unattend.xml file in the autoinst dir my $tmperr; - if (-r $::XCATROOT . "/share/xcat/install/windows/$profile.$os.$arch.tmpl") + if (-r "$tmplfile") { $tmperr = xCAT::Template->subvars( - $::XCATROOT - . "/share/xcat/install/windows/$profile.$os.$arch.tmpl", + $tmplfile, "/install/autoinst/$node", $node ); } - elsif (-r $::XCATROOT . "/share/xcat/install/windows/$profile.$arch.tmpl") - { - $tmperr = - xCAT::Template->subvars( - $::XCATROOT . "/share/xcat/install/windows/$profile.$arch.tmpl", - "/install/autoinst/$node", $node); - } - elsif (-r $::XCATROOT . "/share/xcat/install/windows/$profile.$os.tmpl") - { - $tmperr = - xCAT::Template->subvars( - $::XCATROOT . "/share/xcat/install/windows/$profile.$os.tmpl", - "/install/autoinst/$node", $node); - } - elsif (-r $::XCATROOT . "/share/xcat/install/windows/$profile.tmpl") - { - $tmperr = - xCAT::Template->subvars( - $::XCATROOT . "/share/xcat/install/windows/$profile.tmpl", - "/install/autoinst/$node", $node); - } + if ($tmperr) { $callback->( @@ -348,4 +330,34 @@ sub copycd } } +sub get_tmpl_file_name { + my $base=shift; + my $profile=shift; + my $os=shift; + my $arch=shift; + if (-r "$base/$profile.$os.$arch.tmpl") { + return "$base/$profile.$os.$arch.tmpl"; + } + elsif (-r "$base/$profile.$arch.tmpl") { + return "$base/$profile.$arch.tmpl"; + } + elsif (-r "$base/$profile.$os.tmpl") { + return "$base/$profile.$os.tmpl"; + } + elsif (-r "$base/$profile.tmpl") { + return "$base/$profile.tmpl"; + } + + return ""; +} + + 1; + + + + + + + +