summaryrefslogtreecommitdiff
path: root/trunk/src/ekeyword
diff options
context:
space:
mode:
authorkarltk <karltk@gentoo.org>2003-07-26 20:50:03 +0000
committerkarltk <karltk@gentoo.org>2003-07-26 20:50:03 +0000
commit4071f33e9b356f18e8c04c9234188ec6b83ef4fa (patch)
tree86667cfd8ca348744946519bf4bfe3dc0fae8d2a /trunk/src/ekeyword
parent211ae13b7e4c3cc390cab780b9b6570a1e27788d (diff)
downloadgentoolkit-4071f33e9b356f18e8c04c9234188ec6b83ef4fa.tar.gz
Preparing for Gentoolkit relaunch; added basic gentoolkit library.
svn path=/; revision=32
Diffstat (limited to 'trunk/src/ekeyword')
-rw-r--r--trunk/src/ekeyword/AUTHORS1
-rw-r--r--trunk/src/ekeyword/README20
-rw-r--r--trunk/src/ekeyword/ekeyword38
3 files changed, 59 insertions, 0 deletions
diff --git a/trunk/src/ekeyword/AUTHORS b/trunk/src/ekeyword/AUTHORS
new file mode 100644
index 0000000..36d5bfd
--- /dev/null
+++ b/trunk/src/ekeyword/AUTHORS
@@ -0,0 +1 @@
+Aron Griffis <agriffis@gentoo.org>
diff --git a/trunk/src/ekeyword/README b/trunk/src/ekeyword/README
new file mode 100644
index 0000000..ec7ff5e
--- /dev/null
+++ b/trunk/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/trunk/src/ekeyword/ekeyword b/trunk/src/ekeyword/ekeyword
new file mode 100644
index 0000000..f5eb133
--- /dev/null
+++ b/trunk/src/ekeyword/ekeyword
@@ -0,0 +1,38 @@
+#!/usr/bin/perl -w
+#
+# Copyright 2003, Gentoo Technologies, Inc.
+# Author: 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"
+
+
+die "syntax: ekeyword { arch | ~arch | -arch } ebuild...\n" unless @ARGV > 1;
+
+my $kw = shift @ARGV;
+(my $arch = $kw) =~ s|^[-~]||;
+
+die "$kw doesn't look like a keyword to me\n" unless $arch =~ /^\w+$/;
+
+for my $f (@ARGV) {
+ 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;
+ s/[-~]?$arch/$kw/ || s/(.*?['"].*?)\s*(?=['"])/$1 $kw/;
+ print $_, <I> or die "Can't write $f.new: $!\n";
+ }
+
+ close I;
+ close O;
+
+ system "diff $f $f.new"; # don't die because the files might be the same
+ rename "$f.new", "$f" or die "Can't rename: $!\n";
+}