update Mon Jun 21 06:37:00 PDT 2010
[pkgsrc.git] / wip / pkg_summary-utils / files / enrich_XDEPENDS.in
1 #!/usr/bin/env runawk
2
3 #use "psu_funcs.awk"
4
5 #
6 # usage: enrich_XDEPENDS - <filename>
7 #
8
9 FILENAME == "-" {
10         if (/^PKGPATH=/){
11                 pkgpath = substr($0, 9)
12                 idx = index(pkgpath, ":")
13                 if (idx){
14                         assigns = substr(pkgpath, idx+1)
15                         pkgpath = substr(pkgpath, 1, idx-1)
16                 }
17         }else if (/^PKGNAME=/){
18                 pkgbase = substr($0, 9)
19                 sub(/-[^-]+$/, "", pkgbase)
20         }else if (/^ASSIGNMENTS=/){
21                 assigns = substr($0, 13)
22         }else if (NF == 0){
23                 if (assigns == "" || !((pkgpath SUBSEP pkgbase) in p2a))
24                         p2a [pkgpath, pkgbase] = assigns
25
26                 assigns = pkgpath = pkgbase = ""
27         }
28         next
29 }
30
31 match($0, /^(BUILD_)?DEPENDS=/) {
32         field = substr($0, 1, RLENGTH)
33         $0 = substr($0, RLENGTH+1)
34         for (i=1; i <= NF; ++i){
35                 idx = index($i, ":")
36                 pkgpath = normalize_pkgpath(substr($i, idx+1))
37                 pkgbase = pkgname2pkgbase(substr($i, 1, idx-1))
38 #               print "??????????????????????????", pkgpath, pkgbase
39                 if (((pkgpath SUBSEP pkgbase) in p2a) && p2a [pkgpath, pkgbase] != ""){
40                         $i = $i ":" p2a [pkgpath, pkgbase]
41                 }
42         }
43         print field $0
44         next
45 }
46
47 {
48         print $0
49 }