From 53fd0d240963eab98bd668c5a42f4ae4e6c59742 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Mon, 16 Nov 2015 09:55:45 -0600 Subject: [PATCH] Add get_rpm_dist function to build_utils This function is used in jobs that need to post binaries to chacra. Calling it creates DISTRO and DISTRO_VESION global variables that are suitable for creating a chacra endpoint with. Signed-off-by: Andrew Schoen --- scripts/build_utils.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/scripts/build_utils.sh b/scripts/build_utils.sh index 1145aa86..36b7765f 100644 --- a/scripts/build_utils.sh +++ b/scripts/build_utils.sh @@ -38,3 +38,45 @@ user = "$CHACRACTL_USER" key = "$CHACRACTL_KEY" EOF } + +get_rpm_dist() { + # creates a DISTRO_VERSION and DISTRO global variable for + # use in constructing chacra urls for rpm distros + + LSB_RELEASE=/usr/bin/lsb_release + [ ! -x $LSB_RELEASE ] && echo unknown && exit + + ID=`$LSB_RELEASE --short --id` + + case $ID in + RedHatEnterpriseServer) + DISTRO_VERSION=`$LSB_RELEASE --short --release | cut -d. -f1` + DISTRO=rhel + ;; + CentOS) + DISTRO_VERSION=`$LSB_RELEASE --short --release | cut -d. -f1` + DISTRO=centos + ;; + Fedora) + DISTRO_VERSION=`$LSB_RELEASE --short --release` + DISTRO=fedora + ;; + SUSE\ LINUX) + DESC=`$LSB_RELEASE --short --description` + DISTRO_VERSION=`$LSB_RELEASE --short --release` + case $DESC in + *openSUSE*) + DISTRO=opensuse + ;; + *Enterprise*) + DISTRO=sles + ;; + esac + ;; + *) + DIST=unknown + DISTRO=unknown + ;; + esac + +} -- 2.39.5