1 # 2 # CDDL HEADER START 3 # 4 # The contents of this file are subject to the terms of the 5 # Common Development and Distribution License (the "License"). 6 # You may not use this file except in compliance with the License. 7 # 8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 # or http://www.opensolaris.org/os/licensing. 10 # See the License for the specific language governing permissions 11 # and limitations under the License. 12 # 13 # When distributing Covered Code, include this CDDL HEADER in each 14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 # If applicable, add the following below this CDDL HEADER, with the 16 # fields enclosed by brackets "[]" replaced with your own identifying 17 # information: Portions Copyright [yyyy] [name of copyright owner] 18 # 19 # CDDL HEADER END 20 # 21 22 # 23 # Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 # Use is subject to license terms. 25 # 26 # ident "%Z%%M% %I% %E% SMI" 27 # 28 my $cluster = $ARGV[0]; 29 my $wos = $ARGV[1]; 30 my $toc = "$wos/Solaris_11/Product/.clustertoc"; 31 my (@lines); 32 my ($product_prefix) = "$wos/Solaris_11/Product"; 33 34 #print "Processing $cluster from $wos\n"; 35 #print "Cluster TOC: $toc \n"; 36 37 open(TOC, "<$toc") || die "Unable to open $toc"; 38 39 while (my $line=<TOC>) { 40 chomp($line); 41 $lines[++$#lines] = $line; 42 } 43 close(TOC); 44 45 #print "Loaded TOC\n"; 46 47 sub scan_depends($) { 48 my ($name1) = shift(@_); 49 my ($dcount) = 0; 50 51 if ( -e "$product_prefix/$name1/install/depend" ) { 52 open(DEP, "<$product_prefix/$name1/install/depend") || die "Unable to open $product_prefix/$name1/install/depend"; 53 while ( my $dep=<DEP> ) { 54 chomp($dep); 55 56 if ($dep =~ /^P/) { 57 my ($d, $pkg) = split(/\s+/, $dep); 58 $pkg =~ s/\s+//g; 59 print "$name1 $pkg\n"; 60 $dcount++; 61 62 } elsif ($dep =~ /^R/) { 63 my ($d, $pkg) = split(/\s+/, $dep); 64 $pkg =~ s/\s+//g; 65 print "$pkg $name1\n"; 66 $dcount++; 67 } 68 } 69 close (DEP); 70 if ($dcount == 0) { 71 print "$name1 SUNWdummy\n"; 72 } 73 } else { 74 print "$name1 SUNWdummy\n"; 75 } 76 } 77 78 sub scan_toc($) { 79 my ($name) = @_; 80 my ($state) = 1; 81 my ($tag, $value); 82 83 for $line (@lines) { 84 if ($state == 1) { 85 # Searching for given cluster/metacluster name 86 if ($line =~ /=$name$/) { 87 ($tag, $value) = split(/=/, $line); 88 if ($tag eq "CLUSTER" || $tag eq "METACLUSTER") { 89 $state = 2; 90 91 } elsif ($tag eq "SUNW_CSRMEMBER") { 92 # Found a leaf package. 93 # Print it along with partial dependencies. 94 scan_depends($value); 95 return; 96 97 } else { 98 die "Invalid entry $line"; 99 } 100 } 101 } elsif ($state == 2) { 102 # Scanning for SUNW_CSRMEMBER entries in current cluster/metacluster 103 if ($line =~ /^END/) { 104 return; 105 106 } elsif ($line =~ /SUNW_CSRMEMBER=/) { 107 ($tag, $value) = split(/=/,$line); 108 scan_toc($value); 109 } 110 } 111 } 112 } 113 114 #print "Dumping TOC\n"; 115 scan_toc($cluster); 116 117