From 80db1d67a846ad663ab680a77950129b5df8dfcf Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Tue, 20 Oct 2015 17:36:48 -0200 Subject: Use information from pkg to show installed packages --- src/usr/local/www/pkg_mgr_installed.php | 64 ++++++++++++++------------------- 1 file changed, 27 insertions(+), 37 deletions(-) (limited to 'src/usr/local/www/pkg_mgr_installed.php') diff --git a/src/usr/local/www/pkg_mgr_installed.php b/src/usr/local/www/pkg_mgr_installed.php index 45b56e3..93434c8 100644 --- a/src/usr/local/www/pkg_mgr_installed.php +++ b/src/usr/local/www/pkg_mgr_installed.php @@ -86,14 +86,6 @@ if (is_subsystem_dirty('packagelock')) { include("head.inc"); -if(is_array($config['installedpackages']['package'])) { - $tocheck = array(); - foreach($config['installedpackages']['package'] as $instpkg) { - $tocheck[] = $g['pkg_prefix'] . get_package_internal_name($instpkg); - } - - $current_info = get_pkg_info($tocheck); -} $closehead = false; $pgtitle = array(gettext("System"), gettext("Package Manager")); @@ -102,7 +94,16 @@ $tab_array[] = array(gettext("Available Packages"), false, "pkg_mgr.php"); $tab_array[] = array(gettext("Installed Packages"), true, "pkg_mgr_installed.php"); display_top_tabs($tab_array); -if(!is_array($config['installedpackages']['package'])):?> +$installed_packages = array(); +$package_list = get_pkg_info(); +foreach ($package_list as $pkg) { + if (!isset($pkg['installed'])) { + continue; + } + $installed_packages[] = $pkg; +} + +if(empty($installed_packages)):?>
@@ -121,44 +122,33 @@ if(!is_array($config['installedpackages']['package'])):?> $pkgname): - $pkg = $config['installedpackages']['package'][$index]; + foreach ($installed_packages as $pkg): if(!$pkg['name']) { continue; } - $full_name = $g['pkg_prefix'] . get_package_internal_name($pkg); + $shortname = $pkg['name']; + pkg_remove_prefix($shortname); - unset($latest_package); - foreach ($current_info as $pkg_info) { - if ($full_name != $pkg_info['name']) { - continue; - } + $id = get_package_id($shortname); - $latest_package = $pkg_info['version']; - $pkgdescr = $pkg_info['desc']; - $pkgwww = $pkg_info['www']; + if ($id == -1) { + continue; } // get history/changelog git dir - $commit_dir=explode("/",$pkg['config_file']); + $commit_dir=explode("/",$config['installedpackages']['package'][$id]['config_file']); $changeloglink ="https://github.com/pfsense/pfsense-packages/commits/master/config/".$commit_dir[(count($commit_dir)-2)]; #check package version - if (isset($latest_package)) { - $version_compare = pkg_version_compare($pkg['version'], $latest_package); + if (isset($pkg['installed_version']) && isset($pkg['version'])) { + $version_compare = pkg_version_compare($pkg['version'], $pkg['installed_version']); if ($version_compare == '>') { // we're running a newer version of the package - $status = 'Newer then available ('. $latest_package .')'; + $status = 'Newer then available ('. $pkg['version'] .')'; $statusicon = 'exclamation'; } else if ($version_compare == '<') { // we're running an older version of the package - $status = 'Upgrade available to '.$latest_package; + $status = 'Upgrade available to '.$pkg['version']; $statusicon = 'plus'; } else if ($version_compare == '=') { // we're running the current version @@ -181,7 +171,7 @@ if(!is_array($config['installedpackages']['package'])):?> - + @@ -194,13 +184,13 @@ if(!is_array($config['installedpackages']['package'])):?> - + - Remove - Reinstall - - " href="" class="btn btn-info btn-xs">Info + Remove + Reinstall + + " href="" class="btn btn-info btn-xs">Info -- cgit v1.1