Skip to content

Instantly share code, notes, and snippets.

@maxice8
Created November 5, 2021 09:03
Show Gist options
  • Save maxice8/a3c83e466c9aeae081cb9468840d00fe to your computer and use it in GitHub Desktop.
Save maxice8/a3c83e466c9aeae081cb9468840d00fe to your computer and use it in GitHub Desktop.
#!/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