pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_rolling-replace pkg_rolling-replace-0.12:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/df397b578e8d
branches:  trunk
changeset: 536071:df397b578e8d
user:      tnn <tnn%pkgsrc.org@localhost>
date:      Sun Dec 02 02:11:05 2007 +0000

description:
pkg_rolling-replace-0.12:
Replace the nested shell loops in depgraph_installed() with some awk
that only needs to invoke pkg_info once. This gives a ~20x speedup.

Previously, if many packages were installed, depgraph generation took a
considerable amount of time; in the order of 30 seconds even on moderately
fast hardware.

diffstat:

 pkgtools/pkg_rolling-replace/Makefile                     |   6 +-
 pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh |  30 +++++++++-----
 2 files changed, 22 insertions(+), 14 deletions(-)

diffs (81 lines):

diff -r a76c84fd38b4 -r df397b578e8d pkgtools/pkg_rolling-replace/Makefile
--- a/pkgtools/pkg_rolling-replace/Makefile     Sun Dec 02 00:35:23 2007 +0000
+++ b/pkgtools/pkg_rolling-replace/Makefile     Sun Dec 02 02:11:05 2007 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.14 2007/08/17 01:19:45 gdt Exp $
+# $NetBSD: Makefile,v 1.15 2007/12/02 02:11:05 tnn Exp $
 
-DISTNAME=      pkg_rolling-replace-0.11
+DISTNAME=      pkg_rolling-replace-0.12
 CATEGORIES=    pkgtools
 MASTER_SITES=  # empty
 DISTFILES=     # empty
@@ -28,7 +28,7 @@
 SUBST_STAGE.tools=     pre-configure
 SUBST_MESSAGE.tools=   Substituting tool locations.
 SUBST_FILES.tools=     pkg_rolling-replace.sh
-SUBST_VARS.tools=      PKG_INFO_CMD MAKE PKG_CHK
+SUBST_VARS.tools=      PKG_INFO_CMD MAKE PKG_CHK AWK
 
 SUBST_CLASSES+=                makeconf
 SUBST_STAGE.makeconf=  pre-configure
diff -r a76c84fd38b4 -r df397b578e8d pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh
--- a/pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh Sun Dec 02 00:35:23 2007 +0000
+++ b/pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh Sun Dec 02 02:11:05 2007 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# $NetBSD: pkg_rolling-replace.sh,v 1.14 2007/08/17 01:19:45 gdt Exp $
+# $NetBSD: pkg_rolling-replace.sh,v 1.15 2007/12/02 02:11:05 tnn Exp $
 #<license>
 # Copyright (c) 2006 BBN Technologies Corp.  All rights reserved.
 #
@@ -63,6 +63,7 @@
 
 # Substituted by pkgsrc at pre-configure time.
 MAKE="@MAKE@"
+AWK="@AWK@"
 
 test -z "$MAKECONF" && MAKECONF="@MAKECONF@"
 test -f "$MAKECONF" && test -z "$PKGSRCDIR" && PKGSRCDIR="` \
@@ -151,15 +152,22 @@
 # echo dep->pkg edges for all installed packages
 depgraph_installed()
 {
-    for pkgver in $(${PKG_INFO} -e '*'); do
-        pkg=$(echo $pkgver | sed 's/-[0-9][^-]*$//')
-       # Include $pkg as a node without dependencies in case it has none.
-        echo $pkg $pkg
-        for depver in $(${PKG_INFO} -Nq $pkg); do
-            dep=$(echo $depver | sed 's/-[0-9][^-]*$//')
-            echo $dep $pkg
-        done
-    done
+       ${PKG_INFO} -N '*' | ${AWK} '                                   \
+               /^Information for/ {                                    \
+                       pkg=$3; sub("-[0-9][^-]*:$", "", pkg);          \
+                       print pkg" "pkg;                                \
+                       state=1;                                        \
+               }                                                       \
+               /^./ {                                                  \
+                       if (state == 2) {                               \
+                               dep=$1; sub("-[0-9][^-]*$", "", dep);   \
+                               print dep" "pkg;                        \
+                       }                                               \
+               }                                                       \
+               /^Built using/ {                                        \
+                       state=2                                         \
+               }                                                       \
+       '
 }
 
 # usage: who_requires pkg --in-graph DEPGRAPH
@@ -320,7 +328,7 @@
             break;
         fi
     done
-    pkgdir=$(${PKG_INFO} -Bq $pkg | awk -F= '/PKGPATH=/{print $2}' | sed -e 's/^ //')
+    pkgdir=$(${PKG_INFO} -Bq $pkg | ${AWK} -F= '/PKGPATH=/{print $2}' | sed -e 's/^ //')
     echo "${OPI} Selecting $pkg ($pkgdir) as next package to replace"
     sleep 1
 



Home | Main Index | Thread Index | Old Index