Annotation of openbsd/update_openbsd/post_dmesg_to_nycbug, Revision 1.11
1.1 andrew 1: #!/usr/bin/perl
2: use strict;
3: use warnings;
4: use feature 'say';
1.6 andrew 5: use feature 'signatures';
6: no warnings 'experimental::signatures';
1.1 andrew 7:
1.5 andrew 8: use Sys::Hostname;
1.1 andrew 9: use HTTP::Tiny;
10:
11: # This script posts your OpenBSD dmesg to the NYC*BUG dmesg archive.
12:
1.6 andrew 13: sub sysctl (@s) {
14: open my $de, '-|', qw( sysctl -n ), @s or die $!;
15: my $s = join ' ', split /\s+/s,
16: do { local $/ = undef; readline $de };
17: close $de or die $!;
18: return $s;
19: }
20:
1.5 andrew 21: my $nickname = "$ENV{USER}";
22: my $email = "$ENV{USER}\@" . hostname();
23:
1.3 andrew 24: my @sysctls = (
25: [qw( hw.vendor hw.product hw.version )],
26: [qw( hw.model )],
27: );
1.1 andrew 28:
1.3 andrew 29: my $description = "@ARGV";
30:
1.9 andrew 31: unless ($description) {
32: while ( @sysctls and not $description ) {
33: $description = sysctl @{ shift @sysctls };
34: }
1.3 andrew 35:
1.9 andrew 36: if (my $version = sysctl qw( kern.version )) {
1.10 andrew 37: my $machine = sysctl qw( hw.machine );
38: $version =~ s/\)\K.*/ $machine/;
1.9 andrew 39: $description = "$version on $description";
40: }
1.2 andrew 41: }
42:
1.11 ! andrew 43: print "'$description'\nAbout to post as $email ($nickname), OK? ";
1.4 andrew 44: readline STDIN;
45:
1.1 andrew 46: open my $dm, '<', '/var/run/dmesg.boot' or die $!;
47: my $dmesg = do { local $/ = undef; readline $dm };
48: close $dm;
49:
50: # Remove leftover cruft from previous boots
51: $dmesg =~ s/^.*\n(OpenBSD )/$1/s;
52:
53: my $res = HTTP::Tiny->new->post_form(
1.7 andrew 54: 'http://dmesgd.nycbug.org/index.cgi',
1.1 andrew 55: { action => 'dmesgd',
56: do => 'addd',
1.5 andrew 57: nickname => $nickname,
58: email => $email,
1.1 andrew 59: description => $description,
60: dmesg => $dmesg,
61: }
62: );
63:
64: say $res->{success}
65: ? 'Sent dmesg'
66: : "Unable to send dmesg: $res->{status} $res->{reason}";
1.8 andrew 67:
68: say $res->{content};
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>