pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkgsrc-todo Initial import of pkgsrc-todo-1.0:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/71a7d8e33ce7
branches:  trunk
changeset: 398424:71a7d8e33ce7
user:      wiz <wiz%pkgsrc.org@localhost>
date:      Sun Aug 30 10:40:34 2009 +0000

description:
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:

 pkgtools/pkgsrc-todo/DESCR                  |    8 +
 pkgtools/pkgsrc-todo/Makefile               |   50 +++++++++
 pkgtools/pkgsrc-todo/PLIST                  |    5 +
 pkgtools/pkgsrc-todo/files/add_todo.1       |   66 ++++++++++++
 pkgtools/pkgsrc-todo/files/add_todo.pl      |  153 ++++++++++++++++++++++++++++
 pkgtools/pkgsrc-todo/files/obsolete_todo.1  |   73 +++++++++++++
 pkgtools/pkgsrc-todo/files/obsolete_todo.pl |   97 +++++++++++++++++
 7 files changed, 452 insertions(+), 0 deletions(-)

diffs (truncated from 480 to 300 lines):

diff -r a4b55bb0ef8f -r 71a7d8e33ce7 pkgtools/pkgsrc-todo/DESCR
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkgsrc-todo/DESCR        Sun Aug 30 10:40:34 2009 +0000
@@ -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 -r a4b55bb0ef8f -r 71a7d8e33ce7 pkgtools/pkgsrc-todo/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkgsrc-todo/Makefile     Sun Aug 30 10:40:34 2009 +0000
@@ -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@localhost
+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 -r a4b55bb0ef8f -r 71a7d8e33ce7 pkgtools/pkgsrc-todo/PLIST
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkgsrc-todo/PLIST        Sun Aug 30 10:40:34 2009 +0000
@@ -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 -r a4b55bb0ef8f -r 71a7d8e33ce7 pkgtools/pkgsrc-todo/files/add_todo.1
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkgsrc-todo/files/add_todo.1     Sun Aug 30 10:40:34 2009 +0000
@@ -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@localhost
+.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 -r a4b55bb0ef8f -r 71a7d8e33ce7 pkgtools/pkgsrc-todo/files/add_todo.pl
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkgsrc-todo/files/add_todo.pl    Sun Aug 30 10:40:34 2009 +0000
@@ -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;



Home | Main Index | Thread Index | Old Index