Last active
September 13, 2021 17:38
-
-
Save maxice8/b46e80a4656ab196582f5da816fbdf9c to your computer and use it in GitHub Desktop.
Script to get all binaries that use a specific module
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
#!/usr/bin/env rc | |
# Assume all packages given are already installed | |
if(test $#* -lt 2) exit 1 | |
module=$1 | |
shift | |
for(pkg in $*) { | |
# Get all go binaries by checking for 'Go BuildID=' | |
for(bin in `{apk info -q -L $pkg \ | |
| grep -v '^usr/share' \ | |
| xargs -I '{}' file /'{}' \ | |
| grep 'Go BuildID=' \ | |
| cut -d : -f1}) { | |
# Use 'grep >/dev/null' instead of 'grep -q' since the latter | |
# gives a sigpipe for some reason | |
if(grep -q -x $module <{strings $bin}) { | |
echo $pkg | |
break | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment