summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorwiz <wiz@pkgsrc.org>2009-08-30 10:40:34 +0000
committerwiz <wiz@pkgsrc.org>2009-08-30 10:40:34 +0000
commit0a08f23b8674a12ea02f666cd8c6d90bd5543a70 (patch)
tree34ff578243b852830d99c78b354d715df1fcb477 /pkgtools
parent4c73c8fb015fa51bed5d98b141c3ec399d6dca38 (diff)
downloadpkgsrc-0a08f23b8674a12ea02f666cd8c6d90bd5543a70.tar.gz
Initial import of pkgsrc-todo-1.0:
This package contains two tools for maintaining pkgsrc/doc/TODO. add_todo adds lines for newly available updates for packages to the TODO file. obsolete_todo checks the contents of pkgsrc/doc/TODO against updates noted in the CHANGES-* files and removes entries for packages which were already updated to newer files.
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkgsrc-todo/DESCR8
-rw-r--r--pkgtools/pkgsrc-todo/Makefile50
-rw-r--r--pkgtools/pkgsrc-todo/PLIST5
-rw-r--r--pkgtools/pkgsrc-todo/files/add_todo.166
-rwxr-xr-xpkgtools/pkgsrc-todo/files/add_todo.pl153
-rw-r--r--pkgtools/pkgsrc-todo/files/obsolete_todo.173
-rwxr-xr-xpkgtools/pkgsrc-todo/files/obsolete_todo.pl97
7 files changed, 452 insertions, 0 deletions
diff --git a/pkgtools/pkgsrc-todo/DESCR b/pkgtools/pkgsrc-todo/DESCR
new file mode 100644
index 00000000000..9e9d7782971
--- /dev/null
+++ b/pkgtools/pkgsrc-todo/DESCR
@@ -0,0 +1,8 @@
+This package contains two tools for maintaining pkgsrc/doc/TODO.
+
+add_todo adds lines for newly available updates for packages to
+the TODO file.
+
+obsolete_todo checks the contents of pkgsrc/doc/TODO against updates
+noted in the CHANGES-* files and removes entries for packages which
+were already updated to newer files.
diff --git a/pkgtools/pkgsrc-todo/Makefile b/pkgtools/pkgsrc-todo/Makefile
new file mode 100644
index 00000000000..4b91d198485
--- /dev/null
+++ b/pkgtools/pkgsrc-todo/Makefile
@@ -0,0 +1,50 @@
+# $NetBSD: Makefile,v 1.1.1.1 2009/08/30 10:40:34 wiz Exp $
+#
+
+DISTNAME= pkgsrc-todo-1.0
+CATEGORIES= pkgtools
+MASTER_SITES= # none
+DISTFILES= # none
+
+MAINTAINER= wiz@NetBSD.org
+HOMEPAGE= http://www.NetBSD.org/docs/pkgsrc/
+COMMENT= Tools for maintaing pkgsrc/doc/TODO
+
+DEPENDS+= p5-pkgsrc-Dewey-[0-9]*:../../pkgtools/p5-pkgsrc-Dewey
+
+PKG_DESTDIR_SUPPORT= user-destdir
+
+WRKSRC= ${WRKDIR}
+NO_BUILD= yes
+USE_LANGUAGES= # none
+USE_TOOLS+= perl:build
+
+INSTALLATION_DIRS= bin ${PKGMANDIR}/man1
+
+.include "../../mk/bsd.prefs.mk"
+
+SUBST_CLASSES+= todo
+SUBST_STAGE.todo= post-configure
+SUBST_FILES.todo+= add_todo.pl
+SUBST_FILES.todo+= add_todo.1
+SUBST_FILES.todo+= obsolete_todo.pl
+SUBST_FILES.todo+= obsolete_todo.1
+SUBST_SED.todo+= -e s\|@PKGSRCDIR@\|${PKGSRCDIR}\|g
+SUBST_SED.todo+= -e s\|pkgsrc/\|${PKGSRCDIR}\|g
+SUBST_SED.todo+= -e s\|@PERL@\|${PERL5:Q}\|g
+
+do-extract:
+ cd ${FILESDIR} && ${CP} add_todo.1 add_todo.pl obsolete_todo.1 \
+ obsolete_todo.pl ${WRKSRC}
+
+do-install:
+ ${INSTALL_SCRIPT} ${WRKSRC}/add_todo.pl \
+ ${DESTDIR}${PREFIX}/bin/add_todo
+ ${INSTALL_SCRIPT} ${WRKSRC}/obsolete_todo.pl \
+ ${DESTDIR}${PREFIX}/bin/obsolete_todo
+ ${INSTALL_MAN} ${WRKSRC}/add_todo.1 \
+ ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
+ ${INSTALL_MAN} ${WRKSRC}/obsolete_todo.1 \
+ ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/pkgtools/pkgsrc-todo/PLIST b/pkgtools/pkgsrc-todo/PLIST
new file mode 100644
index 00000000000..00657c3ffa3
--- /dev/null
+++ b/pkgtools/pkgsrc-todo/PLIST
@@ -0,0 +1,5 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2009/08/30 10:40:34 wiz Exp $
+bin/add_todo
+bin/obsolete_todo
+man/man1/add_todo.1
+man/man1/obsolete_todo.1
diff --git a/pkgtools/pkgsrc-todo/files/add_todo.1 b/pkgtools/pkgsrc-todo/files/add_todo.1
new file mode 100644
index 00000000000..469ed9f720a
--- /dev/null
+++ b/pkgtools/pkgsrc-todo/files/add_todo.1
@@ -0,0 +1,66 @@
+.\" $NetBSD: add_todo.1,v 1.1.1.1 2009/08/30 10:40:34 wiz Exp $
+.\"
+.Dd August 30, 2009
+.Dt ADD_TODO 1
+.Sh NAME
+.Nm add_todo
+.Nd add entries to pkgsrc/doc/TODO
+.Sh SYNOPSIS
+.Nm add_todo
+.Op Fl f
+.Ar package
+.Sh DESCRIPTION
+.Nm
+adds an entry for
+.Ar package
+to the
+.Pa pkgsrc/doc/TODO
+file.
+The
+.Ar package
+argument needs to of the form
+.Dq PKGNAME-PKGVERSION ,
+e.g.
+.Dq pkgsrc-todo-1.0 .
+.Nm
+checks if the package exists in pkgsrc by looking for an entry for it
+in the
+.Pa CHANGES-*
+files (to catch typos).
+.Nm
+also checks if the update was already committed, i.e. if an entry for
+it or a newer version exists in any
+.Pa CHANGES-*
+files.
+This second check can be overridden by using the
+.Fl f
+flag.
+.Pp
+.Nm
+assumes that the contents of
+.Pa pkgsrc/doc
+are up-to-date.
+The
+.Pa TODO
+file needs to be committed manually afterwards.
+.Sh FILES
+.Bl -tag -width 20n
+.It Pa pkgsrc/doc/TODO
+.Nm
+adds entries to this file.
+.It Pa pkgsrc/doc/CHANGES-*
+.Nm
+checks these files before adding entries.
+.El
+.Sh AUTHORS
+.An Thomas Klausner Aq wiz@NetBSD.org
+.Sh BUGS
+.Nm
+currently can't add an entry at the end of the list.
+.Pp
+.Nm
+should check if a package was removed before adding an entry for it.
+.Pp
+.Nm
+should check if a package was downgraded; this information is
+currently disregarded.
diff --git a/pkgtools/pkgsrc-todo/files/add_todo.pl b/pkgtools/pkgsrc-todo/files/add_todo.pl
new file mode 100755
index 00000000000..2feeb89fc87
--- /dev/null
+++ b/pkgtools/pkgsrc-todo/files/add_todo.pl
@@ -0,0 +1,153 @@
+#!@PERL@
+
+# $NetBSD: add_todo.pl,v 1.1.1.1 2009/08/30 10:40:34 wiz Exp $
+
+# TODO:
+# fix adding entry after last one (currently broken)
+# check if package was removed
+# check if package was downgraded (e.g. oto)
+# allow multiple command line arguments
+
+use strict;
+use Getopt::Std;
+use pkgsrc::Dewey;
+
+use constant regex_pkgname => qr"^(.*)-(\d[^-]*)$";
+
+my ($comment, $entry, $grep_result, $newname, $newpkg, $newprinted,
+ $newversion, %opt, $verbose);
+
+my $PKGSRCDIR = "@PKGSRCDIR@";
+my $input = "$PKGSRCDIR/doc/TODO";
+my $wipinput = "$PKGSRCDIR/wip/TODO";
+my $output = "$input.new";
+my $changes = "$PKGSRCDIR/doc/CHANGES*";
+
+getopts('fp:', \%opt);
+#usage() if $opt{h};
+if ($opt{p}) {
+ $PKGSRCDIR = $opt{p};
+}
+$newpkg = shift(@ARGV);
+$newpkg =~ regex_pkgname;
+$newname = $1;
+$newversion = $2;
+
+# same code in obsolete_todo, keep in sync
+sub update_done($$) {
+ my ($file, $found_at_all, @files);
+ my ($pkg, $ver) = @_;
+
+ $found_at_all = 0;
+ @files = glob($changes);
+ # XXX: better way of handling +?
+ $pkg =~ s/\+//g;
+ # look in newest files first
+ foreach $file (reverse(@files)) {
+ open IN, $file;
+ while (<IN>) {
+ if (m/[ \/]$pkg version ([^ ]*) / or
+ (m/[ \/]$pkg to ([^ ]*) / and not m/Moved/) or
+ m/[ \/]$pkg-([0-9][^ -]*) /) {
+ $found_at_all = 1;
+ if (dewey_cmp($ver, "<=", $1)) {
+ print STDERR "$pkg already at $1:\n";
+ print STDERR "$file: $_";
+ close(IN);
+ return 1;
+ }
+ }
+ }
+ close(IN);
+ # if found in latest CHANGES file, but no newer version,
+ # assume the version to add is newer and don't check
+ # older files
+ if ($found_at_all) {
+ last;
+ }
+ }
+ return 0;
+}
+
+$newprinted = 0;
+$verbose = 1;
+
+$grep_result = qx/grep -e "[ \/]"$newname"[ -]" $changes/;
+if (not $grep_result) {
+ if (-d "$PKGSRCDIR/wip/$newname") {
+ $input = $wipinput;
+ }
+ else {
+ die "$newname not found in CHANGES* or wip\n";
+ }
+}
+
+if (update_done($newname, $newversion)) {
+ exit if not $opt{f};
+ print STDERR "Ignored old entry (forced)\n";
+}
+
+open IN, $input or die "can't open input file ``$input''";
+open OUT, ">$output" or die "can't open output file ``$output''";
+
+while (<IN>) {
+ if ($newprinted or not m/^ o /) {
+ print OUT $_;
+ next;
+ }
+
+ chomp();
+ s/^\to //;
+ if (m/([^ ]*)( .*)/) {
+ $entry = $1;
+ $comment = $2;
+ } else {
+ $entry = $_;
+ $comment = "";
+ }
+
+ $entry =~ regex_pkgname;
+ my ($entryname, $entryversion) = ($1, $2);
+
+ # different package, alphabetically before new entry
+ if ($newname gt $entryname) {
+ print OUT " o $entry$comment\n";
+ next;
+ }
+
+ # different package, alphabetically after new entry -> add entry
+ if ($newname lt $entryname) {
+ print OUT " o $newpkg\n";
+ print OUT " o $entry$comment\n";
+ $newprinted = 1;
+ next;
+ }
+
+ # $newname eq $entryname
+ if (dewey_cmp($newversion, "<=", $entryversion)) {
+ if ($opt{f}) {
+ print STDERR "Replaced $entry (forced)\n" if $verbose;
+ print OUT " o $newpkg\n";
+ } else {
+ print STDERR "Newer or same version $entry already in TODO\n" if $verbose;
+ print OUT " o $entry$comment\n";
+ }
+ }
+ else {
+ if ($comment) {
+ print STDERR "Keeping $entry because it has a comment:$comment\n";
+ print OUT " o $entry$comment\n";
+ next;
+ }
+
+ print STDERR "Replaced $entry\n" if $verbose;
+ print OUT " o $newpkg\n";
+ }
+
+ $newprinted = 1;
+}
+
+close IN;
+close OUT;
+
+rename($output, $input) or die "can't rename $output to $input";
diff --git a/pkgtools/pkgsrc-todo/files/obsolete_todo.1 b/pkgtools/pkgsrc-todo/files/obsolete_todo.1
new file mode 100644
index 00000000000..3f3bfaa13af
--- /dev/null
+++ b/pkgtools/pkgsrc-todo/files/obsolete_todo.1
@@ -0,0 +1,73 @@
+.\" $NetBSD: obsolete_todo.1,v 1.1.1.1 2009/08/30 10:40:34 wiz Exp $
+.\"
+.Dd August 30, 2009
+.Dt OBSOLETE_TODO 1
+.Sh NAME
+.Nm obsolete_todo
+.Nd remove obsolete entries from pkgsrc/doc/TODO
+.Sh SYNOPSIS
+.Nm obsolete_todo
+.Sh DESCRIPTION
+.Nm
+removes entries from
+.Pa pkgsrc/doc/TODO
+which were already handled, i.e. that or newer versions already exist
+in pkgsrc.
+.Nm
+does this by checking the entries in
+.Pa pkgsrc/doc/TODO
+against the entries in the various
+.Pa pkgsrc/doc/CHANGES-*
+files.
+.Pp
+.Nm
+assumes that the contents of
+.Pa pkgsrc/doc
+are up-to-date.
+The
+.Pa TODO
+file needs to be committed manually afterwards, but read
+.Sx BUGS
+first.
+.Sh FILES
+.Bl -tag -width 20n
+.It Pa pkgsrc/doc/TODO
+.Nm
+removes entries to this file.
+.It Pa pkgsrc/doc/CHANGES-*
+.Nm
+compares against these files for finding entries to remove.
+.El
+.Sh AUTHORS
+.An Thomas Klausner Aq wiz@NetBSD.org
+.Sh BUGS
+.Nm
+removes too many entries, so please don't directly commit the result
+of
+.Nm !
+Currently, the following entries are removed even though they
+shouldn't be:
+.Bl -tag
+.It bonnie++-1.96
+.It drscheme-4.0.2
+.It exempi-2.0.2
+.It fixesproto-4.1
+.It lapack-3.2.1
+.It ldapsdk-6.0.2
+.It libixp-0.5
+.It libssh-0.3.3
+.It lmbench-2.5
+.It oto-0.5
+.It sch-3.8.3
+.It zenicb-1.31
+.El
+There are three reasons:
+.Bl -enumerate
+.It
+matching errors (bonnie vs. bonnie++)
+.It
+downgraded packages (exempi, fixesproto, oto, libixp)
+.It
+changes in versioning schemes (drscheme, lapack, ldapsdk, libssh,
+lmbench, sch, zenicb)
+.El
diff --git a/pkgtools/pkgsrc-todo/files/obsolete_todo.pl b/pkgtools/pkgsrc-todo/files/obsolete_todo.pl
new file mode 100755
index 00000000000..839359eecb9
--- /dev/null
+++ b/pkgtools/pkgsrc-todo/files/obsolete_todo.pl
@@ -0,0 +1,97 @@
+#!@PERL@
+
+# $NetBSD: obsolete_todo.pl,v 1.1.1.1 2009/08/30 10:40:34 wiz Exp $
+
+# TODO:
+# check if package was removed
+
+use strict;
+use pkgsrc::Dewey;
+
+my ($comment, $entry, $import, $newfound, $oldfound, $enteredos,
+ $filever, $found, $name, @newlist, @oldlist, $pkg, $version, $verbose);
+
+my $PKGSRCDIR = "@PKGSRCDIR@";
+my $input = "$PKGSRCDIR/doc/TODO";
+my $output = "$PKGSRCDIR/doc/TODO.new";
+my $changes = "$PKGSRCDIR/doc/CHANGES*";
+
+# same code in add_todo, keep in sync
+sub update_done($$) {
+ my ($file, $found_at_all, @files);
+ my ($pkg, $ver) = @_;
+
+ $found_at_all = 0;
+ @files = glob($changes);
+ # XXX: better way of handling +?
+ $pkg =~ s/\+//g;
+ # look in newest files first
+ foreach $file (reverse(@files)) {
+ open SUBIN, $file;
+ while (<SUBIN>) {
+ if (m/[ \/]$pkg version ([^ ]*) / or
+ (m/[ \/]$pkg to ([^ ]*) / and not m/Moved/) or
+ m/[ \/]$pkg-([0-9][^ -]*) /) {
+ $found_at_all = 1;
+ if (dewey_cmp($ver, "<=", $1)) {
+ print STDERR "$pkg already at $1:\n";
+ print STDERR "$file: $_";
+ close(SUBIN);
+ return 1;
+ }
+ }
+ }
+ close(SUBIN);
+ # if found in latest CHANGES file, but no newer version,
+ # assume the version to add is newer and don't check
+ # older files
+ if ($found_at_all) {
+ last;
+ }
+ }
+ return 0;
+}
+
+open IN, $input or die "can't open TODO file";
+open OUT, ">$output" or die "can't open TODO output file";
+
+$verbose = 1;
+$enteredos = 0;
+
+MAIN: while (<IN>) {
+ if ($enteredos == 2 or not m/^ o /) {
+ if ($enteredos == 1) {
+ $enteredos = 2;
+ }
+ print OUT $_;
+ next;
+ }
+
+ $enteredos = 1;
+
+ chomp();
+ s/^ o //;
+ if (m/(\S*)(\s.*)/) {
+ $pkg = $1;
+ $comment = $2;
+ } else {
+ $pkg = $_;
+ $comment = "";
+ }
+
+ $pkg =~ m/(.*)-([^-]*)$/;
+ $name = $1;
+ $version = $2;
+
+ if (update_done($name, $version)) {
+ print STDERR "Removing entry for $name-$version\n";
+ next MAIN;
+ }
+
+ print OUT "\to $pkg$comment\n";
+}
+
+close IN;
+close OUT;
+
+rename($output, $input) or die "can't rename $output to $input";