mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-30 19:02:27 +00:00 
			
		
		
		
	genimage changes to allow removing packges from otherpkgs.pkglist
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4315 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -240,6 +240,7 @@ unless ($onlyinitrd) { | ||||
|       open($yumconfig,">>","/tmp/genimage.$$.yum.conf"); | ||||
|       my $index=1; | ||||
|       foreach (keys(%extra_hash)) { | ||||
| 	  if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE")) { next;}  | ||||
| 	  print $yumconfig "[otherpkgs$index]\nname=otherpkgs$index\nbaseurl=file://$srcdir_otherpkgs/$_\ngpgpcheck=0\n\n"; | ||||
| 	  $index++; | ||||
| 	  my $pa=$extra_hash{$_}; | ||||
| @@ -247,7 +248,6 @@ unless ($onlyinitrd) { | ||||
|       } | ||||
|       close($yumconfig); | ||||
|       $index--; | ||||
|       #enable extra package repo | ||||
|       $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir/ --disablerepo=* "; | ||||
|       foreach (0..$repnum) { | ||||
| 	  $yumcmd .= "--enablerepo=$osver-$arch-$_ "; | ||||
| @@ -255,6 +255,19 @@ unless ($onlyinitrd) { | ||||
|       for (1..$index) { | ||||
| 	  $yumcmd .= "--enablerepo=otherpkgs$_ "; | ||||
|       }  | ||||
|  | ||||
|       #remove the packages that are specified in the otherpkgs.list files with leading '-' | ||||
|       my $yumcmd_remove= "$yumcmd erase "; | ||||
|       if (exists ($extra_hash{'PRE_REMOVE'})) { | ||||
| 	  my $pa=$extra_hash{'PRE_REMOVE'}; | ||||
| 	  my $rm_packges= join(' ', @$pa); | ||||
| 	  if ($rm_packges) { | ||||
| 	      $rc = system("$yumcmd_remove $rm_packges"); | ||||
| 	  } | ||||
|       } | ||||
|  | ||||
|  | ||||
|       #enable extra package repo | ||||
|       $yumcmd .= "install "; | ||||
|       #append extra pkg names to yum command  | ||||
|       if ($extrapkgnames) { | ||||
| @@ -272,6 +285,15 @@ unless ($onlyinitrd) { | ||||
| 	  print "yum invocation failed\n"; | ||||
| 	  exit 1; | ||||
|       } | ||||
| 	 | ||||
|       #remove the packages that are specified in the otherpkgs.list files with leading '--' | ||||
|       if (exists ($extra_hash{'POST_REMOVE'})) { | ||||
| 	  my $pa=$extra_hash{'POST_REMOVE'}; | ||||
| 	  my $rm_packges= join(' ', @$pa); | ||||
| 	  if ($rm_packges) { | ||||
| 	      $rc = system("$yumcmd_remove $rm_packges"); | ||||
| 	  } | ||||
|       } | ||||
|    } | ||||
|  | ||||
|    postscripts(); #run 'postscripts' | ||||
| @@ -709,12 +731,15 @@ sub generic_post { #This function is meant to leave the image in a state approxi | ||||
|    rename(<$rootimg_dir/boot/vmlinuz*>,"$destdir/kernel"); | ||||
| } | ||||
|  | ||||
|  | ||||
| #get th extra package name | ||||
| sub get_extra_package_names { | ||||
|     if (!$imagename) { | ||||
| 	$otherpkglist=get_extra_pkglist_file_name($customdir); | ||||
| 	if (!$otherpkglist) { $otherpkglist=get_extra_pkglist_file_name($pathtofiles); } | ||||
|     } | ||||
|  | ||||
|    #print "customdir=$customdir,pathtofiles=$pathtofiles,otherpkglist=$otherpkglist\n"; | ||||
|    my %pkgnames=(); | ||||
|    my @tmp_array=(); | ||||
|  | ||||
| @@ -746,8 +771,17 @@ sub get_extra_package_names { | ||||
|       | ||||
|         #print "pkgtext=$pkgtext\n"; | ||||
| 	my @tmp=split(',', $pkgtext); | ||||
| 	foreach (@tmp) {  | ||||
| 	    my $idir=dirname($_); | ||||
| 	foreach (@tmp) { | ||||
| 	    my $idir; | ||||
| 	    if (/^--/) {	 | ||||
| 		$idir="POST_REMOVE";   #line starts with -- means the package should be removed after otherpkgs are installed | ||||
| 		s/^--//; | ||||
|             } elsif  (/^-/) { | ||||
| 		$idir="PRE_REMOVE"; #line starts with single - means the package should be removed before otherpkgs are installed | ||||
| 		s/^-//; | ||||
|             } else {  | ||||
| 		$idir=dirname($_);  | ||||
| 	    } | ||||
| 	    my $fn=basename($_); | ||||
| 	    if (exists($pkgnames{$idir})) { | ||||
| 		my $pa=$pkgnames{$idir}; | ||||
| @@ -763,6 +797,7 @@ sub get_extra_package_names { | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| sub include_file | ||||
| { | ||||
|    my $file = shift; | ||||
|   | ||||
| @@ -214,7 +214,7 @@ if(`grep VERSION /etc/SuSE-release` =~ /VERSION = (\d+)/) { | ||||
|  | ||||
|  | ||||
| unless ($onlyinitrd) { | ||||
|     my %extra_hash=get_extra_package_names(); | ||||
|    my %extra_hash=get_extra_package_names(); | ||||
|  | ||||
|  | ||||
|    mkpath "$rootimg_dir/etc"; | ||||
| @@ -235,7 +235,7 @@ unless ($onlyinitrd) { | ||||
|    } | ||||
|  | ||||
|    #remove the old repository for extra packages | ||||
|    my $result=`zypper -R /install/netboot/sles11/ppc64/test/rootimg/ sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; | ||||
|    my $result=`zypper -R $rootimg_dir sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; | ||||
|    if ($result =~ /\S/) { | ||||
|        system("zypper -R $rootimg_dir sd $result"); | ||||
|    } | ||||
| @@ -249,6 +249,7 @@ unless ($onlyinitrd) { | ||||
|    } | ||||
|    my $index=1; | ||||
|    foreach (keys(%extra_hash)) { | ||||
|        if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE")) { next;}  | ||||
|        my $whole_path="$srcdir_otherpkgs/$_"; | ||||
|        if (-r "$srcdir_otherpkgs/$_/repodata/repomd.xml") { | ||||
| 	   if($osver_host == 11) {  | ||||
| @@ -332,6 +333,17 @@ unless ($onlyinitrd) { | ||||
|       exit 1; | ||||
|    } | ||||
|  | ||||
|    #remove the packages that are specified in the otherpkgs.list files with leading '-' | ||||
|    my $yumcmd_remove= "zypper -R $rootimg_dir remove ";  | ||||
|    if ((%extra_hash) && (exists ($extra_hash{'PRE_REMOVE'}))) { | ||||
|        my $pa=$extra_hash{'PRE_REMOVE'}; | ||||
|        my $rm_packges= join(' ', @$pa); | ||||
|        if ($rm_packges) { | ||||
| 	   $rc = system("$yumcmd_remove $rm_packges"); | ||||
|        } | ||||
|    } | ||||
|     | ||||
|  | ||||
|    #add extra packages in the list | ||||
|    if ($extrapkgnames) { | ||||
|        #print "$yumcmd $extrapkgnames\n"; | ||||
| @@ -342,6 +354,16 @@ unless ($onlyinitrd) { | ||||
|        } | ||||
|    } | ||||
|  | ||||
|    #remove the packages that are specified in the otherpkgs.list files with leading '--' | ||||
|    if ((%extra_hash) && (exists ($extra_hash{'POST_REMOVE'}))) { | ||||
|        my $pa=$extra_hash{'POST_REMOVE'}; | ||||
|        my $rm_packges= join(' ', @$pa); | ||||
|        if ($rm_packges) { | ||||
| 	   $rc = system("$yumcmd_remove $rm_packges"); | ||||
|        } | ||||
|    } | ||||
|  | ||||
|  | ||||
|    postscripts(); #run 'postscripts' | ||||
| } | ||||
| unlink "/tmp/genimage.$$.yum.conf"; | ||||
| @@ -645,7 +667,7 @@ END | ||||
|    foreach (@filestoadd) { | ||||
|       if (ref($_)) { | ||||
|          #print "$_->[0], $_->[1]\n"; | ||||
|          my $srcpath = "$rootimg_dir".$_->[0]; | ||||
|          my $srcpath = "$rootimg_dir/".$_->[0]; | ||||
|          if (-f "$customdir/".$_->[0]) { | ||||
|             $srcpath="$customdir/".$_->[0]; | ||||
|          } elsif (-f "$pathtofiles/".$_->[0]) { | ||||
| @@ -811,7 +833,9 @@ sub get_extra_package_names { | ||||
| 	$otherpkglist=get_extra_pkglist_file_name($customdir); | ||||
| 	if (!$otherpkglist) { $otherpkglist=get_extra_pkglist_file_name($pathtofiles); } | ||||
|     } | ||||
|    my %pkgnames=(); | ||||
|  | ||||
|    #print "customdir=$customdir,pathtofiles=$pathtofiles,otherpkglist=$otherpkglist\n"; | ||||
|    my %pkgnames=();   | ||||
|    my @tmp_array=(); | ||||
|  | ||||
|  | ||||
| @@ -842,8 +866,17 @@ sub get_extra_package_names { | ||||
|       | ||||
|         print "pkgtext=$pkgtext\n"; | ||||
| 	my @tmp=split(',', $pkgtext); | ||||
| 	foreach (@tmp) {  | ||||
| 	    my $idir=dirname($_); | ||||
| 	foreach (@tmp) { | ||||
| 	    my $idir; | ||||
| 	    if (/^--/) {	 | ||||
| 		$idir="POST_REMOVE";   #line starts with -- means the package should be removed after otherpkgs are installed | ||||
| 		s/^--//; | ||||
|             } elsif  (/^-/) { | ||||
| 		$idir="PRE_REMOVE"; #line starts with single - means the package should be removed before otherpkgs are installed | ||||
| 		s/^-//; | ||||
|             } else {  | ||||
| 		$idir=dirname($_);  | ||||
| 	    } | ||||
| 	    my $fn=basename($_); | ||||
| 	    if (exists($pkgnames{$idir})) { | ||||
| 		my $pa=$pkgnames{$idir}; | ||||
|   | ||||
| @@ -1,4 +1,10 @@ | ||||
| #!/usr/bin/env perl | ||||
| BEGIN | ||||
| { | ||||
|     $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; | ||||
| } | ||||
| use lib "$::XCATROOT/lib/perl"; | ||||
|  | ||||
| use File::Basename; | ||||
| use File::Path; | ||||
| use File::Copy; | ||||
| @@ -13,11 +19,7 @@ my $prinic; #TODO be flexible on node primary nic | ||||
| my $othernics; #TODO be flexible on node primary nic | ||||
| my $netdriver; | ||||
| my @yumdirs; | ||||
| my $arch = `uname -m`; | ||||
| chomp($arch); | ||||
| if ($arch =~ /i.86$/) { | ||||
|    $arch = x86; | ||||
| } | ||||
| my $arch; | ||||
| my %libhash; | ||||
| my @filestoadd; | ||||
| my $profile; | ||||
| @@ -36,6 +38,14 @@ my $kernelver = ""; #`uname -r`; | ||||
| my $basekernelver; # = $kernelver; | ||||
| my $customdir=$fullpath; | ||||
| $customdir =~ s/.*share\/xcat/$installroot\/custom/; | ||||
| my $imagename; | ||||
| my $pkglist; | ||||
| my $srcdir; | ||||
| my $destdir; | ||||
| my $srcdir_otherpkgs; | ||||
| my $otherpkglist; | ||||
| my $postinstall_filename; | ||||
| my $rootimg_dir; | ||||
|  | ||||
| sub xdie { | ||||
|    system("rm -rf /tmp/xcatinitrd.$$"); | ||||
| @@ -69,12 +79,98 @@ GetOptions( | ||||
|    't=s' => \$tmplimit, | ||||
|    'k=s' => \$kernelver | ||||
| ); | ||||
| if (@ARGV > 0) { | ||||
|     $imagename=$ARGV[0]; | ||||
|     if ($arch or $osver or $profile) { | ||||
| 	print "-o, -p and -a options are not allowed when a image name is specified.\n"; | ||||
|         exit 1; | ||||
|     } | ||||
|     #load the module in memory | ||||
|     eval {require("$::XCATROOT/lib/perl/xCAT/Table.pm")}; | ||||
|     if ($@) { | ||||
| 	print $@; | ||||
| 	exit 1; | ||||
|     } | ||||
|     | ||||
|     #get the info from the osimage and linux  | ||||
|     my $osimagetab=xCAT::Table->new('osimage', -create=>1); | ||||
|     if (!$osimagetab) { | ||||
| 	print "The osimage table cannot be opened.\n"; | ||||
| 	exit 1; | ||||
|     } | ||||
|     my $linuximagetab=xCAT::Table->new('linuximage', -create=>1); | ||||
|     if (!$linuximagetab) { | ||||
| 	print "The linuximage table cannot be opened.\n"; | ||||
| 	exit 1; | ||||
|     } | ||||
|     (my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'osvers', 'osarch', 'profile', 'provmethod'); | ||||
|     if (!$ref) { | ||||
| 	print "Cannot find image \'$imagename\' from the osimage table.\n"; | ||||
| 	exit 1; | ||||
|     } | ||||
|     (my $ref1) = $linuximagetab->getAttribs({imagename => $imagename}, 'pkglist', 'pkgdir', 'otherpkglist', 'otherpkgdir', 'postinstall', 'rootimgdir'); | ||||
|     if (!$ref1) { | ||||
| 	print "Cannot find $imagename from the linuximage table\n"; | ||||
| 	exit 1; | ||||
|     } | ||||
|  | ||||
|     $osver=$ref->{'osvers'}; | ||||
|     $arch=$ref->{'osarch'}; | ||||
|     $profile=$ref->{'profile'}; | ||||
|     my $provmethod=$ref->{'provmethod'}; | ||||
|      | ||||
|     unless ($osver and $arch and $profile and $provmethod) { | ||||
| 	print"osimage.osvers, osimage.osarch, osimage.profile and osimage.provmethod must be specified for the image $imagename in the database.\n"; | ||||
| 	exit 1; | ||||
|     } | ||||
|  | ||||
|     if ($provmethod ne 'netboot') { | ||||
| 	print "\'$imagename\' cannot be used to build diskless image. Make sure osimage.provmethod is 'netboot'."; | ||||
| 	exit 1; | ||||
|     } | ||||
|  | ||||
|     if (! $ref1->{'pkglist'}) { | ||||
| 	print"A .pkglist file must be specified for image \'$imagename\' in the linuximage table.\n"; | ||||
|         exit 0; | ||||
|     } | ||||
|     $pkglist =$ref1->{'pkglist'}; | ||||
|  | ||||
|     $srcdir=$ref1->{'pkgdir'}; | ||||
|     if ($srcdir) { $srcdir="$srcdir/1"; } | ||||
|     $srcdir_otherpkgs=$ref1->{'otherpkgdir'}; | ||||
|     $otherpkglist=$ref1->{'otherpkglist'}; | ||||
|     $postinstall_filename=$ref1->{'postinstall'}; | ||||
|     $destdir=$ref1->{'rootimgdir'}; | ||||
| } | ||||
|  | ||||
| if (!$arch) { | ||||
|     my $arch = `uname -m`; | ||||
|     chomp($arch); | ||||
|     if ($arch =~ /i.86$/) { | ||||
| 	$arch = "x86"; | ||||
|     } | ||||
| } | ||||
|  | ||||
| if (!$srcdir) {  | ||||
|     $srcdir="$installroot/$osver/$arch/1"; | ||||
| } | ||||
|  | ||||
| if (!$srcdir_otherpkgs) {  | ||||
|     $srcdir_otherpkgs = "$installroot/post/otherpkgs/$osver/$arch";  | ||||
| } | ||||
|  | ||||
| if (!$destdir) | ||||
| { | ||||
|     $destdir="$installroot/netboot/$osver/$arch/$profile"; | ||||
| } | ||||
| $rootimg_dir="$destdir/rootimg"; | ||||
|  | ||||
| #Default to the first kernel found in the install image if nothing specified explicitly. | ||||
| #A more accurate guess than whatever the image build server happens to be running | ||||
| #If specified, that takes precedence. | ||||
| #if image has one, that is used | ||||
| #if all else fails, resort to uname -r like this script did before | ||||
| my @KVERS= <$installroot/netboot/$osver/$arch/$profile/rootimg/lib/modules/*>; | ||||
| my @KVERS= <$rootimg_dir/lib/modules/*>; | ||||
| if (scalar(@KVERS)) { | ||||
|     $basekernelver = basename($KVERS[0]); | ||||
| } | ||||
| @@ -86,10 +182,12 @@ unless ($kernelver) { | ||||
| } | ||||
| chomp($kernelver); | ||||
| unless ($osver and $profile and $netdriver and $prinic) { | ||||
|    print 'Usage: genimage -i <nodebootif> -n <nodenetdrivers> [-r <otherifaces>] -o <OSVER> -p <PROFILE> -k <KERNELVER>'."\n"; | ||||
|    print 'Usage: genimage -i <nodebootif> -n <nodenetdrivers> [-r <otherifaces>] -k <KERNELVER> -o <OSVER> -p <PROFILE> -a <ARCH>'."\n"; | ||||
|    print '       genimage -i <nodebootif> -n <nodenetdrivers> [-r <otherifaces>] -k <KERNELVER> <imagename>'."\n"; | ||||
|    print "Examples:\n"; | ||||
|    print " genimage -i eth0 -n tg3 -o centos5.1 -p compute\n"; | ||||
|    print " genimage -i eth0 -r eth1,eth2 -n tg3,bnx2 -o centos5.1 -p compute\n"; | ||||
|    print " genimage -i eth0 -ntg3 myimagename\n"; | ||||
|    exit 1; | ||||
| } | ||||
| my @ndrivers; | ||||
| @@ -114,59 +212,54 @@ if(`grep VERSION /etc/SuSE-release` =~ /VERSION = (\d+)/) { | ||||
| } | ||||
|  | ||||
| unless ($onlyinitrd) { | ||||
|    my $srcdir = "$installroot/$osver/$arch/1"; | ||||
|  | ||||
|  | ||||
|    #this is for extra packages | ||||
|    my $srcdir_otherpkgs = "$installroot/post/otherpkgs/$osver/$arch"; | ||||
|    my %extra_hash=get_extra_package_names(); | ||||
|  | ||||
|  | ||||
|    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"; | ||||
|    system "mknod $installroot/netboot/$osver/$arch/$profile/rootimg/dev/zero c 1 5"; | ||||
|    system "mknod $installroot/netboot/$osver/$arch/$profile/rootimg/dev/null c 1 3"; #that's neccessary for SLES11 | ||||
|    open($fd,">>","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/fstab"); | ||||
|    mkpath "$rootimg_dir/etc"; | ||||
|    mkpath "$rootimg_dir/dev"; | ||||
|    #system "mount -o bind /dev $rootimg_dir/dev"; | ||||
|    system "mknod $rootimg_dir/dev/zero c 1 5"; | ||||
|    system "mknod $rootimg_dir/dev/null c 1 3"; #that's neccessary for SLES11 | ||||
|    open($fd,">>","$rootimg_dir/etc/fstab"); | ||||
|    print $fd "#Dummy fstab for rpm postscripts to see\n"; | ||||
|    close($fd); | ||||
|    if($osver_host == 11) {#zypper in SLES11 is different | ||||
| 	   my $rootimg_dir="$installroot/netboot/$osver/$arch/$profile/rootimg"; | ||||
| 	   if(-e "$rootimg_dir/etc/zypp/repos.d/$osver.repo") { | ||||
| 		   system("rm -rf $rootimg_dir/etc/zypp/repos.d/$osver.repo"); | ||||
| 	   } | ||||
| 	   system("zypper -R $rootimg_dir ar file:$srcdir $osver"); | ||||
|    }else { | ||||
| 	   system("zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ sa file:$srcdir"); | ||||
| 	   system("zypper -R $rootimg_dir sa file:$srcdir"); | ||||
|    } | ||||
|  | ||||
|    #remove the old repository for extra packages | ||||
|    my $result=`zypper -R /install/netboot/sles11/ppc64/test/rootimg/ sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; | ||||
|    my $result=`zypper -R $rootimg_dir sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; | ||||
|    if ($result =~ /\S/) { | ||||
|        system("zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ sd $result"); | ||||
|        system("zypper -R $rootimg_dir sd $result"); | ||||
|    } | ||||
|  | ||||
|    #add the new repository for extra packages | ||||
|    my $extrapkgnames;  | ||||
|    if($osver_host == 11) {	#SLES11 | ||||
|       if(-e "$installroot/netboot/$osver/$arch/$profile/rootimg/etc/zypp/repos.d/otherpkg.repo") { | ||||
| 	  system("rm -rf $installroot/netboot/$osver/$arch/$profile/rootimg/etc/zypp/repos.d/otherpkg.repo"); | ||||
|       if(-e "$rootimg_dir/etc/zypp/repos.d/otherpkg.repo") { | ||||
| 	  system("rm -rf $rootimg_dir/etc/zypp/repos.d/otherpkg.repo"); | ||||
|       } | ||||
|    } | ||||
|    my $index=1; | ||||
|    foreach (keys(%extra_hash)) { | ||||
|        $whole_path="$srcdir_otherpkgs/$_"; | ||||
|        if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE")) { next;}  | ||||
|        my $whole_path="$srcdir_otherpkgs/$_"; | ||||
|        if (-r "$srcdir_otherpkgs/$_/repodata/repomd.xml") { | ||||
| 	   if($osver_host == 11) {  | ||||
| 	       system("zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ ar file:$srcdir_otherpkgs/$_  otherpkg$index"); | ||||
| 	       system("zypper -R $rootimg_dir ar file:$srcdir_otherpkgs/$_  otherpkg$index"); | ||||
| 	   }else { | ||||
| 	       system("zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ sa file:$srcdir_otherpkgs/$_"); | ||||
| 	       system("zypper -R $rootimg_dir sa file:$srcdir_otherpkgs/$_"); | ||||
| 	   } | ||||
|        } else { | ||||
| 	   if($osver_host == 11) {  | ||||
| 	       system("zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ ar -t Plaindir file:$srcdir_otherpkgs/$_  otherpkg$index"); | ||||
| 	       system("zypper -R $rootimg_dir ar -t Plaindir file:$srcdir_otherpkgs/$_  otherpkg$index"); | ||||
| 	   }else { | ||||
| 	       system("zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ sa -t Plaindir file:$srcdir_otherpkgs/$_"); | ||||
| 	       system("zypper -R $rootimg_dir sa -t Plaindir file:$srcdir_otherpkgs/$_"); | ||||
| 	   } | ||||
|        } | ||||
|        $index++; | ||||
| @@ -176,6 +269,7 @@ unless ($onlyinitrd) { | ||||
|    } | ||||
|  | ||||
|    #-- add custom repositories to the image | ||||
|    my $repolist; | ||||
|    if ( -r "$pathtofiles/$profile.$osver.$arch.repolist") { | ||||
|        $repolist = "$pathtofiles/$profile.$osver.$arch.repolist"; | ||||
|    }elsif ( -r "$pathtofiles/$profile.$osver.repolist") { | ||||
| @@ -190,24 +284,26 @@ unless ($onlyinitrd) { | ||||
|      while (<$repoconfig>) { | ||||
|        chomp; | ||||
|        next if /^\s*#/; | ||||
|        ($repotype,$repourl,$repoalias) = split m/\|/; | ||||
|        system("zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ ar $repourl $repoalias"); | ||||
|        my ($repotype,$repourl,$repoalias) = split m/\|/; | ||||
|        system("zypper -R $rootimg_dir ar $repourl $repoalias"); | ||||
|      } | ||||
|    } | ||||
|  | ||||
|    #my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$installroot/netboot/$osver/$arch/$profile/rootimg/ --disablerepo=* "; | ||||
|    #my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir --disablerepo=* "; | ||||
|    #$yumcmd .= "install "; | ||||
|    #mkpath("$installroot/netboot/$osver/$arch/$profile/rootimg/var/lib/yum"); | ||||
|    #mkpath("$rootimg_dir/var/lib/yum"); | ||||
|    my $yumcmd; | ||||
|    if($osver =~ /suse11/ && $osver_host == 11) { | ||||
|        $yumcmd = "zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ install -l "; #add -l for SLES11 | ||||
|        $yumcmd = "zypper -R $rootimg_dir install -l "; #add -l for SLES11 | ||||
|    }else { | ||||
|         $yumcmd = "zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ install "; | ||||
|         $yumcmd = "zypper -R $rootimg_dir install "; | ||||
|    } | ||||
|    if (!$imagename) { | ||||
|        $pkglist= get_pkglist_file_name($customdir); | ||||
|        if (!$pkglist) { | ||||
| 	   $pkglist= get_pkglist_file_name($pathtofiles); | ||||
|        }  | ||||
|    } | ||||
|    my $pkglist= get_pkglist_file_name($customdir); | ||||
|    if (!$pkglist) { | ||||
|      $pkglist= get_pkglist_file_name($pathtofiles); | ||||
|    }  | ||||
|    #print "pkglist=$pkglist\n"; | ||||
|  | ||||
|    if (!$pkglist) { | ||||
| @@ -234,6 +330,16 @@ unless ($onlyinitrd) { | ||||
|       exit 1; | ||||
|    } | ||||
|  | ||||
|    #remove the packages that are specified in the otherpkgs.list files with leading '-' | ||||
|    my $yumcmd_remove= "zypper -R $rootimg_dir remove ";  | ||||
|    if ((%extra_hash) && (exists ($extra_hash{'PRE_REMOVE'}))) { | ||||
|        my $pa=$extra_hash{'PRE_REMOVE'}; | ||||
|        my $rm_packges= join(' ', @$pa); | ||||
|        if ($rm_packges) { | ||||
| 	   $rc = system("$yumcmd_remove $rm_packges"); | ||||
|        } | ||||
|    } | ||||
|  | ||||
|    #add extra packages in the list | ||||
|    if ($extrapkgnames) { | ||||
|        #print "$yumcmd $extrapkgnames\n"; | ||||
| @@ -244,18 +350,28 @@ unless ($onlyinitrd) { | ||||
|        } | ||||
|    } | ||||
|  | ||||
|    #remove the packages that are specified in the otherpkgs.list files with leading '--' | ||||
|    if ((%extra_hash) && (exists ($extra_hash{'POST_REMOVE'}))) { | ||||
|        my $pa=$extra_hash{'POST_REMOVE'}; | ||||
|        my $rm_packges= join(' ', @$pa); | ||||
|        if ($rm_packges) { | ||||
| 	   $rc = system("$yumcmd_remove $rm_packges"); | ||||
|        } | ||||
|  | ||||
|    postscripts(); #run 'postscripts' | ||||
| } | ||||
| unlink "/tmp/genimage.$$.yum.conf"; | ||||
|  | ||||
| #-- run postinstall script | ||||
| my $postinstall_filename= get_postinstall_file_name($customdir); | ||||
| if (!$postinstall_filename) { | ||||
|     $postinstall_filename= get_postinstall_file_name($pathtofiles); | ||||
| }  | ||||
| if (!$imagename) { | ||||
|     $postinstall_filename= get_postinstall_file_name($customdir); | ||||
|     if (!$postinstall_filename) { | ||||
| 	$postinstall_filename= get_postinstall_file_name($pathtofiles); | ||||
|     }  | ||||
| } | ||||
|  | ||||
| if (($postinstall_filename) && (-x $postinstall_filename)) { | ||||
|     my $rc = system($postinstall_filename, "$installroot/netboot/$osver/$arch/$profile/rootimg",$osver,$arch,$profile); | ||||
|     my $rc = system($postinstall_filename, $rootimg_dir,$osver,$arch,$profile); | ||||
|     if($rc) { | ||||
|         print "postinstall script failed\n"; | ||||
|         exit 1; | ||||
| @@ -271,9 +387,9 @@ open MTABFD, "/etc/mtab"; | ||||
| my @lines = <MTABFD>; | ||||
| close MTABFD; | ||||
|  | ||||
| my $ret = grep m{$installroot/netboot/$osver/$arch/$profile/rootimg/proc}, @lines; | ||||
| my $ret = grep m{$rootimg_dir/proc}, @lines; | ||||
| if($ret > 0) { | ||||
|     system("umount $installroot/netboot/$osver/$arch/$profile/rootimg/proc"); | ||||
|     system("umount $rootimg_dir/proc"); | ||||
| } | ||||
|  | ||||
| mkinitrd(); | ||||
| @@ -281,7 +397,7 @@ mkinitrd(); | ||||
|  | ||||
| sub getlibs { | ||||
| 	my $file = shift; | ||||
| 	my $liblist = `chroot $installroot/netboot/$osver/$arch/$profile/rootimg ldd $file`; | ||||
| 	my $liblist = `chroot $rootimg_dir ldd $file`; | ||||
| 	my @libs = split/\n/,$liblist; | ||||
| 	my @return; | ||||
| 	foreach (@libs) { | ||||
| @@ -304,21 +420,21 @@ sub getlibs { | ||||
| sub mkinitrd { | ||||
| 	mkpath("/tmp/xcatinitrd.$$/bin"); | ||||
| 	if($basekernelver eq $kernelver) { | ||||
|         if (-f "$installroot/netboot/$osver/$arch/$profile/rootimg/boot/vmlinuz-$kernelver") { | ||||
| 		    rename(<$installroot/netboot/$osver/$arch/$profile/rootimg/boot/vmlinuz*>,"$installroot/netboot/$osver/$arch/$profile/kernel"); | ||||
| 	         } elsif (-f "$installroot/netboot/$osver/$arch/$profile/rootimg/boot/vmlinux-$kernelver"){ | ||||
|                     rename(<$installroot/netboot/$osver/$arch/$profile/rootimg/boot/vmlinux*>,"$installroot/netboot/$osver/$arch/$profile/kernel"); | ||||
|         if (-f "$rootimg_dir/boot/vmlinuz-$kernelver") { | ||||
| 		    rename(<$rootimg_dir/boot/vmlinuz*>,"$destdir/kernel"); | ||||
| 	         } elsif (-f "$rootimg_dir/boot/vmlinux-$kernelver"){ | ||||
|                     rename(<$rootimg_dir/boot/vmlinux*>,"$destdir/kernel"); | ||||
|                  } | ||||
|         } | ||||
| 	else { | ||||
| 	    if(-r "$installroot/netboot/$osver/$arch/$profile/rootimg/boot/vmlinuz-$kernelver") { | ||||
| 		    rename("$installroot/netboot/$osver/$arch/$profile/rootimg/boot/vmlinuz-$kernelver","$installroot/netboot/$osver/$arch/$profile/kernel"); | ||||
|         } elsif(-r "$installroot/netboot/$osver/$arch/$profile/rootimg/boot/vmlinux-$kernelver") { | ||||
|             rename("$installroot/netboot/$osver/$arch/$profile/rootimg/boot/vmlinux-$kernelver","$installroot/netboot/$osver/$arch/$profile/kernel"); | ||||
| 	    if(-r "$rootimg_dir/boot/vmlinuz-$kernelver") { | ||||
| 		    rename("$rootimg_dir/boot/vmlinuz-$kernelver","$destdir/kernel"); | ||||
|         } elsif(-r "$rootimg_dir/boot/vmlinux-$kernelver") { | ||||
|             rename("$rootimg_dir/boot/vmlinux-$kernelver","$destdir/kernel"); | ||||
|         }  elsif(-r "/boot/vmlinuz-$kernelver") { | ||||
| 		    copy("/boot/vmlinuz-$kernelver","$installroot/netboot/$osver/$arch/$profile/kernel"); | ||||
| 		    copy("/boot/vmlinuz-$kernelver","$destdir/kernel"); | ||||
| 	    } elsif(-r "/boot/vmlinux-$kernelver") {#for SLES10,11 | ||||
| 			copy("/boot/vmlinux-$kernelver","$installroot/netboot/$osver/$arch/$profile/kernel"); | ||||
| 			copy("/boot/vmlinux-$kernelver","$destdir/kernel"); | ||||
| 	    } | ||||
| 	    else { | ||||
| 		    xdie("Cannot read /boot/vmlinuz-$kernelver"); | ||||
| @@ -531,21 +647,21 @@ END | ||||
|    } | ||||
|    push @filestoadd,keys %libhash; | ||||
| 	if($basekernelver ne $kernelver) { | ||||
| 		system("rm -rf $installroot/netboot/$osver/$arch/$profile/rootimg/lib/modules/$basekernelver"); | ||||
|         unless (-d "$installroot/netboot/$osver/$arch/$profile/rootimg/lib/modules/$kernelver") { | ||||
| 		system("rm -rf $rootimg_dir/lib/modules/$basekernelver"); | ||||
|         unless (-d "$rootimg_dir/lib/modules/$kernelver") { | ||||
| 		    if(-d "/lib/modules/$kernelver") { | ||||
| 		    	system("cd /lib/modules;cp -r $kernelver $installroot/netboot/$osver/$arch/$profile/rootimg/lib/modules/"); | ||||
| 		    	system("cd /lib/modules;cp -r $kernelver $rootimg_dir/lib/modules/"); | ||||
| 		    } | ||||
| 		    else { | ||||
| 		    	xdie("Cannot read /lib/modules/$kernelver"); | ||||
| 		    } | ||||
|         } | ||||
| 	} | ||||
|    find(\&isnetdriver, <$installroot/netboot/$osver/$arch/$profile/rootimg/lib/modules/$kernelver/*>); | ||||
|    find(\&isnetdriver, <$rootimg_dir/lib/modules/$kernelver/*>); | ||||
|    foreach (@filestoadd) { | ||||
|       if (ref($_)) { | ||||
|          #print "$_->[0], $_->[1]\n"; | ||||
|          my $srcpath = "$installroot/netboot/$osver/$arch/$profile/rootimg/".$_->[0]; | ||||
|          my $srcpath = "$rootimg_dir/".$_->[0]; | ||||
|          if (-f "$customdir/".$_->[0]) { | ||||
|             $srcpath="$customdir/".$_->[0]; | ||||
|          } elsif (-f "$pathtofiles/".$_->[0]) { | ||||
| @@ -555,7 +671,7 @@ END | ||||
|          chmod 0755,"/tmp/xcatinitrd.$$/".$_->[1]; | ||||
|       } else { | ||||
|          #print "$_\n"; | ||||
|          my $srcpath = "$installroot/netboot/$osver/$arch/$profile/rootimg/$_"; | ||||
|          my $srcpath = "$rootimg_dir/$_"; | ||||
|          if (-f "$customdir/$_") { | ||||
|             $srcpath = "$customdir/$_"; | ||||
|          } elsif (-f "$pathtofiles/$_") { | ||||
| @@ -566,9 +682,9 @@ END | ||||
|       } | ||||
|    } | ||||
|  | ||||
|    #copy("$installroot/netboot/$osver/$arch/$profile/rootimg/lib/modules/*d","/tmp/xcatinitrd.$$/$_"); | ||||
|    #copy("$rootimg_dir/lib/modules/*d","/tmp/xcatinitrd.$$/$_"); | ||||
|    system("cd /tmp/xcatinitrd.$$/bin/; ln -sf bash sh");	#neccessary for SLES11 | ||||
|    system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $installroot/netboot/$osver/$arch/$profile/initrd.gz"); | ||||
|    system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd.gz"); | ||||
|    system("rm -rf /tmp/xcatinitrd.$$"); | ||||
|  | ||||
| } | ||||
| @@ -585,7 +701,7 @@ sub isnetdriver { | ||||
|    foreach (@ndrivers) { | ||||
|       if ($File::Find::name =~ /\/$_/) { | ||||
|          my $filetoadd = $File::Find::name; | ||||
|          $filetoadd =~ s!$installroot/netboot/$osver/$arch/$profile/rootimg/!!; | ||||
|          $filetoadd =~ s!$rootimg_dir!!; | ||||
|          push @filestoadd,[$filetoadd,"lib/$_"]; | ||||
|       } | ||||
|    } | ||||
| @@ -601,26 +717,26 @@ sub postscripts { # TODO: customized postscripts | ||||
|    generic_post(); | ||||
|    if (-d "$installroot/postscripts/hostkeys") { | ||||
|       for my $key (<$installroot/postscripts/hostkeys/*key>) { | ||||
|          copy ($key,"$installroot/netboot/$osver/$arch/$profile/rootimg/etc/ssh/"); | ||||
|          copy ($key,"$rootimg_dir/etc/ssh/"); | ||||
|       } | ||||
|       chmod 0600,</$installroot/netboot/$osver/$arch/$profile/rootimg/etc/ssh/*key>; | ||||
|       chmod 0600,</$rootimg_dir/etc/ssh/*key>; | ||||
|    } | ||||
|    if (-d "/$installroot/postscripts/.ssh") { | ||||
|       mkpath("/$installroot/netboot/$osver/$arch/$profile/rootimg/root/.ssh"); | ||||
|       chmod(0700,"/$installroot/netboot/$osver/$arch/$profile/rootimg/root/.ssh/"); | ||||
|       mkpath("$rootimg_dir/root/.ssh"); | ||||
|       chmod(0700,"$rootimg_dir/root/.ssh/"); | ||||
|       for my $file (</$installroot/postscripts/.ssh/*>) { | ||||
|          copy ($file,"/$installroot/netboot/$osver/$arch/$profile/rootimg/root/.ssh/"); | ||||
|          copy ($file,"$rootimg_dir/root/.ssh/"); | ||||
|       } | ||||
|       chmod(0600,</$installroot/netboot/$osver/$arch/$profile/rootimg/root/.ssh/*>); | ||||
|       chmod(0600,</$rootimg_dir/root/.ssh/*>); | ||||
|    } | ||||
|  | ||||
| } | ||||
|  | ||||
| sub generic_post { #This function is meant to leave the image in a state approximating a normal install | ||||
|    my $cfgfile; | ||||
|    unlink("$installroot/netboot/$osver/$arch/$profile/rootimg/dev/null"); | ||||
|    system("mknod $installroot/netboot/$osver/$arch/$profile/rootimg/dev/null c 1 3"); | ||||
|    open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/fstab"); | ||||
|    unlink("$rootimg_dir/dev/null"); | ||||
|    system("mknod $rootimg_dir/dev/null c 1 3"); | ||||
|    open($cfgfile,">","$rootimg_dir/etc/fstab"); | ||||
|    print $cfgfile "devpts  /dev/pts devpts   gid=5,mode=620 0 0\n"; | ||||
|    print $cfgfile "tmpfs   /dev/shm tmpfs    defaults       0 0\n"; | ||||
|    print $cfgfile "proc    /proc    proc     defaults       0 0\n"; | ||||
| @@ -630,31 +746,31 @@ sub generic_post { #This function is meant to leave the image in a state approxi | ||||
|       print $cfgfile "tmpfs   /var/tmp     tmpfs    defaults       0 0\n"; | ||||
|    } | ||||
|    close($cfgfile); | ||||
|    open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/sysconfig/network"); | ||||
|    open($cfgfile,">","$rootimg_dir/etc/sysconfig/network"); | ||||
|    print $cfgfile "NETWORKING=yes\n"; | ||||
|    close($cfgfile); | ||||
|    open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/resolv.conf"); | ||||
|    open($cfgfile,">","$rootimg_dir/etc/resolv.conf"); | ||||
|    print $cfgfile "#Dummy resolv.conf to make boot cleaner"; | ||||
|    close($cfgfile); | ||||
|    open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/sysconfig/network-scripts/ifcfg-$prinic"); | ||||
|    open($cfgfile,">","$rootimg_dir/etc/sysconfig/network-scripts/ifcfg-$prinic"); | ||||
|    print $cfgfile "ONBOOT=yes\nBOOTPROTO=dhcp\nDEVICE=$prinic\n"; | ||||
|    close($cfgfile); | ||||
|    foreach (split /,/,$othernics) { | ||||
|       if (/^$/) { next; } | ||||
|       open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/sysconfig/network-scripts/ifcfg-$_"); | ||||
|       open($cfgfile,">","$rootimg_dir/etc/sysconfig/network-scripts/ifcfg-$_"); | ||||
|       print $cfgfile "ONBOOT=yes\nBOOTPROTO=dhcp\nDEVICE=$_\n"; | ||||
|       close($cfgfile); | ||||
|    } | ||||
|    open($cfgfile,">>","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/securetty"); | ||||
|    open($cfgfile,">>","$rootimg_dir/etc/securetty"); | ||||
|    print $cfgfile "ttyS0\n"; | ||||
|    print $cfgfile "ttyS1\n"; | ||||
|    print $cfgfile "console\n"; | ||||
|    close($cfgfile); | ||||
|    my @passwd; | ||||
|    open($cfgfile,"<","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/passwd"); | ||||
|    open($cfgfile,"<","$rootimg_dir/etc/passwd"); | ||||
|    @passwd = <$cfgfile>; | ||||
|    close($cfgfile); | ||||
|    open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/passwd"); | ||||
|    open($cfgfile,">","$rootimg_dir/etc/passwd"); | ||||
|    foreach (@passwd) { | ||||
|       if (/^root:/) { | ||||
|          s/^root:\*/root:x/ | ||||
| @@ -662,13 +778,13 @@ sub generic_post { #This function is meant to leave the image in a state approxi | ||||
|       print $cfgfile $_; | ||||
|    } | ||||
|    close($cfgfile); | ||||
|    foreach (<$installroot/netboot/$osver/$arch/$profile/rootimg/etc/skel/.*>) { | ||||
|    foreach (<$rootimg_dir/etc/skel/.*>) { | ||||
|       if (basename($_) eq '.' or basename($_) eq '..') { | ||||
|          next; | ||||
|       } | ||||
|       copy $_,"$installroot/netboot/$osver/$arch/$profile/rootimg/root/"; | ||||
|       copy $_,"$rootimg_dir/root/"; | ||||
|    } | ||||
|    open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/init.d/gettyset"); | ||||
|    open($cfgfile,">","$rootimg_dir/etc/init.d/gettyset"); | ||||
|    print $cfgfile "#!/bin/bash\n";  | ||||
|    print $cfgfile "for i in `cat /proc/cmdline`; do\n";  | ||||
|    print $cfgfile '  KEY=`echo $i|cut -d= -f 1`'."\n"; | ||||
| @@ -686,29 +802,34 @@ sub generic_post { #This function is meant to leave the image in a state approxi | ||||
|    print $cfgfile "/etc/init.d/boot.localnet start\n"; | ||||
|    print $cfgfile "/opt/xcat/xcatdsklspost\n"; | ||||
|    close($cfgfile); | ||||
|    chmod(0755,"$installroot/netboot/$osver/$arch/$profile/rootimg/etc/init.d/gettyset"); | ||||
|    #link("$installroot/netboot/$osver/$arch/$profile/rootimg/sbin/init","$installroot/netboot/$osver/$arch/$profile/rootimg/init"); | ||||
|    my $rc = system("grep sshd $installroot/netboot/$osver/$arch/$profile/rootimg/etc/init.d/.depend.start"); | ||||
|    chmod(0755,"$rootimg_dir/etc/init.d/gettyset"); | ||||
|    #link("$rootimg_dir/sbin/init","$rootimg_dir/init"); | ||||
|    my $rc = system("grep sshd $rootimg_dir/etc/init.d/.depend.start"); | ||||
|    if ($rc) { | ||||
|       system("sed -i '".'s/^\(TARGETS = .*\)$/\1 sshd/'."' $installroot/netboot/$osver/$arch/$profile/rootimg/etc/init.d/.depend.start"); | ||||
|       system("ln -s ../sshd $installroot/netboot/$osver/$arch/$profile/rootimg/etc/init.d/rc3.d/S20sshd"); | ||||
|       system("sed -i '".'s/^\(TARGETS = .*\)$/\1 sshd/'."' $rootimg_dir/etc/init.d/.depend.start"); | ||||
|       system("ln -s ../sshd $rootimg_dir/etc/init.d/rc3.d/S20sshd"); | ||||
|    } | ||||
|    my $rc = system("grep gettyset $installroot/netboot/$osver/$arch/$profile/rootimg/etc/init.d/.depend.start"); | ||||
|    my $rc = system("grep gettyset $rootimg_dir/etc/init.d/.depend.start"); | ||||
|    if ($rc) { | ||||
|       system("sed -i '".'s/^\(TARGETS = .*\)$/\1 gettyset/'."' $installroot/netboot/$osver/$arch/$profile/rootimg/etc/init.d/.depend.start"); | ||||
|       system("ln -s ../gettyset $installroot/netboot/$osver/$arch/$profile/rootimg/etc/init.d/rc3.d/S60gettyset"); | ||||
|       system("sed -i '".'s/^\(TARGETS = .*\)$/\1 gettyset/'."' $rootimg_dir/etc/init.d/.depend.start"); | ||||
|       system("ln -s ../gettyset $rootimg_dir/etc/init.d/rc3.d/S60gettyset"); | ||||
|    } | ||||
|    if(($osver =~ /sles11/) || ($osver =~ /suse11/) || ($osver =~ /sles10/)) {#for sles11,sles10,suse11 | ||||
| 	   rename(<$installroot/netboot/$osver/$arch/$profile/rootimg/boot/vmlinux*>,"$installroot/netboot/$osver/$arch/$profile/kernel"); | ||||
| 	   rename(<$rootimg_dir/boot/vmlinux*>,"$destdir/kernel"); | ||||
|    }else { | ||||
|    	   rename(<$installroot/netboot/$osver/$arch/$profile/rootimg/boot/vmlinuz*>,"$installroot/netboot/$osver/$arch/$profile/kernel"); | ||||
|    	   rename(<$rootimg_dir/boot/vmlinuz*>,"$destdir/kernel"); | ||||
|    } | ||||
| } | ||||
|  | ||||
|  | ||||
| #get th extra package name | ||||
| sub get_extra_package_names { | ||||
|    my $otherpkglist=get_extra_pkglist_file_name($customdir); | ||||
|    if (!$otherpkglist) { $otherpkglist=get_extra_pkglist_file_name($pathtofiles); } | ||||
|     if (!$imagename) { | ||||
| 	$otherpkglist=get_extra_pkglist_file_name($customdir); | ||||
| 	if (!$otherpkglist) { $otherpkglist=get_extra_pkglist_file_name($pathtofiles); } | ||||
|     } | ||||
|  | ||||
|    #print "customdir=$customdir,pathtofiles=$pathtofiles,otherpkglist=$otherpkglist\n"; | ||||
|    my %pkgnames=(); | ||||
|    my @tmp_array=(); | ||||
|  | ||||
| @@ -740,8 +861,17 @@ sub get_extra_package_names { | ||||
|       | ||||
|         print "pkgtext=$pkgtext\n"; | ||||
| 	my @tmp=split(',', $pkgtext); | ||||
| 	foreach (@tmp) {  | ||||
| 	    my $idir=dirname($_); | ||||
| 	foreach (@tmp) { | ||||
| 	    my $idir; | ||||
| 	    if (/^--/) {	 | ||||
| 		$idir="POST_REMOVE";   #line starts with -- means the package should be removed after otherpkgs are installed | ||||
| 		s/^--//; | ||||
|             } elsif  (/^-/) { | ||||
| 		$idir="PRE_REMOVE"; #line starts with single - means the package should be removed before otherpkgs are installed | ||||
| 		s/^-//; | ||||
|             } else {  | ||||
| 		$idir=dirname($_);  | ||||
| 	    } | ||||
| 	    my $fn=basename($_); | ||||
| 	    if (exists($pkgnames{$idir})) { | ||||
| 		my $pa=$pkgnames{$idir}; | ||||
| @@ -757,6 +887,7 @@ sub get_extra_package_names { | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| sub include_file | ||||
| { | ||||
|    my $file = shift; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user