xref: /netbsd-src/external/bsd/am-utils/dist/scripts/fix-amd-map.in (revision a53f50b9b44dc9467ccc9c464999b1d1c509cb0c)
1*a53f50b9Schristos#!@PERL@
2*a53f50b9Schristos#
3*a53f50b9Schristos# fix an old-syntax amd map to new one
4*a53f50b9Schristos#
5*a53f50b9Schristos# takes any number of files on the command line, and produces
6*a53f50b9Schristos# a fixed map on stdout.
7*a53f50b9Schristos#
8*a53f50b9Schristos# Package:	am-utils-6.x
9*a53f50b9Schristos# Author:	Erez Zadok <ezk@cs.columbia.edu>
10*a53f50b9Schristos#
11*a53f50b9Schristos
12*a53f50b9Schristos##############################################################################
13*a53f50b9Schristos### MAINTAINER EDITABLE SECTION
14*a53f50b9Schristos
15*a53f50b9Schristos# Mappings of old names to new ones:
16*a53f50b9Schristos# Update when needed, do not forget commas but not on the last entry!
17*a53f50b9Schristos# For your convenience, this is the complete list of all OSs that were
18*a53f50b9Schristos# supported by amd-upl102, in their old names:
19*a53f50b9Schristos#
20*a53f50b9Schristos#	386bsd acis43 aix3 aoi aux bsd43 bsd44 bsdi11
21*a53f50b9Schristos#	concentrix dgux fpx4 freebsd hcx hlh42 hpux irix3 irix4 irix5 isc3
22*a53f50b9Schristos#	linux mach2 mach3 netbsd news4 next osf1 pyrOSx riscix riscos
23*a53f50b9Schristos#	rtu6 sos3 sos4 sos5 stellix svr4 u2_2 u3_0 u4_0 u4_2 u4_3 u4_4
24*a53f50b9Schristos#	umax43 utek utx32 xinu43
25*a53f50b9Schristos#
26*a53f50b9Schristos%mappings = (
27*a53f50b9Schristos	"sos4",		"sunos4",
28*a53f50b9Schristos	"sos5",		"sunos5",
29*a53f50b9Schristos	"freebsd",	"freebsd2"
30*a53f50b9Schristos);
31*a53f50b9Schristos
32*a53f50b9Schristos##############################################################################
33*a53f50b9Schristos### DO NOT EDIT ANYTHING BELOW
34*a53f50b9Schristos
35*a53f50b9Schristos# This is a trivial parser and works as follows:
36*a53f50b9Schristos# (1) read each line
37*a53f50b9Schristos# (2) search of regexps that start with '=', continue with a word to replace
38*a53f50b9Schristos#     and end with a non-value name (whitespace, ';', or newline
39*a53f50b9Schristoswhile (<>) {
40*a53f50b9Schristos    # skip trivial lines
41*a53f50b9Schristos    if ($_ =~ /^$/  ||  $_ =~ /^#/) {
42*a53f50b9Schristos	print;
43*a53f50b9Schristos	next;
44*a53f50b9Schristos    }
45*a53f50b9Schristos    # modify the line if needed
46*a53f50b9Schristos    foreach $m (keys %mappings) {
47*a53f50b9Schristos	$val = $mappings{$m};
48*a53f50b9Schristos	$_ =~ s/=$m([^a-zA-Z0-9_])/=$val$1/g;
49*a53f50b9Schristos    }
50*a53f50b9Schristos    # print the (possibly) modified line
51*a53f50b9Schristos    print;
52*a53f50b9Schristos}
53