summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakbug
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/standalone/drakbug')
-rwxr-xr-xperl-install/standalone/drakbug331
1 files changed, 217 insertions, 114 deletions
diff --git a/perl-install/standalone/drakbug b/perl-install/standalone/drakbug
index 1828f9d26..dd8d7f469 100755
--- a/perl-install/standalone/drakbug
+++ b/perl-install/standalone/drakbug
@@ -1,7 +1,8 @@
#!/usr/bin/perl
# Drak Bug Report
-# Copyright (C) 2002 MandrakeSoft (daouda@mandrakesoft.com)
+# Copyright (C) 2002-2008 Mandriva (daouda at mandriva dot com)
+# Stew Benedict (sbenedict at mandriva dot com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,135 +21,194 @@
use strict;
use diagnostics;
use lib qw(/usr/lib/libDrakX);
-
+use any;
use standalone;
-use interactive;
+use MDK::Common;
use common;
-use ugtk2 qw(:all);
+BEGIN { $::no_ugtk_init = 1 }
+use mygtk3 qw(gtknew);
+use ugtk3 qw(:all);
use Config;
+use URI::Escape;
+use run_program;
-
-my $in = 'interactive'->vnew;
-
-my $bugzilla_url = "http://drakbug.mandrakesoft.com";
-my $version = "0.9.0";
my $prog;
my $incident = 0;
+my ($table, $comb_app, $com_app, $button_pkg, $button_browse, $package, $distrocode, $error, $user_descr);
-while (defined($_ = shift @ARGV)) {
- /^--report$/ and do { $prog = shift @ARGV };
- /^--incident$/ and do { $incident = 1; $prog = shift @ARGV };
+my $i;
+foreach (@ARGV) {
+ next unless defined $_;
+ $i++;
+ /^--error$/ and do { $error = splice(@ARGV, $i, 1) };
+ /^--report$/ and $prog = splice(@ARGV, $i, 1);
+ /^--incident$/ and do { $incident = 1; $prog = splice(@ARGV, $i, 1) };
}
-my $window = ugtk2->new('drakbug', center => 1);
-my $window_g = $window->{window};
-#$window->{rwindow}->set_policy($false,$false,$true);
+my $segfaulted = $error =~ /SEGV/;
+if (!check_for_xserver()) {
+ print("Cannot be run in console mode.\n");
+ print join("\n",
+ N("The \"%s\" program has crashed with the following error:", $prog),
+ $error,
+ '')
+ if $error;
+ c::_exit(0);
+}
+
+mygtk3::init();
+
+$ugtk3::wm_icon = 'drakbug-16';
+my $window = ugtk3->new(N("%s Bug Report Tool", N("Mageia")), center => 1);
$window->{rwindow}->set_border_width(5);
-$window->{rwindow}->set_title(N("Mandrake Bug Report Tool"));
-$window->{window}->signal_connect("delete_event", \&quit_global);
+$window->{window}->signal_connect("delete_event", sub { ugtk3->exit(0) });
my $mdk_app = {
- N("Mandrake Control Center") => 'drakconf',
+ N("%s Control Center", N("Mageia")) => 'drakconf',
N("First Time Wizard") => 'drakfw',
N("Synchronization tool") => 'draksync',
- N("Standalone Tools") => ['adduserdrake', 'diskdrake', 'drakautoinst', 'drakbackup', 'drakboot', 'drakbug', 'drakfloppy', 'drakfont', 'drakgw', 'drakconnect', 'drakxservices', 'drakxtv', 'keyboardrake', 'logdrake', 'mousedrake', 'net_monitor', 'printerdrake', 'scannerdrake', 'drakfirewall', 'XFdrake'],
- N("HardDrake") => 'harddrake2',
- N("Mandrake Online") => 'mdkonline',
- N("Menudrake") => 'menudrake',
- N("Msec") => 'msec',
+ N("Standalone Tools") => 'drakxtools',
+ "harddrake" => 'harddrake2',
+ N("%s Online", N("Mageia")) => 'mgaonline',
+ N("%s Online", N("Mageia")) => 'mgaapplet',
N("Remote Control") => 'rfbdrake',
N("Software Manager") => 'rpmdrake',
- N("Urpmi") => 'urpmi',
N("Windows Migration tool") => 'transfugdrake',
- N("Userdrake") => 'userdrake',
N("Configuration Wizards") => 'wizdrake',
};
-my @generic_tool = keys %{$mdk_app};
-my @all_drakxtools = @{ $mdk_app->{N("Standalone Tools")} };
-push(@generic_tool,@all_drakxtools);
-
-my $kernel_release = chomp_(`uname -r`) . "";
-
-my $table = new Gtk2::Table(4,2, 'TRUE');
-#$table->set_border_width(5);
-$table->set_row_spacings(10);
-$table->set_col_spacings(5);
-$table->attach(new Gtk2::Label(N("Application:")), 0, 1, 0, 1, 'fill', 'fill',20,0);
-$table->attach(new Gtk2::Label(N("Package: ")), 0, 1, 1, 2, 'fill', 'fill',0,0);
-$table->attach(new Gtk2::Label(N("Kernel:")), 0, 1, 2, 3, 'fill', 'fill',0,0);
-$table->attach(new Gtk2::Label(N("Release: ")), 0, 1, 3, 4, 'fill', 'fill',0,0);
-$table->attach(my $comb_app = new Gtk2::Combo(), 1, 2, 0, 1, 'fill', 'fill',0,0);
-$comb_app->set_size_request(270, undef);
-$comb_app->set_popdown_strings("", sort(@generic_tool));
-$table->attach(my $package = new Gtk2::Entry(), 1, 2, 1, 2, 'fill', 'fill',0,0);
-$package->set_text("...");
-$table->attach(my $kernel_rel = new Gtk2::Entry(), 1, 2, 2, 3, 'fill', 'fill',0,0);
-$kernel_rel->set_text($kernel_release);
-$table->attach(my $mdk_rel = new Gtk2::Entry(), 1, 2, 3, 4, 'fill', 'fill',0,0);
-$mdk_rel->set_text(mandrake_release());
-
-gtkpack2__(
- gtkpack2__(my $vbx = new Gtk2::VBox(0,5),
- gtkadd($table),
- gtkpack(new Gtk2::HBox(0,0),
- gtkpack(gtkset_justify(new Gtk2::Label(N("\n\nTo submit a bug report, click on the button report.\nThis will open a web browser window on https://drakbug.mandrakesoft.com\n where you'll find a form to fill in.The information displayed above will be \ntransferred to that server\n\n")), "left")),
- ),
- gtkpack(new Gtk2::HSeparator),
-
- ),
- );
+my @generic_tool = keys %$mdk_app;
+my @all_drakxtools = qw(adduserdrake diskdrake drakautoinst drakboot drakbug drakclock drakfloppy drakfont draksec drakxservices drakxtools drakxtv logdrake scannerdrake);
+push @generic_tool, @all_drakxtools, qw(MageiaUpdate drakbackup drakconnect drakfirewall drakhosts drakmenustyle draknfs draksambashare drakgw drakroam drakvpn keyboarddrake msec mousedrake net_monitor urpmi userdrake XFdrake);
+
+my $kernel_release = chomp_(`uname -r`);
+my $mageia_release = chomp_(cat_('/etc/release'));
+#- unused for now
+#- (my $mageia_version) = $mageia_release =~ /(\d+\.\d+)/;
+
+if ($mageia_release =~ /(official|community)/i) {
+ $distrocode = $mageia_release;
+ $distrocode =~ s/^.*?(\d+\.\d+) \((\w+)\).*$/$1-\l$2/;
+} else {
+ $distrocode = "cooker";
+}
+my $bugzilla_url = 'http://bugs.mageia.org/enter_bug.cgi';
+my $wizard_name = "Bugzilla";
+
+$table = create_packtable({ col_spacings => 5, row_spacings => 10 },
+ [ gtknew('Label_Left', text => N("Select %s Tool:", N("Mageia"))), $comb_app = Gtk3::ComboBoxText->new, $comb_app->set_wrap_width(3) ],
+ [ gtknew('Label_Left', text => N("or Application Name\n(or Full Path):")),
+ gtkpack_(Gtk3::HBox->new(0, 5),
+ 1, $com_app = gtkset_editable(Gtk3::Entry->new, 1),
+ 0, $button_pkg = Gtk3::Button->new(N("Find Package")),
+ 0, $button_browse = Gtk3::FileChooserButton->new(N("Browse"), 'GTK_FILE_CHOOSER_ACTION_OPEN'),
+ ) ],
+ [ gtknew('Label_Left', text => N("Package: ")), $package = Gtk3::Entry->new_with_text("...") ], # complain on gtk-perl@ml
+ [ gtknew('Label_Left', text => N("Kernel:")), gtkset_editable(Gtk3::Entry->new_with_text($kernel_release), 0) ]
+ );
+$comb_app->set_popdown_strings("", uniq(sort(@generic_tool), if_($prog, $prog)));
+$comb_app->set_text("");
+my $theme_name = $table->get_settings->get('gtk-theme-name');
+
+sub is_a_boot_issue() {
+ $prog =~ /boot|mkinitrd/;
+}
+
+sub format_trace_with_message {
+ my ($message, $trace) = @_;
+ ([ $message ], [ "\n\n " . join("\n ", split("\n", $trace)) . "\n\n", { family => 'monospace' } ]);
+}
+
+my @commands = 'lspcidrake -v';
+
+push @commands, 'blkid' if is_a_boot_issue();
+
+my $parent_uid = get_parent_uid();
+
+my $width = 600;
+gtkadd($window->{window},
+ gtkpack_(Gtk3::VBox->new(0, 5),
+ 0, gtknew('Title1', label => $mageia_release, width => $width),
+ 1, create_scrolled_window(
+ gtknew('TextView', editable => 0, height => 150,
+ text => [
+ if_($prog,
+ if_($error,
+ format_trace_with_message(
+ ($segfaulted ?
+ N("The \"%s\" program has segfaulted with the following error:", $prog)
+ : N("The \"%s\" program has crashed with the following error:", $prog)),
+ $error)
+ ),
+ ),
+ [ N("Used theme: %s", $theme_name) . "\n\n" ],
+ [
+ N("To submit a bug report, click on the report button. \nThis will open a web browser window on %s where you'll find a form to fill in. The information displayed above will be transferred to that server",
+ $wizard_name) . "\n" .
+ P("It would be very useful to attach to your report the output of the following command: %s.",
+ "Things useful to attach to your report are the output of the following commands: %s.",
+ scalar(@commands),
+ join(", ", map { N("'%s'", $_) } @commands)) .
+ if_(is_a_boot_issue(),
+ "\n" .
+ N("You should also attach the following files: %s as well as %s.",
+ '/etc/modprobe.conf, /etc/fstab, /boot/grub/menu.lst, /boot/grub/devices.map',
+ '/etc/lilo.conf',
+ )
+ )
+ ]
+ ])),
+ 0, gtknew('Title2', label => N("Please describe what you were doing when it crashed:"), width => $width),
+ if_($incident,
+ 1, create_scrolled_window(
+ $user_descr = gtknew('TextView', editable => 1, height => 200)
+ ),
+ ),
+ if_(!$error,
+ 0, gtkadd($table),
+ ),
+ 0, gtkpack(Gtk3::HSeparator->new),
+ 0, gtkpack(create_hbox('edge'),
+ gtksignal_connect(
+ Gtk3::Button->new(N("Help")), clicked => sub {
+ run_program::raw({ detach => 1, setuid => $parent_uid }, 'drakhelp', '--id', 'drakbug');
+ }),
+ gtkpack(create_hbox('end'),
+ gtksignal_connect(Gtk3::Button->new(N("Report")), clicked => \&report_bug_to_bugzilla),
+ gtksignal_connect(Gtk3::Button->new(N("Close")), clicked => sub { ugtk3->exit(0) }),
+ ))));
if (defined $prog) {
update_app($prog);
- $comb_app->entry->set_text($prog);
-};
-
-$comb_app->entry->signal_connect('changed', sub { update_app($comb_app->entry->get_text()) });
-my $kernel = $kernel_rel->get_chars(0, -1);
-my $hbx = new Gtk2::HBox(0,0);
-my $Close_Button = new Gtk2::Button(N("Close"));
-$Close_Button->signal_connect(clicked => sub { ugtk2->exit(0) });
-$hbx->pack_start($Close_Button,0,0,0);
-
-my $Report_Button = new Gtk2::Button(N("Report"));
-$Report_Button->signal_connect(clicked => sub { my $options = "mdkbugreport=1";
- $options .= "&incident=1" if $incident;
- my $p = $package->get_text(); my $k = $kernel_rel->get_text(); (my $r = parse_release()) =~ s/\s//;
- $options .= "&package=$p" if $p =~ /mdk/;
- $options .= "&kernel=$k";
- $options .= "&version=$r";
- print($bugzilla_url . "?" . $options . "\n");
- connect_bugzilla($bugzilla_url."?".$options) });
-my $help_button = new Gtk2::Button(" ".N("Help")." ");
-$help_button->signal_connect(clicked => sub { system("drakhelp https://qa.mandrakesoft.com &") });
-$hbx->pack_end($Report_Button,0,0,0);
-$hbx->pack_end($help_button,0,0,5);
-$vbx->pack_start($hbx,0,0,0);
-$window->{window}->add($vbx);
-
-$window->{window}->show_all();
+ $comb_app->set_text($prog);
+}
+$comb_app->entry->signal_connect('changed', sub {
+ my $text = $comb_app->entry->get_text;
+ $text and update_app($text);
+ });
+
+$button_pkg->signal_connect('clicked', sub {
+ $comb_app->set_text("");
+ my $pkg_name = get_package($com_app->get_text);
+ $package->set_text($pkg_name);
+ });
+
+$button_browse->signal_connect('file-set', sub { $com_app->set_text($button_browse->get_filename) });
+
+$window->{window}->show_all;
$window->main;
-ugtk2->exit(0);
+ugtk3->exit(0);
sub update_app {
my ($text) = @_;
my $app_choice;
$ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}";
- if (member($text,@all_drakxtools) || $text eq N("Standalone Tools")) {
+ if (member($text, @all_drakxtools) || $text eq N("Standalone Tools")) {
$app_choice = chomp_(`rpm -q drakxtools`);
- } elsif (member($text, keys %{$mdk_app}) && $text ne N("Standalone Tools")) {
+ } elsif (exists($mdk_app->{$text})) {
$app_choice = get_package($mdk_app->{$text});
} else {
- LOOP: while (my ($key,$value) = each %{$mdk_app}) {
- next if $key eq N("Standalone Tools");
- if ($value eq $text) {
- $app_choice = get_package($text);
- $prog = $key;
- last LOOP;
- }
- }
-
+ $app_choice = get_package($text);
}
$app_choice ? $package->set_text($app_choice) : $package->set_text(N("Not installed"));
}
@@ -160,31 +220,74 @@ sub get_package {
my ($rpm_package, $which_app);
$rpm_package = $packages{$executable};
if (!defined $rpm_package) {
+ local $ENV{PATH} = "$ENV{PATH}:/sbin:/usr/sbin";
$which_app = chomp_(`which '$executable' 2> /dev/null`);
# deush, rpm can takes some time aka it'll sleeps if something has opened rpm db !
- $rpm_package = $which_app eq "" ? N("Package not installed") : chomp_(`rpm -qf '$which_app' 2>&1`);
+ $rpm_package = $which_app eq "" ? N("Package not installed") : common::to_utf8(chomp_(`rpm -qf '$which_app' 2>&1`));
$packages{$executable} = $rpm_package;
}
$rpm_package;
}
-sub parse_release {
- my ($rel) = mandrake_release() =~ /release\s(\S+\s\(.*\))/;
- $rel;
+sub get_top_of_trace {
+ my ($error) = @_;
+ return if !$error;
+ sprintf(" (%s)", first(split(/\n/, $error)));
}
-sub connect_bugzilla {
- my ($url) = @_;
- my $w = $in->wait_message('', N("connecting to Bugzilla wizard ..."));
- sleep(3);
- exec $ENV{BROWSER},$url if exists $ENV{BROWSER};
- my @browser = qw(mozilla konqueror galeon);
- foreach (@browser) {
- if (-e "/usr/bin/$_") { log::explanations("Contacting $url with $_\n "); exec $_,$url }
+sub report_bug_to_bugzilla() {
+ my $p = $package->get_text;
+ my ($product, $version) = $p =~ /^(.*)-([^-]+-[^-]+(mga.*))$/; # FIXME: fragile!
+ my $app = $comb_app->entry->get_text;
+ my $_component = $app ?
+ if_(member($app, @all_drakxtools), $app) || $mdk_app->{$app} :
+ $product;
+ my $text;
+ if ($incident) {
+ my $buffer = $user_descr->get_buffer;
+ $text = $buffer->get_text($buffer->get_start_iter, $buffer->get_end_iter, 0);
+ if (!$text) {
+ err_dialog(N("Warning"),
+ N("You must type in what you were doing when this bug happened in order to enable us to reproduce this bug and to increase the odds of fixing it")
+ . "\n\n" . N("Thanks."));
+ return;
+ }
}
- $in->ask_warn('', N("No browser available! Please install one"));
-}
+ my $rel_data = mageia_release_info();
+ my $rel = standalone::real_version();
+ my $cpuinfo;
+ if (cat_('/proc/cpuinfo') =~ /model name\s*:\s*(.*)$/m) {
+ $cpuinfo = $1;
+ }
+ my $arch = arch();
+ $arch = 'i686' if arch() =~ /^i.86/;
+ my $options = join('&',
+ ($product || $version ? 'cf_rpmpkg=' . join('-', $product, $version) : ()),
+ 'version=' . ($rel_data->{branch} eq 'Devel' ? 'Cauldron' : $rel_data->{version}),
+ 'component=RPM%20Packages',
+ 'product=Mageia',
+ "rep_platform=$arch",
+ if_($incident,
+ join('', "short_desc=$prog%20",
+ ($segfaulted ? 'segfaulted' : 'crashed'),
+ ),
+ ),
+ 'comment=' . uri_escape(
+ if_($incident,
+ qq(The "$prog" program crashed. Drakbug-$rel caught it.
-sub quit_global {
- ugtk2->exit(0);
+) . ($text || "Please describe what you were doing when it crashed.") . "\n\n"
+ . ($error ||
+ qq(If you can, try to run the "$prog" program from a terminal and copy and paste here any error messages and/or backtrace))
+ )
+ . qq(
+Theme name: $theme_name
+Kernel version = $kernel_release
+Distribution=) . cat_('/etc/release')
+. if_($cpuinfo, "CPU=$cpuinfo")
+ ),
+ );
+ print($bugzilla_url . "?" . $options . "\n");
+ run_program::raw({ detach => 1, setuid => $parent_uid }, '/usr/bin/www-browser', "$bugzilla_url?$options");
}
+