13 METADATA
=> '/usr/portage/metadata/cache'
16 open(GRAMMAR
, 'grammar.rd')
17 or die "Can't open grammar file: $!";
27 print <<'END_OF_USAGE';
31 --log <str> * Put garbage here
32 --[no-]meta * Parse metadata
35 --try-data | -d <str> * Validate a string
36 --try-file | -f <str> * Validate a file
38 (this is only for testing purpose)
42 [1] ebuild-deps --log meta.log
44 clean-up the log file ;)
46 [2] ebuild-deps --log meta.log --meta
48 parse everyting in /usr/portage/metadata/cache
50 [3] ebuild-deps --try-data '>=app-some/pkg-1.0'
52 validate trivial and not so trivial dependencies
59 my $log = '/dev/null';
65 my $result = GetOptions(
68 'try-data|d=s' => \@todo_data,
69 'try-file|f=s' => \@todo_file,
70 'help|h' => sub { usage() },
74 or die "Can't open ${log}: $! \n";
76 $Parse::RecDescent::skip = '';
78 my $parser = Parse::RecDescent->new($grammar)
79 or die "Invalid grammar specification";
83 for my $text (@todo_data) {
84 my $result = $parser->start($text);
86 print ">>> Input #$index ... ";
88 if (defined $result) {
89 print colored('OK', 'bold green'), "\n";
90 print Dumper($result);
92 print colored('FAILED', 'bold red'), "\n";
98 for my $file (@todo_file) {
100 or die "Can't open ${file}: $! \n";
109 my $result = $parser->start($text);
111 print ">>> File '$file' ... ";
113 if (defined $result) {
114 print colored('OK', 'bold green'), "\n";
115 print Dumper($result);
117 print colored('FAILED', 'bold red'), "\n";
122 if (not @todo_data and not @todo_file) {
123 print "Seems nothing to be done. Bye.\n";
129 my @paths = glob(METADATA . '/*');
130 my $count = scalar @paths;
133 my $progress = Term::ProgressBar->new({
134 count => $count, ETA => 'linear'});
136 my ($pkg_ok, $pkg_failed) = (0, 0);
138 for my $path (@paths) {
140 for my $file (glob($path . '/*')) {
141 my $category = basename($path);
142 my $package = basename($file);
144 print LOG $category, '/', $package, ' ... ';
147 or die "Can't open ${file}: $! \n";
149 my $depend = <INPUT>;
151 my $result = $parser->start($depend);
153 if (defined $result) {
157 print LOG "FAILED\n";
165 $progress->update(++$sofar);
168 if ($pkg_failed == 0) {
169 print "\n\nProcessed $pkg_ok versions. All OK. Bye.\n";