From e44e5f3a79aba14a054f351178030fc87b1f4771 Mon Sep 17 00:00:00 2001 From: jim-p Date: Mon, 3 Jan 2011 16:47:26 -0500 Subject: Simplify package version checking code and use the existing pfs_version_compare function that does much (and more) of what the old code was trying to do on its own. --- usr/local/www/pkg_mgr.php | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/usr/local/www/pkg_mgr.php b/usr/local/www/pkg_mgr.php index 3109313..3c1ba89 100755 --- a/usr/local/www/pkg_mgr.php +++ b/usr/local/www/pkg_mgr.php @@ -80,12 +80,7 @@ include("head.inc"); "" ? false : true, "pkg_mgr.php"); @@ -113,9 +108,6 @@ include("head.inc"); if(!$pkg_info) { echo "
" . gettext("There are currently no packages available for installation.") . ""; } else { - $installed_pfsense_version = rtrim(file_get_contents("/etc/version")); - $dash = strpos($installed_pfsense_version, "-"); - $installed_pfsense_version = substr($installed_pfsense_version, 0, $dash); $pkgs = array(); $instpkgs = array(); if($config['installedpackages']['package'] != "") @@ -134,30 +126,28 @@ include("head.inc"); if($g['platform'] == "nanobsd") if($index['noembedded']) continue; - $dash = strpos($index['required_version'], "-"); - $index['major_version'] = substr($index['required_version'], 0, $dash); + /* If we are on not on HEAD, and the package wants it, skip */ if ($version <> "HEAD" && $index['required_version'] == "HEAD" && $requested_version <> "other") continue; + /* If there is no required version, and the requested package + version is not 'none', then skip */ if (empty($index['required_version']) && $requested_version <> "none") continue; - if($index['major_version'] > $major && - $requested_version <> "other") - continue; - if(isset($index['major_version']) && - $requested_version == "none") + /* If the requested version is not 'other', and the required version is newer than what we have, skip. */ + if($requested_version <> "other" && + (pfs_version_compare("", $version, $index['required_version']) < 0)) continue; - if($index['major_version'] == $major && - $requested_version == "other") + /* If the requestion version is 'other' and we are on the version requested, skip. */ + if($requested_version == "other" && + (pfs_version_compare("", $version, $index['required_version']) == 0)) continue; - /* Package is for a newer version, lets skip */ - if($installed_pfsense_version < $index['required_version']) + /* Package is only for an older version, lets skip */ + if($index['maximum_version'] && + (pfs_version_compare("", $version, $index['maximum_version']) > 0)) continue; - if($index['maximum_version']) - if($installed_pfsense_version > $index['maximum_version']) - continue; ?> -- cgit v1.1