summaryrefslogtreecommitdiffstats
path: root/move/tools
ModeNameSize
-rwxr-xr-xbusy-files590logstatsplain
-rw-r--r--busy-files-accesses948logstatsplain
-rw-r--r--check-fc-cache.pl724logstatsplain
-rwxr-xr-xfix-fc-cache.pl525logstatsplain
-rw-r--r--kernel-nfsd.patch1616logstatsplain
-rwxr-xr-xnfs-accesses1939logstatsplain
-rwxr-xr-xscan-etc.pl1045logstatsplain
234' href='#n234'>234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 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
# vim: set et ts=4 sw=4:
package AdminPanel::Rpmdragora::pkg;
#*****************************************************************************
#
#  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: pkg.pm 270160 2010-06-22 19:55:40Z jvictor $

use strict;
use MDK::Common::Func 'any';
use lib qw(/usr/lib/libDrakX);
use common;
use POSIX qw(_exit);
use URPM;
use utf8;
use AdminPanel::Rpmdragora::open_db;
use AdminPanel::Rpmdragora::gurpm;
use AdminPanel::Rpmdragora::formatting;
use AdminPanel::Rpmdragora::rpmnew;

use AdminPanel::rpmdragora;
use urpm;
use urpm::lock;
use urpm::install;
use urpm::signature;
use urpm::get_pkgs;
use urpm::select;
use urpm::main_loop;
use urpm::args qw();


use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(
                    $priority_up_alread_warned
                    download_callback
                    extract_header
                    find_installed_version
                    get_pkgs
                    perform_installation
                    perform_removal
                    run_rpm
                    sort_packages
                    );

#use mygtk2 qw(gtknew);
#use ugtk2 qw(:all);

our $priority_up_alread_warned;

sub sort_packages_biarch {
    sort {
        my ($na, $aa) = $a =~ /^(.*-[^-]+-[^-]+)\.([^.-]+)$/;
        my ($nb, $ab) = $b =~ /^(.*-[^-]+-[^-]+)\.([^.-]+)$/;
        $na cmp $nb || ($ab =~ /64$/) <=> ($aa =~ /64$/);
    } @_;
}

sub sort_packages_monoarch {
    sort { uc($a) cmp uc($b) } @_;
}

*sort_packages = arch() =~ /x86_64/ ? \&sort_packages_biarch : \&sort_packages_monoarch;

sub run_rpm {
    foreach (qw(LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION LC_ALL)) {
        local $ENV{$_} = $ENV{$_} . '.UTF-8' if $ENV{$_} && $ENV{$_} !~ /UTF-8/;
    }
    my @l = map { ensure_utf8($_); $_ } run_program::get_stdout(@_);
    wantarray() ? @l : join('', @l);
}


