pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/revbump Standardize option handling (use geto...
details: https://anonhg.NetBSD.org/pkgsrc/rev/d0a2da9e26bb
branches: trunk
changeset: 509244:d0a2da9e26bb
user: wiz <wiz%pkgsrc.org@localhost>
date: Tue Mar 07 04:30:54 2006 +0000
description:
Standardize option handling (use getopts, provide same options for all
three tools).
use strict and cleanup problems found this way.
Remove some unused variables.
Update documentation.
Welcome to 1.3!
diffstat:
pkgtools/revbump/Makefile | 4 ++--
pkgtools/revbump/files/blbump | 36 +++++++++++++++++++-----------------
pkgtools/revbump/files/blbump.1 | 10 ++++++++--
pkgtools/revbump/files/finddepends | 18 +++++++++++++++---
pkgtools/revbump/files/finddepends.1 | 16 ++++++++++++++--
pkgtools/revbump/files/revbump | 31 +++++++++++++++----------------
pkgtools/revbump/files/revbump.1 | 10 ++++++++--
7 files changed, 81 insertions(+), 44 deletions(-)
diffs (truncated from 369 to 300 lines):
diff -r a222bd8634cb -r d0a2da9e26bb pkgtools/revbump/Makefile
--- a/pkgtools/revbump/Makefile Tue Mar 07 04:15:22 2006 +0000
+++ b/pkgtools/revbump/Makefile Tue Mar 07 04:30:54 2006 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.5 2006/03/05 23:35:49 wiz Exp $
+# $NetBSD: Makefile,v 1.6 2006/03/07 04:30:54 wiz Exp $
#
-DISTNAME= revbump-1.2
+DISTNAME= revbump-1.3
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
diff -r a222bd8634cb -r d0a2da9e26bb pkgtools/revbump/files/blbump
--- a/pkgtools/revbump/files/blbump Tue Mar 07 04:15:22 2006 +0000
+++ b/pkgtools/revbump/files/blbump Tue Mar 07 04:30:54 2006 +0000
@@ -1,6 +1,6 @@
#!@PERL@ -w
#
-# $NetBSD: blbump,v 1.1.1.1 2005/01/05 00:31:39 wiz Exp $
+# $NetBSD: blbump,v 1.2 2006/03/07 04:30:54 wiz Exp $
#
# Copyright (c) 2003, 2004 The NetBSD Foundation, Inc.
#
@@ -33,6 +33,10 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
+use strict;
+use Getopt::Std;
+
+my (@PACKAGES, $PKGSRCDIR, %opt, $pkg);
$PKGSRCDIR = $ENV{PKGSRCDIR};
if (! $PKGSRCDIR) {
@@ -40,7 +44,7 @@
}
sub usage {
- print STDERR "usage: blbump [-p pkgsrcdir] [cat1/pkg1 ... catN/pkgN]\n\n";
+ print STDERR "usage: blbump [-h] [-p pkgsrcdir] [cat1/pkg1 ... catN/pkgN]\n\n";
print STDERR "If no packages are given as arguments, the list is read from stdin.\n";
print STDERR "Packages whose buildlink files cannot be updated automatically\n";
print STDERR "are written to stdout.\n";
@@ -49,9 +53,13 @@
sub blbump {
my $pkgdir = shift;
- my ($oldpkgver, $pkgver, $done, $rev, $oldbl, $newbl, $backupbl);
+ my ($pkgver, $ret);
local (*MAKE);
+ # ignore packages without buildlink3.mk files
+ if (not -e "$PKGSRCDIR/$pkgdir/buildlink3.mk") {
+ return 1;
+ }
open(MAKE, '-|', "cd $PKGSRCDIR/$pkgdir ; make show-var VARNAME=PKGNAME");
$pkgver = <MAKE>;
close(MAKE);
@@ -69,9 +77,9 @@
}
sub bumpbl {
+ my ($backupbl, $done, $newbl, $oldbl, $pkgver);
$oldbl = shift;
$pkgver = shift;
- my ($done, $rev, $newbl, $backupbl);
local (*OLDBL);
open(OLDBL, $oldbl) or return 0;
@@ -107,18 +115,14 @@
return 1;
}
-@PACKAGES = ();
+getopts('hp:', \%opt);
+usage() if $opt{h};
+if ($opt{p}) {
+ $PKGSRCDIR = $opt{p};
+}
-while (@ARGV) {
- $arg = shift;
- if ($arg eq '-h') {
- usage();
- } elsif ($arg eq '-p') {
- $PKGSRCDIR = shift;
- } else {
- push @PACKAGES, $arg;
- }
-}
+@PACKAGES = ();
+push @PACKAGES, @ARGV;
if (! -d $PKGSRCDIR || ! -d "$PKGSRCDIR/doc" || ! -d "$PKGSRCDIR/mk") {
print STDERR "Invalid pkgsrc directory $PKGSRCDIR\n";
@@ -132,14 +136,12 @@
}
}
-@valid = ();
foreach $pkg (@PACKAGES) {
if (! -f "$PKGSRCDIR/$pkg/Makefile") {
print "$pkg\n";
} else {
print "$pkg\n" if blbump("$pkg") == 0;
$pkg =~ /\/(.*)$/;
- push @valid, $1;
}
}
diff -r a222bd8634cb -r d0a2da9e26bb pkgtools/revbump/files/blbump.1
--- a/pkgtools/revbump/files/blbump.1 Tue Mar 07 04:15:22 2006 +0000
+++ b/pkgtools/revbump/files/blbump.1 Tue Mar 07 04:30:54 2006 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: blbump.1,v 1.2 2006/03/05 23:35:49 wiz Exp $
+.\" $NetBSD: blbump.1,v 1.3 2006/03/07 04:30:54 wiz Exp $
.\"
.\" Copyright (c) 2003, 2004, 2005 The NetBSD Foundation, Inc.
.\"
@@ -31,7 +31,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd March 6, 2006
+.Dd March 7, 2006
.Dt BLBUMP 1
.Os
.Sh NAME
@@ -39,6 +39,7 @@
.Nd tool to help bumping dependencies in buildlink3 files automatically
.Sh SYNOPSIS
.Nm
+.Op Fl h
.Op Fl p Ar pkgsrcdir
.Op cat1/pkg1 ... catN/pkgN
.Sh DESCRIPTION
@@ -50,12 +51,17 @@
format) on the command line or stdin, it will try to adjust the
.Dv BUILDLINK_RECOMMENDED
line for that package to the current version automatically.
+.Pp
+.Nm Fl h
+displays a short usage.
+.Pp
If
.Fl p
is given,
.Ar pkgsrcdir
is used instead of the default
.Pa /usr/pkgsrc .
+.Pp
.Nm
reports successful updates on stdout, and prints the package name
(in
diff -r a222bd8634cb -r d0a2da9e26bb pkgtools/revbump/files/finddepends
--- a/pkgtools/revbump/files/finddepends Tue Mar 07 04:15:22 2006 +0000
+++ b/pkgtools/revbump/files/finddepends Tue Mar 07 04:30:54 2006 +0000
@@ -1,6 +1,6 @@
#!@PERL@ -w
#
-# $NetBSD: finddepends,v 1.1 2006/03/05 23:35:49 wiz Exp $
+# $NetBSD: finddepends,v 1.2 2006/03/07 04:30:54 wiz Exp $
#
# Copyright (c) 2006 The NetBSD Foundation, Inc.
#
@@ -34,19 +34,31 @@
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
+use strict;
+use Getopt::Std;
+
+my ($PKGSRCDIR, $arg, $bl3, %bl3content, @bl3files, @bl3result,
+ $content, $found, $key, $makefile, @makefiles, %opt,
+ $pattern, @searchlist);
+
$PKGSRCDIR = $ENV{PKGSRCDIR};
if (! $PKGSRCDIR) {
$PKGSRCDIR = "/usr/pkgsrc";
}
sub usage {
- print STDERR "usage: finddepends package\n\n";
+ print STDERR "usage: finddepends [-h] [-p pkgsrcdir] package\n\n";
print STDERR "Find all packages that depend on the argument package.\n";
exit 0;
}
+getopts('hp:', \%opt);
+usage() if $opt{h};
+if ($opt{p}) {
+ $PKGSRCDIR = $opt{p};
+}
+
usage if (1 ne @ARGV);
-
$arg = shift;
@searchlist = ();
diff -r a222bd8634cb -r d0a2da9e26bb pkgtools/revbump/files/finddepends.1
--- a/pkgtools/revbump/files/finddepends.1 Tue Mar 07 04:15:22 2006 +0000
+++ b/pkgtools/revbump/files/finddepends.1 Tue Mar 07 04:30:54 2006 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: finddepends.1,v 1.1 2006/03/05 23:35:49 wiz Exp $
+.\" $NetBSD: finddepends.1,v 1.2 2006/03/07 04:30:54 wiz Exp $
.\"
.\" Copyright (c) 2006 The NetBSD Foundation, Inc.
.\"
@@ -31,7 +31,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd March 6, 2006
+.Dd March 7, 2006
.Dt FINDDEPENDS 1
.Os
.Sh NAME
@@ -39,6 +39,8 @@
.Nd tool for finding packages including a particular file
.Sh SYNOPSIS
.Nm
+.Op Fl h
+.Op Fl p Ar pkgsrcdir
.Ar pattern
.Sh DESCRIPTION
.Nm
@@ -50,6 +52,16 @@
that include it, and then find all Makefiles that include any of the
buildlink3.mk files.
.Pp
+.Nm Fl h
+displays a short usage.
+.Pp
+If
+.Fl p
+is given,
+.Ar pkgsrcdir
+is used instead of the default
+.Pa /usr/pkgsrc .
+.Pp
See
.Xr revbump 1
for an example of a complete recursive PKGREVISION bump.
diff -r a222bd8634cb -r d0a2da9e26bb pkgtools/revbump/files/revbump
--- a/pkgtools/revbump/files/revbump Tue Mar 07 04:15:22 2006 +0000
+++ b/pkgtools/revbump/files/revbump Tue Mar 07 04:30:54 2006 +0000
@@ -1,6 +1,6 @@
#!@PERL@ -w
#
-# $NetBSD: revbump,v 1.1.1.1 2005/01/05 00:31:38 wiz Exp $
+# $NetBSD: revbump,v 1.2 2006/03/07 04:30:54 wiz Exp $
#
# Copyright (c) 2003, 2004 The NetBSD Foundation, Inc.
#
@@ -34,13 +34,18 @@
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
+use strict;
+use Getopt::Std;
+
+my (@PACKAGES, $PKGSRCDIR, %opt, $pkg);
+
$PKGSRCDIR = $ENV{PKGSRCDIR};
if (! $PKGSRCDIR) {
$PKGSRCDIR = "/usr/pkgsrc";
}
sub usage {
- print STDERR "usage: revbump [-p pkgsrcdir] [cat1/pkg1 ... catN/pkgN]\n\n";
+ print STDERR "usage: revbump [-h] [-p pkgsrcdir] [cat1/pkg1 ... catN/pkgN]\n\n";
print STDERR "If no packages are given as arguments, the list is read from stdin.\n";
print STDERR "Packages for which revision cannot be bumped are written to stdout.\n";
exit 0;
@@ -48,7 +53,7 @@
sub revbump {
my $pkgdir = shift;
- my ($pkg, $oldpkgver, $pkgver, $done, $rev, $oldmk, $newmk, $backupmk);
+ my ($pkg, $oldpkgver, $pkgver, $done, $oldmk, $newmk, $backupmk);
local (*OLDMK, *MAKE);
$pkgdir =~ /\/(.*)$/;
@@ -126,18 +131,14 @@
return 1;
}
-@PACKAGES = ();
+getopts('hp:', \%opt);
+usage() if $opt{h};
+if ($opt{p}) {
+ $PKGSRCDIR = $opt{p};
+}
-while (@ARGV) {
- $arg = shift;
- if ($arg eq '-h') {
- usage();
- } elsif ($arg eq '-p') {
Home |
Main Index |
Thread Index |
Old Index