| @@ -1,16 +1,16 @@ | | | @@ -1,16 +1,16 @@ |
1 | #!/usr/bin/awk -f | | 1 | #!/usr/bin/awk -f |
2 | # | | 2 | # |
3 | # $NetBSD: reduce-depends.awk,v 1.3 2014/10/08 10:04:45 jperkin Exp $ | | 3 | # $NetBSD: reduce-depends.awk,v 1.4 2017/05/19 14:58:51 joerg Exp $ |
4 | # | | 4 | # |
5 | # Copyright (c) 2006 The NetBSD Foundation, Inc. | | 5 | # Copyright (c) 2006 The NetBSD Foundation, Inc. |
6 | # All rights reserved. | | 6 | # All rights reserved. |
7 | # | | 7 | # |
8 | # This code is derived from software contributed to The NetBSD Foundation | | 8 | # This code is derived from software contributed to The NetBSD Foundation |
9 | # by Johnny C. Lam. | | 9 | # by Johnny C. Lam. |
10 | # | | 10 | # |
11 | # Redistribution and use in source and binary forms, with or without | | 11 | # Redistribution and use in source and binary forms, with or without |
12 | # modification, are permitted provided that the following conditions | | 12 | # modification, are permitted provided that the following conditions |
13 | # are met: | | 13 | # are met: |
14 | # 1. Redistributions of source code must retain the above copyright | | 14 | # 1. Redistributions of source code must retain the above copyright |
15 | # notice, this list of conditions and the following disclaimer. | | 15 | # notice, this list of conditions and the following disclaimer. |
16 | # 2. Redistributions in binary form must reproduce the above copyright | | 16 | # 2. Redistributions in binary form must reproduce the above copyright |
| @@ -71,26 +71,29 @@ BEGIN { | | | @@ -71,26 +71,29 @@ BEGIN { |
71 | # Gather all dependencies into the depends array. Index 0 of the | | 71 | # Gather all dependencies into the depends array. Index 0 of the |
72 | # depends[pkgpath] array is the number of patterns associated with | | 72 | # depends[pkgpath] array is the number of patterns associated with |
73 | # that pkgpath. | | 73 | # that pkgpath. |
74 | # | | 74 | # |
75 | args = ARGV[1] | | 75 | args = ARGV[1] |
76 | ARGC = split(args, ARGV); ARGC++ | | 76 | ARGC = split(args, ARGV); ARGC++ |
77 | for (i = 1; i < ARGC; i++) { | | 77 | for (i = 1; i < ARGC; i++) { |
78 | pattern = ARGV[i]; sub(":.*", "", pattern) | | 78 | pattern = ARGV[i]; sub(":.*", "", pattern) |
79 | dir = ARGV[i]; sub(".*:", "", dir) | | 79 | dir = ARGV[i]; sub(".*:", "", dir) |
80 | if (pattern ":" dir != ARGV[i]) { | | 80 | if (pattern ":" dir != ARGV[i]) { |
81 | print "ERROR: [" PROGNAME "] invalid dependency pattern: " ARGV[i] | ERRCAT | | 81 | print "ERROR: [" PROGNAME "] invalid dependency pattern: " ARGV[i] | ERRCAT |
82 | exit 1 | | 82 | exit 1 |
83 | } | | 83 | } |
| | | 84 | if (pattern_seen[pattern] == 1) |
| | | 85 | continue |
| | | 86 | pattern_seen[pattern] = 1 |
84 | cmd = TEST " -d " dir | | 87 | cmd = TEST " -d " dir |
85 | if (system(cmd) == 0) { | | 88 | if (system(cmd) == 0) { |
86 | cmd = "cd " dir " && " PWD_CMD | | 89 | cmd = "cd " dir " && " PWD_CMD |
87 | while ((cmd | getline pkgpath) > 0) { | | 90 | while ((cmd | getline pkgpath) > 0) { |
88 | if (!(pkgpath in pkgsrcdirs)) { | | 91 | if (!(pkgpath in pkgsrcdirs)) { |
89 | pkgpaths[P++] = pkgpath | | 92 | pkgpaths[P++] = pkgpath |
90 | pkgsrcdirs[pkgpath] = dir | | 93 | pkgsrcdirs[pkgpath] = dir |
91 | } | | 94 | } |
92 | depends[pkgpath, 0]++; | | 95 | depends[pkgpath, 0]++; |
93 | depends[pkgpath, depends[pkgpath, 0]] = pattern | | 96 | depends[pkgpath, depends[pkgpath, 0]] = pattern |
94 | } | | 97 | } |
95 | close(cmd) | | 98 | close(cmd) |
96 | } else { | | 99 | } else { |