Last active
April 22, 2016 12:59
-
-
Save rhencke/9a3b0f31126584fc8a58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/awk -f | |
# use: print-pkg-build-order.awk <package> [<package>...] | |
# prints all packages that would be built by building <package>(s), in build order. | |
BEGIN { | |
if (!ENVIRON["S"]) { | |
error("$S is not set. be sure to source config: . ./config") | |
} | |
if (ARGC<2) { | |
error("please provide one or more packages to print the build order for.") | |
} | |
for(a=1; a<ARGC; a++) { | |
print_build_order(ARGV[a]) | |
} | |
} | |
function error(msg) { | |
print "error: " msg > "/dev/stderr" | |
exit 1 | |
} | |
function print_build_order(pkg, inDepsSection, dep, pkgFile) { | |
pkgFile=ENVIRON["S"] "/pkg/" pkg | |
if (SEEN[pkg]) { | |
return | |
} | |
while ((r = getline < pkgFile) == 1) { | |
dep=$0 | |
if (/\[deps(\.host|\.run)?\]/) { | |
inDepsSection=1 | |
continue | |
} | |
if (/\[/) { | |
inDepsSection=0 | |
} | |
if (/^\s*$/ || !inDepsSection) { | |
continue | |
} | |
print_build_order(dep) | |
} | |
if (r == -1) { | |
error("unable to read from " pkgFile) | |
} | |
if(SEEN[pkg]) { | |
error("circular dependency detected for " pkg ".") | |
} | |
print pkg | |
SEEN[pkg]=1 | |
close(pkgFile) | |
} |
Whup - hi, @rofl0r! Sorry, I didn't get a notice until the mention.
Please feel free to use this in Sabotage under the terms of the Sabotage license. If it would help if I made a PR instead, just let me know.
thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi there, i'd like to use this in sabotage under the terms of the sabotage license.
since you didn't file a PR (which implies that your contribution is made under the project's license) i have to ask for the licensing terms.