get debian packages for linked libraries in an executable


/ Published in: Bash
Save to your folder(s)

You can use this snippet to get the packages your application depends on in a debian distro. Quite usefull when you are a new debian package maintainer and want to package a pretty highlevel c++ binary


Copy this code and paste it in your HTML
  1. #! /bin/bash
  2. links=$(ldd $1 | cut -f2 | cut -d">" -f2 | cut -d"(" -f1)
  3. packages=$(dpkg -S $links 2>/dev/null | cut -d":" -f1)
  4. touch ./packages.txt
  5. for i in $packages
  6. do
  7. if [ ! "$(grep "$i" packages.txt)" ]; then
  8. version=$(apt-cache policy $i | grep "Installed:" | cut -d" " -f4)
  9. echo "$i (>= $version )" >> packages.txt
  10. fi
  11. done

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.