]> xenbits.xensource.com Git - people/gdunlap/raisin.git/.git/commitdiff
Basic distro recognition and dependency installation framework
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>
Mon, 16 Mar 2015 11:54:29 +0000 (11:54 +0000)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Mon, 16 Mar 2015 11:56:21 +0000 (11:56 +0000)
Fix config file.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
build.sh
config
grub.sh
libvirt.sh
xen.sh

index a96f403f03827f6b2a6c34388388ea6b9524ad10..7dafda7c42ca78fc42d866c558ff11d4b5683c5a 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -15,11 +15,86 @@ source xen.sh
 source grub.sh
 source libvirt.sh
 
+function get_distro() {
+    if test -x `which lsb_release 2>/dev/null`
+    then
+        os_VENDOR=`lsb_release -i -s`
+        os_RELEASE=`lsb_release -r -s`
+        os_CODENAME=`lsb_release -c -s`
+        os_UPDATE=""
+    elif test -r /etc/redhat-release
+    then
+        # Red Hat Enterprise Linux Server release 5.5 (Tikanga)
+        # Red Hat Enterprise Linux Server release 7.0 Beta (Maipo)
+        # CentOS release 5.5 (Final)
+        # CentOS Linux release 6.0 (Final)
+        # Fedora release 16 (Verne)
+        # XenServer release 6.2.0-70446c (xenenterprise)
+        os_CODENAME=""
+        for r in "Red Hat" "CentOS" "Fedora" "XenServer"; do
+            os_VENDOR="$r"
+            if test -n "`grep -i \"$r\" /etc/redhat-release`"
+            then
+                ver=`sed -e 's/^.* \([0-9].*\) (\(.*\)).*$/\1\|\2/' /etc/redhat-release`
+                os_CODENAME=${ver#*|}
+                os_RELEASE=${ver%|*}
+                os_UPDATE=${os_RELEASE##*.}
+                os_RELEASE=${os_RELEASE%.*}
+                break
+            fi
+        done
+    elif test -r /etc/SuSE-release
+    then
+        for r in "openSUSE" "SUSE Linux"
+        do
+            os_VENDOR="$r"
+
+            if test -n "`grep -i \"$r\" /etc/SuSE-release`"
+            then
+                os_CODENAME=`grep "CODENAME = " /etc/SuSE-release | sed 's:.* = ::g'`
+                os_RELEASE=`grep "VERSION = " /etc/SuSE-release | sed 's:.* = ::g'`
+                os_UPDATE=`grep "PATCHLEVEL = " /etc/SuSE-release | sed 's:.* = ::g'`
+                break
+            fi
+        done
+    # If lsb_release is not installed, we should be able to detect Debian OS
+    elif test -f /etc/debian_version && [[ `cat /proc/version` =~ "Debian" ]]
+    then
+        os_VENDOR="Debian"
+        os_CODENAME=`awk '/VERSION=/' /etc/os-release | sed 's/VERSION=//' | sed -r 's/\"|\(|\)//g' | awk '{print $2}'`
+        os_RELEASE=`awk '/VERSION_ID=/' /etc/os-release | sed 's/VERSION_ID=//' | sed 's/\"//g'`
+    fi
+
+    # Simply distro version string
+    case "$os_VENDOR" in
+        "Ubuntu"* | "LinuxMint"* )
+            DISTRO="Ubuntu"
+            ;;
+        "SUSE"* )
+            DISTRO="SUSE"
+            ;;
+        "OpenSUSE"* | "openSUSE"* )
+            DISTRO="openSUSE"
+            ;;
+        "Red"* | "CentOS"* )
+            DISTRO="CentOS"
+            ;;
+        *)
+            DISTRO=$os_VENDOR
+            ;;
+    esac
+
+    export os_VENDOR os_RELEASE os_UPDATE os_CODENAME
+    export DISTRO
+}
+
 
 # execution
 rm -rf "$INST_DIR"
 mkdir -p "$INST_DIR"
 
+get_distro
+
 if test "$XEN_UPSTREAM_REVISION"
 then
     xen_clean
diff --git a/config b/config
index 5ef080387aad439ebb444e0625078e2ac5400697..a69aa65a9787b72ec27a2c9b58b92fa63723cd44 100644 (file)
--- a/config
+++ b/config
@@ -7,15 +7,15 @@ PREFIX="/usr"
 DESTDIR=dist
 
 # Git urls
