#!/usr/bin/perl -w use strict; my $CONFIG = shift || die "usage: tweakcompile \n"; # dirty, dirty, you can also point at a file here my $GETDMESG = "/sbin/dmesg |"; open(DMESG, $GETDMESG) || die "cannot get dmesg: $!\n"; open(CONFIG, $CONFIG) || die "cannot open $CONFIG: $!\n"; my %dmesgdev; $dmesgdev{"mainbus0 at root"}++; # always there while () { if (m/^([a-z]{2,}[0-9]+) at ([a-z]{2,}[0-9]+)/) { $dmesgdev{"$1 at $2"}++; } } LINE: while () { my $orig = $_; s/\s+/ /g; # the following line is funky in GENERIC at the moment # (the space between pci and ?) s/^pciide\* at pci \?/pciide* at pci?/; s/^ //; if (m/^([a-z0-9?*]+) at ([a-z0-9?*]+)/) { my $regex = "$1 at $2"; $regex =~ s/[*?]/\\d\+/g; foreach (keys %dmesgdev) { if ($_ =~ m/^$regex$/) { print $orig; next LINE; } } # device did not match print "#T $orig"; } else { # no device on this line print $orig; } }