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 <kcwu@csie.org> PR: ports/92942
This commit is contained in:
parent
d0ccdc7ed4
commit
75654bee2f
@ -6,7 +6,7 @@
|
||||
#
|
||||
|
||||
PORTNAME= portaudit
|
||||
PORTVERSION= 0.5.10
|
||||
PORTVERSION= 0.5.11
|
||||
CATEGORIES= security
|
||||
DISTFILES=
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
#
|
||||
|
||||
PORTNAME= portaudit
|
||||
PORTVERSION= 0.5.10
|
||||
PORTVERSION= 0.5.11
|
||||
CATEGORIES= security
|
||||
DISTFILES=
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user