]> git.apps.os.sepia.ceph.com Git - ceph-build.git/commitdiff
Add get_rpm_dist function to build_utils
authorAndrew Schoen <aschoen@redhat.com>
Mon, 16 Nov 2015 15:55:45 +0000 (09:55 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Mon, 16 Nov 2015 21:32:58 +0000 (15:32 -0600)
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 <aschoen@redhat.com>
scripts/build_utils.sh

index 1145aa862909748699cfc9ad6e1cda5671acb468..36b7765fcdb04461f3433e0f9df687c0ca9989aa 100644 (file)
@@ -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
+
+}