sub extract_header {
    my ($pkg, $urpm, $xml_info, $o_installed_version) = @_;
    my %fields = (
        info => 'description',
        files => 'files',
        changelog => 'changelog',
    );
    # already extracted:
    return if $pkg->{$fields{$xml_info}};

    my $p = $pkg->{pkg};

    if (!$p) {
        warn ">> ghost package '$pkg' has no URPM object!!!\n";
        return;
    }

    my $name = $p->fullname;
    # fix extracting info for SRPMS and RPM GPG keys:
    $name =~ s!\.src!!;

    if ($p->flag_installed && !$p->flag_upgrade) {
        my @files = map { chomp_($_) } run_rpm("rpm -ql $name");
	add2hash($pkg, { files => [ @files ? @files : N("(none)") ],
                         description => rpm_description(scalar(run_rpm("rpm -q --qf '%{description}' $name"))),
                         changelog => format_changelog_string($o_installed_version, scalar(run_rpm("rpm -q --changelog $name"))) });
    } else {
	my $medium = pkg2medium($p, $urpm);
        my ($local_source, %xml_info_pkgs, $bar_id);
        my $_statusbar_clean_guard = before_leaving { $bar_id and statusbar_msg_remove($bar_id) };
        my $dir = urpm::file_from_local_url($medium->{url});
        print "p->filename: ". $p->filename."\n";
	    $local_source = "$dir/" . $p->filename if $dir;
        print "local_source: $local_source\n";
        if (-e $local_source) {
            $bar_id = statusbar_msg(N("Getting information from %s...", $dir), 0);
            $urpm->{log}("getting information from rpms from $dir");
        } else {
            my $gurpm;
            $bar_id = statusbar_msg(N("Getting '%s' from XML meta-data...", $xml_info), 0);
            my $_gurpm_clean_guard = before_leaving { undef $gurpm };
                if (my $xml_info_file = eval { urpm::media::any_xml_info($urpm, $medium, $xml_info, undef, sub {
                                                                      $gurpm ||= Rpmdragora::gurpm->new(N("Please wait"),
                                                                                                      '', # FIXME: add a real string after cooker
                                                                                                      transient => $::main_window);
                                                                      download_callback($gurpm, @_)
                                                                        or goto header_non_available;
                                                                  }) }) {
                    require urpm::xml_info;
                    require urpm::xml_info_pkg;
                    $urpm->{log}("getting information from $xml_info_file");
                    my %nodes = eval { urpm::xml_info::get_nodes($xml_info, $xml_info_file, [ $name ]) };
                    goto header_non_available if $@;
                    put_in_hash($xml_info_pkgs{$name} ||= {}, $nodes{$name});
                } else {
                    if ($xml_info eq 'info') {
                        $urpm->{info}(N("No xml info for medium \"%s\", only partial result for package %s", $medium->{name}, $name));
                    } else {
                        $urpm->{error}(N("No xml info for medium \"%s\", unable to return any result for package %s", $medium->{name}, $name));
                    }
                }
	}

        #- even if non-root, search for a header in the global cachedir
        if (-s $local_source) {
            $p->update_header($local_source) or do {
		warn "Warning, could not extract header for $name from $medium!";
		goto header_non_available;
	    };
	    my @files = $p->files;
	    @files = N("(none)") if !@files;
	    add2hash($pkg, { description => rpm_description($p->description),
	        files => \@files,
	        url => $p->url,
		changelog => format_changelog_changelogs($o_installed_version, $p->changelogs) });
	    $p->pack_header; # needed in order to call methods on objects outside ->traverse
        } elsif ($xml_info_pkgs{$name}) {
            if ($xml_info eq 'info') {
                add2hash($pkg, { description => rpm_description($xml_info_pkgs{$name}{description}),
                                 url => $xml_info_pkgs{$name}{url}
                             });
            } elsif ($xml_info eq 'files') {
                my @files = map { chomp_(to_utf8($_)) } split("\n", $xml_info_pkgs{$name}{files});
                add2hash($pkg, { files => [ @files ? @files : N("(none)") ] });
            } elsif ($xml_info eq 'changelog') {
                add2hash($pkg, { 
                    changelog => format_changelog_changelogs($o_installed_version,
                                                             @{$xml_info_pkgs{$name}{changelogs}})
                });
            }
        } else {
            goto header_non_available;
        }
        return;
           header_non_available:
             add2hash($pkg, { summary => $p->summary || N("(Not available)"), description => undef });
    }
}

sub find_installed_version {
    my ($p) = @_;
    my $version;
    open_rpm_db()->traverse_tag_find('name', $p->name, sub { $version = $_[0]->EVR });
    $version || N("(none)");
}

