From: Kamalesh B. <kam...@li...> - 2015-06-29 08:30:02
|
This patch introduce deprecated warning on SLES 12 onwards to use supportconfig. supportconfig captures all the information collected by snap, so it safe to deprecate snap. It also rearranges check for distribution (RHEL/SLES/Ubuntu) into common function check_distro_support(). Signed-off-by: Kamalesh Babulal <kam...@li...> Cc: Vasant Hegde <heg...@li...> Cc: Nathan Fontenot <nf...@li...> --- Changes from v1: - Moved the check for ubuntu into check_distro_support(). scripts/snap | 61 +++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/scripts/snap b/scripts/snap index f7bc72a..613f504 100755 --- a/scripts/snap +++ b/scripts/snap @@ -34,18 +34,45 @@ my $outfile = "snap.tar.gz"; # in the working dir. my $cmddir = "snap_commands"; # cmd output dir. my $cmdoutdir = "$outdir/$cmddir"; # in outdir dir. my $rsxx_exists = 0; # Does an IBM Flash Adapter exist? -my $distro_file = "/etc/issue"; -my $redhat_release_file = "/etc/redhat-release"; - -if (-e $redhat_release_file) { - open(RELEASE, "< $redhat_release_file") or die "open: $!\n"; - $_ = <RELEASE>; - my $redhat_version = (split / /, $_)[6]; - if ($redhat_version >= 7.0) { - print "snap is not supported on the RHEL 7 onwards..!\n"; - print "Please use sosreport to collect log data..!! \n"; - exit 1; - } + +sub check_distro_support { + my $redhat_release_file = "/etc/redhat-release"; + my $suse_release_file = "/etc/SuSE-release"; + my $distro_file = "/etc/issue"; + + if (-e $redhat_release_file) { + open(RELEASE, "< $redhat_release_file") or die "open: $!\n"; + $_ = <RELEASE>; + my $redhat_version = (split / /, $_)[6]; + if ($redhat_version >= 7.0) { + print "snap is not supported on the RHEL 7 onwards..!\n"; + print "Please use sosreport to collect log data..!! \n"; + close(RELEASE); + exit 1; + } + close(RELEASE); + } elsif (-e $suse_release_file) { + open(RELEASE, "< $suse_release_file") or die "open: $!\n"; + while(<RELEASE>) { + if ($_ =~ /VERSION/) { + my $suse_version = (split /=/, $_)[1]; + if ($suse_version >= 12) { + print "snap is deprecated from SLES 12 onwards..!\n"; + print "Please use supportconfig to collect log data..!! \n"; + close(RELEASE); + exit 1; + } + } # if + } # while + close(RELEASE); + } else { + open(RELEASE, "< $distro_file") or die "open: $!\n"; + if (<RELEASE> =~ /Ubuntu/) { + print "snap: is not supported on the Ubuntu platform\n"; + close(RELEASE); + exit 1; + } #if + } #else } our($opt_a, $opt_d, $opt_h, $opt_o, $opt_t, $opt_v); @@ -333,6 +360,9 @@ sub snap_commands { $< == 0 or error(1, "Must be executed as root"); +#check for the distro version +check_distro_support(); + my $perldumpenv='perl -MData::Dumper -e '."'". '\$Data::Dumper::Terse=1;print Dumper(\%ENV);'."'"; @@ -341,13 +371,6 @@ eval '%ENV=('.$1.')' if `bash -c " $perldumpenv"` =~ /^\s*\{(.*)\}\s*$/mxs; -open(my $input, "<", $distro_file); - -if (<$input> =~ /Ubuntu/) { - print "snap: is not supported on the Ubuntu platform\n"; - exit 1; -} - if ($ENV{'platform'} == $ENV{'PLATFORM_UNKNOWN'} || $ENV{'platform'} == $ENV{'PLATFORM_POWERNV_HOST'}) { print "snap: is not supported on the $ENV{'platform_name'} platform\n"; exit 1; -- 2.1.2 |