diff options
Diffstat (limited to 'src/ekeyword')
-rw-r--r-- | src/ekeyword/AUTHORS | 1 | ||||
-rw-r--r-- | src/ekeyword/ChangeLog | 37 | ||||
-rw-r--r-- | src/ekeyword/Makefile | 24 | ||||
-rw-r--r-- | src/ekeyword/README | 20 | ||||
-rw-r--r-- | src/ekeyword/TODO | 0 | ||||
-rw-r--r-- | src/ekeyword/ekeyword | 114 | ||||
-rw-r--r-- | src/ekeyword/ekeyword.pod | 74 |
7 files changed, 270 insertions, 0 deletions
diff --git a/src/ekeyword/AUTHORS b/src/ekeyword/AUTHORS new file mode 100644 index 0000000..36d5bfd --- /dev/null +++ b/src/ekeyword/AUTHORS @@ -0,0 +1 @@ +Aron Griffis <agriffis@gentoo.org> diff --git a/src/ekeyword/ChangeLog b/src/ekeyword/ChangeLog new file mode 100644 index 0000000..d0fa818 --- /dev/null +++ b/src/ekeyword/ChangeLog @@ -0,0 +1,37 @@ +27 Oct 2005 Aron Griffis <agriffis@gentoo.org> + * Fix handling of comments + * Add support for bare ~ as a synonym for ~all + +23 Mar 2005 Aron Griffis <agriffis@gentoo.org> + * Only modify non-masked keywords with "all" + +17 Mar 2005 Aron Griffis <agriffis@gentoo.org> + * Sort keywords alphabetically + +09 Nov 2004 Aron Griffis <agriffis@gentoo.org> + * Fix mismatching of ppc vs. ppc-macos #69683 + +15 Sep 2004 Aron Griffis <agriffis@gentoo.org> + * Update for GLEP 22 keywords + * Change copyright line for Gentoo Foundation + +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 + +31 Mar 2004 Aron Griffis <agriffis@gentoo.org> + * Fix bug 28426 with patch from Mr_Bones_ to keep ekeyword from confusing + ppc and ppc64 + +2004-01-12 Aron Griffis <agriffis@gentoo.org> + * Allow multiple keywords + +2004-01-07 Karl Trygve Kalleberg <karltk@gentoo.org> + * Added Makefile diff --git a/src/ekeyword/Makefile b/src/ekeyword/Makefile new file mode 100644 index 0000000..c3aed80 --- /dev/null +++ b/src/ekeyword/Makefile @@ -0,0 +1,24 @@ +# Copyright 2004 Karl Trygve Kalleberg <karltk@gentoo.org> +# Copyright 2004 Gentoo Technologies, Inc. +# Distributed under the terms of the GNU General Public License v2 +# +# $Header$ + +include ../../makedefs.mak + +%.1 : %.pod + pod2man $< > $@ + +.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: all + install -m 0755 ekeyword $(bindir)/ + install -d $(docdir)/ekeyword + install -m 0644 AUTHORS README TODO ChangeLog $(docdir)/ekeyword/ + install -m 0644 ekeyword.1 $(mandir)/ + diff --git a/src/ekeyword/README b/src/ekeyword/README new file mode 100644 index 0000000..ec7ff5e --- /dev/null +++ b/src/ekeyword/README @@ -0,0 +1,20 @@ +Package : ekeyword +Version : 0.1.0 +Author : See AUTHORS + +MOTIVATION + +Update the KEYWORDS in an ebuild. + +MECHANICS + +N/A + +IMPROVEMENTS + +- Should rewrite to Python, and use Portage directly to select candidate + ebuilds. +- Should add entry to ChangeLog. + +For improvements, send a mail to agriffis@gentoo.org or make out a bug at +bugs.gentoo.org. diff --git a/src/ekeyword/TODO b/src/ekeyword/TODO new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/ekeyword/TODO diff --git a/src/ekeyword/ekeyword b/src/ekeyword/ekeyword new file mode 100644 index 0000000..e75ce93 --- /dev/null +++ b/src/ekeyword/ekeyword @@ -0,0 +1,114 @@ +#!/usr/bin/perl -w +# +# Copyright 2003-2004, Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# Written by Aron Griffis <agriffis@gentoo.org> +# +# ekeyword: Update the KEYWORDS in an ebuild. For example: +# +# $ ekeyword ~alpha oaf-0.6.8-r1.ebuild +# 12c12 +# < KEYWORDS="x86 ppc sparc" +# --- +# > KEYWORDS="x86 ppc sparc ~alpha" + + +my ($kw_re) = '^(?:([-~^]?)(\w[\w-]*)|([-^]\*))$'; +my (@kw); + +# make sure the cmdline consists of keywords and ebuilds +unless (@ARGV > 0) { + 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"; +} + +for my $f (@ARGV) { + if ($f =~ /$kw_re/o) { + push @kw, $f; + 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 ($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 -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/; + + print $_, <I> or die "Can't write $f.new: $!\n"; + } + + close I; + close O; + select STDOUT; + + system "diff $f $f.new | grep -v '^[0-1]'"; + rename "$f.new", "$f" or die "Can't rename: $!\n"; +} + +# vim:ts=8 sw=4 diff --git a/src/ekeyword/ekeyword.pod b/src/ekeyword/ekeyword.pod new file mode 100644 index 0000000..1fac8ef --- /dev/null +++ b/src/ekeyword/ekeyword.pod @@ -0,0 +1,74 @@ +=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/ |