head	1.7;
access;
symbols
	RELEASE-1_4:1.6.0.2;
locks; strict;
comment	@# @;


1.7
date	2003.08.15.12.50.15;	author lanius;	state dead;
branches;
next	1.6;

1.6
date	2003.02.22.04.51.48;	author agriffis;	state Exp;
branches;
next	1.5;

1.5
date	2003.02.22.04.23.28;	author agriffis;	state Exp;
branches;
next	1.4;

1.4
date	2003.02.13.14.55.16;	author agriffis;	state Exp;
branches;
next	1.3;

1.3
date	2003.02.12.20.37.36;	author agriffis;	state Exp;
branches;
next	1.2;

1.2
date	2003.02.12.19.42.11;	author agriffis;	state Exp;
branches;
next	1.1;

1.1
date	2003.02.10.19.42.03;	author agriffis;	state Exp;
branches;
next	;


desc
@@


1.7
log
@moved to app-portage
@
text
@#!/usr/bin/perl -w
#
# 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";
}
@


1.6
log
@typo
@
text
@@


1.5
log
@fix a few bugs
@
text
@d17 1
a17 1
die "$kw doesn't look like a keyword to me\n" unless $kw =~ /^\w+$/;
@


1.4
log
@fix extra spacing from other keyword tools
@
text
@d17 2
d33 1
a33 1
    system "diff $f $f.new"     or die "Can't run diff: $!\n";
@


1.3
log
@add patch from rendhalver to recognize -arch keyword changes
@
text
@d24 1
a24 1
        s/[-~]?$arch/$kw/ || s/.*?['"].*?(?=['"])/$& $kw/;
@


1.2
log
@updated echangelog and ekeyword
@
text
@d12 1
a12 1
die "syntax: ekeyword { arch | ~arch } ebuild...\n" unless @@ARGV > 1;
d15 1
a15 1
(my $arch = $kw) =~ s|~||;
d24 1
a24 1
        s/~?$arch/$kw/ || s/.*?['"].*?(?=['"])/$& $kw/;
@


1.1
log
@version 0.1.18: add ekeyword and echangelog
@
text
@d19 1
a19 1
    open O, ">$f.new"   or die "Can't write $f.new: $!\n";
d25 1
a25 1
        print $_, <I>;
@

