0N/A# The contents of this file are subject to the terms of the 0N/A# Common Development and Distribution License, Version 1.0 only 2362N/A# (the "License"). You may not use this file except in compliance 0N/A# See the License for the specific language governing permissions 0N/A# and limitations under the License. 0N/A# When distributing Covered Code, include this CDDL HEADER in each 0N/A# If applicable, add the following below this CDDL HEADER, with the 0N/A# fields enclosed by brackets "[]" replaced with your own identifying 0N/A# information: Portions Copyright [yyyy] [name of copyright owner] 0N/A# Copyright (c) 2000 by Sun Microsystems, Inc. 0N/A# All rights reserved. 0N/A# ident "%Z%%M% %I% %E% SMI" 0N/A"This program initializes a set of dbm databases with information 0N/AThere is one required argument: 0N/A\nThe optional argument -h produces this message instead of any processing. 0N/A\nThe optional argument -ifiles is used for symbolic link resolution. 0N/A\nThe optional argument -pkgdef creates the databases based upon a package \npool directory instead of /var/sadm/install/contents on the local machine. 0N/A# check for perl5 -- we use things unavailable in perl4 0N/Adie "Sorry, this program requires perl version 5.000 or up. You have $]. Stopping" if $] <
5.000;
0N/A# make sure the package pool directory exists 0N/A# Here we define the input files which will be parsed 0N/A$Struct = \%
struct;
# here is the structure we'll store everything in 0N/A# now open the dbm databases we will initialize # db for absolute link targets $Debug =
1;
# print extra gibberish # go make the package names db # read and parse each input file in contents file format # Tell the user what we are looking at UNLESS they are looking at a package # pool. A package pool could have hundreds of entries which just creates # a lot of useless (and confusing) output. while (<IFILE>) { # loop over file line-at-a-time next if /^:/; # ignore these lines from a pkgmap next if (/(\S+)\s+[i]\s+/); next if /^#/; # ignore comments next if /^\s*$/; # ignore blanks # if this entry was supplied by a earlier file, skip it # don't bother complaining about directories, we know the same # directory could exist in multiple packages # In the case where we are going through a package pool, we # expect that a file may reside in multiple packages. If # that is detected, we simply add this package to the list of # In the case where we are reading in from # over-ridden files EXCEPT when the "-ifiles" option is used. # This is a hack. In the case of directories like /bin which # would belong in many packages, the $PKGS hash would not # be able to handle such a long entry. So for directories, I # just place the first package I find. For this tool, it doesn't # matter since this tool does not report which directories come # put what we need from this entry line into the dbs # now collect the possible paths for each basename # now convert the relative links into absolute ones # close the dbs -- we're done #===========================END OF MAIN==================================== sub GetAbsLink { # convert relative link to actual one # pop the relative path until a relative dir shows up if ($relhere =~ /\w/) { # there's a letter or number } elsif ($relhere =~ /^\.\.$/) { # its a .. pop up one dir } elsif ($relhere =~ /^\.$/) { # it's a . -- stop # &yelp("***CANNOT RESOLVE ABSOLUTE PATH $abspath\n"); # $base =~ s/.*\///; # get basename we're looking for # @cans = @{$Struct->{"PATHS"}->{$base}}; # get all entities ... # $numcans = $#cans + 1; # ... with this base # &yelp(" There are $numcans entries with this basename:\n"); #invocation: &ParseContentsEntry($l); # $l is a line in the file # look for b or c entries, like: ($l =~ /^(\S+)\s+([bc])\s+(\w+)\s+([0-9]+)\s+([0-9]+)\s+([0-7]+)\s+([a-z]+)\s+([a-z]+)\s+([A-Z].*)/)) { # look for d entries, like ($l =~ /^(\S+)\s+([d])\s+(\w+)\s+([0-7]+)\s+([a-z]+)\s+([a-z]+)\s+([A-Z].*)/)) { # look for f or e or v entries, like # /etc/asppp.cf f none 0744 root sys 360 27915 801314234 SUNWapppr ($l =~ /^(\S+)\s+([fev])\s+(\w+)\s+([0-7]+)\s+([a-z]+)\s+([a-z]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([A-Z].*)/)) { # look for l or s entries, like # /bin=./usr/bin s none SUNWcsr ($l =~ /^([^=]+)=(\S+)\s+([ls])\s+(\w+)\s+([A-Z].*)/)) { # for validation of input # look for d entries, like # 1 d root etc 775 root sys ($line =~ /^(\S+)\s+([d])\s+(\w+)\s+(\S+)\s+(\d+)\s+(\w+)\s+(\w+)/)) { # look for e,f or v entries, like ($line =~ /^(\S+)\s+([efv])\s+(\w+)\s+(\S+)\s+(\d+)\s+(\w+)\s+(\w+)/)) { ($line =~ /^(\S+)\s+([ls])\s+(\w+)\s+(\S+)[=](\S+)/)) { #invocation: &ParsePrototypeEntry($l); # $l is a line in the file # look for b or c entries, like: ($l =~ /^(\S+)\s+([bc])\s+(\w+)\s+([0-9]+)\s+([0-9]+)\s+([0-7]+)\s+([a-z]+)\s+([a-z]+)\s+([A-Z].*)/)) { # look for d entries, like # d root etc 775 root sys ($l =~ /^([d])\s+(\w+)\s+(\S+)\s+([0-7]+)\s+(\w+)\s+(\w+)/)) { # look for f or e or v entries, like ($l =~ /^([fev])\s+(\w+)\s+(\S+)\s+([0-7]+)\s+(\w+)\s+(\w+)/)) { # look for l or s entries, like ($l =~ /^([ls])\s+(\w+)\s+([^=]+)=(\S+)/)) { print STDERR "Unrecognized Prototype File entry: $l\n"; #invocation: &MakePackageNamesDB($PkgDir); local ($PkgDir) = @_; # argument is parent directory of pkg dirs $str =~ s/\s*\n$//; # trim trailing ws $str =~ s/.*=\s*//; # trim leading NAME= if ($str =~ /\w/) { # if the name has a letter or number in it } # end of loop over package directories