From d4a397adce112baff1129b8ef91f66c20194a2b5 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Sun, 14 Aug 2016 23:17:23 -0400 Subject: [PATCH] support tar for redhat6.8 --- xCAT-server/lib/xcat/plugins/packimage.pm | 14 ++++++++++++-- xCAT-server/share/xcat/netboot/rh/dracut/xcatroot | 6 ++++++ .../share/xcat/netboot/rh/dracut_033/xcatroot | 6 ++++++ xCAT-server/share/xcat/netboot/rh/genimage | 6 ++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index 60062d26d..216e21ae1 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -488,14 +488,24 @@ sub process_request { $oldmask = umask 0077; } elsif ($method =~ /tar/) { if (!$exlistloc) { - $excludestr = "find . -xdev -print0 | tar --selinux --xattrs-include='*' --no-recursion --use-compress-program=$compress --null -T - -cf ../rootimg.$suffix"; + my $checkoption = `tar --xattrs-include 2>&1`; + if ($checkoption =~ /unrecognized/) { + $excludestr = "find . -xdev -print0 | tar --selinux --no-recursion --use-compress-program=$compress --null -T - -cf ../rootimg.$suffix"; + } else { + $excludestr = "find . -xdev -print0 | tar --selinux --xattrs-include='*' --no-recursion --use-compress-program=$compress --null -T - -cf ../rootimg.$suffix"; + } } else { chdir("$rootimg_dir"); system("$excludestr >> $xcat_packimg_tmpfile"); if ($includestr) { system("$includestr >> $xcat_packimg_tmpfile"); } - $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --xattrs-include='*' --no-recursion --use-compress-program=$compress -T - -cf ../rootimg.$suffix"; + my $checkoption = `tar --xattrs-include 2>&1`; + if ($checkoption =~ /unrecognized/) { + $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --no-recursion --use-compress-program=$compress -T - -cf ../rootimg.$suffix"; + } else { + $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --xattrs-include='*' --no-recursion --use-compress-program=$compress -T - -cf ../rootimg.$suffix"; + } } $oldmask = umask 0077; } elsif ($method =~ /squashfs/) { diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot index 367625618..b53ccb366 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot @@ -107,8 +107,14 @@ elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then echo -n "Extracting root filesystem:" if [ -r /rootimg.tar.gz ]; then tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz + if [ $? -ne 0 ]; then + tar --selinux -zxf /rootimg.tar.gz + fi elif [ -r /rootimg.tar.xz ]; then tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz + if [ $? -ne 0 ]; then + tar --selinux -Jxf /rootimg.tar.xz + fi fi $NEWROOT/etc/init.d/localdisk echo Done diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot index 58a33895e..c53a209b6 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot @@ -111,8 +111,14 @@ elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then echo -n "Extracting root filesystem:" if [ -r /rootimg.tar.gz ]; then tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz + if [ $? -ne 0 ]; then + tar --selinux -zxf /rootimg.tar.gz + fi elif [ -r /rootimg.tar.xz ]; then tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz + if [ $? -ne 0 ]; then + tar --selinux -Jxf /rootimg.tar.xz + fi fi $NEWROOT/etc/init.d/localdisk [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index bc5104c41..a56e157b6 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -1641,8 +1641,14 @@ EOMS print $inifile " echo -n \"Extracting root filesystem:\"\n"; print $inifile " if [ -r /rootimg.tar.gz ]; then\n"; print $inifile " tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz\n"; + print $inifile " if [ \$? -ne 0 ]; then\n"; + print $inifile " tar --selinux -zxf /rootimg.tar.gz\n"; + print $inifile " fi\n"; print $inifile " elif [ -r /rootimg.tar.xz ]; then\n"; print $inifile " tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz\n"; + print $inifile " if [ \$? -ne 0 ]; then\n"; + print $inifile " tar --selinux -Jxf /rootimg.tar.xz\n"; + print $inifile " fi\n"; print $inifile " fi\n"; print $inifile " echo Done\n"; print $inifile "else\n";