aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfuzzyray <fuzzyray@gentoo.org>2009-04-30 21:08:44 +0000
committerfuzzyray <fuzzyray@gentoo.org>2009-04-30 21:08:44 +0000
commitb8b86224215139835cd001f3d77def718e0eb624 (patch)
treea122d4bccb8dbca0c975d3dce597ca7f2882bb2c /src/ekeyword
parentMerge changes from trunk to fix issues in 0.2.4 (diff)
parentFixed git detection. (diff)
downloadgentoolkit-b8b86224215139835cd001f3d77def718e0eb624.tar.gz
gentoolkit-b8b86224215139835cd001f3d77def718e0eb624.tar.bz2
gentoolkit-b8b86224215139835cd001f3d77def718e0eb624.zip
Merge changes from trunk to fix issues in 0.2.4gentoolkit-0.2.4.3
svn path=/branches/gentoolkit-0.2.4/; revision=557
Diffstat (limited to 'src/ekeyword')
-rw-r--r--src/ekeyword/ChangeLog9
-rwxr-xr-x[-rw-r--r--]src/ekeyword/ekeyword161
2 files changed, 96 insertions, 74 deletions
diff --git a/src/ekeyword/ChangeLog b/src/ekeyword/ChangeLog
index d0fa818..68d99e5 100644
--- a/src/ekeyword/ChangeLog
+++ b/src/ekeyword/ChangeLog
@@ -1,3 +1,12 @@
+24 Apr 2009 Paul Varner <fuzzyray@gentoo.org>
+ * Handle multiline KEYWORDS
+
+07 Jan 2009 Mike Frysinger <vapier@gentoo.org>
+ * Support intended KEYWORDS
+ * Convert every instance of KEYWORDS in the file
+ * Error out on invalid arguments #156827
+ * Tighten up diff output to show KEYWORDS changes
+
27 Oct 2005 Aron Griffis <agriffis@gentoo.org>
* Fix handling of comments
* Add support for bare ~ as a synonym for ~all
diff --git a/src/ekeyword/ekeyword b/src/ekeyword/ekeyword
index e75ce93..2e49ac0 100644..100755
--- a/src/ekeyword/ekeyword
+++ b/src/ekeyword/ekeyword
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
-# Copyright 2003-2004, Gentoo Foundation
+# Copyright 2003-2009, Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Written by Aron Griffis <agriffis@gentoo.org>
#
@@ -18,97 +18,110 @@ my (@kw);
# make sure the cmdline consists of keywords and ebuilds
unless (@ARGV > 0) {
- die "syntax: ekeyword { arch | ~[arch] | -[arch] } ebuild...\n"
+ die "syntax: ekeyword { arch | ~[arch] | -[arch] } ebuild...\n"
}
for my $a (@ARGV) {
- $a = '~all' if $a eq '~' or $a eq $ENV{'HOME'}; # for vapier
- next if $a =~ /$kw_re/o; # keyword
- next if $a =~ /^\S+\.ebuild$/; # ebuild
- die "I don't understand $a\n";
+ $a = '~all' if $a eq '~' or $a eq $ENV{'HOME'}; # for vapier
+ next if $a =~ /$kw_re/o; # keyword
+ next if $a =~ /^\S+\.ebuild$/; # ebuild
+ die "I don't understand $a\n";
}
+my $files = 0;
for my $f (@ARGV) {
- if ($f =~ /$kw_re/o) {
- push @kw, $f;
- next;
- }
+ if ($f =~ /$kw_re/o) {
+ push @kw, $f;
+ next;
+ }
- print "$f\n";
+ print "$f\n";
- open I, "<$f" or die "Can't read $f: $!\n";
- open O, ">$f.new" or die "Can't create $f.new: $!\n";
- select O;
+ open I, "<$f" or die "Can't read $f: $!\n";
+ open O, ">$f.new" or die "Can't create $f.new: $!\n";
+ select O;
- while (<I>) {
- /^KEYWORDS/ or print, next;
+ while (<I>) {
+ if (/^\s*KEYWORDS=/) {
- # extract the quoted section from KEYWORDS
- (my $quoted = $_) =~ s/^.*?["'](.*?)["'].*/$1/s;
+ # extract the quoted section from KEYWORDS
+ while (not /^KEYWORDS=["'].*?["']/) {
+ chomp;
+ my $next = <I>;
+ $_ = join " ", $_, $next;
+ }
+ (my $quoted = $_) =~ s/^.*?["'](.*?)["'].*/$1/s;
+
+ # replace -* with -STAR for our convenience below
+ $quoted =~ s/-\*/-STAR/;
+
+ for my $k (@kw) {
+ my ($leader, $arch, $star) = ($k =~ /$kw_re/o);
+
+ # handle -* and ^*
+ if (defined $star) {
+ $leader = substr $star,0,1;
+ $arch = 'STAR';
+ }
+
+ # remove keywords
+ if ($leader eq '^') {
+ if ($arch eq 'all') {
+ $quoted = '';
+ } else {
+ $quoted =~ s/[-~]?\Q$arch\E\b//;
+ }
+
+ # add or modify keywords
+ } else {
+ if ($arch eq 'all') {
+ # modify all non-masked keywords in the list
+ $quoted =~ s/(^|\s)~?(?=\w)/$1$leader/g;
+ } else {
+ # modify or add keyword
+ unless ($quoted =~ s/[-~]?\Q$arch\E(\s|$)/$leader$arch$1/) {
+ # modification failed, need to add
+ if ($arch eq 'STAR') {
+ $quoted = "$leader$arch $quoted";
+ } else {
+ $quoted .= " $leader$arch";
+ }
+ }
+ }
+ }
+ }
- # replace -* with -STAR for our convenience below
- $quoted =~ s/-\*/-STAR/;
+ # replace -STAR with -*
+ $quoted =~ s/-STAR\b/-*/;
- for my $k (@kw) {
- my ($leader, $arch, $star) = ($k =~ /$kw_re/o);
+ # sort keywords and fix spacing
+ $quoted = join " ", sort {
+ (my $sa = $a) =~ s/^\W//;
+ (my $sb = $b) =~ s/^\W//;
+ return -1 if $sa eq '*';
+ return +1 if $sb eq '*';
+ $sa cmp $sb;
+ } split " ", $quoted;
- # handle -* and ^*
- if (defined $star) {
- $leader = substr $star,0,1;
- $arch = 'STAR';
- }
+ # re-insert quoted to KEYWORDS
+ s/(["']).*?["']/$1$quoted$1/;
- # remove keywords
- if ($leader eq '^') {
- if ($arch eq 'all') {
- $quoted = '';
+ print $_ or die "Can't write $f.new: $!\n";
} else {
- $quoted =~ s/[-~]?\Q$arch\E\b//;
+ print, next;
}
- }
-
- # add or modify keywords
- else {
- if ($arch eq 'all') {
- # modify all non-masked keywords in the list
- $quoted =~ s/(^|\s)~?(?=\w)/$1$leader/g;
- } else {
- # modify or add keyword
- unless ($quoted =~ s/[-~]?\Q$arch\E(\s|$)/$leader$arch$1/) {
- # modification failed, need to add
- if ($arch eq 'STAR') {
- $quoted = "$leader$arch $quoted";
- } else {
- $quoted .= " $leader$arch";
- }
- }
- }
- }
}
- # replace -STAR with -*
- $quoted =~ s/-STAR\b/-*/;
-
- # sort keywords and fix spacing
- $quoted = join " ", sort {
- (my $sa = $a) =~ s/^\W//;
- (my $sb = $b) =~ s/^\W//;
- return -1 if $sa eq '*';
- return +1 if $sb eq '*';
- $sa cmp $sb;
- } split " ", $quoted;
-
- # re-insert quoted to KEYWORDS
- s/(["']).*?["']/$1$quoted$1/;
+ close I;
+ close O;
+ select STDOUT;
- print $_, <I> or die "Can't write $f.new: $!\n";
- }
-
- close I;
- close O;
- select STDOUT;
+ system "diff -U 0 $f $f.new | sed -n '/KEYWORDS=/s:^: :p'";
+ rename "$f.new", "$f" or die "Can't rename: $!\n";
+ $files++;
+}
- system "diff $f $f.new | grep -v '^[0-1]'";
- rename "$f.new", "$f" or die "Can't rename: $!\n";
+if ($files == 0) {
+ die "No ebuilds processed!";
}
-# vim:ts=8 sw=4
+# vim:ts=4 sw=4