Created
December 14, 2017 18:45
-
-
Save popey/d4fab06244eba035892d490b90a7f8d2 to your computer and use it in GitHub Desktop.
Turn the output of ldd into something you can put in a snapcraft.yaml stage-packages section
This file contains 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 | |
# | |
# lddtostage | |
# | |
# usage: | |
# lddtostage somebinary | |
# | |
# This will run through each linked library and figure out which deb | |
# it came from and print the list for pasting into a snapcraft.yaml | |
# in a 'stage-packages' section. | |
# Not perfect, and may include things like libc6 and nvidia-* which | |
# you likely don't want in your snap, but it's a good head start. | |
TMPDIR=$(mktemp -d) | |
LDD=$TMPDIR/LDD | |
PACKAGES=$TMPDIR/PACKAGES | |
ldd $1 | awk -F ' ' '{print $3}' | sed '/^$/d' | sed '/^(/d' > $LDD | |
while read p; do | |
echo -n . | |
dpkg -S $p | awk -F ' ' '{ print $1 }' | sed 's/:$//' >> $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