#!/bin/bash ACTION="$1" DEPENDS="libgl1-mesa-glx" shift PACKAGE_LIST=$@ case $ACTION in preInstall) for ix in $DEPENDS do apt-get install -y $ix TEST=$( dpkg-query -s $ix 2> /dev/null| grep Status | cut -d " " -f 4 ) if [ "$TEST" != 'installed' ];then exit 1 fi done ;; remove) for ix in $PACKAGE_LIST do apt-get remove -y $ix TEST=$( dpkg-query -s $ix 2> /dev/null| grep Status | cut -d " " -f 4 ) if [ "$TEST" == 'installed' ];then exit 1 fi done ;; esac exit 0