From 6acb72ee8e25dc45be6a9510c383dad9d41fc56f Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 23 Sep 2004 11:17:50 +0000 Subject: [PATCH] Add --delete option to make this suitable for running in cron after the nightly builds This commit was SVN r2819. --- contrib/nightly/illegal_symbols_report.pl | 71 +++++++++++++++-------- 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/contrib/nightly/illegal_symbols_report.pl b/contrib/nightly/illegal_symbols_report.pl index 35b87e0e0d..17bbb0d2d3 100755 --- a/contrib/nightly/illegal_symbols_report.pl +++ b/contrib/nightly/illegal_symbols_report.pl @@ -170,6 +170,31 @@ sub find_program { #-------------------------------------------------------------------------- +# Did we find anything? + +sub mail_symbols { + my ($bad, $mail) = @_; + + foreach my $file (sort keys(%{$$bad})) { + print $mail "File: $file\n"; + foreach my $location (sort keys(%{$$bad->{$file}})) { + print $mail " Source: $location\n"; + my $array = $$bad->{$file}->{$location}; + foreach my $symbol (@$array) { + if ($symbol->{line}) { + print $mail " --> Line $symbol->{line}: $symbol->{symbol}\n"; + } else { + print $mail " --> $symbol->{symbol}\n"; + } + } + + } + print $mail "\n"; + } +} + +#-------------------------------------------------------------------------- + # # main # @@ -182,6 +207,7 @@ my @compdir_arg; my @comp_arg; my $prefix_arg; my $email_arg; +my $delete_arg; # parse the command line &Getopt::Long::Configure("bundling", "require_order"); @@ -191,6 +217,7 @@ my $ok = Getopt::Long::GetOptions("libdir|l=s" => \@libdir_arg, "comp=s" => \@comp_arg, "prefix|p=s" => \$prefix_arg, "email|e=s" => \$email_arg, + "delete" => \$delete_arg, ); # Check args @@ -247,29 +274,6 @@ foreach my $dir (@comp_arg) { my $bad_compsymbols = check_comps(@comps); -# Did we find anything? - -sub mail_symbols { - my ($bad, $mail) = @_; - - foreach my $file (sort keys(%{$$bad})) { - print $mail "File: $file\n"; - foreach my $location (sort keys(%{$$bad->{$file}})) { - print $mail " Source: $location\n"; - my $array = $$bad->{$file}->{$location}; - foreach my $symbol (@$array) { - if ($symbol->{line}) { - print $mail " --> Line $symbol->{line}: $symbol->{symbol}\n"; - } else { - print $mail " --> $symbol->{symbol}\n"; - } - } - - } - print $mail "\n"; - } -} - if ($$bad_compsymbols || $$bad_libsymbols) { open MAIL, "|$mail -s \"$subject\" \"$email_arg\"" || @@ -286,3 +290,24 @@ if ($$bad_compsymbols || $$bad_libsymbols) { print MAIL "\nYour friendly server,\nCyrador\n"; close MAIL; } + +# If --delete was given, remove all the dirs and files listed on the +# command line -- ignore any errors in case subdirectories were given. + +if ($delete_arg) { + foreach my $file (@lib_arg) { + system("rm -rf $file >/dev/null 2>/dev/null"); + } + foreach my $file (@comp_arg) { + system("rm -rf $file >/dev/null 2>/dev/null"); + } + foreach my $file (@libdir_arg) { + system("rm -rf $file >/dev/null 2>/dev/null"); + } + foreach my $file (@compdir_arg) { + system("rm -rf $file >/dev/null 2>/dev/null"); + } + if ($prefix_arg) { + system("rm -rf $prefix_arg >/dev/null 2>/dev/null"); + } +}