diff options
author | jim-p <jimp@pfsense.org> | 2011-01-03 16:47:26 -0500 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2011-01-03 16:50:42 -0500 |
commit | e44e5f3a79aba14a054f351178030fc87b1f4771 (patch) | |
tree | 6db47d1959b460cd67cf9e26f9470ce5bd92fb70 /usr/local/www/pkg_mgr.php | |
parent | e1daff07b2f35197abb977437cbb317097423f6f (diff) | |
download | pfsense-e44e5f3a79aba14a054f351178030fc87b1f4771.zip pfsense-e44e5f3a79aba14a054f351178030fc87b1f4771.tar.gz |
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.
Diffstat (limited to 'usr/local/www/pkg_mgr.php')
-rwxr-xr-x | usr/local/www/pkg_mgr.php | 36 |
1 files 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"); <tr> <td> <?php - $version = file_get_contents("/etc/version"); - $dash = strpos($version, "."); - $hyphen = strpos($version, "-"); - $major = substr($version, 0, $dash); - $minor = substr($version, $dash + 1, $hyphen - $dash - 1); - $testing_version = substr($version, $hyphen + 1, strlen($version) - $hyphen); + $version = rtrim(file_get_contents("/etc/version")); $tab_array = array(); $tab_array[] = array(gettext("Available Packages"), $requested_version <> "" ? false : true, "pkg_mgr.php"); @@ -113,9 +108,6 @@ include("head.inc"); if(!$pkg_info) { echo "<tr><td colspan=\"5\"><center>" . gettext("There are currently no packages available for installation.") . "</td></tr>"; } 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; ?> <tr valign="top"> <td class="listlr"> |