Skip to content

Instantly share code, notes, and snippets.

@rhencke
Last active April 22, 2016 12:59
Show Gist options
  • Save rhencke/9a3b0f31126584fc8a58 to your computer and use it in GitHub Desktop.
Save rhencke/9a3b0f31126584fc8a58 to your computer and use it in GitHub Desktop.
#!/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)
}
@rofl0r
Copy link

rofl0r commented Apr 18, 2016

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.

@rhencke
Copy link
Author

rhencke commented Apr 22, 2016

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.

@rofl0r
Copy link

rofl0r commented Apr 22, 2016

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment