3 # $NetBSD: reduce-resolved-depends.awk,v 1.1 2012/07/02 14:53:13 joerg Exp $
5 # Copyright (c) 2012 The NetBSD Foundation, Inc.
8 # This code is derived from software contributed to The NetBSD Foundation
9 # by Joerg Sonnenberger.
11 # Redistribution and use in source and binary forms, with or without
12 # modification, are permitted provided that the following conditions
14 # 1. Redistributions of source code must retain the above copyright
15 # notice, this list of conditions and the following disclaimer.
16 # 2. Redistributions in binary form must reproduce the above copyright
17 # notice, this list of conditions and the following disclaimer in the
18 # documentation and/or other materials provided with the distribution.
20 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 # POSSIBILITY OF SUCH DAMAGE.
33 ######################################################################
36 # reduce-resolved-depends.awk -- drop redundant build dependencies
39 # reduce-resolved-depends.awk
42 # reduce-resolved-depends.awk removes build dependencies from the
43 # dependency list on stdin, if they provided as dependency of
44 # one of the full dependencies in the list.
49 # HOST_PKG_INFO (for cross-compilation)
51 ######################################################################
54 CAT =
ENVIRON["CAT"] ?
ENVIRON["CAT"] : "cat"
55 PKG_INFO =
ENVIRON["PKG_INFO"] ?
ENVIRON["PKG_INFO"] : "pkg_info"
56 HOST_PKG_INFO =
ENVIRON["HOST_PKG_INFO"] ?
ENVIRON["HOST_PKG_INFO"] : "pkg_info"
58 PROGNAME =
"reduce-resolved-depends.awk"
61 while (getline ==
1) {
63 print "ERROR: [" PROGNAME
"] invalid dependency line " $
0 | ERRCAT
70 print "ERROR: [" PROGNAME
"] invalid dependency line " $
0 | ERRCAT
79 # Register all full dependencies first.
80 # Keep track of the first line for each of them to skip duplicates later.
81 for (i =
0; i
< lines
; ++i
) {
82 if (type
[i
] ==
"full" && checked_full
[pkg
[i
]] != 1) {
83 checked_full
[pkg
[i
]] =
1
84 checked_build
[pkg
[i
]] =
1
85 checked_tool
[pkg
[i
]] =
1
86 checked_bootstrap
[pkg
[i
]] =
1
91 for (i =
0; i
< lines
; ++i
) {
92 if (type
[i
] ==
"bootstrap" && checked_bootstrap
[pkg
[i
]] != 1) {
93 checked_bootstrap
[pkg
[i
]] =
1
95 if (PKG_INFO == HOST_PKG_INFO
) {
96 cmd = PKG_INFO
" -qr " pkg
[i
]
97 while (cmd
| getline dpkg
) {
98 if (checked_full
[dpkg
] ==
1)
108 for (i =
0; i
< lines
; ++i
) {
109 if (type
[i
] ==
"tool" && checked_tool
[pkg
[i
]] != 1) {
110 checked_tool
[pkg
[i
]] =
1
111 if (checked_bootstrap
[pkg
[i
]] ==
1)
114 if (PKG_INFO == HOST_PKG_INFO
) {
115 cmd = PKG_INFO
" -qr " pkg
[i
]
116 while (cmd
| getline dpkg
) {
117 if (checked_full
[dpkg
] ==
1)
127 for (i =
0; i
< lines
; ++i
) {
128 if (type
[i
] ==
"build" && checked_build
[pkg
[i
]] != 1) {
129 checked_build
[pkg
[i
]] =
1
130 if (PKG_INFO == HOST_PKG_INFO
)
131 if (checked_bootstrap
[pkg
[i
]] ==
1)
134 cmd = PKG_INFO
" -qr " pkg
[i
]
135 while (cmd
| getline dpkg
) {
136 if (checked_full
[dpkg
] ==
1)
145 for (i =
0; i
< lines
; ++i
) {
146 if (print_line
[i
] ==
1)
147 printf("%s\t%s\t%s\n", type
[i
], pattern
[i
], pkg
[i
])