diff options
author | Thierry Vignaud <tv@mandriva.org> | 2007-02-20 11:47:23 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mandriva.org> | 2007-02-20 11:47:23 +0000 |
commit | 832b42b76e562cca0d4db7c57999ef20f60137f7 (patch) | |
tree | 894b09fbadc6f2785cc8e3d8218d1db828ce9329 /rpmdrake | |
parent | 0d4000656d0c159ef878d899d4f45de5c1c0a1ef (diff) | |
download | rpmdrake-832b42b76e562cca0d4db7c57999ef20f60137f7.tar rpmdrake-832b42b76e562cca0d4db7c57999ef20f60137f7.tar.gz rpmdrake-832b42b76e562cca0d4db7c57999ef20f60137f7.tar.bz2 rpmdrake-832b42b76e562cca0d4db7c57999ef20f60137f7.tar.xz rpmdrake-832b42b76e562cca0d4db7c57999ef20f60137f7.zip |
split out initialization stuff into Rpmdrake::init
Diffstat (limited to 'rpmdrake')
-rwxr-xr-x | rpmdrake | 111 |
1 files changed, 4 insertions, 107 deletions
@@ -30,38 +30,9 @@ use common; use POSIX qw(_exit); use URPM; use utf8; -BEGIN { $::no_global_argv_parsing = 1 } use standalone; -BEGIN { #- we want to run this code before the Gtk->init of the use-my_gtk - my $basename = sub { local $_ = shift; s|/*\s*$||; s|.*/||; $_ }; - any { /^--?h/ } @ARGV and do { - printf join("\n", N("Usage: %s [OPTION]...", $basename->($0)), -N(" --changelog-first display changelog before filelist in the description window"), -N(" --media=medium1,.. limit to given media"), -N(" --merge-all-rpmnew propose to merge all .rpmnew/.rpmsave files found"), -N(" --mode=MODE set mode (install (default), remove, update)"), -N(" --no-confirmation don't ask first confirmation question in update mode"), -N(" --no-media-update don't update media at startup"), -N(" --no-verify-rpm don't verify packages signatures"), -N(" --parallel=alias,host be in parallel mode, use \"alias\" group, use \"host\" machine to show needed deps"), -N(" --pkg-nosel=pkg1,.. show only these packages"), -N(" --pkg-sel=pkg1,.. preselect these packages"), -N(" --root force to run as root"), -N(" --search=pkg run search for \"pkg\""), -"" -); - exit 0; - }; -} - -BEGIN { #- for mcc - if ("@ARGV" =~ /--embedded (\w+)/) { - $::XID = $1; - $::isEmbedded = 1; - } -} - +use Rpmdrake::init; use rpmdrake; use Rpmdrake::rpmnew; use Rpmdrake::formatting; @@ -69,58 +40,13 @@ use Rpmdrake::pkg; use urpm::media; use urpm::select; -#- This is needed because text printed by Gtk2 will always be encoded -#- in UTF-8; we first check if LC_ALL is defined, because if it is, -#- changing only LC_COLLATE will have no effect. -use POSIX qw(setlocale LC_ALL LC_COLLATE strftime); -use locale; -my $collation_locale = $ENV{LC_ALL}; -if ($collation_locale) { - $collation_locale =~ /UTF-8/ or setlocale(LC_ALL, "$collation_locale.UTF-8"); -} else { - $collation_locale = setlocale(LC_COLLATE); - $collation_locale =~ /UTF-8/ or setlocale(LC_COLLATE, "$collation_locale.UTF-8"); -} - -our %options; -foreach (@ARGV) { - /^-?-(\S+)$/ or next; - my $val = $1; - if ($val =~ /=/) { - my ($name, $values) = split /=/, $val; - my @values = split /,/, $values; - $options{$name} = \@values if @values; - } else { - $options{$val} = 1; - } -} - -our $MODE = ref $options{mode} ? $options{mode}[0] : undef; -unless ($MODE) { - $MODE = 'install'; - $0 =~ m|remove$| and $MODE = 'remove'; - $0 =~ m|update$|i and $MODE = 'update'; -} - -my $default_list_mode; -$default_list_mode = 'all' if $MODE eq 'install'; -if ($MODE eq 'remove') { - $default_list_mode = 'installed'; -} elsif ($MODE eq 'update') { - $default_list_mode = 'all_updates'; -} - use mygtk2 qw(gtknew); #- do not import anything else, especially gtkadd() which conflicts with ugtk2 one use ugtk2 qw(:all); use Gtk2::Gdk::Keysyms; -$MODE eq 'update' || $options{root} and require_root_capability(); $ugtk2::wm_icon = "title-$MODE"; -$::noborderWhenEmbedded = 1; - our $w; -my $changelog_first; my $treeview_dialog_run = 0; our $statusbar; @@ -128,10 +54,7 @@ sub interactive_list_ { interactive_list(@_, if_($::main_window, transient => $: sub wait_msg_with_banner { push @_, banner => 1 if $::isEmbedded && !$treeview_dialog_run; &statusbar_msg } sub interactive_msg_with_banner { push @_, banner => 1 if $::isEmbedded; &interactive_msg } -$> and (interactive_msg(N("Running in user mode"), -N("You are launching this program as a normal user. -You will not be able to perform modifications on the system, -but you may still browse the existing database."), yesno => 1, text => { no => N("Cancel"), yes => N("Ok") }) or myexit(0)); +warn_about_user_mode(); my $dont_show_selections = $> ? 1 : 0; @@ -1260,34 +1183,8 @@ if ($options{'merge-all-rpmnew'}) { } readconf(); -$changelog_first = $changelog_first_config->[0]; -$changelog_first = 1 if $options{'changelog-first'}; - -if (!$> && !member($MODE, @$already_splashed)) { - interactive_msg(N("Welcome"), -N("%s - -Is it ok to continue?", - $MODE eq 'remove' ? - N("Welcome to the software removal tool! - -This tool will help you choose which software you want to remove from -your computer.") - : $MODE eq 'update' ? - N("Welcome to %s! - -This tool will help you choose the updates you want to install on your -computer.", $rpmdrake::myname_update) - : - ($rpmdrake::branded ? N("Welcome to the software installation tool!") - : N("Welcome to the software installation tool! - -Your Mandriva Linux system comes with several thousands of software -packages on CDROM or DVD. This tool will help you choose which software -you want to install on your computer."))) - , yesno => 1) or myexit(-1); - push @$already_splashed, $MODE; - } + +init(); if ($MODE eq 'remove') { run_treeview_dialog(\&perform_removal); |