From 38488004c207508834543e02e991e6129669bc8c Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 30 Aug 2012 07:20:32 -0500 Subject: changes for REQUIRES in SBos for 14, and many cleanups, fixes, enhancements --- t/prep.pl | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 t/prep.pl (limited to 't/prep.pl') diff --git a/t/prep.pl b/t/prep.pl new file mode 100755 index 0000000..e2fe9bf --- /dev/null +++ b/t/prep.pl @@ -0,0 +1,46 @@ +#!/usr/bin/perl + +use strict; +use warnings FATAL => 'all'; +use File::Copy; +use Tie::File; + +chomp (my $pwd = `pwd`); +mkdir "$pwd/SBO" unless -d "$pwd/SBO"; +copy ('/home/d4wnr4z0r/projects/sbotools/SBO-Lib/lib/SBO/Lib.pm', "$pwd/SBO"); +my @subs; +open my $file_h, '<', "$pwd/SBO/Lib.pm"; +my $regex = qr/^sub\s+([^\s]+)\s+/; +while (my $line = <$file_h>) { + if (my $sub = ($line =~ $regex)[0]) { + push @subs, $sub; + } +} + +seek $file_h, 0, 0; +my @not_exported; +FIRST: for my $sub (@subs) { + my $found = 'FALSE'; + my $has = 'FALSE'; + SECOND: while (my $line = <$file_h>) { + if ($found eq 'FALSE') { + $found = 'TRUE', next SECOND if $line =~ /\@EXPORT/; + } else { + last SECOND if $line =~ /^\);$/; + $has = 'TRUE', last SECOND if $line =~ /$sub/; + } + } + push @not_exported, $sub unless $has eq 'TRUE'; + seek $file_h, 0, 0; +} + +close $file_h; +tie my @file, 'Tie::File', "$pwd/SBO/Lib.pm"; +FIRST: for my $line (@file) { + if ($line =~ /\@EXPORT/) { + $line = "our \@EXPORT = qw(". join ' ', @not_exported; + } + $line = "#$line" if $line =~ /root privileges/; +} + + -- cgit v1.2.3 From f8c22cc9dd4828416555f0081c154a6adff9e80b Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 30 Aug 2012 14:13:18 -0500 Subject: um? --- t/prep.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/prep.pl') diff --git a/t/prep.pl b/t/prep.pl index e2fe9bf..08efc61 100755 --- a/t/prep.pl +++ b/t/prep.pl @@ -7,7 +7,7 @@ use Tie::File; chomp (my $pwd = `pwd`); mkdir "$pwd/SBO" unless -d "$pwd/SBO"; -copy ('/home/d4wnr4z0r/projects/sbotools/SBO-Lib/lib/SBO/Lib.pm', "$pwd/SBO"); +copy ('/home/d4wnr4z0r/projects/slack14/sbotools/SBO-Lib/lib/SBO/Lib.pm', "$pwd/SBO"); my @subs; open my $file_h, '<', "$pwd/SBO/Lib.pm"; my $regex = qr/^sub\s+([^\s]+)\s+/; -- cgit v1.2.3 From d55dbdf17977ed9b1dfd91c98a4a569960b851cd Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Fri, 31 Aug 2012 15:53:21 -0500 Subject: epic changes and fixes and much further testing --- t/prep.pl | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 't/prep.pl') diff --git a/t/prep.pl b/t/prep.pl index 08efc61..c5591dc 100755 --- a/t/prep.pl +++ b/t/prep.pl @@ -1,5 +1,6 @@ #!/usr/bin/perl +use 5.16.0; use strict; use warnings FATAL => 'all'; use File::Copy; @@ -8,6 +9,49 @@ use Tie::File; chomp (my $pwd = `pwd`); mkdir "$pwd/SBO" unless -d "$pwd/SBO"; copy ('/home/d4wnr4z0r/projects/slack14/sbotools/SBO-Lib/lib/SBO/Lib.pm', "$pwd/SBO"); + +open my $write, '>>', "$pwd/SBO/Lib.pm"; + +print {$write} "my \$interactive = 1;\n"; +print {$write} "my \%locations;"; +print {$write} "my \$compat32 = 1;\n"; +print {$write} "my \$no_readme = 1;\n"; +print {$write} "my \$jobs = 1;\n"; +print {$write} "my \$distclean = 1;\n"; +print {$write} "my \$noclean = 1;\n"; +print {$write} "my \$no_install = 1;\n"; + +sub get_subs ($) { + my $read = shift; + my $begin_regex = qr/^sub\s+[a-z0-9_]+/; + my $usage_regex = qr/^sub\s+show_usage/; + my $end_regex = qr/^}$/; + my $begin = 0; + my $end = 0; + while (my $line = <$read>) { + if (! $begin) { + if ($line =~ $begin_regex) { + if ($line !~ $usage_regex) { + $end = 0, $begin++, print {$write} $line; + } + } + } elsif (! $end) { + if ($line =~ $end_regex) { + $begin = 0, $end++, print {$write} $line; + } else { + print {$write} $line; + } + } + } +} + +for my $file (qw(sbocheck sboclean sboconfig sbofind sboupgrade)) { + open my $read, '<', "../$file"; + get_subs $read; + close $read; +} +close $write; + my @subs; open my $file_h, '<', "$pwd/SBO/Lib.pm"; my $regex = qr/^sub\s+([^\s]+)\s+/; -- cgit v1.2.3 From 8b08c603ae79c145bc3b344f6dca4f0a95ed6201 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sat, 1 Sep 2012 04:52:02 -0500 Subject: more and more cleanups and fixes --- t/prep.pl | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 't/prep.pl') diff --git a/t/prep.pl b/t/prep.pl index c5591dc..6b38a33 100755 --- a/t/prep.pl +++ b/t/prep.pl @@ -12,14 +12,17 @@ copy ('/home/d4wnr4z0r/projects/slack14/sbotools/SBO-Lib/lib/SBO/Lib.pm', "$pwd/ open my $write, '>>', "$pwd/SBO/Lib.pm"; -print {$write} "my \$interactive = 1;\n"; -print {$write} "my \%locations;"; -print {$write} "my \$compat32 = 1;\n"; -print {$write} "my \$no_readme = 1;\n"; -print {$write} "my \$jobs = 1;\n"; -print {$write} "my \$distclean = 1;\n"; -print {$write} "my \$noclean = 1;\n"; -print {$write} "my \$no_install = 1;\n"; +sub pr ($) { + my $thing = shift; + print {$write} "our \$$thing = 1;\n"; +} + +for my $thing (qw(interactive compat32 no_readme jobs distclean noclean no_install no_reqs)) { + pr $thing; +} + +print {$write} "my \%locations;\n"; +print {$write} "my \%options = (nothing => 'to see here');\n"; sub get_subs ($) { my $read = shift; -- cgit v1.2.3 From a4cf58095097080537001f9ff25518584b7286ca Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Fri, 21 Sep 2012 07:02:25 -0500 Subject: prep.pl and test.t updated to test correctly --- t/prep.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 't/prep.pl') diff --git a/t/prep.pl b/t/prep.pl index 6b38a33..ebffd40 100755 --- a/t/prep.pl +++ b/t/prep.pl @@ -17,7 +17,8 @@ sub pr ($) { print {$write} "our \$$thing = 1;\n"; } -for my $thing (qw(interactive compat32 no_readme jobs distclean noclean no_install no_reqs)) { +for my $thing (qw(interactive compat32 no_readme jobs distclean noclean + no_install no_reqs force force_reqs clean non_int)) { pr $thing; } -- cgit v1.2.3