From 5a0c39fe60c6ed4b4a2027165f106a7689a214dc Mon Sep 17 00:00:00 2001 From: Colin Smith Date: Sun, 13 Mar 2005 23:32:26 +0000 Subject: Update get_pkg_depends() to use pkgid code. --- etc/inc/pfsense-utils.inc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'etc') diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 3d10a0b..18ab517 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -670,18 +670,18 @@ function reverse_strrchr($haystack, $needle) { */ function get_pkg_depends($pkg_name, $filetype = ".xml", $format = "files", $return_nosync = 1) { global $config; - foreach($config['installedpackages']['package'] as $package) { - if ($package['name'] == $pkg_name) { - $package_xml = $package; - if(!file_exists("/usr/local/pkg/" . $package['configurationfile'])) { // If the package's config file doesn't exist, log an error and fetch it. - log_error("Fetching missing configuration XML for " . $pkg_name); - mwexec("/usr/bin/fetch -o /usr/local/pkg/" . $package['configurationfile'] . " http://www.pfsense.com/packages/config/" . $package['configurationf -ile']); - } - break; - } + if(!is_numeric($pkg_name)) { + $pkg_name = get_pkg_id($pkg_name); + if($pkg_id == -1) return -1; // This package doesn't really exist - exit the function. + } else { + if(!isset($config['installedpackages'][$pkg_id])) return; // No package belongs to the pkg_id passed to this function. } - $pkg_xml = parse_xml_config_pkg("/usr/local/pkg/" . $package_xml['configurationfile'], "packagegui"); + $package = $config['installedpackages'][$pkg_id]; + if(!file_exists("/usr/local/pkg/" . $package['configurationfile'])) { // If the package's config file doesn't exist, log an error and fetch it. + log_error("Fetching missing configuration XML for " . $package['name']); + mwexec("/usr/bin/fetch -o /usr/local/pkg/" . $package['configurationfile'] . " http://www.pfsense.com/packages/config/" . $package['configurationfile']); + } + $pkg_xml = parse_xml_config_pkg("/usr/local/pkg/" . $package['configurationfile'], "packagegui"); if($pkg_xml['additional_files_needed'] != "") { foreach($pkg_xml['additional_files_needed'] as $item) { if (($return_nosync == 0) && (isset($item['nosync']))) continue; // Do not return depends with nosync set if not required. -- cgit v1.1