summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/pkg-utils.inc60
1 files changed, 38 insertions, 22 deletions
diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc
index 87dd0ae..a7e8cc0 100644
--- a/etc/inc/pkg-utils.inc
+++ b/etc/inc/pkg-utils.inc
@@ -440,9 +440,9 @@ function sync_package($pkg_name, $sync_depends = true, $show_message = false) {
if(empty($config['installedpackages']['package'][$pkg_id]))
return; // No package belongs to the pkg_id passed to this function.
}
- if (is_array($config['installedpackages']['package'][$pkg_id]))
+ if (is_array($config['installedpackages']['package'][$pkg_id]))
$package =& $config['installedpackages']['package'][$pkg_id];
- else
+ else
return; /* empty package tag */
if(!file_exists("/usr/local/pkg/" . $package['configurationfile'])) {
log_error(sprintf(gettext("The %s package is missing its configuration file and must be reinstalled."), $package['name']));
@@ -587,7 +587,7 @@ function pkg_fetch_recursive($pkgname, $filename, $dependlevel = 0, $base_url =
return true;
}
-function install_package($package, $pkg_info = "") {
+function install_package($package, $pkg_info = "", $force_install = false) {
global $g, $config, $static_output, $pkg_interface;
/* safe side. Write config below will send to ro again. */
@@ -604,6 +604,24 @@ function install_package($package, $pkg_info = "") {
return -1;
}
}
+ if (!$force_install) {
+ $compatible = true;
+ $version = rtrim(file_get_contents("/etc/version"));
+
+ if (isset($pkg_info['required_version']))
+ $compatible = (pfs_version_compare("", $version, $pkg_info['required_version']) >= 0);
+ if (isset($pkg_info['maximum_version']))
+ $compatible = $compatible && (pfs_version_compare("", $version, $pkg_info['maximum_version']) <= 0);
+
+ if (!$compatible) {
+ log_error(sprintf(gettext('Package %s is not supported on this version.'), $pkg_info['name']));
+ $static_output .= sprintf(gettext("Package %s is not supported on this version."), $pkg_info['name']);
+ update_status($static_output);
+
+ conf_mount_ro();
+ return -1;
+ }
+ }
pkg_debug(gettext("Beginning package installation.") . "\n");
log_error(sprintf(gettext('Beginning package installation for %s .'), $pkg_info['name']));
$static_output .= sprintf(gettext("Beginning package installation for %s ."), $pkg_info['name']);
@@ -794,7 +812,7 @@ function install_package_xml($pkg) {
system("/bin/chmod {$pkg_chmod} {$prefix}{$filename}");
}
$static_output = $static_orig;
- update_output_window($static_output);
+ update_output_window($static_output);
}
$static_output .= gettext("done.") . "\n";
update_output_window($static_output);
@@ -1123,7 +1141,7 @@ function delete_package_xml($pkg) {
if($pkg_config['include_file'] <> "") {
$static_output .= gettext("Removing package instructions...");
update_output_window($static_output);
- pkg_debug(sprintf(gettext("Remove '%s'"), $pkg_config['include_file']) . "\n");
+ pkg_debug(sprintf(gettext("Remove '%s'"), $pkg_config['include_file']) . "\n");
unlink_if_exists("/usr/local/pkg/" . $pkg_config['include_file']);
$static_output .= gettext("done.") . "\n";
update_output_window($static_output);
@@ -1245,31 +1263,29 @@ function pkg_reinstall_all() {
global $g, $config;
@unlink('/conf/needs_package_sync');
- $pkg_id = 0;
- $todo = array();
- if (is_array($config['installedpackages']['package']))
+ if (is_array($config['installedpackages']['package'])) {
+ echo "One moment please, reinstalling packages...\n";
+ echo " >>> Trying to fetch package info...";
+ $pkg_info = get_pkg_info();
+ if ($pkg_info) {
+ echo " Done.\n";
+ } else {
+ $xmlrpc_base_url = isset($config['system']['altpkgrepo']['enable']) ? $config['system']['altpkgrepo']['xmlrpcbaseurl'] : $g['xmlrpcbaseurl'];
+ echo "\n" . sprintf(gettext(' >>> Unable to communicate with %1$s. Please verify DNS and interface configuration, and that %2$s has functional Internet connectivity.'), $xmlrpc_base_url, $g['product_name']) . "\n";
+ return;
+ }
+ $todo = array();
foreach($config['installedpackages']['package'] as $package)
$todo[] = array('name' => $package['name'], 'version' => $package['version']);
- echo "One moment please, reinstalling packages...\n";
- echo " >>> Trying to fetch package info...";
- $pkg_info = get_pkg_info();
- if ($pkg_info) {
- echo " Done.\n";
- } else {
- $xmlrpc_base_url = isset($config['system']['altpkgrepo']['enable']) ? $config['system']['altpkgrepo']['xmlrpcbaseurl'] : $g['xmlrpcbaseurl'];
- echo "\n" . sprintf(gettext(' >>> Unable to communicate with %1$s. Please verify DNS and interface configuration, and that %2$s has functional Internet connectivity.'), $xmlrpc_base_url, $g['product_name']) . "\n";
- return;
- }
- if(is_array($todo)) {
foreach($todo as $pkgtodo) {
$static_output = "";
if($pkgtodo['name']) {
uninstall_package($pkgtodo['name']);
install_package($pkgtodo['name']);
- $pkg_id++;
}
}
- }
+ } else
+ echo "No packages are installed.";
}
function stop_packages() {
@@ -1317,4 +1333,4 @@ function stop_packages() {
}
}
-?>
+?> \ No newline at end of file
OpenPOWER on IntegriCloud