[BACK]Return to post_dmesg_to_nycbug CVS log [TXT][DIR] Up to [local] / openbsd / update_openbsd

Annotation of openbsd/update_openbsd/post_dmesg_to_nycbug, Revision 1.7

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:
                     31: while ( @sysctls and not $description ) {
1.6       andrew     32:     $description = sysctl @{ shift @sysctls };
                     33: }
1.3       andrew     34:
1.6       andrew     35: if (my $version = sysctl qw( kern.version )) {
                     36:     $version =~ s/\)\K.*//;
                     37:     $description = "$version on $description";
1.2       andrew     38: }
                     39:
1.4       andrew     40: print "About to post '$description', OK? ";
                     41: readline STDIN;
                     42:
1.1       andrew     43: open my $dm, '<', '/var/run/dmesg.boot' or die $!;
                     44: my $dmesg = do { local $/ = undef; readline $dm };
                     45: close $dm;
                     46:
                     47: # Remove leftover cruft from previous boots
                     48: $dmesg =~ s/^.*\n(OpenBSD )/$1/s;
                     49:
                     50: my $res = HTTP::Tiny->new->post_form(
1.7     ! andrew     51:     'http://dmesgd.nycbug.org/index.cgi',
1.1       andrew     52:     {   action      => 'dmesgd',
                     53:         do          => 'addd',
1.5       andrew     54:         nickname    => $nickname,
                     55:         email       => $email,
1.1       andrew     56:         description => $description,
                     57:         dmesg       => $dmesg,
                     58:     }
                     59: );
                     60:
                     61: say $res->{success}
                     62:     ? 'Sent dmesg'
                     63:     : "Unable to send dmesg: $res->{status} $res->{reason}";

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>