summaryrefslogtreecommitdiffstats
path: root/src/etc
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2017-05-10 15:45:46 -0300
committerRenato Botelho <renato@netgate.com>2017-05-10 15:45:46 -0300
commit3459c6ec61e40d41f14c366c08f30f981e78ba0f (patch)
tree49326721c34db2831ad40ed8536bea951eacb987 /src/etc
parent6e0bfeb217a5c812dfe4f0d217a318476f5815ca (diff)
parentdd6ecfa27246935ca03747162b802fcd4ba36100 (diff)
downloadpfsense-3459c6ec61e40d41f14c366c08f30f981e78ba0f.zip
pfsense-3459c6ec61e40d41f14c366c08f30f981e78ba0f.tar.gz
Merge pull request #3719 from phil-davis/no-packages
Diffstat (limited to 'src/etc')
-rw-r--r--src/etc/inc/pkg-utils.inc29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/etc/inc/pkg-utils.inc b/src/etc/inc/pkg-utils.inc
index df4ac49..0842ab9 100644
--- a/src/etc/inc/pkg-utils.inc
+++ b/src/etc/inc/pkg-utils.inc
@@ -354,6 +354,12 @@ function get_pkg_info($pkgs = 'all', $remote_repo_usage_disabled = false,
}
+ if ($installed_pkgs_only && !is_pkg_installed($pkgs)) {
+ // Return early if the caller wants just installed packages and there are none.
+ // Saves doing any calls that might access a remote package repo.
+ return array();
+ }
+
if (!function_exists('is_subsystem_dirty')) {
require_once("util.inc");
}
@@ -374,13 +380,18 @@ function get_pkg_info($pkgs = 'all', $remote_repo_usage_disabled = false,
$extra_param = "-U ";
}
- if (!$installed_pkgs_only) {
+ // If we want more than just the currently installed packages or
+ // we want up-to-date remote repo info
+ // then do a full pkg search
+ if (!$installed_pkgs_only || !$remote_repo_usage_disabled) {
$rc = pkg_exec(
"search {$extra_param}-R --raw-format json-compact " .
$pkgs, $out, $err);
}
- if (($installed_pkgs_only || ($rc != 0 && $remote_repo_usage_disabled))
- && is_pkg_installed($pkgs)) {
+
+ if (($installed_pkgs_only || $rc != 0) &&
+ $remote_repo_usage_disabled &&
+ is_pkg_installed($pkgs)) {
/*
* Fall back on pkg info to return locally installed matching
* pkgs instead, if:
@@ -391,7 +402,9 @@ function get_pkg_info($pkgs = 'all', $remote_repo_usage_disabled = false,
* but it didn't have any contents, or for other reasons
* returned an error.
* AND
- * (2) at least some pkgs matching <pattern> are installed
+ * (2) remote repo data is not required
+ * AND
+ * (3) at least some pkgs matching <pattern> are installed
*
* Following an unsuccessful attempt to access a remote repo
* catalog, the local copy is wiped clear. Thereafter any
@@ -455,8 +468,11 @@ function get_pkg_info($pkgs = 'all', $remote_repo_usage_disabled = false,
"https://github.com/pfsense/FreeBSD-ports/commits/devel/" .
$pkg_info['categories'][0] . '/' . $pkg_info['name'];
+ $pkg_is_installed = false;
+
if (is_pkg_installed($pkg_info['name'])) {
$pkg_info['installed'] = true;
+ $pkg_is_installed = true;
$rc = pkg_exec("query %v {$pkg_info['name']}", $out,
$err);
@@ -477,12 +493,15 @@ function get_pkg_info($pkgs = 'all', $remote_repo_usage_disabled = false,
$out);
} else if (is_package_installed($pkg_info['shortname'])) {
$pkg_info['broken'] = true;
+ $pkg_is_installed = true;
}
$pkg_info['desc'] = preg_replace('/\n+WWW:.*$/', '',
$pkg_info['desc']);
- $result[] = $pkg_info;
+ if (!$installed_pkgs_only || $pkg_is_installed) {
+ $result[] = $pkg_info;
+ }
unset($pkg_info);
}
OpenPOWER on IntegriCloud