Codebase list debian-goodies / 227af49
Add --install and --ssh options to find-dbgsym-packages. Suggest sudo and openssh-client. Related to #935567. Axel Beckert 4 years ago
4 changed file(s) with 59 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
77 * Bump debhelper compatibility level to 12.
88 + Build-depend on "debhelper-compat (= 12)" to replace debian/compat.
99 * Declare compliance with Debian Policy 4.5.0. (No changes needed.)
10 * Add --install and --ssh options to find-dbgsym-packages. (See #935567)
11 + Suggest sudo and openssh-client.
1012
1113 -- Axel Beckert <abe@debian.org> Sat, 18 Apr 2020 23:54:38 +0200
1214
3131 libgnome2-bin,
3232 lsb-release,
3333 lsof,
34 openssh-client,
35 sudo,
3436 x-www-browser | www-browser,
3537 xdg-utils
3638 Conflicts: bikeshed,
7072 find-dbgsym-packages
7173 - Get list of dbgsym packages from core dump or PID [dctrl-tools,
7274 elfutils, libfile-which-perl, libipc-system-simple-perl]
75 Usage of the --ssh option requires openssh-client.
7376 popbugs - Display a customized release-critical bug list based on
7477 packages you use (using popularity-contest data) [python3,
7578 popularity-contest]
44 #
55 # Copyright (C) 2017 Stefan Fritsch <sf@debian.org>
66 # Copyright (C) 2017 Paul Wise <pabs@debian.org>
7 # Copyright (C) 2017-2018 Axel Beckert <abe@debian.org>
7 # Copyright (C) 2017-2020 Axel Beckert <abe@debian.org>
88 # Copyright (C) 2018 Jakub Wilk <jwilk@jwilk.net>
99 #
1010 # This program is free software; you can redistribute it and/or modify
3535 }
3636
3737 my $vdso_regexp = qr/^linux-(gate|vdso\d*)[.]so[.]/;
38 my $call_apt = 0;
39 my $use_ssh = 0;
3840
3941 my %pkgs;
4042 my @out_of_date_files;
4143 foreach my $arg (@ARGV) {
44 if ($arg eq '--install') {
45 $call_apt = 1;
46 next;
47 }
48 if ($arg eq '--ssh') {
49 $use_ssh = 1;
50 next;
51 }
52
4253 my %build_ids;
4354 if ($arg =~ /^\d+$/) {
4455 %build_ids = get_build_ids_from_pid($arg);
7485 "W: they are not at the expected (usually older) package version.\n";
7586 }
7687
77 say join(" ", sort keys %pkgs);
88 my @pkgs = sort keys %pkgs;
89 if (@pkgs) {
90 if ($call_apt) {
91 my @cmd = (qw(apt install --no-install-recommends), @pkgs);
92 unless ($> == 0) {
93 if ($use_ssh) {
94 @cmd = (qw(ssh root@localhost -t), @cmd);
95 } else {
96 if (which('sudo')) {
97 unshift(@cmd, 'sudo');
98 } else {
99 @cmd = (qw(su - -c), join(' ', @cmd));
100 }
101 }
102 }
103 exec(@cmd);
104 } else {
105 say join(" ", @pkgs);
106 }
107 } else {
108 warn "I: All needed dbgsym packages are already installed.\n";
109 }
78110
79111 exit 0;
80112
296328 {
297329 print << "EOF";
298330 usage:
299 $0 <core file or PID> [ ... ]
331 $0 [--install] [--ssh] <core file or PID or program> [ ... ]
300332
301333 You must already have the correct debug lines in your sources.list and have
302334 executed 'apt-get update'.
55
66 =head1 SYNOPSIS
77
8 B<find-dbgsym-packages> I<executable, core file or PID> [I<executable, library, core file or PID> …]
8 B<find-dbgsym-packages> [I<options>] I<executable, core file or PID> [I<executable, library, core file or PID> …]
99
1010 =head1 DESCRIPTION
1111
2424
2525 Additionally, B<find-dbgsym-packages> requires the I<elfutils> and
2626 I<dctrl-tools> packages to be installed.
27
28 =head1 OPTIONS
29
30 =over 4
31
32 =item C<--install>
33
34 Don't display the list of required dbgsym packages but directly use
35 L<apt(1)> to install them. If not being run as root and L<sudo(1)> is
36 installed, call C<sudo apt install ...>, else use C<su - -c "apt
37 install">.
38
39 =item C<--ssh>
40
41 Use C<ssh root@localhost -t> instead of C<sudo> or C<su - -c>. to gain
42 administrative privileges.
43
44 =back
2745
2846 =head1 EXAMPLES
2947