Skip to content

Instantly share code, notes, and snippets.

@0x715C
Forked from popey/lddtostage
Last active October 31, 2019 23:57
Show Gist options
  • Save 0x715C/8414f2f5f5ef2a5ceb3bfc737325b9f6 to your computer and use it in GitHub Desktop.
Save 0x715C/8414f2f5f5ef2a5ceb3bfc737325b9f6 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=$(pacman -Fq $p | 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