author  Mike Sullivan <Mike.Sullivan@Oracle.COM> 
Wed, 17 Jun 2015 11:14:40 0700  
branch  s11update 
changeset 4496  1a405bbe5189 
parent 3532  b2e7186fdcce 
child 7682  8e5bb71809b9 
permissions  rwxrxrx 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

1 
#!/usr/bin/python2.6 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

2 
# 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

3 
# CDDL HEADER START 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

4 
# 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

5 
# The contents of this file are subject to the terms of the 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

6 
# Common Development and Distribution License (the "License"). 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

7 
# You may not use this file except in compliance with the License. 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

8 
# 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

9 
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

10 
# or http://www.opensolaris.org/os/licensing. 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

11 
# See the License for the specific language governing permissions 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

12 
# and limitations under the License. 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

13 
# 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

14 
# When distributing Covered Code, include this CDDL HEADER in each 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

15 
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

16 
# If applicable, add the following below this CDDL HEADER, with the 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

17 
# fields enclosed by brackets "[]" replaced with your own identifying 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

18 
# information: Portions Copyright [yyyy] [name of copyright owner] 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

19 
# 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

20 
# CDDL HEADER END 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

21 
# 
3532
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

22 
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

23 
# 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

24 
# 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

25 
# userlandmangler  a file mangling utility 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

26 
# 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

27 
# A simple program to mangle files to conform to Solaris WOS or Consoldation 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

28 
# requirements. 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

29 
# 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

30 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

31 
import os 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

32 
import sys 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

33 
import re 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

34 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

35 
import pkg.fmri 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

36 
import pkg.manifest 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

37 
import pkg.actions 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

38 
import pkg.elf as elf 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

39 

2408
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

40 
attribute_oracle_table_header = """ 
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

41 
.\\\" Oracle has added the ARC stability level to this manual page""" 
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

42 

181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

43 
attribute_table_header = """ 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

44 
.SH ATTRIBUTES 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

45 
See 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

46 
.BR attributes (5) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

47 
for descriptions of the following attributes: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

48 
.sp 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

49 
.TS 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

50 
box; 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

51 
cbp1  cbp1 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

52 
l  l . 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

53 
ATTRIBUTE TYPE ATTRIBUTE VALUE """ 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

54 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

55 
attribute_table_availability = """ 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

56 
= 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

57 
Availability %s""" 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

58 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

59 
attribute_table_stability = """ 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

60 
= 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

61 
Stability %s""" 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

62 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

63 
attribute_table_footer = """ 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

64 
.TE 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

65 
.PP 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

66 
""" 
2408
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

67 
def attributes_section_text(availability, stability, modified_date): 
448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

68 
result = '' 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

69 

181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

70 
# is there anything to do? 
448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

71 
if availability is not None or stability is not None: 
2408
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

72 
result = attribute_oracle_table_header 
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

73 
if modified_date is not None: 
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

74 
result += ("\n.\\\" on %s" % modified_date) 
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

75 
result += attribute_table_header 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

76 

448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

77 
if availability is not None: 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

78 
result += (attribute_table_availability % availability) 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

79 
if stability is not None: 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

80 
result += (attribute_table_stability % stability.capitalize()) 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

81 
result += attribute_table_footer 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

82 

448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

83 
return result 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

84 

2408
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

85 
notes_oracle_comment = """ 
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

86 
.\\\" Oracle has added source availability information to this manual page""" 
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

87 

181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

88 
notes_header = """ 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

89 
.SH NOTES 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

90 
""" 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

91 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

92 
notes_community = """ 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

93 
Further information about this software can be found on the open source community website at %s. 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

94 
""" 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

95 
notes_source = """ 
2855
576d5a7857b7
16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
2408
diff
changeset

96 
This software was built from source available at https://java.net/projects/solarisuserland. The original community source was downloaded from %s 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

97 
""" 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

98 

2408
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

99 
def notes_section_text(header_seen, community, source, modified_date): 
448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

100 
result = '' 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

101 

448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

102 
# is there anything to do? 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

103 
if community is not None or source is not None: 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

104 
if header_seen == False: 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

105 
result += notes_header 
2408
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

106 
result += notes_oracle_comment 
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

107 
if modified_date is not None: 
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

108 
result += ("\n.\\\" on %s" % modified_date) 
448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

109 
if source is not None: 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

110 
result += (notes_source % source) 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

111 
if community is not None: 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

112 
result += (notes_community % community) 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

113 

448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

114 
return result 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

115 

448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

116 
so_re = re.compile('^\.so.+$', re.MULTILINE) 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

117 
section_re = re.compile('\.SH "?([^"]+).*$', re.IGNORECASE) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

118 
# 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

119 
# mangler.man.stability = (mangler.man.stability) 
2408
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

