diff options
Diffstat (limited to 'perl-install/standalone/harddrake2')
| -rwxr-xr-x | perl-install/standalone/harddrake2 | 289 |
1 files changed, 152 insertions, 137 deletions
diff --git a/perl-install/standalone/harddrake2 b/perl-install/standalone/harddrake2 index 8a832d155..43f857996 100755 --- a/perl-install/standalone/harddrake2 +++ b/perl-install/standalone/harddrake2 @@ -1,18 +1,24 @@ #!/usr/bin/perl +# -*- coding: utf-8 -*- +use utf8; use strict; use diagnostics; use lib qw(/usr/lib/libDrakX); use standalone; +use MDK::Common; # help perl_checker 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 modules::parameters; use harddrake::data; #- needs to stay after use-ugtk2 as long as this module defines globals containing some N() +use fsedit; +use pkgs; use POSIX qw(:sys_wait_h); @@ -38,19 +44,20 @@ 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") ], "extended_partitions" => [ N("Extended partitions"), N("the number of extended partitions") ], "geometry" => [ N("Geometry"), N("Cylinder/head/sectors geometry of the disk") ], "host" => [ N("Disk controller"), N("the disk controller on the host side") ], + "info" => [ N("Identifier"), N("usually the device serial number") ], "media_type" => [ N("Media class"), N("class of hardware device") ], "Model" => [ N("Model"), N("hard disk model") ], "port" => [ N("Port"), N("network printer port") ], "primary_partitions" => [ N("Primary partitions"), N("the number of the primary partitions") ], "Vendor" => [ N("Vendor"), N("the vendor name of the device") ], + "pci_domain" => [ N("PCI domain"), N("the PCI domain of the device") ], + "pci_revision" => [ N("PCI revision"), N("the PCI domain of the device") ], "pci_bus" => [ N("Bus PCI #"), N("the PCI bus on which the device is plugged") ], "pci_device" => [ N("PCI device #"), N("PCI device number") ], "pci_function" => [ N("PCI function #"), N("PCI function number") ], @@ -62,25 +69,23 @@ my %fields = }, CPU => { + "system type" => [ "Sytem Type", "Name of the system" ], + "BogoMIPS" => [ N("Bogomips"), N("the GNU/Linux kernel needs to run a calculation loop at boot time to initialize a timer counter. Its result is stored as bogomips as a way to \"benchmark\" the cpu.") ], "bogomips" => [ N("Bogomips"), N("the GNU/Linux kernel needs to run a calculation loop at boot time to initialize a timer counter. Its result is stored as bogomips as a way to \"benchmark\" the cpu.") ], "cache size" => [ N("Cache size"), N("size of the (second level) cpu cache") ], - "coma_bug" => [ - #-PO: here "comas" is the medical coma, not the lexical coma!! - N("Coma bug"), N("whether this cpu has the Cyrix 6x86 Coma bug") ], "cpu family" => [ N("Cpuid family"), N("family of the cpu (eg: 6 for i686 class)") ], "cpuid level" => [ N("Cpuid level"), N("information level that can be obtained through the cpuid instruction") ], "cpu MHz" => [ N("Frequency (MHz)"), N("the CPU frequency in MHz (Megahertz which in first approximation may be coarsely assimilated to number of instructions the cpu is able to execute per second)") ], "flags" => [ N("Flags"), N("CPU flags reported by the kernel") ], - "fdiv_bug" => [ N("Fdiv bug"), - N("Early Intel Pentium chips manufactured have a bug in their floating point processor which did not achieve the required precision when performing a Floating point DIVision (FDIV)") ], - "fpu" => [ N("Is FPU present"), N("yes means the processor has an arithmetic coprocessor") ], - "fpu_exception" => [ N("Whether the FPU has an irq vector"), N("yes means the arithmetic coprocessor has an exception vector attached") ], - "f00f_bug" => [ N("F00f bug"), N("early pentiums were buggy and freezed when decoding the F00F bytecode") ], - "hlt_bug" => [ N("Halt bug"), - N("Some of the early i486DX-100 chips cannot reliably return to operating mode after the \"halt\" instruction is used") ], + "cpu cores" => [ N("Cores"), N("CPU cores") ], + "core id" => [ N("Core ID"), N("Core ID") ], + "physical id" => [ N("Physical ID"), N("Physical ID") ], + "apicid" => [ N("ACPI ID"), N("ACPI ID") ], + "siblings" => [ N("Siblings"), N("Siblings") ], "level" => [ N("Level"), N("sub generation of the cpu") ], "model" => [ N("Model"), N("generation of the cpu (eg: 8 for Pentium III, ...)") ], "model name" => [ N("Model name"), N("official vendor name of the cpu") ], + "cpu model" => [ N("Model name"), N("official vendor name of the cpu") ], "name" => [ N("Name"), N("the name of the CPU") ], "processor" => [ N("Processor ID"), N("the number of the processor") ], "stepping" => [ N("Model stepping"), N("stepping of the cpu (sub model (generation) number)") ], @@ -95,7 +100,8 @@ my %fields = { channel => [ N("Channel"), N("EIDE/SCSI channel") ], info => [ N("Disk identifier"), N("usually the disk serial number") ], - lun => [ N("Logical unit number"), N("the SCSI target number (LUN). SCSI devices connected to a host are uniquely identified by a + id => [ N("Target id number"), N("the SCSI target identifier") ], + lun => [ N("Logical unit number"), N("the SCSI Logical Unit Number (LUN). SCSI devices connected to a host are uniquely identified by a channel number, a target id and a logical unit number") ], }, MEMORY => @@ -112,20 +118,21 @@ 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") ], } ); +my $identification = N("Identification"); my %groups = ( generic => { - N("Identification") => [ qw(Vendor model description info media_type) ], - N("Connection") => [ qw(bus pci_bus pci_device pci_function vendor id subvendor subid) ], + $identification => [ qw(Vendor model description info media_type) ], + N("Connection") => [ qw(bus pci_domain pci_bus pci_device pci_function pci_revision vendor id subvendor subid) ], }, AUDIO => { @@ -133,23 +140,22 @@ my %groups = ( }, CPU => { - N("Identification") => [ qw(processor vendor_id), "model name", "cpu family", qw(model level stepping) ], + $identification => [ qw(processor vendor_id), "model name", "cpu family", qw(model level stepping), "cpuid level" ], + N("Cores") => [ 'cpu cores', 'core id', 'physical id', 'apicid', 'siblings' ], N("Performances") => [ "cpu MHz", "cache size", "bogomips" ], - N("Bugs") => [ qw(fdiv_bug coma_bug f00f_bug hlt_bug) ], - N("FPU") => [ qw(fpu fpu_exception) ], }, HARDDISK => { - N("Identification") => [ qw(Vendor Model description info media_type) ], - N("Connection") => [ qw(bus channel lun) ], + $identification => [ qw(Vendor Model description info media_type) ], + N("Connection") => [ qw(bus channel lun id) ], 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) ], + $identification => [ qw(name type MOUSETYPE Protocol) ], + N("Features") => [ qw(EmulateWheel nbuttons) ], }, ); @@ -183,11 +189,14 @@ 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 = ( [ N("/_File"), undef, undef, undef, '<Branch>' ], - [ N("/_File") . N("/_Upload the hardware list"), undef, \&upload, undef, '<Item>' ], [ N("/_File") . N("/_Quit"), N("<control>Q"), \&quit_global, undef, '<Item>' ], [ join('', @{$menu_options{PRINTERS_DETECTION}}), undef, sub { $options{PRINTERS_DETECTION} = $check_boxes{PRINTERS_DETECTION}->get_active }, undef, '<CheckItem>' ], @@ -199,68 +208,72 @@ 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]))); } sort keys %$current_device), - { use_markup => 1, if_(!$::isEmbedded, transient => $w->{real_window}), height => 400, scroll => 1 }); + { use_markup => 1, transient => $w->{real_window}, height => 400, scroll => 1 }); } else { - create_dialog(N("Select a device!"), N("Once you've selected a device, you'll be able to see the device information in fields displayed on the right frame (\"Information\")"), { if_(!$::isEmbedded, transient => $w->{real_window}) }); + create_dialog(N("Select a device!"), N("Once you've selected a device, you'll be able to see the device information in fields displayed on the right frame (\"Information\")"), { transient => $w->{real_window} }); } }, 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, if_(!$::isEmbedded, 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 => mageia_release_info()->{version}, + copyright => N("Copyright (C) %s by %s", '2001-2008', 'Mandriva') . "\n" . N("Copyright (C) %s by %s", '2011', N("Mageia")), + license => $license, wrap_license => 1, + comments => N("This is HardDrake, a %s hardware configuration tool.", $distro_name), + website => 'http://www.mageia.org', + website_label => N("Mageia"), + authors => 'Thierry Vignaud <thierry.vignaud.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(); -my $wait = $in->wait_message(N("Please wait"), N("Detection in progress")); -gtkflush(); - %options = getVarsFromSh($conffile); +$options{MDV_ONLINE} ||= []; # Build the gui add_icon_path('/usr/share/pixmaps/harddrake2/'); -$w = ugtk2->new(N("Harddrake2")); -local $::main_window; # fake diagnostics pragma -my ($menubar, $factory); -if ($::isEmbedded) { - ($menubar, $factory) = create_factory_menu($::Plug, @menu_items); -} else { - $::main_window = $w->{real_window}; - ($menubar, $factory) = create_factory_menu($w->{rwindow}, @menu_items); - $w->{window}->set_size_request(805, 550); -} +$::noborderWhenEmbedded = 1; + + +my ($menubar, $factory) = create_factory_menu($w->{real_window}, @menu_items); +$w->{window}->set_size_request(805, 550) if !$::isEmbedded; my $tree_model = Gtk2::TreeStore->new("Gtk2::Gdk::Pixbuf", "Glib::String", "Glib::Int"); $w->{window}->add(gtkpack_(0, Gtk2::VBox->new(0, 0), 0, $menubar, 0, Gtk2::Banner->new("/usr/share/mcc/themes/default/harddrake-mdk.png", translate("Hardware")), 1, create_hpaned(gtkadd(Gtk2::Frame->new(N("Detected hardware")), - create_scrolled_window(gtkset_size_request(my $tree = Gtk2::TreeView->new_with_model($tree_model), $::isEmbedded ? 250 : 350, -1), ['automatic', 'automatic'])), + create_scrolled_window(gtkset_size_request(my $tree = Gtk2::TreeView->new_with_model($tree_model), 350, -1), ['automatic', 'automatic'])), 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; @@ -271,10 +284,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); }) ), ), @@ -285,9 +295,15 @@ $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 { + my ($text) = @_; + $text->get_buffer->set_text(N("Click on a device in the tree on the left in order to display its information here.")); +} + +my %has_parameter; $tree->get_selection->signal_connect('changed' => sub { my ($select) = @_; my ($model, $iter) = $select->get_selected; @@ -318,7 +334,7 @@ $tree->get_selection->signal_connect('changed' => sub { member($field, map { @$_ } values %groups); } keys %device_fields; my @formated; - foreach my $group (N("Identification"), grep { $_ ne N("Identification") } keys %groups) { + foreach my $group ($identification, grep { $_ ne $identification } keys %groups) { my @fields = @{$groups{$group}}; # have we at least a member in that group? next unless any { member($_, @fields) } @$grouped; @@ -334,19 +350,38 @@ $tree->get_selection->signal_connect('changed' => sub { } # if we've valid driver, let's offer to configure it, else hide buttons - show_hide(defined($current_device->{driver}) && $current_device->{driver} !~ /^unknown|^Bad|^Card|^Hsf|^Removable:|\|/, $module_cfg_button); + show_hide(defined($current_device->{driver}) && $current_device->{driver} !~ /^unknown|^Bad|^Card|^Hsf|^kbd|^Mouse:USB|^mouse\d|^Removable:|\|/, $module_cfg_button); $current_configurator = $configurators[$idx]; show_hide($current_configurator && -x first(split /\s+/, $current_configurator), $config_button); # strip arguments for -x test + + # hide module configuration button if needed: + my $driver = $current_device->{driver}; + if (!defined $has_parameter{$driver}) { + local $SIG{CHLD} = undef; + $has_parameter{$driver} ||= to_bool(scalar modules::parameters::parameters($driver)); + } + show_hide($has_parameter{$driver}, $module_cfg_button); + return 1; } } - $text->get_buffer->set_text(N("Click on a device in the left tree in order to display its information here.")); + # No device is selected: + fill_default_text($text); undef $current_device; $config_button->hide; $module_cfg_button->hide; }); +# 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; + + my $index = 0; my @classes; @@ -355,12 +390,10 @@ my @classes; foreach my $hw_class (@harddrake::data::tree) { my ($Ident, $title, $icon, $configurator, $detector) = @$hw_class{qw(class string icon configurator detector)}; next if ref($detector) ne "CODE"; #skip class witouth detector - # blacklist agp controllers b/c string is not yet translated: - next if $Ident eq 'AGP'; next if $Ident =~ /(MODEM|PRINTER)/ && $::testing; next if $Ident =~ /JAZZ/ && !$options{JAZZ_DETECTION}; - next if $Ident =~ /MODEM/ && !$options{MODEMS_DETECTION}; next if $Ident =~ /PRINTER/ && !$options{PRINTERS_DETECTION}; + $detect_devices::detect_serial_modem = 0 if $Ident =~ /MODEM/ && !$options{MODEMS_DETECTION}; my @devices = $detector->(\%options); next unless @devices; # Skip empty class (no devices) @@ -381,7 +414,7 @@ foreach (@classes) { # 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 @@ -404,8 +437,8 @@ foreach (@classes) { $configurator .= harddrake::data::set_removable_configurator($Ident, $_); if ($Ident eq "AUDIO") { require harddrake::sound; - my $alter = harddrake::sound::get_alternative($_->{driver}); - if (my $alternative_drivers = $alter->[0] ne 'unknown' && join(', ', @$alter)) { + my @alter = harddrake::sound::get_alternative($_->{driver}); + if (my $alternative_drivers = join(', ', @alter)) { $_->{alternative_drivers} = $alternative_drivers; } } @@ -413,8 +446,8 @@ foreach (@classes) { my $hd = $_; my $info = find { $_->{device} eq $hd->{device} } @{$all_hds->{hds}}; $hd->{geometry} = join('/', map { $info->{geom}{$_} } qw(cylinders heads sectors)) . " (CHS)"; - $hd->{primary_partitions} = @{$info->{primary}{normal}}; - $hd->{extended_partitions} = @{$info->{extended}}; + $hd->{primary_partitions} = @{$info->{primary}{normal}} if $info->{primary}{normal}; + $hd->{extended_partitions} = @{$info->{extended}} if $info->{extended}; $hd->{primary_partitions} .= " (" . join(', ', map { $_->{device} }@{$info->{primary}{normal}}) . ")" if $hd->{primary_partitions}; if ($hd->{extended_partitions}) { $hd->{extended_partitions} .= " (" . join(', ', map { $_->{normal}{device} }@{$info->{extended}}) . ")"; @@ -422,34 +455,56 @@ 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'); + force_rename_field($_, 'nice_media_type', 'media_type'); rename_field($_, 'usb_pci_bus', 'bus'); + force_rename_field($_, 'nice_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}; } + format_bus_ids($_); + if ($_->{pci_revision}) { + $_->{pci_revision} = sprintf("0x%02x", $_->{pci_revision}); + } else { + delete $_->{pci_revision};# if $_->{pci_revision} eq "0x0000"; + } + $tree_model->append_set($parent_iter, [ 1 => $custom_id, 2 => $index++ ]); push @data, [ $_, $Ident ]; push @configurators, $configurator; } - $tree->expand_row($tree_model->get_path($parent_iter), 1) unless $title eq N("Unknown/Others"); } -$SIG{CHLD} = sub { - undef $pid; +undef $flush_guard; + +sub format_bus_ids { + my ($device) = @_; + # do not vivify ids: + return if !($device->{vendor} && $device->{id}); + foreach my $field (qw(vendor id subvendor subid)) { + next if !$device->{$field}; + $device->{$field} = sprintf("0x%04x", $device->{$field}); + delete $device->{$field} if $device->{$field} eq "0xffff"; # 0xffff equals to '*' + } +} + +sub reap_children() { # reap zombies my $child_pid; - do { $child_pid = waitpid(-1, POSIX::WNOHANG) } until $child_pid > 0; -}; + do { $child_pid = waitpid(-1, POSIX::WNOHANG); undef $pid if $pid == $child_pid } until $child_pid > 0; +} + +$SIG{CHLD} = \&reap_children; $w->{rwindow}->signal_connect(delete_event => \&quit_global); $w->{rwindow}->set_position('center') unless $::isEmbedded; @@ -466,26 +521,30 @@ $textcolumn->set_min_width(350); $textcolumn->set_sizing('GTK_TREE_VIEW_COLUMN_AUTOSIZE');#GROW_ONLY #$tree->columns_autosize(); $tree->signal_connect(realize => sub { $tree->get_selection->select_path(Gtk2::TreePath->new_first) }); -$w->{rwindow}->show_all; -$_->hide foreach $module_cfg_button, $config_button; # hide buttons while no device { $SIG{CHLD} = undef; #local $SIG{CHLD} = sub {}; - if (my @packages = difference2([ simple_read_rpmsrate() ], [ qw(ati.2 dmraid gnome-alsamixer mdadm xmms-alsa) ])) { - my $do_pkgs = do_pkgs_standalone->new; - my @packages2install = grep { $do_pkgs->is_available($_) && !$do_pkgs->is_installed($_) } @packages; + + if (my @packages = difference2([ pkgs::detect_hardware_packages($in->do_pkgs) ], [ qw(ati.2 dmraid gnome-alsamixer mdadm xmms-alsa) ])) { + @packages = difference2(\@packages, [ $in->do_pkgs->are_installed(@packages) ]); + # we use uniq() because on biarch machines, we got packages twice: + my @packages2install = uniq($in->do_pkgs->are_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); } } } +$SIG{CHLD} = \&reap_children; undef $wait; gtkset_mousecursor_normal(); +# fill in default right text since no device is selected on startup: +fill_default_text($text); $w->main; @@ -517,6 +576,15 @@ sub titleFormat { [ $title . "\n", { 'weight' => Gtk2::Pango->PANGO_WEIGHT_BOLD, scale => Gtk2::Pango->PANGO_SCALE_LARGE } ]; } +sub force_rename_field { + my ($dev, $new_field, $field) = @_; + if ($dev->{$new_field}) { + delete $dev->{$field}; + rename_field($dev, $new_field, $field); + } +} + + sub rename_field { my ($dev, $field, $new_field) = @_; if ($dev->{$field}) { @@ -541,56 +609,3 @@ sub popup_menu { return 0; }; } - -sub upload() { - my $dialog = _create_dialog(N("Upload the hardware list"), - { if_(!$::isEmbedded, transient => $w->{real_window}) }); #, height => 400 - gtkpack($dialog->vbox, - gtkset_markup(Gtk2::Label->new, qq(<span weight="bold">) . N("Upload the hardware list") . "</span>\n"), - create_packtable({ col_spacings => 10, row_spacings => 5, mcc => 1 }, - [ N("Account:"), my $account_w = Gtk2::Entry->new ], - [ N("Password:"), my $password_w = Gtk2::Entry->new ], - [ N("Hostname:"), my $system_name_w = Gtk2::Entry->new ], - ), - ); -$password_w->set_visibility(0); #set_invisible_char('*'); - - my ($password, $account, $name); - gtkadd($dialog->action_area, - create_okcancel( - { - cancel_clicked => sub { $dialog->destroy; Gtk2->main_quit }, - ok_clicked => sub { - $name = $system_name_w->get_text; - $account = $account_w->get_text; - $password = $password_w->get_text; - $dialog->destroy; - Gtk2->main_quit; - }, - }, - undef, undef, '', - ), - ); - - $dialog->set_has_separator(0); - $dialog->show_all; - Gtk2->main; - if ($account) { - local $ENV{HWDB_PASSWD} = $password; - require run_program; - run_program::raw({ detach => 1 }, "/usr/sbin/hwdb_add_system", $account, $name); - } -} - - -sub simple_read_rpmsrate { - map { split(' ', $_) } map { - if (my ($p, $packages) = /[^!]HW"(.*)"(.*)/) { - if_(detect_devices::matching_desc__regexp($p), $packages); - } elsif (($p, $packages) = /[^!]DRIVER"(.*)"(.*)/) { - if_(detect_devices::matching_driver__regexp($p), $packages); - } else { - (); - } - } cat_("/usr/share/harddrake/rpmsrate"); -} |
