2 # Do an actual comparison
4 require './cluster-software-lib.pl';
5 &error_setup($text{'compare_err'});
8 # Work out which servers to use
10 @hosts = &list_software_hosts();
13 @allhosts = &list_software_hosts();
14 @servers = &list_servers();
15 @groups = &servers::list_all_groups(\@servers);
16 foreach $s (split(/\0/, $in{'hosts'})) {
17 if ($s =~ /^group_(.*)$/) {
18 # Add all group members
19 ($group) = grep { $_->{'name'} eq $1 } @groups;
20 foreach $m (@{$group->{'members'}}) {
21 ($server) =grep { $_->{'host'} eq $m } @servers;
22 ($host) = grep { $_->{'id'} eq $server->{'id'} } @allhosts;
23 push(@hosts, $host) if ($host);
28 ($host) = grep { $_->{'id'} eq $s } @allhosts;
29 push(@hosts, $host) if ($host);
33 @hosts >= 2 || &error($text{'compare_etwo'});
35 &ui_print_header(undef, $text{'compare_title'}, "");
37 # Find union of all packages
39 foreach $p (@{$h->{'packages'}}) {
41 push(@{$packs{$p->{'name'}}}, $p);
45 # Show results by package
46 %smap = map { $_->{'id'}, $_ } &list_servers();
47 print &ui_columns_start([ $text{'compare_pack'},
48 map { &server_name($smap{$_->{'id'}}) } @hosts ]);
49 foreach $pn (sort { $a cmp $b } (keys %packs)) {
50 local @row = ( "<a href='edit_pack.cgi?package=$pn'>$pn</a>" );
53 local ($ph) = grep { $_->{'host'} eq $h } @{$packs{$pn}};
55 push(@row, $text{'compare_miss'});
59 push(@row, $ph->{'version'} || $text{'compare_got'});
60 if ($ph->{'version'} &&
61 $ph->{'version'} != $packs{$pn}->[0]->{'version'}) {
66 if (!$ok || $in{'showall'}) {
67 print &ui_columns_row(\@row);
70 print &ui_columns_end();
72 &ui_print_footer("", $text{'index_return'});