2010-07-02: Christian Ruppert <idl0r@gentoo.org>
* imlate: Don't ignore package names without category.
* ekeyword: Show "diff -U 0" to cover all changes.
+ Add file_parse, get_portdir and get_architectures functions.
+ file_parse is a file parser which strips trailing and starting
+ whitespace, replaces multiple whitespace by one whitespace and ignores
+ comments. It returns an array.
+ get_portdir uses portageq to determine the PORTDIR value.
+ get_architectures reads $PORTDIR/profiles/arch.list and adds all
+ available architectures to the %ARCH hash which can be used for
+ validation.
2010-05-17: Christian Ruppert <idl0r@gentoo.org>
* echangelog: Update copyright in other files too (except binaries and
my ($kw_re) = '^(?:([-~^]?)(\w[\w-]*)|([-^]\*))$';
my (@kw);
+sub file_parse {
+ my $fname = shift;
+ my @content = ();
+
+ if ( ! -r $fname ) {
+ printf STDERR ("Error: File '%s' doesn't exist or is not readable!\n", $fname);
+ exit(1);
+ }
+
+ open(FILE, '<', $fname);
+ while(defined(my $line = <FILE>)) {
+ chomp($line);
+ $line =~ s/^\s*//g;
+ $line =~ s/\s*$//g;
+ $line =~ s/\s+/ /g;
+ next if length($line) eq 0;
+
+ next if $line =~ m/^#/;
+
+ push(@content, $line);
+ }
+ close(FILE);
+
+ return @content;
+}
+
+sub get_portdir() {
+ open(PORTAGEQ, '-|', 'portageq portdir');
+ chomp(my $portdir = <PORTAGEQ>);
+ close(PORTAGEQ);
+
+ if (length($portdir) eq 0) {
+ printf STDERR ("Error: Couldn't determine your PORTDIR...\n");
+ exit(1);
+ }
+ return $portdir;
+}
+
+sub get_architectures() {
+ foreach my $arch (file_parse("${PORTDIR}/profiles/arch.list")) {
+ $ARCH{$arch} = 0;
+ }
+}
+
# make sure the cmdline consists of keywords and ebuilds
unless (@ARGV > 0) {
# NOTE: ~all will ignore all -arch keywords