From 8bc3677aec491480b2b2db0cd8529900608a6530 Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Tue, 18 Oct 2011 07:08:12 +0000 Subject: [PATCH] Adding SLES10 SP4 supports git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10820 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/share/xcat/netboot/sles/genimage | 88 ++++++++++++++------ 1 file changed, 63 insertions(+), 25 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 216ad6047..8581bc4dd 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -263,10 +263,18 @@ unless ($onlyinitrd) { system("zypper -R $rootimg_dir --non-interactive --no-gpg-checks sa file:$kerneldir"); } } + #remove the old repository for extra packages - my $result=`zypper -R $rootimg_dir --non-interactive --no-gpg-checks sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; - if ($result =~ /\S/) { - system("zypper -R $rootimg_dir --non-interactive --no-gpg-checks sd $result"); + if ($osver_host == 11) { + my $result=`zypper -R $rootimg_dir --non-interactive --no-gpg-checks lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; + if ($result =~ /\S/) { + system("zypper -R $rootimg_dir --non-interactive --no-gpg-checks rr $result"); + } + } else { + my $result=`zypper -R $rootimg_dir --non-interactive --no-gpg-checks sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; + if ($result =~ /\S/) { + system("zypper -R $rootimg_dir --non-interactive --no-gpg-checks sd $result"); + } } #add the new repository for extra packages @@ -290,7 +298,7 @@ unless ($onlyinitrd) { } } else { if($osver_host == 11) { - system("zypper -R $rootimg_dir --non-interactive --no-gpg-checks ar -t Plaindir file:$srcdir_otherpkgs/$_ otherpkg$index"); + system("zypper -R $rootimg_dir --non-interactive --no-gpg-checks ar -t Plaindir file:$srcdir_otherpkgs/$_ otherpkg$index"); }else { system("zypper -R $rootimg_dir --non-interactive --no-gpg-checks sa -t Plaindir file:$srcdir_otherpkgs/$_"); } @@ -318,12 +326,16 @@ unless ($onlyinitrd) { chomp; next if /^\s*#/; my ($repotype,$repourl,$repoalias) = split m/\|/; - system("zypper -R $rootimg_dir --non-interactive --no-gpg-checks ar $repourl $repoalias"); + if($osver_host == 11) { + system("zypper -R $rootimg_dir --non-interactive --no-gpg-checks ar $repourl $repoalias"); + }else { + system("zypper -R $rootimg_dir --non-interactive --no-gpg-checks sa $repourl $repoalias"); + } } } # Refresh the zypper cache in case there is still old data out there - system("zypper -R $rootimg_dir --non-interactive --no-gpg-checks refresh"); + system("zypper -R $rootimg_dir --non-interactive --no-gpg-checks refresh"); #my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir --disablerepo=* "; #$yumcmd .= "install "; @@ -332,7 +344,7 @@ unless ($onlyinitrd) { if($osver =~ /sles11/ && $osver_host == 11) { $yumcmd = "zypper -R $rootimg_dir --non-interactive --no-gpg-checks install -l "; #add -l for SLES11 }else { - $yumcmd = "zypper -R $rootimg_dir --non-interactive --no-gpg-checks install "; + $yumcmd = "zypper -R $rootimg_dir --non-interactive --no-gpg-checks install "; } #install packages from pkglist file @@ -400,16 +412,14 @@ unless ($onlyinitrd) { $pkgnames .= " " . join(' ', @npa); $group_pkgnames .= " " . join(' ', @npa_group); } - my $envlist; if(exists $pkg_hash{$pass}{ENVLIST}){ $envlist = join(' ', @{$pkg_hash{$pass}{ENVLIST}}); } - if($pkgnames ne ' ') { - print "$envlist $yumcmd $pkgnames\n"; - my $rc = system("$envlist $yumcmd $pkgnames"); + print "$envlist $yumcmd -t pattern $group_pkgnames\n"; + $rc = system("$envlist $yumcmd -t pattern $group_pkgnames"); $rc = $rc >> 8; if (($rc) && ($rc != '104')) { print "zypper invocation failed with rc: $rc\n"; @@ -418,8 +428,8 @@ unless ($onlyinitrd) { } if($group_pkgnames ne ' ') { - print "$envlist $yumcmd -t pattern $group_pkgnames\n"; - $rc = system("$envlist $yumcmd -t pattern $group_pkgnames"); + print "$envlist $yumcmd -t pattern $group_pkgnames\n"; + $rc = system("$envlist $yumcmd -t pattern $group_pkgnames"); $rc = $rc >> 8; if (($rc) && ($rc != '104')) { print "zypper invocation failed with rc: $rc\n"; @@ -435,7 +445,7 @@ unless ($onlyinitrd) { $envlist = join(' ', @{$extra_hash{$pass}{ENVLIST}}); } - my $yumcmd_remove= "zypper -R $rootimg_dir --non-interactive --no-gpg-checks remove "; + my $yumcmd_remove= "zypper -R $rootimg_dir --non-interactive --no-gpg-checks remove "; if (exists ($extra_hash{$pass}{'PRE_REMOVE'})) { my $pa=$extra_hash{$pass}{'PRE_REMOVE'}; my $rm_packges= join(' ', @$pa); @@ -470,7 +480,12 @@ unless ($onlyinitrd) { # run zypper update to update any installed rpms # needed when running genimage again after updating software in repositories - my $yumcmd_update = "zypper -R $rootimg_dir --non-interactive --no-gpg-checks update "; + my $yumcmd_update; + if ($osver_host == 11) { + $yumcmd_update = "zypper -R $rootimg_dir --non-interactive --no-gpg-checks update "; + } else { + $yumcmd_update = "zypper -R $rootimg_dir --non-interactive --no-gpg-checks update "; + } $rc = system("$yumcmd_update"); # ignore any return code @@ -866,8 +881,11 @@ EOS1 # This script can be found in /lib/mkinitrd echo "Creating device nodes with udev" /sbin/udevd --daemon -/sbin/udevadm trigger -/sbin/udevadm settle --timeout=10 +if [ -f "/sbin/udevadm" ] +then + /sbin/udevadm trigger + /sbin/udevadm settle --timeout=10 +fi EOMS foreach (@ndrivers) { @@ -921,6 +939,8 @@ fi export IFACE=\$IFACE +/usr/bin/touch /var/lib/dhcpcd/dhcpcd-$IFACE.info + netstart \$IFACE while ! ifconfig | grep inet; do echo -e "\${RED}Failed to acquire address, retrying \${RESET}" @@ -1204,17 +1224,28 @@ END } } if($mode eq "statelite") { - foreach ("sbin/ifconfig", "usr/bin/clear", "sbin/mount.nfs","sbin/umount.nfs","bin/hostname","usr/bin/egrep","bin/ln","bin/ls","usr/bin/dirname","usr/bin/expr","usr/bin/chroot","usr/bin/grep","bin/cpio","bin/sleep","bin/mount","bin/umount","sbin/dhcpcd","bin/bash","sbin/insmod","bin/mkdir","bin/mknod","sbin/ip","bin/cat","usr/bin/awk","usr/bin/wget","bin/cp","usr/bin/cpio","usr/bin/zcat","usr/bin/gzip","lib/mkinitrd/bin/run-init","usr/bin/uniq","usr/bin/sed","usr/bin/wc", "bin/sed","sbin/udevd", "sbin/udevadm", "usr/bin/readlink") { + foreach ("sbin/ifconfig", "usr/bin/clear","usr/bin/touch","bin/hostname","usr/bin/egrep","bin/ln","bin/ls","usr/bin/dirname","usr/bin/expr","usr/bin/chroot","usr/bin/grep","bin/cpio","bin/sleep","bin/mount","bin/umount","sbin/dhcpcd","bin/bash","sbin/insmod","bin/mkdir","bin/mknod","sbin/ip","bin/cat","usr/bin/awk","usr/bin/wget","bin/cp","usr/bin/cpio","usr/bin/zcat","usr/bin/gzip","lib/mkinitrd/bin/run-init","usr/bin/uniq","usr/bin/sed","usr/bin/wc", "bin/sed","sbin/udevd", "usr/bin/readlink") { getlibs($_); push @filestoadd,$_; } + if($osver_host == 11) { + foreach ("sbin/mount.nfs", "sbin/umount.nfs", "sbin/udevadm") { + getlibs($_); + push @filestoadd,$_; + } + } }else { - foreach ("sbin/ifconfig","usr/bin/clear", "usr/bin/grep","bin/cpio","bin/sleep","bin/mount","sbin/dhcpcd","bin/bash","sbin/insmod","bin/mkdir","bin/mknod","sbin/ip","bin/cat","usr/bin/awk","usr/bin/wget","bin/cp","usr/bin/cpio","usr/bin/zcat","usr/bin/gzip","lib/mkinitrd/bin/run-init","usr/bin/uniq","usr/bin/sed","sbin/udevd", "sbin/udevadm", "usr/bin/readlink") { + foreach ("sbin/ifconfig","usr/bin/clear","usr/bin/touch","usr/bin/grep","bin/cpio","bin/sleep","bin/mount","sbin/dhcpcd","bin/bash","sbin/insmod","bin/mkdir","bin/mknod","sbin/ip","bin/cat","usr/bin/awk","usr/bin/wget","bin/cp","usr/bin/cpio","usr/bin/zcat","usr/bin/gzip","lib/mkinitrd/bin/run-init","usr/bin/uniq","usr/bin/sed","sbin/udevd", "usr/bin/readlink") { getlibs($_); push @filestoadd,$_; } + if($osver_host == 11) { + getlibs("sbin/udevadm"); + push @filestoadd,"sbin/udevadm"; + } } + if ($arch =~ /x86_64/) { push @filestoadd,"lib64/libnss_dns.so.2"; } @@ -1261,7 +1292,9 @@ END system("mkdir -p /tmp/xcatinitrd.$$/lib/firmware"); system("cp -r $rootimg_dir/etc/udev/* /tmp/xcatinitrd.$$/etc/udev"); system("cp -r $rootimg_dir/bin/uname /tmp/xcatinitrd.$$/bin/"); - system("cp -r $rootimg_dir/lib/firmware/* /tmp/xcatinitrd.$$/lib/firmware"); + if ( -d "$rootimg_dir/lib/firmware/" ) { + system("cp -r $rootimg_dir/lib/firmware/* /tmp/xcatinitrd.$$/lib/firmware"); + } system("cp -r $rootimg_dir/usr/bin/killall /tmp/xcatinitrd.$$/usr/bin"); # Copy rules for network adapter @@ -1270,8 +1303,13 @@ END if ($name =~ m/(\d+\.\d+\.\d+)/g) { $nic = $&; } - system("cp -r /etc/udev/rules.d/*$nic.rules /tmp/xcatinitrd.$$/etc/udev/rules.d"); - system("cp -r /etc/udev/rules.d/*persistent-net.rules /tmp/xcatinitrd.$$/etc/udev/rules.d"); + + if ( -f "/etc/udev/rules.d/*$nic.rules" ) { + system("cp -r /etc/udev/rules.d/*$nic.rules /tmp/xcatinitrd.$$/etc/udev/rules.d"); + } + if ( -f "/etc/udev/rules.d/*persistent-net.rules" ) { + system("cp -r /etc/udev/rules.d/*persistent-net.rules /tmp/xcatinitrd.$$/etc/udev/rules.d"); + } system("mkdir -p /tmp/xcatinitrd.$$/lib/udev"); system("cp -r $rootimg_dir/lib/udev/* /tmp/xcatinitrd.$$/lib/udev"); @@ -1428,13 +1466,13 @@ sub generic_post { # This function is meant to leave the image in a state approx copy("$installroot/postscripts/xcatpostinit", "$rootimg_dir/etc/init.d/xcatpostinit"); chmod(0755, "$rootimg_dir/etc/init.d/xcatpostinit"); system("chroot $rootimg_dir insserv gettyset xcatpostinit"); - - my $rc = system("grep sshd $rootimg_dir/etc/init.d/.depend.start"); + + my $rc = system("grep sshd $rootimg_dir/etc/init.d/.depend.start | grep TARGETS"); if ($rc) { 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 $rootimg_dir/etc/init.d/.depend.start"); + my $rc = system("grep gettyset $rootimg_dir/etc/init.d/.depend.start | grep TARGETS"); if ($rc) { 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");