From 95e94156428fb9db22cee6360ce1e85b6baa0a25 Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 16 Apr 2006 13:32:28 +0000 Subject: Avoid unnecessary invocations of pkg_info by checking whether the package is installed or not using a precalculated regex. This speeds up "portaudit -a" with around a factor of 10. The change is slightly modified from the one from the PR by using pkg_info -aE instead of ls /var/db/pkg for determining installed packages. Submitted by: Kuang-che Wu PR: ports/92942 --- ports-mgmt/portaudit/Makefile | 2 +- ports-mgmt/portaudit/files/portaudit-cmd.sh | 4 ++++ security/portaudit/Makefile | 2 +- security/portaudit/files/portaudit-cmd.sh | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ports-mgmt/portaudit/Makefile b/ports-mgmt/portaudit/Makefile index 914dd0c..8d585f4 100644 --- a/ports-mgmt/portaudit/Makefile +++ b/ports-mgmt/portaudit/Makefile @@ -6,7 +6,7 @@ # PORTNAME= portaudit -PORTVERSION= 0.5.10 +PORTVERSION= 0.5.11 CATEGORIES= security DISTFILES= diff --git a/ports-mgmt/portaudit/files/portaudit-cmd.sh b/ports-mgmt/portaudit/files/portaudit-cmd.sh index b16c7e3..4a30369 100644 --- a/ports-mgmt/portaudit/files/portaudit-cmd.sh +++ b/ports-mgmt/portaudit/files/portaudit-cmd.sh @@ -131,6 +131,7 @@ audit_installed() local osversion=`sysctl -n kern.osreldate` fixedre=`echo -n $portaudit_fixed | tr -c '[:alnum:]- \t\n' 'x' | tr -s ' \t\n' '|'` + installedre=`$pkg_info -aE | sed -e 's/-[^-]*$//g' | paste -s -d '|' -` extract_auditfile | awk -F\| "$PRINTAFFECTED_AWK"' BEGIN { vul=0; fixedre="'"$fixedre"'" } @@ -144,6 +145,9 @@ audit_installed() } next } + $1 ~ /^[^{}*?]*[<=>!]/ { + if ($1 !~ "^('"$installedre"')[<=>!]") next; + } { cmd="'"$pkg_info"' -E \"" $1 "\"" while((cmd | getline pkg) > 0) { diff --git a/security/portaudit/Makefile b/security/portaudit/Makefile index 914dd0c..8d585f4 100644 --- a/security/portaudit/Makefile +++ b/security/portaudit/Makefile @@ -6,7 +6,7 @@ # PORTNAME= portaudit -PORTVERSION= 0.5.10 +PORTVERSION= 0.5.11 CATEGORIES= security DISTFILES= diff --git a/security/portaudit/files/portaudit-cmd.sh b/security/portaudit/files/portaudit-cmd.sh index b16c7e3..4a30369 100644 --- a/security/portaudit/files/portaudit-cmd.sh +++ b/security/portaudit/files/portaudit-cmd.sh @@ -131,6 +131,7 @@ audit_installed() local osversion=`sysctl -n kern.osreldate` fixedre=`echo -n $portaudit_fixed | tr -c '[:alnum:]- \t\n' 'x' | tr -s ' \t\n' '|'` + installedre=`$pkg_info -aE | sed -e 's/-[^-]*$//g' | paste -s -d '|' -` extract_auditfile | awk -F\| "$PRINTAFFECTED_AWK"' BEGIN { vul=0; fixedre="'"$fixedre"'" } @@ -144,6 +145,9 @@ audit_installed() } next } + $1 ~ /^[^{}*?]*[<=>!]/ { + if ($1 !~ "^('"$installedre"')[<=>!]") next; + } { cmd="'"$pkg_info"' -E \"" $1 "\"" while((cmd | getline pkg) > 0) { -- cgit v1.1