summaryrefslogtreecommitdiffstats
path: root/perl-install/fsedit.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/fsedit.pm')
-rw-r--r--perl-install/fsedit.pm130
1 files changed, 51 insertions, 79 deletions
diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm
index dec35b258..ebae53669 100644
--- a/perl-install/fsedit.pm
+++ b/perl-install/fsedit.pm
@@ -20,14 +20,14 @@ use log;
#- Globals
#-#####################################################################################
my @suggestions = (
- { mntpoint => "/boot", minsize => 10 << 11, size => 16 << 11, type => 0x83 },
- { mntpoint => "/", minsize => 50 << 11, size => 100 << 11, type => 0x83 },
- { mntpoint => "swap", minsize => 30 << 11, size => 60 << 11, type => 0x82 },
- { mntpoint => "/usr", minsize => 200 << 11, size => 600 << 11, type => 0x83 },
- { mntpoint => "/home", minsize => 50 << 11, size => 200 << 11, type => 0x83 },
- { mntpoint => "/var", minsize => 200 << 11, size => 250 << 11, type => 0x83 },
- { mntpoint => "/tmp", minsize => 50 << 11, size => 100 << 11, type => 0x83 },
- { mntpoint => "/mnt/iso", minsize => 700 << 11, size => 800 << 11, type => 0x83 },
+ { mntpoint => "/boot", size => 16 << 11, type => 0x83, maxsize => 30 << 11 },
+ { mntpoint => "/", size => 50 << 11, type => 0x83, ratio => 1, maxsize => 300 << 11 },
+ { mntpoint => "swap", size => 30 << 11, type => 0x82, ratio => 1, maxsize => 250 << 11 },
+ { mntpoint => "/usr", size => 200 << 11, type => 0x83, ratio => 6, maxsize =>1500 << 11 },
+ { mntpoint => "/home", size => 50 << 11, type => 0x83, ratio => 3 },
+ { mntpoint => "/var", size => 200 << 11, type => 0x83, ratio => 1, maxsize =>1000 << 11 },
+ { mntpoint => "/tmp", size => 50 << 11, type => 0x83, ratio => 3, maxsize => 500 << 11 },
+ { mntpoint => "/mnt/iso", size => 700 << 11, type => 0x83 },
);
my @suggestions_mntpoints = qw(/mnt/dos);
@@ -44,12 +44,6 @@ sub typeOfPart($) { typeFromMagic(devices::make($_[0]), @partitions_signatures)
#-######################################################################################
#- Functions
#-######################################################################################
-sub suggestions_mntpoint($) {
- my ($hds) = @_;
- sort grep { !/swap/ && !has_mntpoint($_, $hds) }
- (@suggestions_mntpoints, map { $_->{mntpoint} } @suggestions);
-}
-
sub hds($$) {
my ($drives, $flags) = @_;
my @hds;
@@ -94,6 +88,10 @@ sub get_fstab(@) {
map { partition_table::get_normal_parts($_) } @_;
}
+sub free_space(@) {
+ sum map { $_->{size} } map { partition_table::get_holes($_) } @_;
+}
+
sub hasRAID {
my $b = 0;
map { $b ||= isRAID($_) } get_fstab(@_);
@@ -107,30 +105,50 @@ sub get_root($) {
}
sub get_root_ { get_root([ get_fstab(@{$_[0]}) ]) }
+
+sub computeSize($$$$) {
+ my ($part, $best, $hds, $suggestions) = @_;
+ my $max = $part->{maxsize} || $part->{size};
+ my $tot_ratios = sum(map { $_->{ratio} } grep { !has_mntpoint($_->{mntpoint}, $hds) } @$suggestions);
+
+ min($max,
+ $best->{maxsize} || $max,
+ $best->{size}
+ + free_space(@$hds)
+ * ($tot_ratios && $best->{ratio} / $tot_ratios));
+}
+
sub suggest_part($$$;$) {
my ($hd, $part, $hds, $suggestions) = @_;
$suggestions ||= \@suggestions;
- foreach (@$suggestions) { $_->{minsize} ||= $_->{size} }
my $has_swap = grep { isSwap($_) } get_fstab(@$hds);
my ($best, $second) =
- grep { $part->{size} >= $_->{minsize} }
- grep { ! has_mntpoint($_->{mntpoint}, $hds) || isSwap($_) && !$has_swap }
+ grep { !$_->{maxsize} || $part->{size} <= $_->{maxsize} }
+ grep { $_->{size} <= ($part->{maxsize} || $part->{size}) }
+ grep { !has_mntpoint($_->{mntpoint}, $hds) || isSwap($_) && !$has_swap }
+ grep { !$part->{type} || $part->{type} == $_->{type} }
@$suggestions or return;
$best = $second if
$best->{mntpoint} eq '/boot' &&
- $part->{start} + $best->{minsize} > 1024 * partition_table::cylinder_size($hd); #- if the empty slot is beyond the 1024th cylinder, no use having /boot
+ $part->{start} + $best->{size} > 1024 * partition_table::cylinder_size($hd); #- if the empty slot is beyond the 1024th cylinder, no use having /boot
defined $best or return; #- sorry no suggestion :(
$part->{mntpoint} = $best->{mntpoint};
$part->{type} = $best->{type};
- $part->{size} = min($part->{size}, $best->{size});
+ $part->{size} = computeSize($part, $best, $hds, $suggestions);
+ print "<<<<$part->{size}, $part->{maxsize}\n";
1;
}
+sub suggestions_mntpoint($) {
+ my ($hds) = @_;
+ sort grep { !/swap/ && !has_mntpoint($_, $hds) }
+ (@suggestions_mntpoints, map { $_->{mntpoint} } @suggestions);
+}
#-sub partitionDrives {
#-
@@ -183,78 +201,32 @@ sub add($$$;$) {
($part->{mntpoint} = 'swap') :
$options->{force} || check_mntpoint($part->{mntpoint}, $hd, $part, $hds);
+ delete $part->{maxsize};
partition_table::add($hd, $part, $options->{primaryOrExtended});
}
-sub removeFromList($$$) {
- my ($start, $end, $list) = @_;
- my $err = "error in removeFromList: removing an non-free block";
-
- for (my $i = 0; $i < @$list; $i += 2) {
- $start < $list->[$i] and die $err;
- $start > $list->[$i + 1] and next;
-
- if ($start == $list->[$i]) {
- $end > $list->[$i + 1] and die $err;
- if ($end == $list->[$i + 1]) {
- #- the free block is just the same size, removing it
- splice(@$list, $i, 2);
- } else {
- #- the free block now start just after this block
- $list->[$i] = $end;
- }
- } else {
- $end <= $list->[$i + 1] or die $err;
- if ($end < $list->[$i + 1]) {
- splice(@$list, $i + 2, 0, $end, $list->[$i + 1]);
- }
- $list->[$i + 1] = $start; #- shorten the free block
- }
- return;
- }
-}
-
-
sub allocatePartitions($$) {
my ($hds, $to_add) = @_;
- my %free_sectors = map { $_->{device} => [1, $_->{totalsectors} ] } @$hds; #- first sector is always occupied by the MBR
- my $remove = sub { removeFromList($_[0]{start}, $_[0]->{start} + $_[0]->{size}, $free_sectors{$_[0]->{rootDevice}}) };
- my $success = 0;
-
- foreach (get_fstab(@$hds)) { &$remove($_); }
- FSTAB: foreach (@$to_add) {
- my %e = %$_;
- foreach my $hd (@$hds) {
- my $v = $free_sectors{$hd->{device}};
- for (my $i = 0; $i < @$v; $i += 2) {
- my $size = $v->[$i + 1] - $v->[$i];
- $e{size} > $size and next;
-
- if ($v->[$i] + $e{size} > 1024 * partition_table::cylinder_size($hd)) {
- next if $e{mntpoint} eq "/boot" ||
- $e{mntpoint} eq "/" && !has_mntpoint("/boot", $hds);
- }
- $e{start} = $v->[$i];
- $e{rootDevice} = $hd->{device};
- partition_table::adjustStartAndEnd($hd, \%e);
- &$remove(\%e);
- partition_table::add($hd, \%e);
- $success++;
- next FSTAB;
+ foreach my $hd (@$hds) {
+ foreach (partition_table::get_holes($hd)) {
+ my ($start, $size) = @$_{"start", "size"};
+ my $part;
+ while (suggest_part($hd,
+ $part = { start => $start, size => 0, maxsize => $size },
+ $hds, $to_add)) {
+ add($hd, $part, $hds);
+ $start = $part->{start} + $part->{size};
+ $size -= $part->{size};
}
+ $start = $_->{start} + $_->{size};
}
- log::ld("can't allocate partition $e{mntpoint} of size $e{size}, not enough room");
}
- $success;
}
sub auto_allocate($;$) {
- my ($hds, $suggestions) = @_;
- allocatePartitions($hds, [
- grep { ! has_mntpoint($_->{mntpoint}, $hds) }
- @{ $suggestions || \@suggestions }
- ]);
+ my ($hds, $suggestions) = @_;
+ allocatePartitions($hds, $suggestions || \@suggestions);
map { partition_table::assign_device_numbers($_) } @$hds;
}
a id='n519' href='#n519'>519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058
package Rpmdrake::gui;
#*****************************************************************************
#
#  Copyright (c) 2002 Guillaume Cottenceau
#  Copyright (c) 2002-2007 Thierry Vignaud <tvignaud@mandriva.com>
#  Copyright (c) 2003, 2004, 2005 MandrakeSoft SA
#  Copyright (c) 2005-2007 Mandriva SA
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License version 2, as
#  published by the Free Software Foundation.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#*****************************************************************************
#
# $Id$

use strict;
our @ISA = qw(Exporter);
use lib qw(/usr/lib/libDrakX);

use common;
use mygtk2 qw(gtknew); #- do not import gtkadd which conflicts with ugtk2 version

use ugtk2 qw(:helpers :wrappers);
use rpmdrake;
use Rpmdrake::open_db;
use Rpmdrake::formatting;
use Rpmdrake::init;
use Rpmdrake::icon;
use Rpmdrake::pkg;
use Rpmdrake::icon;
use feature 'state';

our @EXPORT = qw(
                    $descriptions
                    $find_entry
                    $force_displaying_group
                    $force_rebuild
                    $pkgs
                    $results_ok
                    $results_none
                    $size_free
                    $size_selected
                    $urpm
                    %grp_columns
                    %pkg_columns
                    @filtered_pkgs
                    @initial_selection
                    ask_browse_tree_given_widgets_for_rpmdrake
                    build_tree
                    callback_choices
                    compute_main_window_size
                    do_action
                    get_info
                    get_summary
                    is_locale_available
                    node_state
                    pkgs_provider
                    real_quit
                    reset_search
                    set_node_state
                    sort_callback
                    switch_pkg_list_mode
                    toggle_all
                    toggle_nodes
            );

our ($descriptions, %filters, @filtered_pkgs, %filter_methods, $force_displaying_group, $force_rebuild, @initial_selection, $pkgs, $size_free, $size_selected, $urpm);
our ($results_ok, $results_none) = (N("Search results"), N("Search results (none)"));

our %grp_columns = (
    label => 0,
    icon => 2,
);

our %pkg_columns = (
    text => 0,
    state_icon => 1,
    state => 2,
    selected => 3,
    short_name => 4,
    version => 5,
    release => 6,
    'arch' => 7,
    selectable => 8,
);


sub compute_main_window_size {
    my ($w) = @_;
    ($typical_width) = string_size($w->{real_window}, translate("Graphical Environment") . "xmms-more-vis-plugins");
    $typical_width > 600 and $typical_width = 600;  #- try to not being crazy with a too large value
    $typical_width < 150 and $typical_width = 150;
}

sub get_summary {
    my ($key) = @_;
    $pkgs->{$key}{summary} ||= $pkgs->{$key}{pkg}->summary;
    my $summary = translate($pkgs->{$key}{summary});
    utf8::valid($summary) ? $summary : ();
}

sub build_expander {
    my ($pkg, $label, $type, $get_data, $o_installed_version) = @_;
    my $textview;
    gtkadd(
        gtkshow(my $exp = gtksignal_connect(
            Gtk2::Expander->new(format_field($label)),
            activate => sub {
                state $first;
                return if $first;
                $first = 1;
                slow_func($::main_window->window, sub {
                              extract_header($pkg, $urpm, $type, $o_installed_version);
                              gtktext_insert($textview, $get_data->() || [ [  N("(Not available)") ] ]);
                          });
            })),
        $textview = gtknew('TextView')
    );
    $exp->set_use_markup(1);
    $exp;
}


sub get_advisory_link {
    my ($update_descr) = @_;
    my $link = gtkshow(Gtk2::LinkButton->new($update_descr->{URL}, N("Security advisory")));
    $link->set_uri_hook(\&run_help_callback);
    [ $link ];
}

sub get_description {
    my ($pkg, $update_descr) = @_;
    @{ ugtk2::markup_to_TextView_format(join("\n",
                                             (eval {
                                                 escape_text_for_TextView_markup_format(
                                                     $pkg->{description}
                                                       || $update_descr->{description});
                                             } || '<i>' . N("No description") . '</i>')
                                         )) };
}

sub get_string_from_keywords {
    my ($medium) = @_;
    return if !$medium->{mediacfg};
    my ($distribconf, $medium_name) = @{$medium->{mediacfg}};

    return if !$distribconf;

    my @media_types = split(':', $distribconf->getvalue($medium_name, 'media_type'));

    my $unsupported = N("It is <b>not supported</b> by Mageia.");
    my $dangerous = N("It may <b>break</b> your system.");
    my $s;
    $s .= N("This package is not free software") . "\n" if member('non-free', @media_types);
    if (member('backport', @media_types)) {
        return join("\n",
                    N("This package contains a new version that was backported."),
                    $unsupported, $dangerous, $s);
    } elsif (member('testing', @media_types)) {
        return join("\n",
                    N("This package is a potential candidate for an update."),
                    $unsupported, $dangerous, $s);
    } elsif (member('updates', @media_types)) {
        return join("\n",
                    (member('official', @media_types) ?
                       N("This is an official update which is supported by Mageia.")
                       : (N("This is an unofficial update."), $unsupported))
                    ,
                    $s);
    } else {
        $s .= N("This is an official package supported by Mageia") . "\n" if member('official', @media_types);
        return $s;
    }
}

sub get_main_text {
    my ($medium, $name, $summary, $is_update, $update_descr) = @_;

    my $txt = get_string_from_keywords($medium);
 
    ugtk2::markup_to_TextView_format(
        # force align "name - summary" to the right with RTL languages (#33603):
        if_(lang::text_direction_rtl(), "\x{200f}") .
          join("\n",
               format_header(join(' - ', $name, $summary)) .
                 # workaround gtk+ bug where GtkTextView wronly limit embedded widget size to bigger line's width (#25533):
                 "\x{200b} \x{feff}" . ' ' x 120,
               if_($txt, format_field(N("Notice: ")) . $txt),
               if_($is_update, # is it an update?
                   format_field(N("Importance: ")) . format_update_field($update_descr->{importance}),
                   format_field(N("Reason for update: ")) . format_update_field(rpm_description($update_descr->{pre})),
               ),
               ''  # extra empty line
           ));
}

sub get_details {
    my ($key, $pkg, $upkg, $installed_version, $raw_medium) = @_;
    my (undef, $version, $release) = split_fullname($key);
    my $a = ugtk2::markup_to_TextView_format(
        $spacing . join("\n$spacing",
                        format_field(N("Version: ")) . $version . '-' . $release,
                        ($upkg->flag_installed ?
                           format_field(N("Currently installed version: ")) . $installed_version : ()
                        ),
                        format_field(N("Group: ")) . translate_group($upkg->group),
                        format_field(N("Architecture: ")) . $upkg->arch,
                        format_field(N("Size: ")) . N("%s KB", int($upkg->size/1024)),
                        eval { format_field(N("Medium: ")) . $raw_medium->{name} },
                    ),
    );
    my @link = get_url_link($upkg, $pkg);
    push @$a, @link if @link;
    $a;
}

sub get_new_deps {
    my ($urpm, $upkg) = @_;
    my $deps_textview;
    my @a = [ gtkadd(
        gtksignal_connect(
            gtkshow(my $dependencies = Gtk2::Expander->new(format_field(N("New dependencies:")))), 
            activate => sub { 
                slow_func($::main_window->window, sub {
                              my $state = {};
                              my @requested = $urpm->resolve_requested(
                                  open_rpm_db(), $state,
                                  { $upkg->id => 1 },
                              );
                              $urpm->disable_selected(open_rpm_db(), $state, @requested);
                              my @nodes_with_deps = map { urpm_name($_) } @requested;
                              my @deps = sort { $a cmp $b } difference2(\@nodes_with_deps, [ urpm_name($upkg) ]);
                              @deps = N("No non installed dependency.") if !@deps;
                              gtktext_insert($deps_textview, join("\n", @deps));
                          });
            }
        ),
        $deps_textview = gtknew('TextView')
    ) ];
    $dependencies->set_use_markup(1);
    @a;
}

sub get_url_link {
    my ($upkg, $pkg) = @_;

    my $url = $upkg->url || $pkg->{url};

    if (!$url) {
        open_rpm_db()->traverse_tag('name', [ $upkg->name ], sub { $url = $_[0]->url });
    }

    return if !$url;

    my @a =
      (@{ ugtk2::markup_to_TextView_format(format_field("\n$spacing" . N("URL: "))) },
        [ my $link = gtkshow(Gtk2::LinkButton->new($url, $url)) ]);
    $link->set_uri_hook(\&run_help_callback);
    @a;
}

sub files_format {
    my ($files) = @_;
    ugtk2::markup_to_TextView_format(
        '<tt>' . $spacing #- to highlight information
          . join("\n$spacing", map { "\x{200e}$_" } @$files)
            . '</tt>');
}

sub format_pkg_simplifiedinfo {
    my ($pkgs, $key, $urpm, $descriptions) = @_;
    my ($name) = split_fullname($key);
    my $pkg = $pkgs->{$key};
    my $upkg = $pkg->{pkg};
    return if !$upkg;
    my $raw_medium = pkg2medium($upkg, $urpm);
    my $medium = !$raw_medium->{fake} ? $raw_medium->{name} : undef;
    my $update_descr = $descriptions->{$medium}{$name};
    # discard update fields if not matching:
    my $is_update = ($upkg->flag_upgrade && $update_descr && $update_descr->{pre});
    my $summary = get_summary($key);
    my $s = get_main_text($raw_medium, $name, $summary, $is_update, $update_descr);
    push @$s, get_advisory_link($update_descr) if $is_update;

    push @$s, get_description($pkg, $update_descr);
    push @$s, [ "\n" ];
    my $installed_version = eval { find_installed_version($upkg) };

    push @$s, [ gtkadd(gtkshow(my $details_exp = Gtk2::Expander->new(format_field(N("Details:")))),
                       gtknew('TextView', text => get_details($key, $pkg, $upkg, $installed_version, $raw_medium))) ];
    $details_exp->set_use_markup(1);
    push @$s, [ "\n\n" ];
    push @$s, [ build_expander($pkg, N("Files:"), 'files', sub { files_format($pkg->{files}) }) ];
    push @$s, [ "\n\n" ];
    push @$s, [ build_expander($pkg, N("Changelog:"), 'changelog',  sub { $pkg->{changelog} }, $installed_version) ];

    push @$s, [ "\n\n" ];
    if ($upkg->id) { # If not installed
        push @$s, get_new_deps($urpm, $upkg);
    }
    $s;
}

sub format_pkg_info {
    my ($pkgs, $key, $urpm, $descriptions) = @_;
    my $pkg = $pkgs->{$key};
    my $upkg = $pkg->{pkg};
    my ($name, $version) = split_fullname($key);
    my @files = (
	format_field(N("Files:\n")),
	exists $pkg->{files}
	    ? '<tt>' . join("\n", map { "\x{200e}$_" } @{$pkg->{files}}) . '</tt>' #- to highlight information
	    : N("(Not available)"),
    );
    my @chglo = (format_field(N("Changelog:\n")), ($pkg->{changelog} ? @{$pkg->{changelog}} : N("(Not available)")));
    my @source_info = (
	$MODE eq 'remove' || !@$max_info_in_descr
	    ? ()
	    : (
		format_field(N("Medium: ")) . pkg2medium($upkg, $urpm)->{name},
		format_field(N("Currently installed version: ")) . find_installed_version($upkg),
	    )
    );
    my @max_info = @$max_info_in_descr && $changelog_first ? (@chglo, @files) : (@files, '', @chglo);
    ugtk2::markup_to_TextView_format(join("\n", format_field(N("Name: ")) . $name,
      format_field(N("Version: ")) . $version,
      format_field(N("Architecture: ")) . $upkg->arch,
      format_field(N("Size: ")) . N("%s KB", int($upkg->size/1024)),
      if_(
	  $MODE eq 'update',
	  format_field(N("Importance: ")) . $descriptions->{$name}{importance}
      ),
      @source_info,
      '', # extra empty line
      format_field(N("Summary: ")) . $pkg->{summary},
      '', # extra empty line
      if_(
	  $MODE eq 'update',
	  format_field(N("Reason for update: ")) . rpm_description($descriptions->{$name}{pre}),
      ),
      format_field(N("Description: ")), ($pkg->{description} || $descriptions->{$name}{description} || N("No description")),
      @max_info,
    ));
}

sub node_state {
    my ($name) = @_;
    return if !$name;
    my $pkg = $pkgs->{$name};
    my $urpm_obj = $pkg->{pkg};
    if (!$urpm_obj) {
        my ($short_name) = split_fullname($name);
        state $warned;
        if (!$warned) {
            $warned = 1;
            interactive_msg(N("Warning"),
                        join("\n",
                             N("The package \"%s\" was found.", $name),
                             N("However this package is not in the package list."),
                             N("You may want to update your urpmi database."),
                             '',
                             N("Matching packages:"),
                             '',
                             join("\n", sort map {
                                 #-PO: this is list fomatting: "- <package_name> (medium: <medium_name>)"
                                 #-PO: eg: "- rpmdrake (medium: "Main Release"
                                 N("- %s (medium: %s)", $_, pkg2medium($pkgs->{$_}{pkg}, $urpm)->{name});
                                 } grep { /^$short_name/ } keys %$pkgs),
                         ),
                        scroll => 1,
                    );
        }
        return 'XXX';
    }