mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 03:12:30 +00:00 
			
		
		
		
	fix issue 5694, not try to install tree for xCAT-probe
This commit is contained in:
		| @@ -8,5 +8,5 @@ Standards-Version: 3.9.4 | ||||
| Package: xcat-probe | ||||
| Architecture: all | ||||
| Depends: ${perl:Depends} | ||||
| Recommends: wget, dnsutils, tftp-hpa, tcpdump, tree | ||||
| Recommends: wget, dnsutils, tftp-hpa, tcpdump | ||||
| Description: Provides a toolkit to probe possible issues in xCAT | ||||
|   | ||||
| @@ -697,6 +697,72 @@ sub convert_second_to_time { | ||||
|  | ||||
| #------------------------------------------ | ||||
|  | ||||
| =head3 | ||||
|     Description: | ||||
|         Call get_files_recursive to get all files under given dir, | ||||
|         and save to target file | ||||
|     Arguments: | ||||
|         dir: the dir want to get files | ||||
|         target_file: the file to save files list | ||||
|          | ||||
| =cut | ||||
|  | ||||
| #------------------------------------------ | ||||
| sub list_files_to_file { | ||||
|     my $src_dir        = shift; | ||||
|     $src_dir           = shift if (($src_dir) && ($src_dir =~ /probe_utils/)); | ||||
|     my $target_file    = shift; | ||||
|     my $errormsg_ref   = shift; | ||||
|  | ||||
|     my @files = (); | ||||
|     get_files_recursive("$src_dir", \@files); | ||||
|     my $all_file = join("\n", @files); | ||||
|  | ||||
|     if (!open f,"> $target_file") { | ||||
|         $$errormsg_ref = "Can not open file $target_file to save files list";  | ||||
|         return 1; | ||||
|     } | ||||
|     print f $all_file; | ||||
|     close f; | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| #------------------------------------------ | ||||
|  | ||||
| =head3 | ||||
|     Description: | ||||
|         Get all files under the given dir | ||||
|     Arguments: | ||||
|         dir: the dir want to get files | ||||
|         files_path_ref: list of all files | ||||
| =cut | ||||
|  | ||||
| #------------------------------------------ | ||||
| sub get_files_recursive { | ||||
|     my $dir            = shift; | ||||
|     my $files_path_ref = shift; | ||||
|  | ||||
|     my $fd = undef; | ||||
|     opendir($fd, $dir); | ||||
|     for (; ;) | ||||
|     { | ||||
|         my $direntry = readdir($fd); | ||||
|         last unless (defined($direntry)); | ||||
|         next if ($direntry =~ m/^\.\w*/); | ||||
|         next if ($direntry eq '..'); | ||||
|         my $target = "$dir/$direntry"; | ||||
|         if (-d $target) { | ||||
|             get_files_recursive($target, $files_path_ref); | ||||
|         } else { | ||||
|             push(@{$files_path_ref}, glob("$target\n")); | ||||
|         } | ||||
|     } | ||||
|     closedir($fd); | ||||
| } | ||||
|  | ||||
| #------------------------------------------ | ||||
|  | ||||
| =head3 | ||||
|     Description: | ||||
|         print table | ||||
|   | ||||
| @@ -579,13 +579,29 @@ sub check_directory { | ||||
|                             $flag = "w" if (!$rst); | ||||
|                             $rst = 1; | ||||
|                         } else { | ||||
|                             my $diffout = `bash -c 'diff <(tree -i --noreport $sitetable_ref->{$dir}) <(tree -i --noreport $tmpdir) | wc -l'`; | ||||
|                             if ($diffout > 4) { | ||||
|                                 push @$error_ref, "$dir '$sitetable_ref->{$dir}' is not the same with MN's, may be error"; | ||||
|                             my $dir_list_file = "/tmp/$dir" . "_list"; | ||||
|                             my $mnt_list_file = $tmpdir . "_list"; | ||||
|                             my $error;  | ||||
|                             if (probe_utils->list_files_to_file($sitetable_ref->{$dir}, $dir_list_file, \$error)) { | ||||
|                                 push @$error_ref, "$error"; | ||||
|                                 $flag = "w" if (!$rst); | ||||
|                                 $rst = 1; | ||||
|                             } elsif (probe_utils->list_files_to_file($tmpdir, $mnt_list_file, \$error)) { | ||||
|                                 push @$error_ref, "$error"; | ||||
|                                 $flag = "w" if (!$rst); | ||||
|                                 $rst = 1; | ||||
|                             } else { | ||||
|                                 `sed -i "s|^$tmpdir|$sitetable_ref->{$dir}|g" $mnt_list_file`; | ||||
|                                 my $diffout = `diff $dir_list_file $mnt_list_file`; | ||||
|                                 if ($diffout) { | ||||
|                                     push @$error_ref, "$dir '$sitetable_ref->{$dir}' is not the same with MN's, may be error"; | ||||
|                                     $flag = "w" if (!$rst); | ||||
|                                     $rst = 1; | ||||
|                                 } | ||||
|                             } | ||||
|                             `umount $tmpdir`; | ||||
|                             unlink($dir_list_file) if (-e "$dir_list_file"); | ||||
|                             unlink($mnt_list_file) if (-e "$mnt_list_file"); | ||||
|                             rmdir($tmpdir); | ||||
|                         } | ||||
|                     } | ||||
| @@ -1194,7 +1210,7 @@ sub get_attribute_value  { | ||||
|     if ($command_info =~ /$attr=(\d+)/) { | ||||
|         $cmd_value = $1 | ||||
|     } | ||||
|     print_check_result("Checking $table table attribute... $attr=$cmd_value", 0, 0, \@error); | ||||
|     probe_utils->send_msg("$output", "i", "Checking $table table attribute... $attr=$cmd_value") if($verbose); | ||||
|     return $cmd_value | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -21,7 +21,6 @@ BuildArch: noarch | ||||
| Requires: /usr/bin/nslookup | ||||
| Requires: /usr/bin/tftp | ||||
| Requires: /usr/bin/wget | ||||
| Requires: /usr/bin/tree | ||||
| # Tool detect_dhcpd requires tcpdump | ||||
| Requires: /usr/sbin/tcpdump | ||||
| %endif | ||||
|   | ||||
		Reference in New Issue
	
	Block a user