Skip to content

Instantly share code, notes, and snippets.

@popey
Last active October 31, 2019 23:58
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save popey/85644e69b4e55eed782908a79d9ed208 to your computer and use it in GitHub Desktop.
Save popey/85644e69b4e55eed782908a79d9ed208 to your computer and use it in GitHub Desktop.
Determine libraries needed by a binary and output in format for snapcraft.yaml
#!/bin/bash
TMPDIR=$(mktemp -d)
LDD=$TMPDIR/LDD
PACKAGES=$TMPDIR/PACKAGES
ldd $1 | awk -F ' ' '{print $3}' | sed '/^$/d' | sed '/^(/d' | grep -v '^not' > $LDD
while read p; do
echo -n .
package=$(dpkg -S $p | awk -F ' ' '{ print $1 }' | sed 's/:$//')
echo " - "$package >> $PACKAGES
done < $LDD
echo " "
sort $PACKAGES | uniq
rm -rf $TMPDIR
@flotwig
Copy link

flotwig commented Mar 2, 2019

Dude, this is awesome, thank you ❤️

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