120 
# mangler.man.modified_date = (mangler.man.modifieddate) 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

121 
# mangler.man.availability = (pkg.fmri) 
464
08f94c414553
7073736 need to turn _ into 
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
452
diff
changeset

122 
# mangler.man.sourceurl = (pkg.sourceurl) 
08f94c414553
7073736 need to turn _ into 
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
452
diff
changeset

123 
# mangler.man.upstreamurl = (pkg.upstreamurl) 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

124 
# 
448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

125 
def mangle_manpage(manifest, action, text): 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

126 
# manpages must have a taxonomy defined 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

127 
stability = action.attrs.pop('mangler.man.stability', None) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

128 
if stability is None: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

129 
sys.stderr.write("ERROR: manpage action missing mangler.man.stability: %s" % action) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

130 
sys.exit(1) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

131 

2408
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

132 
# manpages may have a 'modified date' 
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

133 
modified_date = action.attrs.pop('mangler.man.modifieddate', None) 
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

134 

181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

135 
attributes_written = False 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

136 
notes_seen = False 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

137 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

138 
if 'pkg.fmri' in manifest.attributes: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

139 
fmri = pkg.fmri.PkgFmri(manifest.attributes['pkg.fmri']) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

140 
availability = fmri.pkg_name 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

141 

379  142 
community = None 
464
08f94c414553
7073736 need to turn _ into 
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
452
diff
changeset

143 
if 'info.upstreamurl' in manifest.attributes: 
08f94c414553
7073736 need to turn _ into 
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
452
diff
changeset

144 
community = manifest.attributes['info.upstreamurl'] 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

145 

379  146 
source = None 
464
08f94c414553
7073736 need to turn _ into 
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
452
diff
changeset

147 
if 'info.sourceurl' in manifest.attributes: 
08f94c414553
7073736 need to turn _ into 
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
452
diff
changeset

148 
source = manifest.attributes['info.sourceurl'] 
08f94c414553
7073736 need to turn _ into 
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
452
diff
changeset

149 
elif 'info.repositoryurl' in manifest.attributes: 
08f94c414553
7073736 need to turn _ into 
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
452
diff
changeset

150 
source = manifest.attributes['info.repositoryurl'] 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

151 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

152 
# skip reference only pages 
448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

153 
if so_re.match(text) is not None: 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

154 
return text 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

155 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

156 
# tell man that we want tables (and eqn) 
448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

157 
result = "'\\\" te\n" 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

158 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

159 
# write the orginal data 
448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

160 
for line in text.split('\n'): 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

161 
match = section_re.match(line) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

162 
if match is not None: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

163 
section = match.group(1) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

164 
if section in ['SEE ALSO', 'NOTES']: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

165 
if attributes_written == False: 
448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

166 
result += attributes_section_text( 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

167 
availability, 
2408
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

168 
stability, 
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

169 
modified_date) 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

170 
attributes_written = True 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

171 
if section == 'NOTES': 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

172 
notes_seen = True 
448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

173 
result += ("%s\n" % line) 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

174 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

175 
if attributes_written == False: 
2408
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

176 
result += attributes_section_text(availability, stability, 
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

177 
modified_date) 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

178 

2408
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

179 
result += notes_section_text(notes_seen, community, source, 
54e8d1ce1654
7186815 ncftp needs TPNO and license file modifications
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset

180 
modified_date) 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

181 

448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

182 
return result 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

183 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

184 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

185 
# 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

186 
# mangler.elf.strip = (truefalse) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

187 
# 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

188 
def mangle_elf(manifest, action, src, dest): 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

189 
pass 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

190 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

191 
# 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

192 
# mangler.script.filemagic = 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

193 
# 
448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

194 
def mangle_script(manifest, action, text): 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

195 
return text 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

196 

e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

197 
# 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

198 
# mangler.strip_cddl = false 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

199 
# 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

200 
def mangle_cddl(manifest, action, text): 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

201 
strip_cddl = action.attrs.pop('mangler.strip_cddl', 'true') 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

202 
if strip_cddl is 'false': 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

203 
return text 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

204 
cddl_re = re.compile('^[^\n]*CDDL HEADER START.+CDDL HEADER END[^\n]*$', 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

205 
re.MULTILINEre.DOTALL) 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

206 
return cddl_re.sub('', text) 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

207 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

208 
def mangle_path(manifest, action, src, dest): 
448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

209 
if elf.is_elf_object(src): 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

210 
mangle_elf(manifest, action, src, dest) 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

211 
else: 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

212 
# a 'text' document (script, man page, config file, ... 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

213 
ifp = open(src, 'r') 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

214 
text = ifp.read() 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

215 
ifp.close() 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

216 

e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

