2 # aur-graph - print package/dependency pairs
5 # = 0 : if ver1 == ver2
7 function get_vercmp
(ver1
, ver2
, op
) {
8 command =
("vercmp " ver1
" " ver2
)
10 if (op ==
"-" || ver2 ==
"-") {
11 return "true" # dependency is unversioned
12 } else if (op ==
"=") {
13 return (ver1 == ver2
) # common case
14 } else if (op ==
"<") {
18 } else if (op ==
">") {
22 } else if (op ==
"<=") {
26 } else if (op ==
">=") {
31 printf("invalid operation\n") > "/dev/stderr"
41 # track both the pkgbases themselves and their number of deps
42 dep_counts
[pkgbase
] =
0
52 if ((!
length(DEPENDS
) || DEPENDS ==
1) && !in_split_pkg
)
53 pkg_deps
[pkgbase
, ++dep_counts
[pkgbase
]] = $
3 # versioned
57 if ((!
length(MAKEDEPENDS
) || MAKEDEPENDS ==
1) && !in_split_pkg
)
58 pkg_deps
[pkgbase
, ++dep_counts
[pkgbase
]] = $
3
62 if ((!
length(CHECKDEPENDS
) || CHECKDEPENDS ==
1) && !in_split_pkg
)
63 pkg_deps
[pkgbase
, ++dep_counts
[pkgbase
]] = $
3
67 if (OPTDEPENDS ==
1 && !in_split_pkg
) {
68 pkg_deps
[pkgbase
, ++dep_counts
[pkgbase
]] = $
3
77 pkg_map
[$
3] = pkgbase
# node
78 ver_map
[$
3] = pkgver
# weight
84 # if provider is unversioned, use pkgver
86 ver_map
[prov
[1]] = prov
[2]
88 ver_map
[prov
[1]] = pkgver
91 pkg_map
[prov
[1]] = pkgbase
97 for (pkgbase in dep_counts
) {
98 # add a loop to isolated nodes (#402)
99 printf("%s\t%s\n", pkgbase
, pkgbase
)
101 for (dep =
1; dep
<= dep_counts
[pkgbase
]; dep
++) {
102 dep_op =
"-" # unversioned / no comparison
104 # valid operators (important: <= before <)
105 split("<=|>=|<|=|>", cmp
, "|")
107 # split: fourth argument is gawk extension
109 split(pkg_deps
[pkgbase
, dep
], dep_split
, cmp
[i
])
111 if ("2" in dep_split
) {
117 if ("1" in dep_split
)
118 dep_pkgname = dep_split
[1]
122 if ("2" in dep_split
)
123 dep_pkgver = dep_split
[2]
127 # only print dependency if it was encountered before
128 if (dep_pkgname in pkg_map ==
0)
131 # run vercmp with provider and versioned dependency
132 if (get_vercmp
(ver_map
[dep_pkgname
], dep_pkgver
, dep_op
)) {
133 printf("%s\t%s\n", pkgbase
, pkg_map
[dep_pkgname
])
135 printf("invalid node: %s %s (required: %s%s)\n",
136 dep_pkgname
, ver_map
[dep_pkgname
], dep_op
, dep_pkgver
) > "/dev/stderr"
139 # delay mismatches to loop end