Loading ...
Sorry, an error occurred while loading the content.

deb - determine if a package is installed

Expand Messages
  • J
    So here s an interesting problem... How can you tell, quickly, and cleanly and quietly if a .deb is installed? Meaning without a bunch of grepping. Obviously,
    Message 1 of 3 , Apr 24, 2013
    • 0 Attachment
      So here's an interesting problem...

      How can you tell, quickly, and cleanly and quietly if a .deb is installed?

      Meaning without a bunch of grepping.

      Obviously, you can do this:

      dpkg -l |grep -q packagename

      and for about 99% of the cases, that would work. It apparently does
      not in my case.

      What I have is a python test harness that runs things in subshells via
      python's Popen()

      in one of those test scripts, there's this innocuous bit of code:

      if ! dpkg -l | grep -q obexftp; then
      echo "You must install obexftp to run this script"
      exit 1

      Now, run from a console manually, that works fine. Running it from
      the script, that works fine. BUT, running it from inside the test
      harness results in this:

      dpkg-query: error: error writing to '<standard output>': Broken pipe

      BUT, even with that error, the comparison is still met and the test
      script continues on its merry.

      So I was trying to find a better way to replace the entire dpkg/grep
      combination and so far havent found anything that works.

      there's dpkg-query -s packagename, but that dumps a LOT of non-status
      info so grepping is still necessary.

      There's apt-cache but that too doesn't provide an easy, clean method,
      again dumping a bunch of unnecessary output.

      What I was REALLY hoping for was something like this:

      is_package_installed packagename

      which returns a simple 0 if yes, or 1 if no.

      Anyone know of any deb type tools that do that from a console (or some
      means of doing that using apt-get, dpkg, apt-cache or some other
      standard tool that I am not seeing in the man pages?)

      Cheers,

      Jeff
    • ed
      ... Normally, I d do dpkg --get-selections | grep package ... Oh ... What about dpkg-query -W ? -- Best regards, Ed http://www.s5h.net/
      Message 2 of 3 , Apr 24, 2013
      • 0 Attachment
        On Wed, Apr 24, 2013 at 06:25:47PM -0400, J wrote:
        > So here's an interesting problem...
        >
        > How can you tell, quickly, and cleanly and quietly if a .deb is installed?

        Normally, I'd do dpkg --get-selections | grep package

        > Meaning without a bunch of grepping.

        Oh

        > So I was trying to find a better way to replace the entire dpkg/grep
        > combination and so far havent found anything that works.
        >
        > there's dpkg-query -s packagename, but that dumps a LOT of non-status
        > info so grepping is still necessary.

        What about dpkg-query -W ?

        --
        Best regards,
        Ed http://www.s5h.net/
      • J
        ... Oh boy... thanks! I completely missed that while reading the man pages for dpkg-query. In my own defense, I was also cooking dinner, so that s my excuse
        Message 3 of 3 , Apr 24, 2013
        • 0 Attachment
          On Wed, Apr 24, 2013 at 7:01 PM, ed <ed@...> wrote:
          > On Wed, Apr 24, 2013 at 06:25:47PM -0400, J wrote:
          >> So here's an interesting problem...
          >>
          >> How can you tell, quickly, and cleanly and quietly if a .deb is installed?
          >
          > Normally, I'd do dpkg --get-selections | grep package
          >
          >> Meaning without a bunch of grepping.
          >
          > Oh
          >
          >> So I was trying to find a better way to replace the entire dpkg/grep
          >> combination and so far havent found anything that works.
          >>
          >> there's dpkg-query -s packagename, but that dumps a LOT of non-status
          >> info so grepping is still necessary.
          >
          > What about dpkg-query -W ?

          Oh boy... thanks! I completely missed that while reading the man
          pages for dpkg-query. In my own defense, I was also cooking dinner,
          so that's my excuse for missing something that obvious :)

          but thanks or pointing it out, that works like a charm.
        Your message has been successfully submitted and would be delivered to recipients shortly.