8076 package_names.py can't find everything I need
authorDanek Duvall <danek.duvall@sun.com>
Thu, 09 Apr 2009 13:14:37 -0700
changeset 1030 2da88a296d1e
parent 1029 37317ca76af3
child 1031 5c130cc07e44
8076 package_names.py can't find everything I need
src/util/distro-import/Makefile
src/util/distro-import/package_names.py
src/util/distro-import/solaris.py
--- a/src/util/distro-import/Makefile	Thu Apr 09 19:33:26 2009 +0100
+++ b/src/util/distro-import/Makefile	Thu Apr 09 13:14:37 2009 -0700
@@ -26,7 +26,8 @@
 
 #set default
 ARCH=i386
-PROTO_AREA=../../../proto/root_`uname -p`
+NATIVE_ARCH:sh = uname -p
+PROTO_AREA=../../../proto/root_$(NATIVE_ARCH)
 
 #
 # Needs to point to filesystem on Solaris install dvd
@@ -554,14 +555,14 @@
 $(UNBUNDLED_TARGETS): unbundleds/$$(@:%.import=%)
 	rm -f redist_cluster; ln -s $(BUILDID)/redist_cluster redist_cluster
 	$(SOLARIS.PY) -s $(REPO) $(ALL_PKGS:%=-w %) $(ELIDED_FILES:%=-D %) \
-		`./package_names.py unbundleds/$(@:%.import=%)` \
+		`$(SOLARIS.PY) -N $(INCLUDE_PATH_$(BUILDID):%=-I %) unbundleds/$(@:%.import=%)` \
 		$(INCLUDE_PATH_$(BUILDID):%=-I %) unbundleds/$(@:%.import=%) \
 		redist_cluster
 
 $(UNBUNDLED_CLUSTERS): unbundleds/$$(@:%.import=%)
 	rm -f redist_cluster; ln -s $(BUILDID)/redist_cluster redist_cluster
 	$(SOLARIS.PY) -s $(REPO) $(ALL_PKGS:%=-w %) $(ELIDED_FILES:%=-D %) \
-		`./package_names.py unbundleds/$(@:%.import=%)` \
+		`$(SOLARIS.PY) -N $(INCLUDE_PATH_$(BUILDID):%=-I %) unbundleds/$(@:%.import=%)` \
 		$(INCLUDE_PATH_$(BUILDID):%=-I %) unbundleds/$(@:%.import=%) \
 		$(UNBUNDLED_TARGETS:%.import=unbundleds/%) redist_cluster
 
--- a/src/util/distro-import/package_names.py	Thu Apr 09 19:33:26 2009 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-#!/usr/bin/python2.4
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-
-#
-# scan argument files for driver actions; then act as filter, 
-# removing lines which contain a driver name in the first
-# column
-#
-
-import sys
-
-def scan_import_file(s):
-        file = open(s)
-
-        for line in file:
-                fields = line.split()
-                if fields and fields[0] == "include":
-                        scan_import_file(fields[1])
-                elif len(fields) == 2 and fields[0] == "package":
-                        package_names[fields[1]] = True
-        file.close()
-
-package_names={}
-
-for arg in sys.argv[1:]:
-        scan_import_file(arg)
-
-for name in package_names:
-        print "-j %s" % name
-
--- a/src/util/distro-import/solaris.py	Thu Apr 09 19:33:26 2009 +0100
+++ b/src/util/distro-import/solaris.py	Thu Apr 09 13:14:37 2009 -0700
@@ -950,6 +950,7 @@
 create_repo = False
 nopublish = False
 show_debug = False
+print_pkg_names = False
 def_repo = "http://localhost:10000"
 wos_path = []
 include_path = []
@@ -979,7 +980,7 @@
 macro_definitions = {}
 
 try:
-        _opts, _args = getopt.getopt(sys.argv[1:], "B:D:I:G:T:b:dj:m:ns:v:w:p:")
+        _opts, _args = getopt.getopt(sys.argv[1:], "B:D:I:G:NT:b:dj:m:ns:v:w:p:")
 except getopt.GetoptError, _e:
         print "unknown option", _e.opt
         sys.exit(1)
@@ -1027,6 +1028,8 @@
                 branch_file.close()
         elif opt == "-G": #another file of global includes
                 global_includes.append(arg)
+        elif opt == "-N":
+                print_pkg_names = True
         elif opt == "-T":
                 timestamp_files.append(arg)
 
@@ -1093,8 +1096,6 @@
 reuse_err = \
     "Conflict in path %s: IPS %s SVR4 %s from %s with IPS %s SVR4 %s from %s"
 
-print "First pass:", datetime.now()
-
 
 # First pass: don't actually publish anything, because we're not collecting
 # dependencies here.
@@ -1171,8 +1172,6 @@
         lexer.source = "include"
         lexer.sourcehook = sourcehook
 
-        print "Processing %s" % lexer.infile
-
         while True:
                 token = lexer.get_token()
 
@@ -1182,9 +1181,16 @@
                 if token == "package":
                         curpkg = start_package(lexer.get_token())
 
+                        if print_pkg_names:
+                                print "-j %s" % curpkg.name
+
                 elif token == "end":
                         endarg = lexer.get_token()
                         if endarg == "package":
+                                if print_pkg_names:
+                                        curpkg = None
+                                        continue
+
                                 for filename in global_includes:
                                         for i in include_path:
                                                 f = os.path.join(i, filename)
@@ -1216,16 +1222,18 @@
                         else:
                                 line = read_full_line(lexer)
 
-                        curpkg.import_pkg(package_name, line)
+                        if not print_pkg_names:
+                                curpkg.import_pkg(package_name, line)
 
                 elif token == "from":
                         pkgspec = lexer.get_token()
-                        p = SolarisPackage(pkg_path(pkgspec))
-                        curpkg.imppkg = p
-                        spkgname = p.pkginfo["PKG.PLAT"]
-                        svr4pkgpaths[spkgname] = pkg_path(pkgspec)
-                        svr4pkgsseen[spkgname] = p
-                        curpkg.add_svr4_src(spkgname)
+                        if not print_pkg_names:
+                                p = SolarisPackage(pkg_path(pkgspec))
+                                curpkg.imppkg = p
+                                spkgname = p.pkginfo["PKG.PLAT"]
+                                svr4pkgpaths[spkgname] = pkg_path(pkgspec)
+                                svr4pkgsseen[spkgname] = p
+                                curpkg.add_svr4_src(spkgname)
 
                         junk = lexer.get_token()
                         assert junk == "import"
@@ -1259,6 +1267,8 @@
 
                 elif token == "drop":
                         f = lexer.get_token()
+                        if print_pkg_names:
+                                continue
                         l = [o for o in curpkg.files if o.pathname == f]
                         if not l:
                                 print "Cannot drop '%s' from '%s': not " \
@@ -1279,6 +1289,8 @@
                 elif token == "chattr":
                         fname = lexer.get_token()
                         line = read_full_line(lexer)
+                        if print_pkg_names:
+                                continue
                         try:
                                 curpkg.chattr(fname, line)
                         except Exception, e:
@@ -1289,6 +1301,8 @@
                 elif token == "chattr_glob":
                         glob = lexer.get_token()
                         line = read_full_line(lexer)
+                        if print_pkg_names:
+                                continue
                         try:
                                 curpkg.chattr_glob(glob, line)
                         except Exception, e:
@@ -1317,6 +1331,14 @@
                         raise RuntimeError("Error: unknown token '%s' "
                             "(%s:%s)" % (token, lexer.infile, lexer.lineno))
 
+if print_pkg_names:
+        for _mf in filelist:
+                SolarisParse(_mf)
+        sys.exit(0)
+
+
+print "First pass:", datetime.now()
+
 for _mf in filelist:
         SolarisParse(_mf)