| @@ -1,153 +1,153 @@ | | | @@ -1,153 +1,153 @@ |
1 | # $NetBSD: plist-man.awk,v 1.10 2015/10/07 09:56:14 jperkin Exp $ | | 1 | # $NetBSD: plist-man.awk,v 1.11 2016/04/11 12:29:53 jperkin Exp $ |
2 | # | | 2 | # |
3 | # Copyright (c) 2006 The NetBSD Foundation, Inc. | | 3 | # Copyright (c) 2006 The NetBSD Foundation, Inc. |
4 | # All rights reserved. | | 4 | # All rights reserved. |
5 | # | | 5 | # |
6 | # This code is derived from software contributed to The NetBSD Foundation | | 6 | # This code is derived from software contributed to The NetBSD Foundation |
7 | # by Johnny C. Lam. | | 7 | # by Johnny C. Lam. |
8 | # | | 8 | # |
9 | # Redistribution and use in source and binary forms, with or without | | 9 | # Redistribution and use in source and binary forms, with or without |
10 | # modification, are permitted provided that the following conditions | | 10 | # modification, are permitted provided that the following conditions |
11 | # are met: | | 11 | # are met: |
12 | # 1. Redistributions of source code must retain the above copyright | | 12 | # 1. Redistributions of source code must retain the above copyright |
13 | # notice, this list of conditions and the following disclaimer. | | 13 | # notice, this list of conditions and the following disclaimer. |
14 | # 2. Redistributions in binary form must reproduce the above copyright | | 14 | # 2. Redistributions in binary form must reproduce the above copyright |
15 | # notice, this list of conditions and the following disclaimer in the | | 15 | # notice, this list of conditions and the following disclaimer in the |
16 | # documentation and/or other materials provided with the distribution. | | 16 | # documentation and/or other materials provided with the distribution. |
17 | # 3. All advertising materials mentioning features or use of this software | | 17 | # 3. All advertising materials mentioning features or use of this software |
18 | # must display the following acknowledgement: | | 18 | # must display the following acknowledgement: |
19 | # This product includes software developed by the NetBSD | | 19 | # This product includes software developed by the NetBSD |
20 | # Foundation, Inc. and its contributors. | | 20 | # Foundation, Inc. and its contributors. |
21 | # 4. Neither the name of The NetBSD Foundation nor the names of its | | 21 | # 4. Neither the name of The NetBSD Foundation nor the names of its |
22 | # contributors may be used to endorse or promote products derived | | 22 | # contributors may be used to endorse or promote products derived |
23 | # from this software without specific prior written permission. | | 23 | # from this software without specific prior written permission. |
24 | # | | 24 | # |
25 | # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 25 | # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
26 | # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 26 | # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
27 | # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 27 | # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
28 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 28 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
29 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 29 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
30 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 30 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
31 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 31 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
32 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 32 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
33 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 33 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
34 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 34 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
35 | # POSSIBILITY OF SUCH DAMAGE. | | 35 | # POSSIBILITY OF SUCH DAMAGE. |
36 | | | 36 | |
37 | ### This awk script handles man page entries in PLISTs. This script | | 37 | ### This awk script handles man page entries in PLISTs. This script |
38 | ### requires the following scripts to be included: | | 38 | ### requires the following scripts to be included: |
39 | ### | | 39 | ### |
40 | ### plist-functions.awk (print_entry) | | 40 | ### plist-functions.awk (print_entry) |
41 | ### | | 41 | ### |
42 | ### Certain environment variables must be set prior to running this script: | | 42 | ### Certain environment variables must be set prior to running this script: |
43 | ### | | 43 | ### |
44 | ### CATMAN_SECTION_SUFFIX is a yes/no variable that determines whether to use | | 44 | ### CATMAN_SECTION_SUFFIX is a yes/no variable that determines whether to use |
45 | ### the catman page section as the suffix or .0 if not. | | 45 | ### the catman page section as the suffix or .0 if not. |
46 | ### | | 46 | ### |
47 | ### IMAKE_MANINSTALL specifies how imake-using packages install man pages. | | 47 | ### IMAKE_MANINSTALL specifies how imake-using packages install man pages. |
48 | ### Valid values are: | | 48 | ### Valid values are: |
49 | ### | | 49 | ### |
50 | ### no value the package doesn't use imake | | 50 | ### no value the package doesn't use imake |
51 | ### maninstall the package installed man pages | | 51 | ### maninstall the package installed man pages |
52 | ### catinstall the package installed catman pages | | 52 | ### catinstall the package installed catman pages |
53 | ### | | 53 | ### |
54 | ### Both "maninstall" and "catinstall" may be specified. | | 54 | ### Both "maninstall" and "catinstall" may be specified. |
55 | ### | | 55 | ### |
56 | ### MANINSTALL specifies if man pages are installed by the package. | | 56 | ### MANINSTALL specifies if man pages are installed by the package. |
57 | ### Valid values are: | | 57 | ### Valid values are: |
58 | ### | | 58 | ### |
59 | ### maninstall the package installed man pages | | 59 | ### maninstall the package installed man pages |
60 | ### catinstall the package installed catman pages | | 60 | ### catinstall the package installed catman pages |
61 | ### | | 61 | ### |
62 | ### Both "maninstall" and "catinstall" may be specified. | | 62 | ### Both "maninstall" and "catinstall" may be specified. |
63 | ### | | 63 | ### |
64 | ### MANZ is a yes/no variable that determines whether the man pages | | 64 | ### MANZ is a yes/no variable that determines whether the man pages |
65 | ### should be recorded as compressed or not. | | 65 | ### should be recorded as compressed or not. |
66 | ### | | 66 | ### |
67 | ### PKGMANDIR is the ${PREFIX}-relative path to the installed man pages. | | 67 | ### PKGMANDIR is the ${PREFIX}-relative path to the installed man pages. |
68 | ### | | 68 | ### |
69 | function getenv(varname, defval) { | | 69 | function getenv(varname, defval) { |
70 | return varname in ENVIRON ? ENVIRON[varname] : defval; | | 70 | return varname in ENVIRON ? ENVIRON[varname] : defval; |
71 | } | | 71 | } |
72 | | | 72 | |
73 | BEGIN { | | 73 | BEGIN { |
74 | IMAKE_MANINSTALL = getenv("IMAKE_MANINSTALL", "maninstall catinstall") | | 74 | IMAKE_MANINSTALL = getenv("IMAKE_MANINSTALL", "maninstall catinstall") |
75 | MANINSTALL = getenv("MANINSTALL", "maninstall catinstall") | | 75 | MANINSTALL = getenv("MANINSTALL", "maninstall catinstall") |
76 | MANZ = getenv("MANZ", "no") | | 76 | MANZ = getenv("MANZ", "no") |
77 | PKGMANDIR = getenv("PKGMANDIR", "man") | | 77 | PKGMANDIR = getenv("PKGMANDIR", "man") |
78 | CATMAN_SECTION_SUFFIX = getenv("CATMAN_SECTION_SUFFIX", "no") | | 78 | CATMAN_SECTION_SUFFIX = getenv("CATMAN_SECTION_SUFFIX", "no") |
79 | CATPAGE_REGEX = "cat[1-9ln](am|f)?/[^/]*\\.[0-9ln](am|f)?" | | 79 | CATPAGE_REGEX = "cat[1-9ln](am|f)?/[^/]*\\.[0-9ln](am|f)?" |
80 | MANPAGE_REGEX = "man[1-9ln](am|f)?/[^/]*\\.[1-9ln](am|f)?" | | 80 | MANPAGE_REGEX = "man[1-9ln](am|f)?/[^/]*\\.[1-9ln](am|f)?" |
81 | CATORMAN_REGEX = "(" MANPAGE_REGEX "|" CATPAGE_REGEX ")" | | 81 | CATORMAN_REGEX = "(" MANPAGE_REGEX "|" CATPAGE_REGEX ")" |
82 | } | | 82 | } |
83 | | | 83 | |
84 | ### | | 84 | ### |
85 | ### Canonicalize man page entries by stripping any ".gz" suffixes. | | 85 | ### Canonicalize man page entries by stripping any ".gz" suffixes. |
86 | ### | | 86 | ### |
87 | /^[^@]/ && $0 ~ "^([^/]*/)+" CATORMAN_REGEX "\\.gz$" { | | 87 | /^[^@]/ && $0 ~ "^([^/]*/)+" CATORMAN_REGEX "\\.gz$" { |
88 | sub("\\.gz$", "") | | 88 | sub("\\.gz$", "") |
89 | } | | 89 | } |
90 | | | 90 | |
91 | ### | | 91 | ### |
92 | ### Rewrite "imake-installed" catman pages as man pages if imake only | | 92 | ### Rewrite "imake-installed" catman pages as man pages if imake only |
93 | ### supports man pages. | | 93 | ### supports man pages. |
94 | ### | | 94 | ### |
95 | (IMAKE_MANINSTALL == "maninstall") && /^[^@]/ && $0 ~ "^([^/]*/)+" CATPAGE_REGEX "$" { | | 95 | (IMAKE_MANINSTALL == "maninstall") && /^[^@]/ && $0 ~ "^([^/]*/)+" CATPAGE_REGEX "$" { |
96 | n = split($0, components, "/") | | 96 | n = split($0, components, "/") |
97 | sub("cat", "man", components[n-1]) | | 97 | sub("cat", "man", components[n-1]) |
98 | section = substr(components[n-1], 4, 1) | | 98 | section = substr(components[n-1], 4, 1) |
99 | sub("[0-9ln]$", section, components[n]) | | 99 | sub("[0-9ln]$", section, components[n]) |
100 | $0 = join(components, 1, n, "/") | | 100 | $0 = join(components, 1, n, "/") |
101 | } | | 101 | } |
102 | | | 102 | |
103 | ### | | 103 | ### |
104 | ### Rewrite "imake-installed" man pages as catman pages if imake only | | 104 | ### Rewrite "imake-installed" man pages as catman pages if imake only |
105 | ### supports catman pages. | | 105 | ### supports catman pages. |
106 | ### | | 106 | ### |
107 | (IMAKE_MANINSTALL == "catinstall") && /^[^@]/ && $0 ~ "^([^/]*/)+" MANPAGE_REGEX "$" { | | 107 | (IMAKE_MANINSTALL == "catinstall") && /^[^@]/ && $0 ~ "^([^/]*/)+" MANPAGE_REGEX "$" { |
108 | n = split($0, components, "/") | | 108 | n = split($0, components, "/") |
109 | sub("man", "cat", components[n-1]) | | 109 | sub("man", "cat", components[n-1]) |
110 | if (CATMAN_SECTION_SUFFIX ~ /[yY][eE][sS]/) { | | 110 | if (CATMAN_SECTION_SUFFIX ~ /[yY][eE][sS]/) { |
111 | section = substr(components[n-1], 4, 1) | | 111 | section = substr(components[n-1], 4, 1) |
112 | } else { | | 112 | } else { |
113 | section = "0" | | 113 | section = "0" |
114 | } | | 114 | } |
115 | sub("[0-9ln]$", section, components[n]) | | 115 | sub("[0-9ln]$", section, components[n]) |
116 | $0 = join(components, 1, n, "/") | | 116 | $0 = join(components, 1, n, "/") |
117 | } | | 117 | } |
118 | | | 118 | |
119 | ### | | 119 | ### |
120 | ### If MANINSTALL doesn't contain "maninstall", then strip out man page | | 120 | ### If MANINSTALL doesn't contain "maninstall", then strip out man page |
121 | ### entries from the PLIST, and similarly for "catinstall" and catman page | | 121 | ### entries from the PLIST, and similarly for "catinstall" and catman page |
122 | ### entries. | | 122 | ### entries. |
123 | ### | | 123 | ### |
124 | (MANINSTALL !~ /catinstall/) && /^[^@]/ && $0 ~ "^([^/]*/)+" CATPAGE_REGEX "$" { | | 124 | (MANINSTALL !~ /catinstall/) && /^[^@]/ && $0 ~ "^([^/]*/)+" CATPAGE_REGEX "$" { |
125 | next | | 125 | next |
126 | } | | 126 | } |
127 | (MANINSTALL !~ /maninstall/) && /^[^@]/ && $0 ~ "^([^/]*/)+" MANPAGE_REGEX "$" { | | 127 | (MANINSTALL !~ /maninstall/) && /^[^@]/ && $0 ~ "^([^/]*/)+" MANPAGE_REGEX "$" { |
128 | next | | 128 | next |
129 | } | | 129 | } |
130 | | | 130 | |
131 | ### | | 131 | ### |
132 | ### Append ".gz" to the end of man page entries if compressed pages are | | 132 | ### Fixup catman entries to use section suffixes if required. |
133 | ### requested. | | | |
134 | ### | | 133 | ### |
135 | (MANZ ~ /[yY][eE][sS]/) && /^[^@]/ && $0 ~ "^([^/]*/)+" CATORMAN_REGEX "$" { | | 134 | (CATMAN_SECTION_SUFFIX ~ /[yY][eE][sS]/)&& /^[^@]/ && $0 ~ "^man/([^/]*/)?" CATPAGE_REGEX { |
136 | $0 = $0 ".gz" | | 135 | n = split($0, components, "/") |
| | | 136 | sub("^cat", "", components[n-1]) |
| | | 137 | sub("0$", components[n-1], $0) |
137 | } | | 138 | } |
138 | | | 139 | |
139 | ### | | 140 | ### |
140 | ### Convert man/ to ${PKGMANDIR}/ for all man and catman page entries. | | 141 | ### Convert man/ to ${PKGMANDIR}/ for all man and catman page entries. |
141 | ### | | 142 | ### |
142 | /^[^@]/ && $0 ~ "^man/([^/]*/)?" CATORMAN_REGEX { | | 143 | /^[^@]/ && $0 ~ "^man/([^/]*/)?" CATORMAN_REGEX { |
143 | sub("^man/", PKGMANDIR "/") | | 144 | sub("^man/", PKGMANDIR "/") |
144 | } | | 145 | } |
145 | | | 146 | |
146 | ### | | 147 | ### |
147 | ### Fixup catman entries to use section suffixes if required. | | 148 | ### Append ".gz" to the end of man page entries if compressed pages are |
| | | 149 | ### requested. |
148 | ### | | 150 | ### |
149 | (CATMAN_SECTION_SUFFIX ~ /[yY][eE][sS]/)&& /^[^@]/ && $0 ~ "^man/([^/]*/)?" CATPAGE_REGEX { | | 151 | (MANZ ~ /[yY][eE][sS]/) && /^[^@]/ && $0 ~ "^([^/]*/)+" CATORMAN_REGEX "$" { |
150 | n = split($0, components, "/") | | 152 | $0 = $0 ".gz" |
151 | sub("^cat", "", components[n-1]) | | | |
152 | sub("0$", components[n-1], $0) | | | |
153 | } | | 153 | } |