+12 Apr 2004 Aron Griffis <agriffis@gentoo.org>
+ * Add ability to remove keywords with ^, for example:
+ ekeyword ^alpha blah.ebuild
+ * Add support for -*, for example: ekeyword -* would add it;
+ ekeyword ^* would remove it.
+ * Add a man-page for ekeyword
+
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
include ../../makedefs.mak
-all:
- echo "ALBACETE (AL-ba-seet n.) A single surprisingly long hair growing in the middle of nowhere."
+%.1 : %.pod
+ pod2man $< > $@
-dist:
+.PHONY: all
+all: ekeyword.1
+
+dist: ekeyword.1
mkdir -p ../../$(distdir)/src/ekeyword
cp {Makefile,AUTHORS,README,TODO,ChangeLog,ekeyword,ekeyword.1} ../../$(distdir)/src/ekeyword/
-install:
+install: all
install -m 0755 ekeyword $(bindir)/
install -d $(docdir)/ekeyword
install -m 0644 {AUTHORS,README,TODO,ChangeLog} $(docdir)/ekeyword/
# > KEYWORDS="x86 ppc sparc ~alpha"
-my ($kw_re) = '^[-~]?\w+$';
+my ($kw_re) = '^(?:([-~^]?)(\w+)|([-^]\*))$';
+my (@kw);
# make sure the cmdline consists of keywords and ebuilds
unless (@ARGV > 1 && $ARGV[0] =~ /$kw_re/o) {
next;
}
+ 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;
while (<I>) {
/^KEYWORDS/ or print, next;
+
+ # extract the quoted section from KEYWORDS
+ (my $quoted = $_) =~ s/^.*["'](.*?)["'].*/$1/s;
+
+ # replace -* with -star for our convenience below
+ $quoted =~ s/-\*/-star/;
+
for my $k (@kw) {
- (my $arch = $k) =~ s/^[-~]//;
- 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/;
+ 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 every keyword in the list
+ $quoted =~ s/(^|\s)[-~]?(?=\w)/$1$leader/g;
+ } else {
+ # modify or add keyword
+ unless ($quoted =~ s/[-~]?\Q$arch\E\b/$leader$arch/) {
+ # modification failed, need to add
+ if ($arch eq 'star') {
+ $quoted = "$leader$arch $quoted";
+ } else {
+ $quoted .= " $leader$arch";
+ }
+ }
+ }
}
}
+
+ # replace -star with -*
+ $quoted =~ s/-star\b/-*/;
+
+ # fixup spacing
+ $quoted =~ s/^\s*(.*?)\s*$/$1/; # leading/trailing
+ $quoted =~ s/\s+/ /g; # inner
+
+ # re-insert quoted to KEYWORDS
+ s/(["']).*?["']/$1$quoted$1/;
+
print $_, <I> or die "Can't write $f.new: $!\n";
}
close I;
close O;
+ select STDOUT;
- system "diff $f $f.new"; # don't die because the files might be the same
+ system "diff $f $f.new | grep -v '^[0-1]'";
rename "$f.new", "$f" or die "Can't rename: $!\n";
}
+
+# vim:ts=8 sw=4
+++ /dev/null
-.TH ekeyword "1" "Nov 2003" "gentoolkit"
-.SH NAME
-ekeyword \- Gentoo: ebuild Keyword Changer
-.SH SYNOPSIS
-.B ekeyword
-.SH BUGS
-This tool does not yet have a man page. Feel free to submit a bug about it to
-http://bugs.gentoo.org
-.SH AUTHORS
-This informative man page was written by Karl Trygve Kalleberg
-<karltk@gentoo.org>.
-
--- /dev/null
+=head1 NAME
+
+ekeyword - Gentoo: modify package KEYWORDS
+
+=head1 SYNOPSIS
+
+ekeyword { arch|~arch|-arch|^arch } ebuild...
+
+=head1 DESCRIPTION
+
+This tool provides a simple way to add or update KEYWORDS in a set of
+ebuilds. Each command-line argument is processed in order, so that
+keywords are added to the current list as they appear, and ebuilds are
+processed as they appear.
+
+Instead of specifying a specific arch, it's possible to use the word
+"all". This causes the change to apply to all keywords presently
+specified in the ebuild.
+
+The ^ leader instructs ekeyword to remove the specified arch.
+
+=head1 OPTIONS
+
+Presently ekeyword is simple enough that it supplies no options.
+Probably I'll add B<--help> and B<--version> in the future, but for
+now it's enough to track the gentoolkit version.
+
+=head1 EXAMPLES
+
+To mark a single arch stable:
+
+ $ ekeyword alpha metalog-0.7-r1.ebuild
+ metalog-0.7-r1.ebuild
+ < KEYWORDS="~x86 ~ppc ~sparc ~alpha ~mips ~hppa ~amd64 ~ia64"
+ ---
+ > KEYWORDS="~x86 ~ppc ~sparc alpha ~mips ~hppa ~amd64 ~ia64"
+
+When bumping a package, to mark all arches for testing:
+
+ $ ekeyword ~all metalog-0.7-r2.ebuild
+ metalog-0.7-r2.ebuild
+ < KEYWORDS="x86 ppc sparc alpha mips hppa amd64 ia64"
+ ---
+ > KEYWORDS="~x86 ~ppc ~sparc ~alpha ~mips ~hppa ~amd64 ~ia64"
+
+To signify that a package is broken for all arches except one:
+
+ $ ekeyword ^all -* ~x86 metalog-0.7-r3.ebuild
+ metalog-0.7-r3.ebuild
+ < KEYWORDS="~x86 ~ppc ~sparc ~alpha ~mips ~hppa ~amd64 ~ia64"
+ ---
+ > KEYWORDS="-* ~x86"
+
+To do lots of things at once:
+
+ $ ekeyword alpha metalog-0.7-r1.ebuild \
+ ~all metalog-0.7-r2.ebuild ^all -* ~x86 metalog-0.7-r3.ebuild
+ metalog-0.7-r1.ebuild
+ < KEYWORDS="~x86 ~ppc ~sparc ~alpha ~mips ~hppa ~amd64 ~ia64"
+ ---
+ > KEYWORDS="~x86 ~ppc ~sparc alpha ~mips ~hppa ~amd64 ~ia64"
+ metalog-0.7-r2.ebuild
+ < KEYWORDS="x86 ppc sparc alpha mips hppa amd64 ia64"
+ ---
+ > KEYWORDS="~x86 ~ppc ~sparc ~alpha ~mips ~hppa ~amd64 ~ia64"
+ metalog-0.7-r3.ebuild
+ < KEYWORDS="~x86 ~ppc ~sparc ~alpha ~mips ~hppa ~amd64 ~ia64"
+ ---
+ > KEYWORDS="-* ~x86"
+
+=head1 NOTES
+
+This tool was written by Aron Griffis <agriffis@gentoo.org>. Bugs
+found should be filed against me at http://bugs.gentoo.org/