Skip to content

Instantly share code, notes, and snippets.

@n00bsys0p
Last active August 29, 2015 13:58
Show Gist options
  • Save n00bsys0p/10021929 to your computer and use it in GitHub Desktop.
Save n00bsys0p/10021929 to your computer and use it in GitHub Desktop.
Generates a list of installed packages that are required to go in the "Depends" section of a debian package for a single binary.
#!/bin/bash
# Pass this program the relative or full path to a binary to parse with `ldd`
PROGRAM=$1
LDD_FILES=$(ldd "$1" | awk '{print $3}' | sed '/^$/d' | egrep -v "^\(0x.*\)")
for FILE in $LDD_FILES
do
dpkg -S $FILE | awk '{print $1}' | tr -d ':'
echo
done | tr '\n' ',' | sed 's/,,/, /g' | sed 's/..$//g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment