aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfuzzyray <fuzzyray@gentoo.org>2009-05-05 16:02:10 +0000
committerfuzzyray <fuzzyray@gentoo.org>2009-05-05 16:02:10 +0000
commitab5d6784bbb1382b8a48cae001cbd2d075f58d21 (patch)
treeb123d2e675a998d8a28bd108e3dd66592922e89c
parentMerge changes from trunk to fix issues in 0.2.4 (diff)
parentAdd some useful informations when using $EDITOR. (diff)
downloadgentoolkit-ab5d6784bbb1382b8a48cae001cbd2d075f58d21.tar.gz
gentoolkit-ab5d6784bbb1382b8a48cae001cbd2d075f58d21.tar.bz2
gentoolkit-ab5d6784bbb1382b8a48cae001cbd2d075f58d21.zip
Merge changes from trunk in prep for making trunk ready for version 0.3
svn path=/branches/gentoolkit-0.2.4/; revision=588
-rw-r--r--Makefile11
-rw-r--r--src/echangelog/Makefile17
-rwxr-xr-xsrc/echangelog/echangelog166
-rw-r--r--src/echangelog/echangelog.pod136
-rwxr-xr-xsrc/echangelog/test/test.sh38
-rw-r--r--src/eclean/eclean55
-rwxr-xr-xsrc/ekeyword/ekeyword4
-rwxr-xr-xsrc/ekeyword2/ekeyword296
-rwxr-xr-xsrc/euse/euse7
-rwxr-xr-xsrc/glsa-check/glsa-check8
-rw-r--r--src/glsa-check/glsa-check.12
-rw-r--r--src/glsa-check/glsa.py10
-rwxr-xr-xsrc/revdep-rebuild/revdep-rebuild2
13 files changed, 319 insertions, 233 deletions
diff --git a/Makefile b/Makefile
index 3906c52..834b050 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,9 @@ all:
echo $(sbindir)
echo $(mandir)
+test:
+ make -C src/echangelog test
+
clean:
rm -rf release/*
@@ -39,7 +42,7 @@ dist-gentoolkit-dev:
dist-gentoolkit:
mkdir -p release/gentoolkit-$(VERSION)$(RELEASE_TAG)
rm -rf release/gentoolkit-$(VERSION)$(RELEASE_TAG)/
- for x in eclean equery eread euse gentoolkit revdep-rebuild glsa-check genpkgindex epkginfo; do \
+ for x in eclean equery eread euse gentoolkit revdep-rebuild glsa-check epkginfo; do \
( cd src/$$x ; $(MAKE) distdir=release/gentoolkit-$(VERSION)$(RELEASE_TAG) dist ) \
done
cp Makefile AUTHORS README TODO COPYING NEWS ChangeLog release/gentoolkit-$(VERSION)$(RELEASE_TAG)/
@@ -51,7 +54,7 @@ dist-gentoolkit:
( cd release ; tar zcf gentoolkit-$(VERSION)$(RELEASE_TAG).tar.gz gentoolkit-$(VERSION)$(RELEASE_TAG)/ )
install:
- echo "Err0r: Must use either install-gentoolkit or install-gentoolkit-dev"
+ echo "Error: Must use either install-gentoolkit or install-gentoolkit-dev"
exit 1
install-gentoolkit:
@@ -65,7 +68,7 @@ install-gentoolkit:
install -m 0644 AUTHORS ChangeLog COPYING NEWS README TODO $(docdir)/
install -m 0644 src/99gentoolkit-env $(sysconfdir)/env.d/
- for x in eclean equery eread euse gentoolkit revdep-rebuild glsa-check genpkgindex epkginfo; do \
+ for x in eclean equery eread euse gentoolkit revdep-rebuild glsa-check epkginfo; do \
( cd src/$$x ; $(MAKE) DESTDIR=$(DESTDIR) install ) \
done
@@ -80,6 +83,6 @@ install-gentoolkit-dev:
install -m 0644 AUTHORS ChangeLog COPYING NEWS README README.Developer TODO $(docdir)/
- for x in ekeyword echangelog ego ebump gensync eviewcvs ; do \
+ for x in ekeyword echangelog ego ebump eviewcvs ; do \
( cd src/$$x ; $(MAKE) DESTDIR=$(DESTDIR) install ) \
done
diff --git a/src/echangelog/Makefile b/src/echangelog/Makefile
index 61c5e57..4825683 100644
--- a/src/echangelog/Makefile
+++ b/src/echangelog/Makefile
@@ -6,15 +6,18 @@
include ../../makedefs.mak
-%.1 : %.pod
- pod2man $< > $@
+.PHONY: all test
-.PHONY: all
-all: echangelog.1
+all:
-dist: echangelog.1
- mkdir -p ../../$(distdir)/src/echangelog/
- cp Makefile AUTHORS README TODO ChangeLog echangelog echangelog.pod echangelog.1 ../../$(distdir)/src/echangelog/
+test:
+ cd test; sh test.sh
+
+dist:
+ mkdir -p ../../$(distdir)/src/echangelog/test/templates
+ cp Makefile AUTHORS README TODO ChangeLog echangelog echangelog.1 ../../$(distdir)/src/echangelog/
+ cp test/TEST.pm test/test.sh ../../$(distdir)/src/echangelog/test/
+ cp test/templates/test.patch test/templates/vcstest-0.0.1.ebuild ../../$(distdir)/src/echangelog/test/templates
install: all
install -m 0755 echangelog $(bindir)/
diff --git a/src/echangelog/echangelog b/src/echangelog/echangelog
index fea1af6..551d9b9 100755
--- a/src/echangelog/echangelog
+++ b/src/echangelog/echangelog
@@ -76,6 +76,74 @@ sub version {
exit 0;
}
+sub getenv($) {
+ my $key = shift;
+
+ # Ensure our variable exist
+ if ( defined($ENV{$key}) ) {
+ # Ensure we don't get empty variables
+ if ( length($ENV{$key}) > 0 ) {
+ return $ENV{$key};
+ }
+ }
+ return undef;
+}
+
+# Bug 264146.
+# Copied from Text::Wrap.
+# The only modified thing is:
+# We trim _just_ tab/space etc. but not \n/\r.
+# \s treats even \n/\r as whitespace.
+# BUGS:
+# ' test'
+# ' test'
+# Will end up in:
+# ' test'
+# ''
+# 'test'
+# See 'my $ps = ($ip eq $xp) ? "\n\n" : "\n";'
+sub text_fill {
+ my ($ip, $xp, @raw) = @_;
+ my @para;
+ my $pp;
+
+ for $pp ( split(/\n\s+/, join("\n", @raw)) ) {
+ $pp =~ s/[\x09|\x0B|\x0C|\x20]+/ /g;
+ my $x = Text::Wrap::wrap($ip, $xp, $pp);
+ push(@para, $x);
+ }
+
+ # if paragraph_indent is the same as line_indent,
+ # separate paragraphs with blank lines
+ my $ps = ($ip eq $xp) ? "\n\n" : "\n";
+ return join ($ps, @para);
+}
+
+sub changelog_info(%) {
+ my %changed = @_;
+
+ open(INFO, '>', 'ChangeLog.new');
+
+ print(INFO "\n");
+ print(INFO "# Please enter the ChangeLog message for your changes. Lines starting\n");
+ print(INFO "# with '#' will be ignored, and an empty message aborts the ChangeLog.\n");
+ print(INFO "#\n# Changes:\n");
+
+ foreach my $key (keys(%changed)) {
+ if ($changed{$key} eq "+") {
+ printf(INFO "# new file:\t%s\n", $key);
+ }
+ elsif ($changed{$key} eq "-") {
+ printf(INFO "# deleted:\t%s\n", $key);
+ }
+ else {
+ printf(INFO "# modified:\t%s\n", $key);
+ }
+ }
+
+ close(INFO);
+}
+
GetOptions(
'help' => \$opt_help,
'strict' => \$opt_strict,
@@ -91,10 +159,16 @@ if ( -d "CVS" ) {
} elsif ( -d '.svn' ) {
$vcs = "svn";
} else {
- if ( -x '/usr/bin/git' ) {
- open(GIT, '-|', "git rev-parse --git-dir 2>/dev/null");
- $vcs = "git" if defined(<GIT>);
- close(GIT);
+ # Respect $PATH while looking for git
+ if (getenv("PATH")) {
+ foreach my $path ( split(":", getenv("PATH")) ) {
+ if ( -X "$path/git" ) {
+ open(GIT, '-|', "git rev-parse --git-dir 2>/dev/null");
+ $vcs = "git" if defined(<GIT>);
+ close(GIT);
+ last;
+ }
+ }
}
if ( ! $vcs ) {
@@ -115,7 +189,7 @@ if (-f 'ChangeLog') {
close C;
$new =~ s/\s+$//;
- open I, "< $new/skel.ChangeLog"
+ open I, "< $new/skel.ChangeLog"
or die "Can't open $new/skel.ChangeLog for input: $!\n";
{ local $/ = undef; $text = <I>; }
close I;
@@ -140,7 +214,7 @@ while (<C>) {
push @conflicts, $1;
next;
}
-
+
push @conflicts, $1;
next;
} elsif (/^\?\s+(\S+)/) {
@@ -157,18 +231,18 @@ while (<C>) {
} else {
push @unknown, $1;
}
-
+
$actions{$1} = '+';
next;
} elsif (/^([ARMD])\s+\+?\s*(\S+)/) {
my ($status, $filename) = ($1,$2);
-
+
if($vcs eq "git") {
open P, "git rev-parse --sq --show-prefix |";
my $prefix = <P>;
$prefix = substr($prefix, 0, -1);
close P;
-
+
if ($filename =~ /$prefix(\S*)/) {
$filename = $1 ;
}
@@ -176,11 +250,11 @@ while (<C>) {
next;
}
}
-
+
if( -d $filename ) {
next;
}
-
+
push @files, $filename;
($actions{$filename} = $status) =~ tr/DARM/-+-/d;
}
@@ -199,12 +273,12 @@ sub git_unknown_objects {
# Ignore empty directories - git doesn't version them and cvs removes them.
if ( (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) && ! -d _ ) {
open C, $vcs." status $_ 2>&1 1>/dev/null |";
-
+
while (<C>) {
$_ = <C>;
push @unknown, $object;
};
-
+
close C;
};
}
@@ -301,7 +375,7 @@ sub sortfunc($$) {
# compare suffix number
return +5 if defined $sna and !defined $snb;
return -5 if defined $snb and !defined $sna;
-
+
if (defined $sna) { # and defined $snb
$retval = ($sna <=> $snb);
return $retval if $retval;
@@ -313,7 +387,7 @@ sub sortfunc($$) {
#
return +6 if defined $ra and !defined $rb;
return -6 if defined $rb and !defined $ra;
-
+
if (defined $ra) { # and defined $rb
return ($ra <=> $rb);
}
@@ -324,8 +398,6 @@ sub sortfunc($$) {
return 0;
}
-@files = sort sortfunc @files;
-
# Just to ensure we don't get duplicate entries.
sub mypush(\@@) {
my $aref = shift;
@@ -362,7 +434,7 @@ if (@ebuilds) {
if ($vcs eq "git") {
my $version = $2;
-
+
while (<C>) {
last if /^deleted file mode|^index/;
if (/^new file mode/) {
@@ -412,7 +484,7 @@ if (($vcs eq "svn") and (@ebuilds)) {
mypush(@files, $1);
mypush(@new_versions, $2);
}
-
+
$_ = <C>;
}
}
@@ -439,7 +511,12 @@ unless (@files) {
}
@files = sort sortfunc @trivial;
- @files = qw/ChangeLog/ unless @files; # last resort to put something in the list
+
+ # last resort to put something in the list
+ unless (@files) {
+ @files = qw/ChangeLog/;
+ $actions{'ChangeLog'} = "";
+ }
}
# sort
@@ -450,34 +527,39 @@ unless (@files) {
if ($ARGV[0]) {
$input = "@ARGV";
} else {
- # Testing for defined() allows ECHANGELOG_EDITOR='' to cancel EDITOR
- $editor = defined($ENV{'ECHANGELOG_EDITOR'}) ? $ENV{'ECHANGELOG_EDITOR'} :
- $ENV{'EDITOR'} || undef;
-
+ $editor = getenv('ECHANGELOG_EDITOR') ? getenv('ECHANGELOG_EDITOR') : getenv('EDITOR') || undef;
+
if ($editor) {
+ # Append some informations.
+ changelog_info(%actions);
+
system("$editor ChangeLog.new");
if ($? != 0) {
# This usually happens when the editor got forcefully killed; and
# the terminal is probably messed up: so we reset things.
- system('/usr/bin/stty sane');
+ system('stty sane');
print STDERR "Editor died! Reverting to stdin method.\n";
undef $editor;
} else {
if (open I, "<ChangeLog.new") {
local $/ = undef;
$input = <I>;
- close I;
+ close(I);
+
+ # Remove comments from changelog_info().
+ local $/ = "\n";
+ $input =~ s/^#.*//mg;
+ local $/ = undef;
} else {
print STDERR "Error opening ChangeLog.new: $!\n";
print STDERR "Reverting to stdin method.\n";
undef $editor;
}
-
- unlink 'ChangeLog.new';
}
+ unlink('ChangeLog.new') if -f 'ChangeLog.new';
}
-
+
unless ($editor) {
print "Please type the log entry: use Ctrl-d to finish, Ctrl-c to abort...\n";
local $/ = undef;
@@ -488,14 +570,28 @@ die "Empty entry; aborting\n" unless $input =~ /\S/;
# If there are any long lines, then wrap the input at $columns chars
# (leaving 2 chars on left, one char on right, after adding indentation below).
-$input =~ s/^\s*(.*?)\s*\z/$1/s; # trim whitespace
-$input = Text::Wrap::fill(' ', ' ', $input);
+$input = text_fill(' ', ' ', $input);
# Prepend the user info to the input
-unless ($user = $ENV{'ECHANGELOG_USER'}) {
+# Changes related to bug 213374;
+# This sequence should be right:
+# 1. GENTOO_COMMITTER_NAME && GENTOO_COMMITTER_EMAIL
+# 2. GENTOO_AUTHOR_NAME && GENTOO_AUTHOR_EMAIL
+# 3. ECHANGELOG_USER (fallback/obsolete?)
+# 4. getpwuid()..
+if ( getenv("GENTOO_COMMITTER_NAME") && getenv("GENTOO_COMMITTER_EMAIL") ) {
+ $user = sprintf("%s <%s>", getenv("GENTOO_COMMITTER_NAME"), getenv("GENTOO_COMMITTER_EMAIL"));
+}
+elsif ( getenv("GENTOO_AUTHOR_NAME") && getenv("GENTOO_AUTHOR_EMAIL") ) {
+ $user = sprintf("%s <%s>", getenv("GENTOO_AUTHOR_NAME"), getenv("GENTOO_AUTHOR_EMAIL"));
+}
+elsif ( getenv("ECHANGELOG_USER") ) {
+ $user = getenv("ECHANGELOG_USER");
+}
+else {
my ($fullname, $username) = (getpwuid($<))[6,0];
- $fullname =~ s/,.*//; # remove GECOS, bug 80011
- $user = sprintf "%s <%s\@gentoo.org>", $fullname, $username;
+ $fullname =~ s/,.*//; # remove GECOS, bug 80011
+ $user = sprintf('%s <%s@gentoo.org>', $fullname, $username);
}
# Make sure that we didn't get "root"
@@ -516,7 +612,7 @@ $entry .= "\n$input"; # append user input
if (@new_versions) {
# Insert at the top with a new version marker
$text =~ s/^( .*? ) # grab header
- \s*\n(?=\ \ \d|\*|\z) # suck up trailing whitespace
+ \s*\n(?=\ \ \d|\*|\z) # suck up trailing whitespace
/"$1\n\n" .
join("\n", map "*$_ ($date)", reverse @new_versions) .
"\n\n$entry\n\n"/sxe
diff --git a/src/echangelog/echangelog.pod b/src/echangelog/echangelog.pod
deleted file mode 100644
index 192af8d..0000000
--- a/src/echangelog/echangelog.pod
+++ /dev/null
@@ -1,136 +0,0 @@
-=head1 NAME
-
-echangelog - Gentoo: update portage ChangeLogs
-
-=head1 SYNOPSIS
-
-echangelog [ I<text> ]
-
-=head1 DESCRIPTION
-
-This tool provides an easy way to create or update portage ChangeLogs
-in Gentoo. The tool scans the current directory, which is assumed to
-be a package directory such as /usr/portage/app-editors/vim, finds
-what files have been changed or added, and inserts the appropriate
-entry to ChangeLog. If I<text> is not provided on the command-line,
-echangelog prompts for it.
-
-All modifications should occur before running echangelog so that it
-can include the appropriate file information in the ChangeLog entry.
-For example, you should run "cvs add" on your files, otherwise
-echangelog won't know those files are part of the update.
-
-If your text would cause the ChangeLog entry to exceed 80 columns, it
-will be rewrapped to keep the ChangeLog neat. If you need special
-formatting in the ChangeLog, then you can either (1) run echangelog
-with no text on the command-line, and make sure that your text won't
-be too wide, (2) edit the ChangeLog manually. If you prefer (2), I'd
-recommend something like "echangelog blah" so that the header lines
-are computed correctly, then edit and change "blah" to your preferred
-text.
-
-In addition to updating the ChangeLog, echangelog will automatically
-update the copyright year of all out-of-date ebuilds, as well as the
-ChangeLog itself. These updates are included in the diff displayed by
-echangelog when it finishes its work.
-
-=head1 OPTIONS
-
-Presently echangelog 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 create a ChangeLog for a completely new package. The header is
-parsed from skel.ebuild.
-
- $ cvs add metalog-0.1.ebuild
- cvs server: use 'cvs commit' to add this file permanently
-
- $ echangelog 'New ebuild, thanks to Harvey McGillicuddy'
- --- ChangeLog 1969-12-31 19:00:00.000000000 -0500
- +++ ChangeLog.new 2003-02-23 14:04:06.000000000 -0500
- @@ -0,0 +1,9 @@
- +# ChangeLog for app-admin/metalog
- +# Copyright 2000-2003 Gentoo Technologies, Inc.; Distributed under the GPL v2
- +# $Header$
- +
- +*metalog-0.1 (23 Feb 2003)
- +
- + 23 Feb 2003; Aron Griffis <agriffis@gentoo.org> metalog-0.1.ebuild :
- + New ebuild, thanks to Harvey McGillicuddy
- +
-
-To bump a revision. Note you need to "cvs add" so that echangelog
-will notice the new file.
-
- $ cvs add metalog-0.1-r1.ebuild
- cvs server: use 'cvs commit' to add this file permanently
-
- $ echangelog 'Bump revision to fix bug #999'
- --- ChangeLog 2003-02-23 14:04:06.000000000 -0500
- +++ ChangeLog.new 2003-02-23 14:07:48.000000000 -0500
- @@ -2,6 +2,11 @@
- # Copyright 2000-2003 Gentoo Technologies, Inc.; Distributed under the GPL v2
- # $Header$
-
- +*metalog-0.1-r1 (23 Feb 2003)
- +
- + 23 Feb 2003; Aron Griffis <agriffis@gentoo.org> metalog-0.1-r1.ebuild :
- + Bump revision to fix bug #999
- +
- *metalog-0.1 (23 Feb 2003)
-
- 23 Feb 2003; Aron Griffis <agriffis@gentoo.org> metalog-0.1.ebuild :
-
-For a multi-line entry, omit the command-line arg.
-
- $ echangelog
- Please type the log entry, finish with ctrl-d
- Bump revision to fix bug #999. Necessary to bump the revision because
- the problem appears at run-time, not compile-time. This should also
- give users the updated default configuration file.
- --- ChangeLog 2003-02-23 14:09:12.000000000 -0500
- +++ ChangeLog.new 2003-02-23 14:12:43.000000000 -0500
- @@ -2,6 +2,13 @@
- # Copyright 2000-2003 Gentoo Technologies, Inc.; Distributed under the GPL v2
- # $Header$
-
- +*metalog-0.1-r1 (23 Feb 2003)
- +
- + 23 Feb 2003; Aron Griffis <agriffis@gentoo.org> metalog-0.1-r1.ebuild :
- + Bump revision to fix bug #999. Necessary to bump the revision because
- + the problem appears at run-time, not compile-time. This should also
- + give users the updated default configuration file.
- +
- *metalog-0.1 (23 Feb 2003)
-
- 23 Feb 2003; Aron Griffis <agriffis@gentoo.org> metalog-0.1.ebuild :
-
-=head1 ENVIRONMENT VARIABLES
-
-=over
-
-=item ECHANGELOG_USER
-
-If echangelog can't figure out your username for the entry, you should
-set ECHANGELOG_USER. For example, export ECHANGELOG_USER="Aron
-Griffis <agriffis@gentoo.org>"
-
-=back
-
-=head1 NOTES
-
-As of the most recent version of echangelog (when this man-page
-appeared), echangelog puts all new entries at the top of the file
-instead of finding the appropriate *version line within the file.
-This is because that "new" ChangeLog format was never agreed upon by
-the Gentoo developers. Unfortunately the existence of both formats
-will undoubtedly cause much confusion.
-
-This also means that the examples above are wrong, since I just copied
-them from some old email. However they're not much wrong. ;-)
-
-This tool was written by Aron Griffis <agriffis@gentoo.org>. Bugs
-found should be filed against me at http://bugs.gentoo.org/
diff --git a/src/echangelog/test/test.sh b/src/echangelog/test/test.sh
index 374522f..f2052f3 100755
--- a/src/echangelog/test/test.sh
+++ b/src/echangelog/test/test.sh
@@ -2,22 +2,17 @@
source /etc/init.d/functions.sh
+SUPPORTED_VCS=( "cvs" "svn" "git" )
VCSTEST="echangelog-test/vcstest"
_ROOT=$(pwd)
export ECHANGELOG_USER="Just a test <echangelogtest@gentoo.org>"
-#MD5_INIT="34d54bc2ab1a2154b0c7bd5cdd7f6119"
MD5_INIT="34d54bc2ab1a2154b0c7bd5cdd7f6119"
-#MD5_PATCH="d910ab6b76cfb48b68e11ae1f06612bb"
MD5_PATCH="db1ab89bb7374824d0f198078f79a83f"
-#MD5_REVBUMP="8e36650a644ba49cc13bcbe93fdb2d2d"
MD5_REVBUMP="31ddfa60d2ae4dd1fccd7e3d2bd2c06c"
-#MD5_COPYRIGHT="55a6097d8e3913a9feb0dff250649c00"
MD5_COPYRIGHT="6f39fa409ea14bb6506347c53f6dee50"
-#MD5_OBSOLETE="6c30d84f603f5f0e4b09a88d9cfdaaa8"
MD5_OBSOLETE="0aedadf159c6f3add97a3f79fb867221"
-#MD5_FINAL="cdd58fea5cfcef5820013d82ccbe0e89"
MD5_FINAL="17eb0df69f501cc6fdaffebd118b7764"
function md5() {
@@ -168,25 +163,16 @@ else
exit 1
fi
-if [[ -x $(which git) ]];
-then
- ebegin "Starting test with git"
- make_test $_ROOT "git" || set $?
- eend ${1:-0}
-fi
-
-if [[ -x $(which cvs) ]];
-then
- ebegin "Starting test with cvs"
- make_test $_ROOT "cvs" || set $?
- eend ${1:-0}
-fi
-
-if [[ -x $(which svn) ]];
-then
- ebegin "Starting test with svn"
- make_test $_ROOT "svn" || set $?
- eend ${1:-0}
-fi
+for vcs in ${SUPPORTED_VCS[*]};
+do
+ if [[ -x "$(which ${vcs} 2>/dev/null)" ]];
+ then
+ ebegin "Starting test with ${vcs}"
+ make_test $_ROOT "${vcs}" || set $?
+ eend ${1:-0}
+ else
+ ewarn "No ${vcs} executable found, skipping test..."
+ fi
+done
rm -rf "${_ROOT}/tmp"
diff --git a/src/eclean/eclean b/src/eclean/eclean
index 4fdec10..55cc2a7 100644
--- a/src/eclean/eclean
+++ b/src/eclean/eclean
@@ -1,8 +1,9 @@
-#!/usr/bin/env python
+#!/usr/bin/python
# Copyright 2003-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
+from __future__ import with_statement
###############################################################################
# Meta:
@@ -15,6 +16,7 @@ __description__ = "A cleaning tool for Gentoo distfiles and binaries."
###############################################################################
# Python imports:
+
import sys
import os, stat
import re
@@ -40,7 +42,6 @@ port_settings = portage.settings
distdir = port_settings["DISTDIR"]
pkgdir = port_settings["PKGDIR"]
-
###############################################################################
# printVersion:
def printVersion():
@@ -507,12 +508,13 @@ def exclDictMatch(excl_dict,pkg):
# findDistfiles: find all obsolete distfiles.
# XXX: what about cvs ebuilds? i should install some to see where it goes...
def findDistfiles( \
+ myoptions, \
exclude_dict={}, \
destructive=False,\
fetch_restricted=False, \
package_names=False, \
time_limit=0, \
- size_limit=0):
+ size_limit=0,):
# this regexp extracts files names from SRC_URI. It is not very precise,
# but we don't care (may return empty strings, etc.), since it is fast.
file_regexp = re.compile('([a-zA-Z0-9_,\.\-\+\~]*)[\s\)]')
@@ -553,7 +555,12 @@ def findDistfiles( \
except KeyError: continue
del pkg_list
- # create a dictionary of files which should be deleted
+ # create a dictionary of files which should be deleted
+ if not (os.path.isdir(distdir)):
+ eerror("%s does not appear to be a directory." % distdir, myoptions['nocolor'])
+ eerror("Please set DISTDIR to a sane value.", myoptions['nocolor'])
+ eerror("(Check your /etc/make.conf and environment).", myoptions['nocolor'])
+ exit(1)
for file in os.listdir(distdir):
filepath = os.path.join(distdir, file)
try: file_stat = os.stat(filepath)
@@ -594,12 +601,19 @@ def findDistfiles( \
# XXX: packages are found only by symlinks. Maybe i should also return .tbz2
# files from All/ that have no corresponding symlinks.
def findPackages( \
+ myoptions, \
exclude_dict={}, \
destructive=False, \
time_limit=0, \
package_names=False):
clean_dict = {}
- # create a full package dictionnary
+ # create a full package dictionary
+
+ if not (os.path.isdir(pkgdir)):
+ eerror("%s does not appear to be a directory." % pkgdir, myoptions['nocolor'])
+ eerror("Please set PKGDIR to a sane value.", myoptions['nocolor'])
+ eerror("(Check your /etc/make.conf and environment).", myoptions['nocolor'])
+ exit(1)
for root, dirs, files in os.walk(pkgdir):
if root[-3:] == 'All': continue
for file in files:
@@ -636,7 +650,7 @@ def findPackages( \
del clean_dict[mycpv]
continue
if portage.cpv_getkey(mycpv) in cp_all:
- # exlusion because of --package-names
+ # exlusion because of --package-names
del clean_dict[mycpv]
return clean_dict
@@ -678,7 +692,12 @@ def doCleanup(clean_dict,action,myoptions):
"Do you want to delete this " \
+ file_type+"?"):
# non-interactive mode or positive answer.
- # For each file,...
+ # For each file, try to delete the file and clean it out
+ # of Packages metadata file
+ if action == 'packages':
+ metadata = portage.getbinpkg.PackageIndex()
+ with open(os.path.join(pkgdir, 'Packages')) as metadata_file:
+ metadata.read(metadata_file)
for file in clean_dict[mykey]:
# ...get its size...
filesize = 0
@@ -688,11 +707,21 @@ def doCleanup(clean_dict,action,myoptions):
except: eerror("Could not read size of "\
+file, myoptions['nocolor'])
# ...and try to delete it.
- try: os.unlink(file)
- except: eerror("Could not delete "+file, \
- myoptions['nocolor'])
+ try:
+ os.unlink(file)
+ except:
+ eerror("Could not delete "+file, \
+ myoptions['nocolor'])
# only count size if successfully deleted
- else: clean_size += filesize
+ else:
+ clean_size += filesize
+ if action == 'packages':
+ metadata.packages[:] = [p for p in metadata.packages if 'CPV' in p and p['CPV'] != file]
+
+ if action == 'packages':
+ with open(os.path.join(pkgdir, 'Packages'), 'w') as metadata_file:
+ metadata.write(metadata_file)
+
# return total size of deleted or to delete files
return clean_size
@@ -709,13 +738,15 @@ def doAction(action,myoptions,exclude_dict={}):
einfo("Building file list for "+action+" cleaning...", \
myoptions['nocolor'])
if action == 'packages':
- clean_dict = findPackages( \
+ clean_dict = findPackages(
+ myoptions, \
exclude_dict=exclude_dict, \
destructive=myoptions['destructive'], \
package_names=myoptions['package-names'], \
time_limit=myoptions['time-limit'])
else:
clean_dict = findDistfiles( \
+ myoptions, \
exclude_dict=exclude_dict, \
destructive=myoptions['destructive'], \
fetch_restricted=myoptions['fetch-restricted'], \
diff --git a/src/ekeyword/ekeyword b/src/ekeyword/ekeyword
index 2e49ac0..002e44b 100755
--- a/src/ekeyword/ekeyword
+++ b/src/ekeyword/ekeyword
@@ -99,6 +99,10 @@ for my $f (@ARGV) {
(my $sb = $b) =~ s/^\W//;
return -1 if $sa eq '*';
return +1 if $sb eq '*';
+ $sa .= "-";
+ $sb .= "-";
+ $sa =~ s/([a-z0-9]+)-([a-z0-9]*)/$2-$1/g;
+ $sb =~ s/([a-z0-9]+)-([a-z0-9]*)/$2-$1/g;
$sa cmp $sb;
} split " ", $quoted;
diff --git a/src/ekeyword2/ekeyword2 b/src/ekeyword2/ekeyword2
new file mode 100755
index 0000000..ce8842d
--- /dev/null
+++ b/src/ekeyword2/ekeyword2
@@ -0,0 +1,96 @@
+#!/usr/bin/python
+
+# Output like:
+# setuptools-0.6_rc9.ebuild
+# < KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~sparc-fbsd -x86 ~x86-fbsd"
+# ---
+# > KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~sparc-fbsd x86 ~x86-fbsd"
+
+from __future__ import with_statement
+from sys import argv
+from fnmatch import fnmatch
+from shutil import copyfile
+from os import environ as env
+
+import re
+import string
+
+from portage import settings
+
+STABLE_KEYWORDS = frozenset(settings["PORTAGE_ARCHLIST"].split())
+BROKEN_KEYWORDS = frozenset(['-*'] + ['-'+k for k in STABLE_KEYWORDS])
+TEST_KEYWORDS = frozenset(['~'+k for k in STABLE_KEYWORDS])
+KNOWN_KEYWORDS = STABLE_KEYWORDS | TEST_KEYWORDS | BROKEN_KEYWORDS
+
+argv = set(argv[1:])
+kw_re = re.compile(r'KEYWORDS="([^"]*)"')
+ebuilds = frozenset([x for x in argv if fnmatch(x, '*.ebuild')])
+pretend = bool(argv.intersection(('-p', '--pretend',)))
+keywords = argv.difference(('-p', '--pretend',)) - ebuilds
+
+if not ebuilds:
+ print 'usage: ekeyword [-p|--pretend] [^|~|-][all] [[^|~|-]arch [[^|~|-]arch]...] ebuild [ebuild...]'
+
+for e in ebuilds:
+ # TODO: error handling for file I/O
+ kw = set(keywords)
+ if not pretend:
+ try:
+ copyfile(e, e+'.orig')
+ except IOError:
+ print "Can't copy file %s. Check permissions." % e
+ exit(1)
+ try:
+ with open(e) as c:
+ ebuild = c.read()
+ except IOError:
+ print "Can't open file %s. Aborting." % e
+ exit(1)
+
+ orig = kw_re.search(ebuild)
+ curkw = set(orig.groups()[0].split())
+
+ # ^ or ^all by itself means remove all keywords
+ # (however, other keywords established in the same args still get set.)
+ if kw.intersection(('^', '^all',)):
+ kw -= set(('^', '^all',))
+ curkw = set()
+
+ # ~ or ~all by itself means set ~keyword for all keywords
+ # since ~ expands to "$HOME" in the shell, assume the user meant ~ if we see
+ # the expansion of "$HOME". (Hope there's no user named 'all'.)
+ if kw.intersection(('~', '~all', env['HOME'],)):
+ kw -= set(('~', '~all', env['HOME'],))
+ curkw = set(['~'+k if k in STABLE_KEYWORDS else k for k in curkw])
+
+ for k in kw:
+ # Remove keywords starting with ^
+ if k[0] == '^':
+ curkw -= set((k[1:], '-'+k[1:], '~'+k[1:], ))
+ # Set ~ and - keywords to TEST and BROKEN, respectively
+ elif k[0] == '~' or k[0] == '-':
+ curkw -= set((k[1:], '-'+k[1:], '~'+k[1:], ))
+ curkw |= set((k,))
+ # Set remaining keywords to STABLE
+ else:
+ curkw -= set(('~'+k,))
+ curkw |= set((k,))
+
+ # Sort by arch, then OS (Luckily, this makes -* show up first if it's there)
+ result = 'KEYWORDS="%s"' % ' '.join(sorted(curkw,
+ key=lambda x: x.strip(string.punctuation).lower()))
+
+ if not pretend:
+ try:
+ with open(e, 'w') as rebuild:
+ rebuild.write(kw_re.sub(result, ebuild))
+ except IOError:
+ print "Can't write file %s. Aborting." % e
+ exit(1)
+
+ unknown_keywords = curkw - KNOWN_KEYWORDS
+ if unknown_keywords:
+ print "\nWarning: Unknown keywords '%s'.\n" % ', '.join(sorted(unknown_keywords))
+
+ print '<<< %s' % orig.group()
+ print '>>> %s' % result
diff --git a/src/euse/euse b/src/euse/euse
index 7400709..f9fd2fd 100755
--- a/src/euse/euse
+++ b/src/euse/euse
@@ -347,7 +347,7 @@ showinstdesc() {
local current_desc
local args
local -i foundone=0
- local IFS
+ local OIFS="$IFS"
args=("${@:-*}")
@@ -377,7 +377,7 @@ showinstdesc() {
echo "$desc"
# get list of installed packages matching this USE flag.
IFS=$'\n'
- packages=($(equery -q -C hasuse -i "${1}" | awk '{ print $(NF-1) }'))
+ packages=($(equery -q -C hasuse -i "${1}" | awk '{ print $(NF-1) }' | sort))
foundone+=${#packages[@]}
printf "\nInstalled packages matching this USE flag: "
if [ ${foundone} -gt 0 ]; then
@@ -397,7 +397,9 @@ showinstdesc() {
# exit status of equery instead of a subshell and pipe to wc -l
if [ $(equery -q -C list -i -e "${pkg}" | wc -l) -gt 0 ]; then
foundone=1
+ IFS="$OIFS"
get_flagstatus "${flag}"
+ IFS=': '
printf "%s (%s):\n%s\n\n" "${flag}" "${pkg}" "${desc#- }"
fi
done < <(grep ":${1} *-" "${descdir}/use.local.desc")
@@ -409,6 +411,7 @@ showinstdesc() {
if [ ${foundone} -lt 1 ]; then
echo "no matching entries found"
fi
+ IFS="$OIFS"
}
# show a list of all currently active flags and where they are activated
diff --git a/src/glsa-check/glsa-check b/src/glsa-check/glsa-check
index efb9e91..fe38331 100755
--- a/src/glsa-check/glsa-check
+++ b/src/glsa-check/glsa-check
@@ -17,7 +17,7 @@ try:
except ImportError:
from output import *
-from getopt import getopt,GetoptError
+from getopt import getopt, GetoptError
__program__ = "glsa-check"
__author__ = "Marius Mauch <genone@gentoo.org>"
@@ -230,7 +230,7 @@ def summarylist(myglsalist, fd1=sys.stdout, fd2=sys.stderr):
fd1.write(")")
if list_cve:
fd1.write(" "+(",".join([r[:13] for r in myglsa.references if r[:4] in ["CAN-", "CVE-"]])))
- fd1.write("\n")
+ fd1.write("\n")
return 0
if mode == "list":
@@ -328,12 +328,12 @@ if mode == "mail":
# color doesn't make any sense for mail
nocolor()
- if glsaconfig.has_key("PORTAGE_ELOG_MAILURI"):
+ if "PORTAGE_ELOG_MAILURI" in glsaconfig:
myrecipient = glsaconfig["PORTAGE_ELOG_MAILURI"].split()[0]
else:
myrecipient = "root@localhost"
- if glsaconfig.has_key("PORTAGE_ELOG_MAILFROM"):
+ if "PORTAGE_ELOG_MAILFROM" in glsaconfig:
myfrom = glsaconfig["PORTAGE_ELOG_MAILFROM"]
else:
myfrom = "glsa-check"
diff --git a/src/glsa-check/glsa-check.1 b/src/glsa-check/glsa-check.1
index 5a7a525..8e0df42 100644
--- a/src/glsa-check/glsa-check.1
+++ b/src/glsa-check/glsa-check.1
@@ -12,7 +12,7 @@ glsa\-check <\fIoption\fP> [\fIglsa\-list\fP]
This tool is used to locally monitor and manage Gentoo Linux Security Advisories.
Please read:
.br
-http://www.gentoo.org/proj/en/portage/glsa\-integration.xml
+http://www.gentoo.org/security
.br
before reporting a bug.
.LP
diff --git a/src/glsa-check/glsa.py b/src/glsa-check/glsa.py
index 4c8f280..dfd9acd 100644
--- a/src/glsa-check/glsa.py
+++ b/src/glsa-check/glsa.py
@@ -21,7 +21,7 @@ import codecs
import re
import xml.dom.minidom
-if sys.version_info[0:2] < (2,3):
+if sys.version_info[0:2] < (2, 3):
raise NotImplementedError("Python versions below 2.3 have broken XML code " \
+"and are not supported")
@@ -32,8 +32,8 @@ except ImportError:
import portage
# Note: the space for rgt and rlt is important !!
-opMapping = {"le": "<=", "lt": "<", "eq": "=", "gt": ">", "ge": ">=",
- "rge": ">=~", "rle": "<=~", "rgt": " >~", "rlt": " <~"}
+opMapping = {"le": "<=", "lt": "<", "eq": "=", "gt": ">", "ge": ">=",
+ "rge": ">=~", "rle": "<=~", "rgt": " >~", "rlt": " <~"}
NEWLINE_ESCAPE = "!;\\n" # some random string to mark newlines that should be preserved
SPACE_ESCAPE = "!;_" # some random string to mark spaces that should be preserved
@@ -510,7 +510,7 @@ class Glsa:
self.packages = {}
for p in self.affected.getElementsByTagName("package"):
name = p.getAttribute("name")
- if not self.packages.has_key(name):
+ if not name in self.packages:
self.packages[name] = []
tmp = {}
tmp["arch"] = p.getAttribute("arch")
@@ -563,7 +563,7 @@ class Glsa:
if i < len(self.bugs)-1:
outstream.write(", ")
else:
- outstream.write("\n")
+ outstream.write("\n")
if self.background:
outstream.write("\n"+wrap(self.background, width, caption="Background: "))
outstream.write("\n"+wrap(self.description, width, caption="Description: "))
diff --git a/src/revdep-rebuild/revdep-rebuild b/src/revdep-rebuild/revdep-rebuild
index 5177a52..72efba0 100755
--- a/src/revdep-rebuild/revdep-rebuild
+++ b/src/revdep-rebuild/revdep-rebuild
@@ -749,7 +749,7 @@ main_checks() {
if [[ $depend = /* && ! -e $depend ]]; then
echo "obj $target_file" >> "$BROKEN_FILE"
echo_v " broken $target_file (requires $depend)"
- elif [[ $depend = "-L/"* || $depend = "-R/"* ]]; then
+ elif [[ $depend = -[LR]/* ]]; then
if ! [[ $'\n'${la_SEARCH_DIRS}$'\n' == *$'\n'${depend#-?}$'\n'* ]]; then
la_SEARCH_DIRS+=$'\n'"${depend#-?}"
fi