Annotation of pkgsrc/mk/scripts/chkdatabase.awk, revision 1.4
1.1 dmcmahil 1: #!/usr/bin/awk -f
2: #
1.4 ! maya 3: # $NetBSD: chkdatabase.awk,v 1.3 2006/12/15 12:46:24 martti Exp $
1.1 dmcmahil 4: #
5: # Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
6: # All rights reserved.
7: #
8: # This code is derived from software contributed to The NetBSD Foundation
9: # by Dan McMahill.
10: #
11: # Redistribution and use in source and binary forms, with or without
12: # modification, are permitted provided that the following conditions
13: # are met:
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.
19: #
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.
31: #
32:
33: # This script reads a pkgsrc database created with the 'print-summary-data'
34: # target and returns a lists of packages which are listed as DEPENDS and/or
35: # BUILD_DEPENDS but do not have their own dependencies recorded yet.
36: # This can be used as part of a loop which makes several passes to record
37: # the complete dependency tree for a package in the database
38: #
39:
40: BEGIN {
41: if(debug) {
42: printf("Reading database file\n") > "/dev/stderr";
43: fflush("/dev/stderr");
44: }
45: }
46:
47: /^(build_)?depends / {
48: #
49: # Read in the entire depends tree
50: # These lines look like:
51: #
52: #depends /usr/pkgsrc/math/scilab xless-[0-9]*:../../x11/xless pvm-3.4.3:../../parallel/pvm3
53: #build_depends /usr/pkgsrc/math/scilab libtool-base>=1.4.20010614nb9:../../devel/libtool-base
54: #
55: pkg = $2;
1.3 martti 56:
1.1 dmcmahil 57: # mark this package as having its depencencies listed
58: depended_pkgs[pkg] = 1;
1.3 martti 59:
1.1 dmcmahil 60: # now go through the dependency lists and pull out all pkg directories that
61: # we will need to examine to ensure they have been depended.
62: for(i=3; i<=NF; i++) {
63: split($i,a,":");
64: pkgpat=a[1];
65: pkgdir=a[2];
66: sub(/[\.\/]*/,"",pkgdir);
67: if(pkgdir !~ /\//) {
68: pkgcat=pkg;
69: gsub(/\/.*/,"",pkgcat);
70: pkgdir=pkgcat "/" pkgdir;
71: if(debug) printf("Corrected missing category directory to get \"%s\"\n",pkgdir) > "/dev/stderr";
72: }
73: if(debug){
74: printf("package in directory %s %s on:\n",pkg,deptype) > "/dev/stderr";
75: printf("\tpkgpat = %s\n",pkgpat) > "/dev/stderr";
76: printf("\tpkgdir = %s\n",pkgdir) > "/dev/stderr";
77: }
1.3 martti 78:
1.1 dmcmahil 79: # mark this package directory as being one which is depended upon
80: depended_on_pkgs[pkgdir] = 1;
1.3 martti 81:
1.1 dmcmahil 82: }
83: next;
84: }
85:
86:
87: END {
88: i=0;
89: for(pkg in depended_on_pkgs) {
90: if(pkg in depended_pkgs) {
91: if(debug) printf("Package: %s is already depended\n",pkg) > "/dev/stderr";
92: }
93: else {
94: if(debug)printf("Package: %s is NOT depended\n",pkg) > "/dev/stderr";
95: not_depended[i]=pkg;
96: i++;
97: }
98: }
1.3 martti 99:
1.1 dmcmahil 100: i=0;
101: while(i in not_depended) {
102: printf("%s\n",not_depended[i]);
103: i++;
104: }
105: close("/dev/stderr");
1.3 martti 106:
1.1 dmcmahil 107: exit(0);
108: }
CVSweb <webmaster@jp.NetBSD.org>