my $canceled;
sub download_callback {
    my ($gurpm, $mode, $file, $percent, $total, $eta, $speed) = @_;
    $canceled = 0;
    if ($mode eq 'start') {
        $gurpm->label(N("Downloading package `%s'...", basename($file)));
        $gurpm->validate_cancel(but(N("Cancel")), sub { $canceled = 1 });
    } elsif ($mode eq 'progress') {
        $gurpm->label(
            join("\n",
                 N("Downloading package `%s'...", basename($file)),
                 (defined $total && defined $eta ?
                    N("        %s%% of %s completed, ETA = %s, speed = %s", $percent, $total, $eta, $speed)
                      : N("        %s%% completed, speed = %s", $percent, $speed)
                  ) =~ /^\s*(.*)/
              ),
        );
	#$gurpm->progress($percenti/100);
        $gurpm->progress($percent);
    } elsif ($mode eq 'end') {
        $gurpm->progress(100);
        $gurpm->invalidate_cancel;
    }
    !$canceled;
}


# -=-=-=---=-=-=---=-=-=-- install packages -=-=-=---=-=-=---=-=-=-

my (@update_medias, $is_update_media_already_asked);

sub warn_about_media {
    my ($w, %options) = @_;

    return if $::MODE ne 'update';
    return if $::rpmdragora_options{'no-media-update'};

    # we use our own instance of the urpmi db in order not to mess up with skip-list managment (#31092):
    # and no need to fully configure urpmi since we may have to do it again anyway because of new media:
    my $urpm = fast_open_urpmi_db();

    my $_lock = urpm::lock::urpmi_db($urpm, undef, wait => $urpm->{options}{wait_lock});

    # build media list:
    @update_medias = get_update_medias($urpm);

    # do not update again media after installing/removing some packages:
    $::rpmdragora_options{'no-media-update'} ||= 1;

	    if (@update_medias > 0) {
		if (!$options{skip_updating_mu} && !$is_update_media_already_asked) {
              $is_update_media_already_asked = 1;
		     $::rpmdragora_options{'no-confirmation'} or interactive_msg(N("Confirmation"),
N("I need to contact the mirror to get latest update packages.
Please check that your network is currently running.

Is it ok to continue?"), yesno => 1,
                   widget =>  gtknew('CheckButton', text => N("Do not ask me next time"),
                                     active_ref => \$::rpmdragora_options{'no-confirmation'}
                                 )) or myexit(-1);
		    writeconf();
		    urpm::media::select_media($urpm, map { $_->{name} } @update_medias);
		    update_sources($urpm, noclean => 1, medialist => [ map { $_->{name} } @update_medias ]);
		}
	    } else {
		if (any { $_->{update} } @{$urpm->{media}}) {
		    interactive_msg(N("Already existing update media"),
N("You already have at least one update medium configured, but
all of them are currently disabled. You should run the Software
Media Manager to enable at least one (check it in the \"%s\"
column).

Then, restart \"%s\".", N("Enabled"), $rpmdragora::myname_update));
		    myexit(-1);
		}
		my ($mirror) = choose_mirror($urpm, transient => $w->{real_window} || $::main_window,
                                       message => join("\n\n",
                                                       N("You have no configured update media. MageiaUpdate cannot operate without any update media."),
                                                       N("I need to contact the Mageia website to get the mirror list.
Please check that your network is currently running.

Is it ok to continue?"),
                                                         ),
                                   );
		my $m = ref($mirror) ? $mirror->{url} : '';
		$m or interactive_msg(N("How to choose manually your mirror"),
N("You may also choose your desired mirror manually: to do so,
launch the Software Media Manager, and then add a `Security
updates' medium.

Then, restart %s.", $rpmdragora::myname_update)), myexit(-1);
		add_distrib_update_media($urpm, $mirror, only_updates => 1);
	    }
}


sub get_parallel_group() {
    $::rpmdragora_options{parallel} ? $::rpmdragora_options{parallel}[0] : undef;
}

my ($count, $level, $limit, $new_stage, $prev_stage, $total);

sub init_progress_bar {
    my ($urpm) = @_;
    undef $_ foreach $count, $prev_stage, $new_stage, $limit;
    $level = 0.05;
    $total = @{$urpm->{depslist}};
}
    
sub reset_pbar_count {
    undef $prev_stage;
    $count = 0;
    $limit = $_[0];
}

sub update_pbar {
    my ($gurpm) = @_;
    return if !$total;          # don't die if there's no source
    $count++;
    $new_stage = $level+($limit-$level)*$count/$total;
    $prev_stage = 0 if(!defined($prev_stage));
    if ($prev_stage + 0.01*100 < $new_stage) {
        $prev_stage = $new_stage;
        $gurpm->progress($new_stage);
    }
}


sub get_installed_packages {
    my ($urpm, $db, $all_pkgs, $gurpm) = @_;

    $urpm->{global_config}{'prohibit-remove'} = '' if(!defined($urpm->{global_config}{'prohibit-remove'}));
    my @base = ("basesystem", split /,\s*/, $urpm->{global_config}{'prohibit-remove'});
    my (%base, %basepackages, @installed_pkgs, @processed_base);
    reset_pbar_count(0.33);
    while (defined(local $_ = shift @base)) {
	exists $basepackages{$_} and next;
	$db->traverse_tag(m|^/| ? 'path' : 'whatprovides', [ $_ ], sub {
			      update_pbar($gurpm);
			      my $name = $_[0]->fullname;
			      # workaround looping in URPM:
			      return if member($name, @processed_base);
			      push @processed_base, $name;
			      push @{$basepackages{$_}}, $name;
			      push @base, $_[0]->requires_nosense;
			  });
    }
    foreach (values %basepackages) {
	my $n = @$_;            #- count number of times it's provided
	foreach (@$_) {
	    $base{$_} = \$n;
	}
    }
    # costly:
    $db->traverse(sub {
                      my ($pkg) = @_;
                      update_pbar($gurpm);
                      my $fullname = urpm_name($pkg);
                      return if $fullname =~ /@/;
                      $all_pkgs->{$fullname} = {
                          pkg => $pkg, urpm_name => $fullname,
                      } if !($all_pkgs->{$fullname} && $all_pkgs->{$fullname}{description});
                      if (my $name = $base{$fullname}) {
                          $all_pkgs->{$fullname}{base} = \$name;
                          $pkg->set_flag_base(1) if $$name == 1;
                      }
                      push @installed_pkgs, $fullname;
                      $pkg->set_flag_installed;
                      $pkg->pack_header; # needed in order to call methods on objects outside ->traverse
                  });
    @installed_pkgs;
}

urpm::select::add_packages_to_priority_upgrade_list('rpmdragora', 'perl-Glib', 'perl-Gtk2');

my ($priority_state, $priority_requested);
our $need_restart;

our $probe_only_for_updates;

sub get_updates_list {
    my ($urpm, $db, $state, $requested, $requested_list, $requested_strict, $all_pkgs, %limit_preselect) = @_;

    $urpm->request_packages_to_upgrade(
	$db,
	$state,
	$requested,
	%limit_preselect
    );

    my %common_opts = (
        callback_choices => \&Rpmdragora::gui::callback_choices,
        priority_upgrade => $urpm->{options}{'priority-upgrade'},
    );

    if ($urpm->{options}{'priority-upgrade'}) {
        $need_restart =
          urpm::select::resolve_priority_upgrades_after_auto_select($urpm, $db, $state,
                                                                    $requested, %common_opts);
    }

    # list of updates (including those matching /etc/urpmi/skip.list):
    @$requested_list = sort map {
	my $name = urpm_name($_);
        $all_pkgs->{$name} = { pkg => $_ };
	$name;
    } @{$urpm->{depslist}}[keys %$requested];

    # list of pure updates (w/o those matching /etc/urpmi/skip.list but with their deps):
    if ($probe_only_for_updates && !$need_restart) {
        @$requested_strict = sort map {
            urpm_name($_);
        } $urpm->resolve_requested($db, $state, $requested, callback_choices => \&Rpmdragora::gui::callback_choices);

        if (my @l = grep { $state->{selected}{$_->id} }
              urpm::select::_priority_upgrade_pkgs($urpm, $urpm->{options}{'priority-upgrade'})) {
            if (!$need_restart) {
                $need_restart =