summaryrefslogtreecommitdiff
path: root/pkgtools/pkgdepgraph
diff options
context:
space:
mode:
authoratatat <atatat@pkgsrc.org>2003-03-25 18:21:20 +0000
committeratatat <atatat@pkgsrc.org>2003-03-25 18:21:20 +0000
commit67a94dc41f21e88b8aed3d3429af787c4d7cc218 (patch)
tree78dc698b4517870bb5cbc59c136ec1fce2361e00 /pkgtools/pkgdepgraph
parent3ee822b062043c09154d9bd9a52c1556c12fa835 (diff)
downloadpkgsrc-67a94dc41f21e88b8aed3d3429af787c4d7cc218.tar.gz
Add -F for "fetch" output, so that you can pre-fetch all the distfiles
you need and then build off-line (suggested by smb). Add -M to set the name/location of the make program (for the -F and -R output formats) to be used on systems where the make program is not the one you want (suggested by seb). Clean up a bug with subgraph assignment and counting. Move to 2.3.
Diffstat (limited to 'pkgtools/pkgdepgraph')
-rw-r--r--pkgtools/pkgdepgraph/Makefile4
-rw-r--r--pkgtools/pkgdepgraph/files/pkgdepgraph.193
-rwxr-xr-xpkgtools/pkgdepgraph/files/pkgdepgraph.pl73
3 files changed, 129 insertions, 41 deletions
diff --git a/pkgtools/pkgdepgraph/Makefile b/pkgtools/pkgdepgraph/Makefile
index 93e44292525..db937352c32 100644
--- a/pkgtools/pkgdepgraph/Makefile
+++ b/pkgtools/pkgdepgraph/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.7 2003/03/14 23:39:54 atatat Exp $
+# $NetBSD: Makefile,v 1.8 2003/03/25 18:21:20 atatat Exp $
#
-DISTNAME= pkgdepgraph-2.2
+DISTNAME= pkgdepgraph-2.3
CATEGORIES= pkgtools devel
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/pkgtools/pkgdepgraph/files/pkgdepgraph.1 b/pkgtools/pkgdepgraph/files/pkgdepgraph.1
index 3e2d04efa83..3d0fc8a5e72 100644
--- a/pkgtools/pkgdepgraph/files/pkgdepgraph.1
+++ b/pkgtools/pkgdepgraph/files/pkgdepgraph.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkgdepgraph.1,v 1.5 2003/03/14 23:39:56 atatat Exp $
+.\" $NetBSD: pkgdepgraph.1,v 1.6 2003/03/25 18:21:20 atatat Exp $
.\"
.\" Copyright (c) 2002, 2003 by Andrew Brown <atatat@netbsd.org>
.\" Absolutely no warranty.
@@ -10,9 +10,10 @@
.Nd visual representation of installed packages
.Sh SYNOPSIS
.Nm
-.Op Fl ACcDfgLloRv
+.Op Fl ACcDFfgLloRv
.Op Fl d Ar pkg_dbdir
.Op Fl K Ar packages
+.Op Fl M Ar make
.Op Fl O Ar package
.Op Fl P Ar pkgsrcdir
.Op Fl t Ar target
@@ -120,6 +121,13 @@ This defaults to the value of the
.Pa PKG_DBDIR
environment variable, if it is set, or to
.Pa @PKG_DBDIR@ .
+.It Fl F
+Makes
+.Nm
+emit a series of
+.Xr sh 1
+commands that will fetch all the required distfiles for rebuilding out
+of date packages.
.It Fl f
Force a rebuild of all dependent packages.
This option is for use in conjunction with the
@@ -151,12 +159,23 @@ Adds package
.Dq location
information to the labels on the nodes.
This is the path to the package under the local pkgsrc tree.
-.It Fl P Ar pkgsrcdir
-The root of the pkgsrc source tree.
-This defaults to the value of the
-.Pa PKGSRCDIR
-environment variable, if it is set, or to
-.Pa @PKGSRCDIR@ .
+.It Fl M Ar make
+Sets the name or path of the proper
+.Xr make 1
+program for the
+.Xr sh 1
+commands generated by the
+.Fl R
+and
+.Fl F
+options.
+Some systems may have more than one
+.Xr make 1
+command or the correct choice might not be named
+.Dq make .
+The default value for this is taken from the MAKE environment
+variable, if it is set, or is simply
+.Dq make .
.It Fl O Ar package
Marks
.Ar package
@@ -176,6 +195,12 @@ that each node has a number greater than that of anything which
depends on it, and with the
.Dq leaf
nodes numbered one.
+.It Fl P Ar pkgsrcdir
+The root of the pkgsrc source tree.
+This defaults to the value of the
+.Pa PKGSRCDIR
+environment variable, if it is set, or to
+.Pa @PKGSRCDIR@ .
.It Fl R
Instead of the standard graph output, emits a series of
.Xr sh 1
@@ -213,6 +238,16 @@ base will be accordingly greater.
Adds the package version number to the node's label in the graph.
.El
.Sh ENVIRONMENT
+.Ss MAKE
+The default name for the
+.Dq make
+program used in the
+.Xr sh 1
+commands generated by the
+.Fl F
+and
+.Fl R
+output modes.
.Ss PKG_DBDIR
Where to find registered packages instead of
.Pa @PKG_DBDIR@ .
@@ -233,8 +268,7 @@ The default output:
$ pkgdepgraph | dotty -
.Ed
.Pp
-To generate colored graph output for later use, and a postscript image
-of it:
+To generate graph output for later use, and a postscript image of it:
.Bd -literal -offset indent
$ lintpkgsrc -i \*[Gt] pkgdepgraph.in
$ audit-packages \*[Gt]\*[Gt] pkgdepgraph.in
@@ -242,7 +276,7 @@ $ pkgdepgraph -lv pkgdepgraph.in \*[Gt] pkgdepgraph.dot
$ dot -Tps pkgdepgraph.dot \*[Gt] pkgdepgraph.ps
.Ed
.Pp
-To generate a graph of just the out-of-date nodes as a gif:
+To generate a graph of just the out of date nodes as a gif:
.Bd -literal -offset indent
$ pkgdepgraph -L pkgdepgraph.in \*[Gt] out-of-date.dot
$ dot -Tgif out-of-date.dot \*[Gt] out-of-date.gif
@@ -261,18 +295,28 @@ $ pkg_delete `cat delete_order`
$ sh rebuild.sh
.Ed
.Pp
-The last step will probably take a while, but if you need to stop it
-or it stops by itself for any reason, you can rerun the script, and it
-will pick up where it left off.
+You may also find it useful to
+.Dq pre-fetch
+all the required distfiles for the rebuild as below, so that you can
+do all the rebuilding while off-line:
+.Bd -literal -offset indent
+$ pkgdepgraph -F pkgdepgraph.in \*[Gt] fetch.sh
+$ sh fetch.sh
+.Ed
+.Pp
+Running the rebuild script will probably take a while, but if you
+need to stop it or it stops by itself for any reason, you can rerun
+the script, and it will pick up where it left off.
If there are certain packages that you want installed before others
are reinstalled, feel free to reorder the lines in the script.
.Pp
You can also
.Dq make clean
-wherever you like when the script is not running, or even update your
-tree in between runs of the script, though in the latter case, it
-would be prudent to resume the script in the following manner so that
-any packages that are newly out of date are removed and replaced.
+wherever you like when the rebuild script is not running, or even
+update your tree in between runs of the script, though in the latter
+case, it would be prudent to resume the script in the following manner
+so that any packages that are newly out of date are removed and
+replaced.
.Bd -literal -offset indent
$ pkgdepgraph -D pkgdepgraph.in \*[Gt] delete_order
$ pkgdepgraph -R pkgdepgraph.in \*[Gt]\*[Gt] rebuild.sh
@@ -324,3 +368,16 @@ was written in
.Xr perl 1 ,
but I believe the balance of code layout and comments is actually
reasonable, despite what you may think of perl.
+.Pp
+The
+.Dq rebuild
+output and the
+.Dq fetch
+output (see the
+.Fl R
+and
+.Fl F
+options) do not deal very well with packages that have moved within
+the pkgsrc tree.
+It is necessary that you edit the rebuild script by hand to work
+around this.
diff --git a/pkgtools/pkgdepgraph/files/pkgdepgraph.pl b/pkgtools/pkgdepgraph/files/pkgdepgraph.pl
index 81c911d94eb..c54a12af393 100755
--- a/pkgtools/pkgdepgraph/files/pkgdepgraph.pl
+++ b/pkgtools/pkgdepgraph/files/pkgdepgraph.pl
@@ -3,7 +3,7 @@
# Copyright (c) 2002, 2003 by Andrew Brown <atatat@netbsd.org>
# Absolutely no warranty.
-# $NetBSD: pkgdepgraph.pl,v 1.5 2003/03/14 23:39:56 atatat Exp $
+# $NetBSD: pkgdepgraph.pl,v 1.6 2003/03/25 18:21:20 atatat Exp $
# pkgdepgraph: @DISTVER@
use strict;
@@ -13,12 +13,12 @@ Getopt::Long::Configure("bundling");
my(@opts, %opt);
my($iam, $version, $usecolor, $group, $locations, $order, $versions);
my($limit, $delete, $rebuild, $force, @outofdate, @update, $clean);
-my($pkg_dbdir, $pkgsrcdir, $packages, $pkgadd);
+my($pkg_dbdir, $pkgsrcdir, $packages, $pkgadd, $fetch, $make);
$version = '@DISTVER@';
($iam = $0) =~ s:.*/::;
-@opts = ('A', 'C', 'c', 'D', 'd=s', 'f', 'g', 'K=s', 'L', 'l', 'O=s',
- 'o', 'P=s', 'R', 't=s', 'U=s', 'v');
+@opts = ('A', 'C', 'c', 'D', 'd=s', 'F', 'f', 'g', 'K=s', 'L', 'l',
+ 'M=s', 'O=s', 'o', 'P=s', 'R', 't=s', 'U=s', 'v');
%opt = (
'A' => \$pkgadd,
# 'C' => implies "realclean", handled later
@@ -26,10 +26,12 @@ $version = '@DISTVER@';
'D' => \$delete,
'd' => \$pkg_dbdir,
'f' => \$force,
+ 'F' => \$fetch,
'g' => \$group,
'K' => \$packages,
'L' => \$limit,
'l' => \$locations,
+ 'M' => \$make,
'O' => \@outofdate,
'o' => \$order,
'P' => \$pkgsrcdir,
@@ -38,11 +40,18 @@ $version = '@DISTVER@';
'U' => \@update,
'v' => \$versions,
);
-die("usage: $iam [-ACcDfgLloRv] [-d pkg_dbdir] [-K packages] [-O package]\n",
+die("usage: $iam [-ACcDFfgLloRv] [-d pkg_dbdir] [-K packages] [-M make]\n",
" " x (length($iam) + 8),
- "[-P pkgsrcdir] [-t target] [-U package] [data ...]\n")
+ "[-O package] [-P pkgsrcdir] [-t target] [-U package]\n",
+ " " x (length($iam) + 8),
+ "[data ...]\n")
if (!GetOptions(\%opt, @opts));
+die("$iam: -D, -F, and -R are mutually exclusive -- please pick one\n")
+ if (($delete != 0) +
+ ($fetch != 0) +
+ ($rebuild ne "") > 1);
+
$pkg_dbdir ||= $ENV{'PKG_DBDIR'} || "/var/db/pkg";
$pkgsrcdir ||= $ENV{'PKGSRCDIR'} || "/usr/pkgsrc";
$packages = $ENV{'PKG_PATH'} if (!$packages);
@@ -51,12 +60,13 @@ $packages = $pkgsrcdir . "/packages/All" if (!$packages);
$rebuild &&= $opt{t} || "install";
$clean = "clean" if ($opt{c});
$clean = "CLEANDEPENDS=YES clean" if ($opt{C});
+$make ||= $ENV{'MAKE'} || "make";
my(@pkgs, $pkg, $req, %req, @reqs, @rreqs);
my(%clusters, $cluster);
my(%where, $pkgcnt, $num, %num, @num, %ord, @ord, $suffix);
my(%color, $color, %vuln);
-my(%need, $label);
+my(%need, %forced, $label);
my($recolor, @graph);
##
@@ -203,16 +213,21 @@ foreach $pkg (@pkgs) {
## create a hash of clusters of package prefixes, with counts. later,
## clusters that have more than one member can be marked as subgraphs.
##
-## the outer map() iterates over each pkg name. the inner map()
-## breaks each pkg name up into tokens that end in either _ or - and
-## loops over the resulting list, appending each one to $a. for
-## example:
+## the outer map() iterates over each pkg name after all instances of
+## _ in the pkg name have been changed to - (for the purposes of
+## accurate clustering). the inner map() breaks each pkg name up into
+## tokens that end in - and loops over the resulting list, appending
+## each one to $a. for example:
##
## pkg: one_two-three-4.56
-## tokens: one_ two- three-
-## $a: one_ one_two- one_two-three-
+## tokens: one- two- three-
+## $a: one- one-two- one-two-three-
##
-map({ $a = ""; map({ $a .= $_; $clusters{$a}++; } /([^-_]*[-_])/g); } @pkgs);
+map({ $a = "";
+ ($b = $_) =~ s/_/-/g;
+ map({ $a .= $_; $clusters{$a}++; }
+ $b =~ /([^-]*-)/g); }
+ @pkgs);
##
## impose some sort of order on the pkgs by assigning them numbers
@@ -254,7 +269,8 @@ if (@outofdate) {
foreach (@outofdate) {
if ($color{$_} ne "red") {
$color{$_} = "red";
- $need{$_} = "$_ (forced)";
+ $need{$_} = $_;
+ $forced{$_} = " (forced)";
}
}
}
@@ -276,7 +292,8 @@ if (@update) {
foreach (@update) {
if ($color{$_} ne "red") {
$color{$_} = "red";
- $need{$_} = "$_ (forced)";
+ $need{$_} = $_;
+ $forced{$_} = " (forced)";
}
}
}
@@ -304,6 +321,19 @@ if ($delete) {
}
##
+## "fetch" output, in no particular order (as with the rebuild
+## output), but with all out-of-date pkgs listed, instead of all stale
+## leaf pkgs.
+##
+if ($fetch) {
+ printf("MAKE=\"$make\"\nexport MAKE\n");
+ map(print("( cd $pkgsrcdir/$where{$_} && \${MAKE} fetch ) &&\n"),
+ grep(color($_) eq "red", @pkgs));
+ print("true\n");
+ exit(0);
+}
+
+##
## "rebuild" output for sh(1), with just leaves listed. all the
## dependencies will be built "automagically" by the regular build
## mechanism. if $add is set, emit commands for installing binary
@@ -311,13 +341,14 @@ if ($delete) {
##
if ($rebuild) {
printf("PKG_PATH=\"$packages\"\nexport PKG_PATH\n") if ($pkgadd);
+ printf("MAKE=\"$make\"\nexport MAKE\n") if (!$pkgadd);
map($pkgadd ?
printf("( pkg_info -qe %s || pkg_add %s.tgz ) &&\n",
/(.*)-.*/, ($need{$_} || $_)) :
- printf("( pkg_info -qe %s || ( cd %s && make %s%s )) &&\n",
+ printf("( pkg_info -qe %s || ( cd %s && \${MAKE} %s%s )) &&\n",
/(.*)-.*/, "$pkgsrcdir/$where{$_}",
- $rebuild, $clean ? " && make $clean" : ""),
+ $rebuild, $clean ? " && \${MAKE} $clean" : ""),
grep(color($_) ne "green" && $ord{$_} == 1, @pkgs));
print("true\n");
exit(0);
@@ -338,7 +369,7 @@ foreach $pkg (sort(bynum @pkgs)) {
$label =~ s/(.*)-.*/$1/ if (!$versions);
$label = "($ord{$pkg}) $label" if ($order);
$label = "$where{$pkg}\\n$label" if ($locations);
- $label .= "\\n$need{$pkg}" if ($need{$pkg});
+ $label .= "\\n$need{$pkg}$forced{$pkg}" if ($need{$pkg});
if ($vuln{$pkg}) {
$label .= "\\n(no update available)" if (!$need{$pkg});
$label .= "\\n[$vuln{$pkg}]";
@@ -354,10 +385,10 @@ foreach $pkg (sort(bynum @pkgs)) {
## discovery order, so that we end up with the "least-specific"
## subgroup announced first.
##
- $a = $pkg;
+ ($a = $pkg) =~ s/_/-/g;
$b = 1;
$cluster = "";
- while ($group && $a =~ s/([-_])[^-_]+[-_]?$/$1/) {
+ while ($group && $a =~ s/-[^-]+-?$/-/) {
next if ($clusters{$a} == $b);
$b = $clusters{$a};
$cluster = sprintf("subgraph \"cluster_%s\" {\n", substr($a, 0, -1)) .