#!/bin/sh # 2019, Joost van Baal-Ilić # This code is in the public domain, no copyright is claimed # copy from: # $Id: apt-is 105635 2019-08-19 10:34:27Z joostvb $ # # apt-is - test status of packages # # usage: # apt-is action package # # examples: # # $ apt-is available uruk # true # # $ apt-is installed caspar # false # # apt-is installed $pkg && do stuff # # if `apt-is missing $module`; then pip cargo pear install blah; fi # case "$1" in installed) if dpkg -s "$2" 2>/dev/null | grep Status | grep -q installed then echo true else echo false exit 1 fi ;; available) if apt-cache show "$2" >/dev/null 2>&1 then echo true else echo false exit 1 fi ;; missing) # candidate for installing from non-debian non-apt sources: not installed, not available if dpkg -s "$2" 2>/dev/null | grep Status | grep -q installed then echo false exit 1 elif apt-cache show "$2" >/dev/null 2>&1 then echo false exit 1 else echo true fi ;; *) echo "$0: usage: apt-is {available|installed|missing} " esac exit 0