Gentoo Archives: gentoo-commits

From: "Christian Ruppert (idl0r)" <idl0r@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoolkit r787 - in trunk/gentoolkit-dev: . src/ekeyword
Date: Fri, 02 Jul 2010 15:30:19
Message-Id: 20100702153014.135F62CE15@corvid.gentoo.org
1 Author: idl0r
2 Date: 2010-07-02 15:30:13 +0000 (Fri, 02 Jul 2010)
3 New Revision: 787
4
5 Modified:
6 trunk/gentoolkit-dev/ChangeLog
7 trunk/gentoolkit-dev/src/ekeyword/ekeyword
8 Log:
9 ekeyword: Add file_parse, get_portdir and get_architectures functions.
10 file_parse is a file parser which strips trailing and starting
11 whitespace, replaces multiple whitespace by one whitespace and ignores
12 comments. It returns an array.
13 get_portdir uses portageq to determine the PORTDIR value.
14 get_architectures reads $PORTDIR/profiles/arch.list and adds all
15 available architectures to the %ARCH hash which can be used for
16 validation.
17
18
19 Modified: trunk/gentoolkit-dev/ChangeLog
20 ===================================================================
21 --- trunk/gentoolkit-dev/ChangeLog 2010-07-02 15:10:52 UTC (rev 786)
22 +++ trunk/gentoolkit-dev/ChangeLog 2010-07-02 15:30:13 UTC (rev 787)
23 @@ -1,6 +1,14 @@
24 2010-07-02: Christian Ruppert <idl0r@g.o>
25 * imlate: Don't ignore package names without category.
26 * ekeyword: Show "diff -U 0" to cover all changes.
27 + Add file_parse, get_portdir and get_architectures functions.
28 + file_parse is a file parser which strips trailing and starting
29 + whitespace, replaces multiple whitespace by one whitespace and ignores
30 + comments. It returns an array.
31 + get_portdir uses portageq to determine the PORTDIR value.
32 + get_architectures reads $PORTDIR/profiles/arch.list and adds all
33 + available architectures to the %ARCH hash which can be used for
34 + validation.
35
36 2010-05-17: Christian Ruppert <idl0r@g.o>
37 * echangelog: Update copyright in other files too (except binaries and
38
39 Modified: trunk/gentoolkit-dev/src/ekeyword/ekeyword
40 ===================================================================
41 --- trunk/gentoolkit-dev/src/ekeyword/ekeyword 2010-07-02 15:10:52 UTC (rev 786)
42 +++ trunk/gentoolkit-dev/src/ekeyword/ekeyword 2010-07-02 15:30:13 UTC (rev 787)
43 @@ -13,6 +13,50 @@
44 my ($kw_re) = '^(?:([-~^]?)(\w[\w-]*)|([-^]\*))$';
45 my (@kw);
46
47 +sub file_parse {
48 + my $fname = shift;
49 + my @content = ();
50 +
51 + if ( ! -r $fname ) {
52 + printf STDERR ("Error: File '%s' doesn't exist or is not readable!\n", $fname);
53 + exit(1);
54 + }
55 +
56 + open(FILE, '<', $fname);
57 + while(defined(my $line = <FILE>)) {
58 + chomp($line);
59 + $line =~ s/^\s*//g;
60 + $line =~ s/\s*$//g;
61 + $line =~ s/\s+/ /g;
62 + next if length($line) eq 0;
63 +
64 + next if $line =~ m/^#/;
65 +
66 + push(@content, $line);
67 + }
68 + close(FILE);
69 +
70 + return @content;
71 +}
72 +
73 +sub get_portdir() {
74 + open(PORTAGEQ, '-|', 'portageq portdir');
75 + chomp(my $portdir = <PORTAGEQ>);
76 + close(PORTAGEQ);
77 +
78 + if (length($portdir) eq 0) {
79 + printf STDERR ("Error: Couldn't determine your PORTDIR...\n");
80 + exit(1);
81 + }
82 + return $portdir;
83 +}
84 +
85 +sub get_architectures() {
86 + foreach my $arch (file_parse("${PORTDIR}/profiles/arch.list")) {
87 + $ARCH{$arch} = 0;
88 + }
89 +}
90 +
91 # make sure the cmdline consists of keywords and ebuilds
92 unless (@ARGV > 0) {
93 # NOTE: ~all will ignore all -arch keywords