Commit c91cd889 authored by niclone's avatar niclone

[FIX]mods: cleanup informations of what's install/remove will do

parent 40bc7a89
......@@ -689,7 +689,7 @@ class ModsLib {
function find_deps($modspath, $mods_server, $modnames) {
$deps=array("wanted" => array(),
"requires" => array(),
"toinstall" => array(),
"suggests" => array(),
"conflicts" => array(),
"unavailable" => array());
......@@ -710,24 +710,16 @@ class ModsLib {
/* now remove duplicates from suggests */
foreach ($deps['suggests'] as $suggest) {
if (isset($deps['requires'][$suggest[0]->modname]))
if (isset($deps['toinstall'][$suggest[0]->modname]))
unset($deps['suggests'][$suggest[0]->modname]);
}
/* now remove all wanted from requires */
foreach ($deps['wanted'] as $k => $mod) {
if (isset($deps['requires'][$mod->modname])) {
$deps['wanted'][$k]=$deps['requires'][$mod->modname];
unset($deps['requires'][$mod->modname]);
}
}
/* now search conflicts from the requireds */
foreach ($deps['requires'] as $mod) {
foreach ($deps['toinstall'] as $mod) {
if (!is_array($mod->conflicts)) continue;
foreach($mod->conflicts as $moddep) {
/* compare required conflicts with requireds */
foreach($deps['requires'] as $dep) {
foreach($deps['toinstall'] as $dep) {
if ($moddep->isitin($dep)) {
if (!isset($deps['conflicts'][$dep->modname])) {
$dep->errors[]="1/conflict avec ".$mod->modname;
......@@ -762,7 +754,7 @@ class ModsLib {
if (!is_array($mod->conflicts)) continue;
foreach($mod->conflicts as $moddep) {
/* compare installed with requireds */
foreach($deps['requires'] as $dep) {
foreach($deps['toinstall'] as $dep) {
if ($moddep->isitin($dep)) {
if (!isset($deps['conflicts'][$dep->modname])) {
$mod->errors[]="5/conflict avec ".$dep->modname;
......@@ -789,9 +781,9 @@ class ModsLib {
$deps['unavailable'][]=$moddep;
} else {
if ($mod->repository == 'installed') continue;
if (isset($deps['requires'][$mod->modname])) {
if ($mod->isnewer($deps['requires'][$mod->modname])) {
// if there is an older version in the deps['requires'],
if (isset($deps['toinstall'][$mod->modname])) {
if ($mod->isnewer($deps['toinstall'][$mod->modname])) {
// if there is an older version in the deps['toinstall'],
// this is because a previous requires was requiring
// an older one. So we don't try to upgrade it, we
// just try to see if it is compatible with this require.
......@@ -806,7 +798,7 @@ class ModsLib {
// not newer, let it
}
} else {
$deps['requires'][$mod->modname]=$mod;
$deps['toinstall'][$mod->modname]=$mod;
$this->_find_deps($repos, $mod, &$deps);
}
}
......@@ -860,14 +852,7 @@ class ModsLib {
/* download packages if necessary */
foreach($deps['requires'] as $mod) {
if ($mod->repository == 'remote') {
$res=$this->dl_remote($mods_server,$mod->modname.'-'.$mod->revision,$modspath);
if ($res === false) return false;
}
}
foreach($deps['wanted'] as $mod) {
foreach($deps['toinstall'] as $mod) {
if ($mod->repository == 'remote') {
$res=$this->dl_remote($mods_server,$mod->modname.'-'.$mod->revision,$modspath);
if ($res === false) return false;
......@@ -879,11 +864,7 @@ class ModsLib {
/* install packages */
foreach($deps['requires'] as $mod) {
$this->install($modspath, $mod);
}
foreach($deps['wanted'] as $mod) {
foreach($deps['toinstall'] as $mod) {
$this->install($modspath, $mod);
}
......
......@@ -75,14 +75,21 @@ function command_install($goption, $coption, $cparams) {
}
failure($err);
}
if (count($deps['conflicts'])) {
$err="Sorry, theses packages are required but conflicts:\n";
foreach ($deps['conflicts'] as $mod) {
$err.=" - ".$mod->modname."\n";
}
failure($err);
}
if (count($deps['wanted'])) {
echo "The following packages will be installed:\n";
echo "You asked to install these mods:\n";
foreach ($deps['wanted'] as $mod) {
echo " ".$mod->modname." (".$mod->revision.")\n";
}
}
if (count($deps['requires'])) {
echo "The following extra packages will be installed:\n";
echo "The following packages will be installed:\n";
foreach ($deps['requires'] as $mod) {
echo " ".$mod->modname." (".$mod->revision.")\n";
}
......@@ -111,13 +118,13 @@ function command_remove($goption, $coption, $cparams) {
$deps=$modslib->find_deps_remove($mods_dir, $mods_server, $cparams);
if (count($deps['wantedtoremove'])) {
echo "The following packages will be REMOVED:\n";
echo "You asked to remove these mods:\n";
foreach ($deps['wantedtoremove'] as $mod) {
echo " ".$mod->modname." (".$mod->revision.")\n";
}
}
if (count($deps['toremove'])) {
echo "The following extra packages will be REMOVED:\n";
echo "The following packages will be REMOVED:\n";
foreach ($deps['toremove'] as $mod) {
echo " ".$mod->modname." (".$mod->revision.")\n";
}
......
......@@ -35,6 +35,31 @@ permission (using "./fixperms fix").{/tr}</div>
<form method='post' action='?'>
<div class="simplebox">
<ul>
{if $installask.wanted}
<li>You asked to install these mods:
<ul>{foreach from=$installask.wanted item=element}
{if $element->repository eq 'unavailable'}
<li>{$element->name|escape} ({$element->type|escape}) but is not in any repository</li>
{else}
<li><input type='checkbox' onchange='update_button_install();' name='install-wants[]' value='{$element->modname|escape}' checked />{$element->name|escape} {$element->revision} ({$element->type|escape})</li>
{/if}
{if $element->repository eq 'remote'}
(will be downloaded)
{/if}
{/foreach}</ul>
</li>
{/if}
{if $installask.wantedtoremove}
<li>You asked to <strong>remove</strong> these mods:
<ul>{foreach from=$installask.wantedtoremove item=element}
{if $element->repository eq 'installed'}
<li><input type='checkbox' onchange='update_button_install();' name='install-wants[]' value='{$element->modname|escape}' checked />{$element->name|escape} {$element->revision} ({$element->type|escape})</li>
{else}
<li>{$element->name|escape} ({$element->type|escape}) but is not installed</li>
{/if}
{/foreach}</ul>
</li>
{/if}
{if $installask.unavailable}
<li style='color:#990000'>The following packages are required, but cannot be installed:
<ul>{foreach from=$installask.unavailable item=element}
......@@ -61,41 +86,16 @@ permission (using "./fixperms fix").{/tr}</div>
</li>
{/foreach}</ul>
{/if}
{if $installask.wanted}
<li>The following packages will be <strong>installed</strong>:
<ul>{foreach from=$installask.wanted item=element}
{if $element->repository eq 'unavailable'}
<li>{$element->name|escape} ({$element->type|escape}) but is not in any repository</li>
{else}
<li><input type='checkbox' onchange='update_button_install();' name='install-wants[]' value='{$element->modname|escape}' checked />{$element->name|escape} {$element->revision} ({$element->type|escape})</li>
{/if}
{if $element->repository eq 'remote'}
(will be downloaded)
{/if}
{/foreach}</ul>
</li>
{/if}
{if $installask.wantedtoremove}
<li>The following packages will be <strong>removed</strong>:
<ul>{foreach from=$installask.wantedtoremove item=element}
{if $element->repository eq 'installed'}
<li><input type='checkbox' onchange='update_button_install();' name='install-wants[]' value='{$element->modname|escape}' checked />{$element->name|escape} {$element->revision} ({$element->type|escape})</li>
{else}
<li>{$element->name|escape} ({$element->type|escape}) but is not installed</li>
{/if}
{/foreach}</ul>
</li>
{/if}
{if $installask.toremove}
<li>The following <strong>extra</strong> packages will be <strong>removed</strong>:
<li>The following mods will be <strong>removed</strong>:
<ul>{foreach from=$installask.toremove item=element}
<li>{$element->name|escape} {$element->revision} ({$element->type|escape})</li>
{/foreach}</ul>
</li>
{/if}
{if $installask.requires}
<li>The following <strong>extra</strong> packages will be <strong>installed</strong>:
<ul>{foreach from=$installask.requires item=element}
{if $installask.toinstall}
<li>The following mods will be <strong>installed</strong>:
<ul>{foreach from=$installask.toinstall item=element}
{if $element->repository eq 'unavailable'}
<li>{$element->name|escape} ({$element->type|escape}) but is not in any repository</li>
{else}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment