diff options
author | Colin Smith <colin@pfsense.org> | 2005-04-26 15:12:31 +0000 |
---|---|---|
committer | Colin Smith <colin@pfsense.org> | 2005-04-26 15:12:31 +0000 |
commit | 7be9819fba5f53d27f5b0b48a464dea9b19f64aa (patch) | |
tree | d9dda0df1b8d4fafc966faa11b8df064c822c3ca /etc | |
parent | 441cd40668493d5e7764ab7074f837e54586a5a0 (diff) | |
download | pfsense-7be9819fba5f53d27f5b0b48a464dea9b19f64aa.zip pfsense-7be9819fba5f53d27f5b0b48a464dea9b19f64aa.tar.gz |
get_available_pkg_id: Don't fetch and parse pkg_config if it's already defined.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/pfsense-utils.inc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 524c664..949ea25 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -369,12 +369,14 @@ function is_package_installed($packagename) { function get_pkg_id($pkg_name) { global $config; global $pkg_config; - $i=0; - if(is_array($config['installedpackages']['package'])) + if(is_array($config['installedpackages']['package'])) { + $i = 0; foreach ($config['installedpackages']['package'] as $pkg) { if($pkg['name'] == $pkg_name) return $i; $i++; } + return $i; + } return -1; } @@ -398,8 +400,11 @@ function get_latest_package_version($pkg_name) { * Lookup pkg_id in pkg_config.xml */ function get_available_pkg_id($pkg_name) { - fetch_latest_pkg_config(); - $pkg_config = parse_xml_config_pkg("{$g['tmp_path']}/pkg_config.xml", "pfsensepkgs"); + global $pkg_config; + if(!is_array($pkg_config)) { + fetch_latest_pkg_config(); + $pkg_config = parse_xml_config_pkg("{$g['tmp_path']}/pkg_config.xml", "pfsensepkgs"); + } $id = 0; foreach($pkg_config as $pkg) { if($pkg_config['name'] == $pkg_name) { |