mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-14 10:09:48 +00:00
Add genericize, a Perl script that converts a kernel config into something
more easily diffable against GENERIC.
This commit is contained in:
parent
ef0ca90319
commit
90fcc4b33b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=134439
@ -23,6 +23,8 @@ gdb_regofs A simple tool that prints out a register offset table
|
||||
for mapping gdb(1) register numbers to struct reg and
|
||||
struct fpreg offsets. The tool is useful on selected
|
||||
platforms only.
|
||||
genericize Turn a kernel config into something that can more easily
|
||||
be diffed against the appropriate GENERIC.
|
||||
hcomp Compress header files by removing comments and whitespace.
|
||||
html-mv Rename HTML generated filenames to human readable filenames.
|
||||
ifinfo Uses the interface MIB to print out all the information
|
||||
|
5
tools/tools/genericize/Makefile
Normal file
5
tools/tools/genericize/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
# $FreeBSD$
|
||||
|
||||
SCRIPTS= genericize.pl
|
||||
|
||||
.include <bsd.prog.mk>
|
108
tools/tools/genericize/genericize.pl
Executable file
108
tools/tools/genericize/genericize.pl
Executable file
@ -0,0 +1,108 @@
|
||||
#!/usr/bin/perl -w
|
||||
#-
|
||||
# Copyright (c) 2004 Dag-Erling Coïdan Smørgrav
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer
|
||||
# in this position and unchanged.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# $FreeBSD$
|
||||
#
|
||||
|
||||
use strict;
|
||||
|
||||
MAIN:{
|
||||
my %config;
|
||||
my $machine;
|
||||
my $ident;
|
||||
|
||||
while (<>) {
|
||||
chomp();
|
||||
s/\s*(\#.*)?$//;
|
||||
next unless $_;
|
||||
#print("$_\n");
|
||||
my ($keyword, $values) = split(' ', $_, 2);
|
||||
foreach my $value (split(/,\s*/, $values)) {
|
||||
if ($keyword eq 'machine') {
|
||||
$machine = $value;
|
||||
} elsif ($keyword eq 'ident') {
|
||||
$ident = $value;
|
||||
} else {
|
||||
$config{$keyword}->{$value} = 1;
|
||||
}
|
||||
#print "$keyword $value\n";
|
||||
}
|
||||
}
|
||||
|
||||
my $generic = "/usr/src/sys/$machine/conf/GENERIC";
|
||||
local *GENERIC;
|
||||
open(GENERIC, "<", $generic)
|
||||
or die("$generic: $!\n");
|
||||
my $blank = 0;
|
||||
while (<GENERIC>) {
|
||||
my $line = $_;
|
||||
chomp();
|
||||
++$blank unless $_;
|
||||
s/\s*(\#.*)?$//;
|
||||
next unless $_;
|
||||
my ($keyword, $value) = split(' ', $_);
|
||||
if ($keyword eq 'machine') {
|
||||
die("$generic is for $value, not $machine\n")
|
||||
unless ($value eq $machine);
|
||||
if ($blank) {
|
||||
print "\n";
|
||||
$blank = 0;
|
||||
}
|
||||
} elsif ($keyword eq 'ident') {
|
||||
$line =~ s/$value/$ident/;
|
||||
} elsif ($config{$keyword}->{$value}) {
|
||||
delete($config{$keyword}->{$value});
|
||||
delete($config{$keyword})
|
||||
unless %{$config{$keyword}};
|
||||
} else {
|
||||
next;
|
||||
}
|
||||
if ($blank) {
|
||||
print "\n";
|
||||
$blank = 0;
|
||||
}
|
||||
print $line;
|
||||
}
|
||||
close(GENERIC);
|
||||
|
||||
if (%config) {
|
||||
print "\n# Addenda\n";
|
||||
foreach my $keyword (sort(keys(%config))) {
|
||||
foreach my $value (sort(keys(%{$config{$keyword}}))) {
|
||||
print "$keyword";
|
||||
if (length($keyword) < 7) {
|
||||
print "\t";
|
||||
} elsif (length($keyword) == 7) {
|
||||
print " ";
|
||||
}
|
||||
print "\t$value\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user