-#XEN_UPSTREAM_URL=${XEN_UPSTREAM_URL-"http://xenbits.xen.org/git-http/xen.git"}
-#GRUB_UPSTREAM_URL=${GRUB_UPSTREAM_URL-"http://git.savannah.gnu.org/r/grub.git"}
-#LIBVIRT_UPSTREAM_URL=${LIBVIRT_UPSTREAM_URL-"https://gitorious.org/libvirt/libvirt.git"}
-XEN_UPSTREAM_URL=${XEN_UPSTREAM_URL-"git://xenbits.xen.org/xen.git"}
-GRUB_UPSTREAM_URL=${GRUB_UPSTREAM_URL-"git://git.savannah.gnu.org/grub.git"}
-LIBVIRT_UPSTREAM_URL=${LIBVIRT_UPSTREAM_URL-"git://libvirt.org/libvirt.git"}
+#XEN_UPSTREAM_URL="http://xenbits.xen.org/git-http/xen.git"
+#GRUB_UPSTREAM_URL="http://git.savannah.gnu.org/r/grub.git"
+#LIBVIRT_UPSTREAM_URL="https://gitorious.org/libvirt/libvirt.git"
+XEN_UPSTREAM_URL="git://xenbits.xen.org/xen.git"
+GRUB_UPSTREAM_URL="git://git.savannah.gnu.org/grub.git"
+LIBVIRT_UPSTREAM_URL="git://libvirt.org/libvirt.git"
 
 # Software versions. Leave blank if you want to avoid the build
 # XEN_UPSTREAM_REVISION=
-XEN_UPSTREAM_REVISION=${XEN_UPSTREAM_REVISION-"RELEASE-4.5.0"}
-GRUB_UPSTREAM_REVISION=${GRUB_UPSTREAM_REVISION-"master"}
-LIBVIRT_UPSTREAM_REVISION=${LIBVIRT_UPSTREAM_REVISION-"v1.2.9.1"}
+XEN_UPSTREAM_REVISION="RELEASE-4.5.0"
+GRUB_UPSTREAM_REVISION="master"
+LIBVIRT_UPSTREAM_REVISION="v1.2.9.1"
diff --git a/grub.sh b/grub.sh
index b1fcc898416f6912f326456af72102a60c633730..cd75003369f6a34cabd7807216d95467ea797f46 100644 (file)
--- a/grub.sh
+++ b/grub.sh
@@ -2,12 +2,23 @@
 
 source config
 
-grub_clean() {
+function grub_clean() {
     rm -rf memdisk.tar
     rm -rf grub-dir
 }
 
-grub_build() {
+function grub_build() {
+    # install dependencies
+    case $DISTRO in
+        "Debian" | "Ubuntu" )
+        apt-get install build-essential
+        ;;
+        * )
+        echo "I don't know how to install grub dependencies on $DISTRO"
+        return 1
+        ;;
+    esac
+
     tar cf memdisk.tar grub.cfg
     ./git-checkout.sh $GRUB_UPSTREAM_URL $GRUB_UPSTREAM_REVISION grub-dir
     cd grub-dir
index 0a587486bbc0733fd3c405519640b48556def0a7..da390f78fa6fbd10368cbb4349dfb7952606a4ad 100644 (file)
@@ -2,11 +2,22 @@
 
 source config
 
-libvirt_clean() {
+function libvirt_clean() {
     rm -rf libvirt-dir
 }
 
-libvirt_build() {
+function libvirt_build() {
+    # install dependencies
+    case $DISTRO in
+        "Debian" | "Ubuntu" )
+        apt-get install build-essential
+        ;;
+        * )
+        echo "I don't know how to install libvirt dependencies on $DISTRO"
+        return 1
+        ;;
+    esac
+
     ./git-checkout.sh $LIBVIRT_UPSTREAM_URL $LIBVIRT_UPSTREAM_REVISION libvirt-dir
     cd libvirt-dir
     ./autogen.sh --disable-threads --with-xen --without-qemu --without-uml     \
diff --git a/xen.sh b/xen.sh
index edf7a37b520134bdb85b16d0a170c3d845a77e52..34ab869b52af6d1005a2bcabc1f37af9d8a46ddb 100644 (file)
--- a/xen.sh
+++ b/xen.sh
@@ -2,11 +2,22 @@
 
 source config
 
-xen_clean() {
+function xen_clean() {
     rm -rf xen-dir
 }
 
-xen_build() {
+function xen_build() {
+    # install dependencies
+    case $DISTRO in
+        "Debian" | "Ubuntu" )
+        apt-get install build-essential
+        ;;
+        * )
+        echo "I don't know how to install xen dependencies on $DISTRO"
+        return 1
+        ;;
+    esac
+
     ./git-checkout.sh $XEN_UPSTREAM_URL $XEN_UPSTREAM_REVISION xen-dir
     cd xen-dir
     ./configure --prefix=$PREFIX