Add ability to modify all keywords via all, ~all, or -all, for example: ekeyword...
authoragriffis <agriffis@gentoo.org>
Fri, 9 Apr 2004 15:31:02 +0000 (15:31 -0000)
committeragriffis <agriffis@gentoo.org>
Fri, 9 Apr 2004 15:31:02 +0000 (15:31 -0000)
svn path=/; revision=101

trunk/src/ekeyword/ChangeLog
trunk/src/ekeyword/ekeyword

index b3c4cff96c25c13b4f9b6afa558d331015adfb20..3ab0d56e96250911e241301ed79e998a3edb12db 100644 (file)
@@ -1,3 +1,7 @@
+09 Apr 2004 Aron Griffis <agriffis@gentoo.org>
+       * Add ability to modify all keywords via all, ~all, or -all, for
+         example: ekeyword -all ~alpha ia64 blah.ebuild
+
 31 Mar 2004 Aron Griffis <agriffis@gentoo.org>
        * Fix bug 28426 with patch from Mr_Bones_ to keep ekeyword from confusing
          ppc and ppc64
index be9cd64c002aa4812c763b99b4b7f5df4b788e8a..4845c38d5297593dad527b907f1c61648e0a0a5d 100644 (file)
@@ -16,7 +16,7 @@ my ($kw_re) = '^[-~]?\w+$';
 
 # make sure the cmdline consists of keywords and ebuilds
 unless (@ARGV > 1 && $ARGV[0] =~ /$kw_re/o) {
-    die "syntax: ekeyword { arch | ~arch | -arch } ebuild...\n" 
+    die "syntax: ekeyword { arch | ~[arch] | -[arch] } ebuild...\n" 
 }
 for my $a (@ARGV) {
     next if $a =~ /$kw_re/o;           # keyword
@@ -38,7 +38,22 @@ for my $f (@ARGV) {
        /^KEYWORDS/ or print, next;
        for my $k (@kw) {
            (my $arch = $k) =~ s/^[-~]//;
-           s/[-~]?$arch\b/$k/ || s/(.*?['"].*?)\s*(?=['"])/$1 $k/;
+           if ($arch eq 'all') {
+               # remove "all" so that only leader is left (blank, ~ or -)
+               $k =~ s/all//;
+
+               # extract the quoted section from KEYWORDS
+               (my $quoted = $_) =~ s/^.*["'](.*?)["'].*/$1/s;
+
+               # modify every keyword in the list
+               $quoted =~ s/(^|\s)[-~]?(?=\w)/$1$k/g;
+
+               # re-insert to KEYWORDS
+               s/(["']).*?["']/$1$quoted$1/;
+           } else {
+               # modify just one keyword
+               s/[-~]?$arch\b/$k/ || s/(.*?['"].*?)\s*(?=['"])/$1 $k/;
+           }
        }
        print $_, <I> or die "Can't write $f.new: $!\n";
     }