diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2007-04-25 12:26:16 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2007-04-25 12:26:16 +0000 |
commit | 126777bc019a54afb4ec51299f2cf9d2841698aa (patch) | |
tree | 97f76e571902ead55ba138f1156a4b4f00b9b779 /perl-install/standalone/harddrake2 | |
parent | f1f67448efc714873378dfeb8279fae68054a90a (diff) | |
download | drakx-126777bc019a54afb4ec51299f2cf9d2841698aa.tar drakx-126777bc019a54afb4ec51299f2cf9d2841698aa.tar.gz drakx-126777bc019a54afb4ec51299f2cf9d2841698aa.tar.bz2 drakx-126777bc019a54afb4ec51299f2cf9d2841698aa.tar.xz drakx-126777bc019a54afb4ec51299f2cf9d2841698aa.zip |
re-sync after the big svn loss
Diffstat (limited to 'perl-install/standalone/harddrake2')
-rwxr-xr-x | perl-install/standalone/harddrake2 | 141 |
1 files changed, 60 insertions, 81 deletions
diff --git a/perl-install/standalone/harddrake2 b/perl-install/standalone/harddrake2 index afce96ad7..741bf6cb0 100755 --- a/perl-install/standalone/harddrake2 +++ b/perl-install/standalone/harddrake2 @@ -1,15 +1,17 @@ #!/usr/bin/perl +# -*- coding: utf-8 -*- +use utf8; use strict; use diagnostics; use lib qw(/usr/lib/libDrakX); use standalone; use common; -use do_pkgs; # i18n: IMPORTANT: to get correct namespace (drakconf instead of only libDrakX) BEGIN { unshift @::textdomains, 'drakconf' } +use mygtk2 qw(gtknew); #- do not import gtkadd which conflicts with ugtk2 version use ugtk2 qw(:create :helpers :wrappers); use interactive; use harddrake::data; #- needs to stay after use-ugtk2 as long as this module defines globals containing some N() @@ -39,8 +41,6 @@ my %fields = "description" => [ N("Description"), N("this field describes the device") ], "device" => [ N("Old device file"), N("old static device name used in dev package") ], - "devfs_device" => [ N("New devfs device"), - N("new dynamic device name generated by core kernel devfs") ], "driver" => [ #-PO: here "module" is the "jargon term" for a kernel driver N("Module"), N("the module of the GNU/Linux kernel that handles the device") ], @@ -113,12 +113,12 @@ channel number, a target id and a logical unit number") ], MOUSE => { "device" => [ N("Device file"), N("the device file used to communicate with the kernel driver for the mouse") ], - EMULATEWHEEL => [ N("Emulated wheel"), N("whether the wheel is emulated or not") ], + EmulateWheel => [ N("Emulated wheel"), N("whether the wheel is emulated or not") ], MOUSETYPE => [ N("Type"), N("the type of the mouse") ], name => [ N("Name"), N("the name of the mouse") ], nbuttons => [ N("Number of buttons"), N("the number of buttons the mouse has") ], type => [ N("Bus"), N("the type of bus on which the mouse is connected") ], - XMOUSETYPE => [ N("Mouse protocol used by X11"), N("the protocol that the graphical desktop use with the mouse") ], + Protocol => [ N("Mouse protocol used by X11"), N("the protocol that the graphical desktop use with the mouse") ], } ); @@ -144,13 +144,13 @@ my %groups = ( N("Identification") => [ qw(Vendor Model description info media_type) ], N("Connection") => [ qw(bus channel lun) ], N("Bus identification") => [ qw(vendor id subvendor subid) ], - N("Device") => [ qw(device devfs_device) ], + N("Device") => [ qw(device) ], N("Partitions") => [ qw(primary_partitions extended_partitions) ], }, MOUSE => { - N("Identification") => [ qw(name type MOUSETYPE XMOUSETYPE) ], - N("Features") => [ qw(EMULATEWHEEL nbuttons) ], + N("Identification") => [ qw(name type MOUSETYPE Protocol) ], + N("Features") => [ qw(EmulateWheel nbuttons) ], }, ); @@ -184,6 +184,10 @@ my %menu_options = ( 'PARALLEL_ZIP_DETECTION' => [ $menus{options}, N("/Autodetect parallel _zip drives") ], ); +$ugtk2::wm_icon = "harddrake"; +$w = ugtk2->new(N("Hardware Configuration")); +# fake diagnostics pragma: +local $::main_window = $w->{real_window}; my @menu_items = ( @@ -199,12 +203,12 @@ my @menu_items = sub { $options{PARALLEL_ZIP_DETECTION} = $check_boxes{PARALLEL_ZIP_DETECTION}->get_active }, undef, '<CheckItem>' ], [ $menus{help}, undef, undef, undef, '<Branch>' ], if_(-x "/usr/sbin/drakhelp_inst", - [ $menus{help} . N("/_Help"), undef, sub { unless (fork()) { exec("drakhelp --id harddrake") } }, undef, '<Item>' ], + [ $menus{help} . N("/_Help"), undef, sub { run_program::raw({ detach => 1 }, 'drakhelp', '--id', 'harddrake') }, undef, '<Item>' ], ), [ $menus{help} . N("/_Fields description"), undef, sub { if ($current_device) { create_dialog(N("Harddrake help"), - N("Description of the fields:\n\n") + '<big><b>' . N("Description of the fields:\n\n") . '</b></big>' . join("\n\n", map { my $info = lookup_field($_); if_($info->[0], formatAlaTeX(qq(<span foreground="royalblue3">$info->[0]:</span> $info->[1]))); @@ -218,19 +222,31 @@ my @menu_items = undef, '<Item>' ], if_(!-e "/etc/sysconfig/oem", - [ $menus{help} . N("/_Report Bug"), undef, sub { unless (fork()) { exec("drakbug --report harddrake2 &") } }, undef, '<Item>' ], + [ $menus{help} . N("/_Report Bug"), undef, sub { run_program::raw({ detach => 1 }, 'drakbug', '--report', 'harddrake') }, undef, '<Item>' ], ), [ $menus{help} . N("/_About..."), undef, sub { - create_dialog(N("About Harddrake"), -#-PO: Do not alter the <span ..> and </span> tags - N("This is HardDrake, a %s hardware configuration tool.\n<span foreground=\"royalblue3\">Version:</span> %s -<span foreground=\"royalblue3\">Author:</span> Thierry Vignaud <tvignaud\@mandriva.com>\n\n", $distro_name, $harddrake::data::version) . "\n" . - formatAlaTeX($::license), { use_markup => 1, transient => $w->{real_window} }); + my $license = formatAlaTeX(translate($::license)); + $license =~ s/\n/\n\n/sg; # nicer formatting + my $w = gtknew('AboutDialog', name => N("Harddrake"), + version => '2007', + copyright => N("Copyright (C) %s by Mandriva", '2001-2006'), + license => $license, wrap_license => 1, + comments => N("This is HardDrake, a %s hardware configuration tool.", $distro_name), + website => 'http://mandrivalinux.com', + website_label => N("Mandriva Linux"), + authors => 'Thierry Vignaud <vignaud@mandriva.com>', + artists => 'Hélène Durosini <ln@mandriva.com>', + translator_credits => + #-PO: put here name(s) and email(s) of translator(s) (eg: "John Smith <jsmith@nowhere.com>") + N("_: Translator(s) name(s) & email(s)\n"), + transient_for => $::main_window, modal => 1, position_policy => 'center-on-parent', + ); + $w->show_all; + $w->run; }, undef, '<Item>' ] ); -$ugtk2::wm_icon = "harddrake"; $in = 'interactive'->vnew('su'); #require_root_capability(); %options = getVarsFromSh($conffile); @@ -239,28 +255,7 @@ $options{MDV_ONLINE} ||= []; # Build the gui add_icon_path('/usr/share/pixmaps/harddrake2/'); $::noborderWhenEmbedded = 1; -$w = ugtk2->new(N("Harddrake2")); -# fake diagnostics pragma: -local $::main_window = $w->{real_window}; -require list_modules; -my @proprietary_drivers = (qw(avmfritz fcpci fcdsl fcdsl fcdsl2 fcdslsl fcdslslusb fcdslusb fcdslusba fcusb fcusb2 fxusb fxusb_CZ), #ISDN - qw(slamr slusb), # SLAMR - qw(ltmodem speedtch), # modem - qw(speedtch), # ADSL - qw(a320raid), # block - qw(ath_pci ipw2100 ipw2200 prism54 speedtch), # network - list_modules::category2modules('network/slmodem'), - ); - -sub need_pkgs_offered_by_club { - my ($device) = @_; - - # need firmware, 3rd party driver or 3rd party program: - $device->{description} =~ /HostRAID/ || - $device->{driver} =~ /^at76|^LT:|^Hcf:|^Hsf:/ || - member($device->{driver}, @proprietary_drivers); -} my ($menubar, $factory) = create_factory_menu($w->{real_window}, @menu_items); $w->{window}->set_size_request(805, 550) if !$::isEmbedded; @@ -274,7 +269,7 @@ $w->{window}->add(gtkpack_(0, Gtk2::VBox->new(0, 0), gtkpack_(0, Gtk2::VBox->new(0, 0), 1, gtkadd(my $frame = Gtk2::Frame->new(N("Information")), create_scrolled_window(my $text = Gtk2::TextView->new)), - 0, my $module_cfg_button = gtksignal_connect(Gtk2::Button->new(N("Configure module")), + 0, my $module_cfg_button = gtksignal_connect(Gtk2::Button->new(N("Set current driver options")), clicked => sub { local $SIG{CHLD} = undef; require modules::interactive; @@ -285,10 +280,7 @@ $w->{window}->add(gtkpack_(0, Gtk2::VBox->new(0, 0), # we've a configurator, let's add a button for it and show it clicked => sub { return 1 if defined $pid; - if ($pid = fork()) { - } else { - exec($current_configurator) or die "$current_configurator missing\n"; - } + run_program::raw({ detach => 1 }, $current_configurator); }) ), ), @@ -299,8 +291,7 @@ $text->set_wrap_mode('word'); $frame->set_size_request(300, 450) unless $::isEmbedded; # $tree->set_column_auto_resize(0, 1); my (@data, @configurators); -$tree->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererPixbuf->new, 'pixbuf' => 0)); -$tree->append_column(my $textcolumn = Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 1)); +$tree->append_column(my $textcolumn = Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::MDV::CellRendererPixWithLabel->new, 'pixbuf' => 0, label => 1)); $tree->set_headers_visible(0); sub fill_default_text { @@ -371,6 +362,7 @@ $tree->get_selection->signal_connect('changed' => sub { # show the main window earlier (so that sub dialogs can use main # window's icon and so that no Gtk+ critical message got displayed): $w->{rwindow}->show_all; +my $flush_guard = Gtk2::GUI_Update_Guard->new; $_->hide foreach $module_cfg_button, $config_button; # hide buttons while no device my $wait = $in->wait_message(N("Please wait"), N("Detection in progress")); gtkflush() if !$::isEmbedded; @@ -405,14 +397,10 @@ foreach (@classes) { # Fill the graphic tree with a "tree leaf" widget per device foreach (@devices) { - if ($options{MDV_ONLINE} ne 'done' && ref $options{MDV_ONLINE}) { - push @{$options{MDV_ONLINE}}, $_ if $_->{need_pkgs_offered_by_club} ||= need_pkgs_offered_by_club($_); - } - # we really should test for $title there: if ($_->{bus} && $_->{bus} eq "PCI") { # do not display unknown driver for system bridges that're managed by kernel core: - delete $_->{driver} if $_->{driver} eq "unknown" && ($Ident =~ /^ATA_STORAGE|BRIDGE|SMB_CONTROLLER$/ || $_->{description} =~ /3Com.*5610/); + delete $_->{driver} if $_->{driver} eq "unknown" && ($Ident =~ /^ATA_STORAGE|BRIDGE|SMB_CONTROLLER|MEMORY_OTHER $/ || $_->{description} =~ /3Com.*5610/); } rename_field($_, 'usb_description', 'description'); # split description into manufacturer/description @@ -453,21 +441,29 @@ foreach (@classes) { delete $hd->{extended_partitions} if $hd->{extended_partitions} eq '0'; } } - $_->{EMULATEWHEEL} = bool2yesno($_->{EMULATEWHEEL}) if $Ident eq "MOUSE"; + $_->{EmulateWheel} = bool2yesno($_->{EmulateWheel}) if $Ident eq "MOUSE"; rename_field($_, 'usb_bus', 'bus'); rename_field($_, 'usb_driver', 'driver'); rename_field($_, 'usb_id', 'id'); rename_field($_, 'usb_media_type', 'media_type'); + if ($_->{nice_media_type}) { + delete $_->{media_type}; + rename_field($_, 'nice_media_type', 'media_type'); + } rename_field($_, 'usb_pci_bus', 'bus'); rename_field($_, 'usb_vendor', 'vendor'); rename_field($_, 'vendor_name', 'Vendor'); - foreach my $i (qw(auxmouse devfs_prefix unsafe val wacom)) { delete $_->{$i} } + foreach my $i (qw(synaptics unsafe val wacom)) { delete $_->{$i} } my $custom_id = harddrake::data::custom_id($_, $title); - foreach my $field (qw(devfs_device device)) { + foreach my $field (qw(device)) { $_->{$field} = "/dev/$_->{$field}" if $_->{$field}; } + foreach my $field (qw(vendor id subvendor subid)) { + $_->{$field} = sprintf("0x%04x", $_->{$field}); + delete $_->{$field} if $_->{$field} eq "0xffff"; # 0xffff equals to '*' + } $tree_model->append_set($parent_iter, [ 1 => $custom_id, 2 => $index++ ]); push @data, [ $_, $Ident ]; push @configurators, $configurator; @@ -475,6 +471,8 @@ foreach (@classes) { $tree->expand_row($tree_model->get_path($parent_iter), 1) unless $title eq N("Unknown/Others"); } +undef $flush_guard; + sub reap_children() { # reap zombies my $child_pid; @@ -500,31 +498,20 @@ $textcolumn->set_sizing('GTK_TREE_VIEW_COLUMN_AUTOSIZE');#GROW_ONLY $tree->signal_connect(realize => sub { $tree->get_selection->select_path(Gtk2::TreePath->new_first) }); { - my $do_pkgs; $SIG{CHLD} = undef; #local $SIG{CHLD} = sub {}; - if (ref $options{MDV_ONLINE} && @{$options{MDV_ONLINE}}) { # was the question already answered? - $do_pkgs ||= do_pkgs_standalone->new; - if (!$do_pkgs->is_available('speedtouch_mgmt') # do we have access to 3rd party programs? - && $in->ask_yesorno(N("Warning"), - N("The following devices needs proprietary drivers or firmwares in order to operate smoothly. The appropriate packages can be retrieved from the Mandriva Club. Do you want to subscribe to the Mandriva Club?") . "\n\n" . - join(",\n", map { print "- $_->{description}\n"; "- " . $_->{description} } @{$options{MDV_ONLINE}}))) { - $do_pkgs->install('drakfirsttime') if !-x '/usr/sbin/drakfirstboot'; - require run_program; - run_program::raw({ detach => 1 }, "/usr/sbin/drakfirstboot"); - } - } - $options{MDV_ONLINE} = 'done'; - if (my @packages = difference2([ simple_read_rpmsrate() ], [ qw(ati.2 dmraid gnome-alsamixer mdadm xmms-alsa) ])) { - $do_pkgs ||= do_pkgs_standalone->new; - my @packages2install = grep { $do_pkgs->is_available($_) && !$do_pkgs->is_installed($_) } @packages; + @packages = grep { !$in->do_pkgs->is_installed($_) } @packages; + + # workarounding do_pkgs->is_available() destroying $_: + my (@packages2install) = (grep { $in->do_pkgs->is_available($_) } @packages); + undef $wait; gtkset_mousecursor_normal(); if (@packages2install && $in->ask_yesorno(N("Warning"), N("The following packages need to be installed:\n") . join(', ', @packages2install))) { - $do_pkgs->install(@packages2install); + $in->do_pkgs->install(@packages2install); } } } @@ -591,15 +578,7 @@ sub popup_menu { } sub simple_read_rpmsrate() { - map { split(' ', $_) } map { - if (my ($priority, $p, $packages) = /(\d+)\s*[^!]HW"(.*)"(.*)/) { - if_(3 < $priority && detect_devices::matching_desc__regexp($p), $packages); - } elsif (($priority, $p, $packages) = /(\d+)\s*[^!]HW_CAT"(.*)"(.*)/) { - if_(3 < $priority && modules::probe_category($p), $packages); - } elsif (($priority, $p, $packages) = /(\d+)\s*[^!]DRIVER"(.*)"(.*)/) { - if_(3 < $priority && detect_devices::matching_driver__regexp($p), $packages); - } else { - (); - } - } cat_("/usr/share/harddrake/rpmsrate"); + require pkgs; + my ($rates, $flags) = pkgs::read_rpmsrate({}, { }, '/usr/share/meta-task/rpmsrate-raw', 0); + grep { member('TRUE', @{$flags->{$_}}) && $rates->{$_} >= 5 } keys %$flags; } |