tools/userland-mangler
changeset 2153 f64a9f4ada4d
parent 1528 76d0288dce57
child 2171 b7344f27cbbc
equal deleted inserted replaced
2152:1cea7a430dd7 2153:f64a9f4ada4d
     1 #!/usr/bin/python2.6
     1 #!/usr/bin/python2.7
     2 #
     2 #
     3 # CDDL HEADER START
     3 # CDDL HEADER START
     4 #
     4 #
     5 # The contents of this file are subject to the terms of the
     5 # The contents of this file are subject to the terms of the
     6 # Common Development and Distribution License (the "License").
     6 # Common Development and Distribution License (the "License").
    17 # fields enclosed by brackets "[]" replaced with your own identifying
    17 # fields enclosed by brackets "[]" replaced with your own identifying
    18 # information: Portions Copyright [yyyy] [name of copyright owner]
    18 # information: Portions Copyright [yyyy] [name of copyright owner]
    19 #
    19 #
    20 # CDDL HEADER END
    20 # CDDL HEADER END
    21 #
    21 #
    22 # Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
    22 # Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
    23 #
    23 #
    24 #
    24 #
    25 # userland-mangler - a file mangling utility
    25 # userland-mangler - a file mangling utility
    26 #
    26 #
    27 #  A simple program to mangle files to conform to Solaris WOS or Consoldation
    27 #  A simple program to mangle files to conform to Solaris WOS or Consoldation
   270 			if directory != destination:
   270 			if directory != destination:
   271 				src = os.path.join(directory, path)
   271 				src = os.path.join(directory, path)
   272 				if os.path.isfile(src):
   272 				if os.path.isfile(src):
   273 					mangle_path(manifest, action, src, dest)
   273 					mangle_path(manifest, action, src, dest)
   274 					break
   274 					break
       
   275 
       
   276 def mangle_manifest(manifest):
       
   277 	# Check for file content and remove tpno data and license actions if
       
   278 	# there is no content in the package that can be licensed.
       
   279 	manifest_has_file_content = False
       
   280 
       
   281 	for action in manifest.gen_actions_by_type("file"):
       
   282 		manifest_has_file_content = True
       
   283 		break
       
   284 
       
   285 	if not manifest_has_file_content:
       
   286 		# search for and remove 'set name=com.oracle.info.tpno ...'
       
   287 		for action in manifest.gen_actions_by_type("set"):
       
   288 			if (action.attrs["name"] == "com.oracle.info.tpno"):
       
   289 				manifest.actions.remove(action)
       
   290 		for action in manifest.gen_actions_by_type("license"):
       
   291 			manifest.actions.remove(action)
   275 
   292 
   276 def load_manifest(manifest_file):
   293 def load_manifest(manifest_file):
   277 	manifest = pkg.manifest.Manifest()
   294 	manifest = pkg.manifest.Manifest()
   278 	manifest.set_content(pathname=manifest_file)
   295 	manifest.set_content(pathname=manifest_file)
   279 
   296 
   319 	if destination == None:
   336 	if destination == None:
   320 		usage()
   337 		usage()
   321 
   338 
   322 	for manifest in manifests:
   339 	for manifest in manifests:
   323 		mangle_paths(manifest, search_paths, destination)
   340 		mangle_paths(manifest, search_paths, destination)
       
   341 		mangle_manifest(manifest)
   324 		print manifest
   342 		print manifest
   325 
   343 
   326 	sys.exit(0)
   344 	sys.exit(0)
   327 
   345 
   328 if __name__ == "__main__":
   346 if __name__ == "__main__":