From: Doug Goldstein Subject: [raisin][PATCH] Gracefully handle an unsupported distro. Date: Tue, 18 Aug 2015 18:12:54 -0500 Message-ID: <1439939574-1225-1-git-send-email-cardoe@cardoe.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZRq4G-0007Nr-Db for xen-devel@lists.xenproject.org; Tue, 18 Aug 2015 23:13:20 +0000 Received: by ykbi184 with SMTP id i184so110195193ykb.2 for ; Tue, 18 Aug 2015 16:13:18 -0700 (PDT) List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Doug Goldstein List-Id: xen-devel@lists.xenproject.org When your distro is not supported, handle the case gracefully and let the user know instead of spitting out bash errors. Signed-off-by: Doug Goldstein --- lib/common-functions.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/common-functions.sh b/lib/common-functions.sh index efde84c..c52174a 100644 --- a/lib/common-functions.sh +++ b/lib/common-functions.sh @@ -176,6 +176,7 @@ function get_distro() { ;; *) DISTRO=$os_VENDOR + PKGTYPE="unknown" ;; esac @@ -220,6 +221,16 @@ function _install-package-rpm() { $SUDO yum install -y $* > /dev/null } +function _check-package-unknown() { + error_echo "I don't know distro $DISTRO. It might be missing packages." + return 1 +} + +function _install-package-unknown() { + error_echo "I don't know distro $DISTRO. Cannot install packages." + return 1 +} + # Modifies inherited variable "missing" function check-package() { for p in $* -- 2.4.6