summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authortnn <tnn>2007-12-02 02:11:05 +0000
committertnn <tnn>2007-12-02 02:11:05 +0000
commit853ca9d11bc9a8ec1a08a7a50d858b44e240b46e (patch)
tree63bdc28b594d5fad1e72208680a61134f7f196e0 /pkgtools
parent665ea6f2d4d0bbef8da1b3d53ea6be9206da36a0 (diff)
downloadpkgsrc-853ca9d11bc9a8ec1a08a7a50d858b44e240b46e.tar.gz
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 (limited to 'pkgtools')
-rw-r--r--pkgtools/pkg_rolling-replace/Makefile6
-rwxr-xr-xpkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh30
2 files changed, 22 insertions, 14 deletions
diff --git a/pkgtools/pkg_rolling-replace/Makefile b/pkgtools/pkg_rolling-replace/Makefile
index a2940531b3d..d094746e762 100644
--- a/pkgtools/pkg_rolling-replace/Makefile
+++ b/pkgtools/pkg_rolling-replace/Makefile
@@ -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_CLASSES+= tools
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 --git a/pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh b/pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh
index 8bffad837f0..c7373919207 100755
--- a/pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh
+++ b/pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh
@@ -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 @@ check_packages_w_flag()
# 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 @@ while [ -n "$REPLACE_TODO" ]; do
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