Last active
October 31, 2019 23:58
-
-
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
This file contains hidden or 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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dude, this is awesome, thank you ❤️