217 
# remove the CDDL from files 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

218 
result = mangle_cddl(manifest, action, text) 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

219 

e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

220 
if 'facet.doc.man' in action.attrs: 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

221 
result = mangle_manpage(manifest, action, result) 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

222 
elif 'mode' in action.attrs and int(action.attrs['mode'], 8) & 0111 != 0: 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

223 
result = mangle_script(manifest, action, result) 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

224 

e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

225 
if text != result: 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

226 
destdir = os.path.dirname(dest) 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

227 
if not os.path.exists(destdir): 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

228 
os.makedirs(destdir) 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

229 
with open(dest, 'w') as ofp: 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

230 
ofp.write(result) 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

231 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

232 
# 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

233 
# mangler.bypass = (truefalse) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

234 
# 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

235 
def mangle_paths(manifest, search_paths, destination): 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

236 
for action in manifest.gen_actions_by_type("file"): 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

237 
bypass = action.attrs.pop('mangler.bypass', 'false').lower() 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

238 
if bypass == 'true': 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

239 
continue 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

240 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

241 
path = None 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

242 
if 'path' in action.attrs: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

243 
path = action.attrs['path'] 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

244 
if action.hash and action.hash != 'NOHASH': 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

245 
path = action.hash 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

246 
if not path: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

247 
continue 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

248 

448
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

249 
if not os.path.exists(destination): 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

250 
os.makedirs(destination) 
e07a264a6e3d
7067302 no more CDDL'ng in Userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
379
diff
changeset

251 

181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

252 
dest = os.path.join(destination, path) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

253 
for directory in search_paths: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

254 
if directory != destination: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

255 
src = os.path.join(directory, path) 
452
ef9282f63da3
7067302 no more CDDL'ng in Userland ('fix' path check)
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
448
diff
changeset

256 
if os.path.isfile(src): 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

257 
mangle_path(manifest, action, src, dest) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

258 
break 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

259 

3532
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

260 
def mangle_manifest(manifest): 
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

261 
# Check for file content and remove tpno data and license actions if 
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

262 
# there is no content in the package that can be licensed. 
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

263 
manifest_has_file_content = False 
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

264 

b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

265 
for action in manifest.gen_actions_by_type("file"): 
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

266 
manifest_has_file_content = True 
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

267 
break 
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

268 

b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

269 
if not manifest_has_file_content: 
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

270 
# search for and remove 'set name=com.oracle.info.tpno ...' 
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

271 
for action in manifest.gen_actions_by_type("set"): 
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

272 
if (action.attrs["name"] == "com.oracle.info.tpno"): 
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

273 
manifest.actions.remove(action) 
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

274 
for action in manifest.gen_actions_by_type("license"): 
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

275 
manifest.actions.remove(action) 
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

276 

181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

277 
def load_manifest(manifest_file): 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

278 
manifest = pkg.manifest.Manifest() 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

279 
manifest.set_content(pathname=manifest_file) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

280 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

281 
return manifest 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

282 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

283 
def usage(): 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

284 
print "Usage: %s [mmanifest (file)] [dsearchdirectory (dir)] [Ddestination (dir)] " % (sys.argv[0].split('/')[1]) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

285 
sys.exit(1) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

286 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

287 
def main(): 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

288 
import getopt 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

289 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

290 
# FLUSH STDOUT 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

291 
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

292 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

293 
search_paths = [] 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

294 
destination = None 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

295 
manifests = [] 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

296 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

297 
try: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

298 
opts, args = getopt.getopt(sys.argv[1:], "D:d:m:", 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

299 
["destination=", "searchdirectory=", "manifest="]) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

300 
except getopt.GetoptError, err: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

301 
print str(err) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

302 
usage() 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

303 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

304 
for opt, arg in opts: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

305 
if opt in [ "D", "destination" ]: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

306 
destination = arg 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

307 
elif opt in [ "d", "searchdirectory" ]: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

308 
search_paths.append(arg) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

309 
elif opt in [ "m", "manifest" ]: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

310 
try: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

311 
manifest = load_manifest(arg) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

312 
except IOError, err: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

313 
print "oops, %s: %s" % (arg, str(err)) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

314 
usage() 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

315 
else: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

316 
manifests.append(manifest) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

317 
else: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

318 
usage() 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

319 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

320 
if destination == None: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

321 
usage() 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

322 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

323 
for manifest in manifests: 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

324 
mangle_paths(manifest, search_paths, destination) 
3532
b2e7186fdcce
19799164 content free packages shouldn't have a TPNO.
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
2855
diff
changeset

325 
mangle_manifest(manifest) 
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

326 
print manifest 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

327 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

328 
sys.exit(0) 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

329 

87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

330 
if __name__ == "__main__": 
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

331 
main() 