5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # ident "%Z%%M% %I% %E% SMI"
26 # Copyright 2002 Sun Microsystems, Inc. All rights reserved.
27 # Use is subject to license terms.
29 # ctfcvtptbl [-o outfile] patch-makeup-table
31 # Given a path to a patch makeup table, this script converts that table to
32 # machine-optimal format and deposits it in the file specified by the -o option
33 # or on stdout depending on whether or not -o is specified.
35 # The user-supplied patch makeup table is in the following format:
41 # genunix_archive=/path/to/genunix/archive
43 # patch 100001-01 kureq 100002-01
44 # usr/src/uts/sparc/sd/debug32/sd
50 # The machine-optimal format for the above looks like this:
52 # GENUNIX_ARCHIVE=/path/to/genunix/archive
53 # module1 100001-01 100002-01
54 # module2 100001-01 100002-01
58 # Macros and other time-savers:
60 # * $RELEASE and $MACH in the genunix archive path will be replaced by the
61 # values of the RELEASE and MACH environment variables, respectively, as
62 # set by the program calling this one.
64 # * BUILD, BUILD32, and BUILD64 will, when used in the path for the module,
65 # will be match as follows:
67 # BUILD debug32, debug64, obj32, obj64
68 # BUILD32 debug32, obj32
69 # BUILD64 debug64, obj64
71 # * The presence of `usr/src' at the beginning of each module path will be
72 # assumed, and is not required to be specified.
79 my $PROGNAME = basename
($0);
84 BUILD
=> [ "debug32", "debug64", "obj32", "obj64" ],
85 BUILD32
=> [ "debug32", "obj32" ],
86 BUILD64
=> [ "debug64", "obj64" ]
91 $err = 1 unless getopts
("ho:", \
%opts);
94 open(STDOUT
, ">" . $opts{"o"}) || do {
95 print STDERR
"Couldn't open " . $opts{"o"} . ": $!\n";
115 if (!open(TABLE
, "<$::table")) {
116 print STDERR
"Couldn't open $::table: $!\n";
131 print STDERR
"Usage: $PROGNAME [-o outfile] table\n";
139 $genunix_archive = "";
144 s/\#.*$//; # Strip comments
147 if (!$patchid && /^genunix_archive=(\S+)\s*$/) {
148 $genunix_archive = $1;
153 if (s
/^patch\s
+(\d
{6}-\d
{2})
154 (\s
+ku
(req
|prev
)\s
+(\d
{6}-\d
{2}|fcs
))?
//x &&
157 $kureq = (defined $4 ?
$4 : "fcs");
158 $kuprev = (defined $3 && $3 eq "prev" ?
1 : 0);
159 } elsif ($patchid && s/^(\S+)//) {
162 if (($module =~ m
:/genunix/:) && !$kuprev) {
163 &parseerror
("No kuprev supplied " .
164 "for entry including genunix");
167 if (($module !~ m
:^usr
/src/:)) {
168 $module = "usr/src/" . $module;
172 m
:^(.*)\
$(BUILD
|BUILD32
|BUILD64
)(/.*)$:)) {
173 foreach my $type (@
{$typehash{$2}}) {
174 $moddata{$1 . $type . $3} =
178 $moddata{$module} = [$patchid, $kureq];
181 &parseerror
("Cannot parse table");
188 if (!$genunix_archive) {
189 print STDERR
"No genunix_archive line in table\n";
194 print STDERR
"No module information read\n";
204 print STDERR
"$msg at line $.\n";
209 my $release = $ENV{"RELEASE"};
210 my $mach = $ENV{"MACH"};
212 $genunix_archive =~ s/\$RELEASE/$release/ if defined $release;
213 $genunix_archive =~ s/\$MACH/$mach/ if defined $mach;
217 print "GENUNIX_ARCHIVE=" . $genunix_archive . "\n";
219 foreach my $mod (sort keys %moddata) {
220 print join(" ", ($mod, @
{$moddata{$mod}})) . "\n";