]> xenbits.xensource.com Git - raisin.git/commitdiff
Introduce common_init fuction
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>
Thu, 26 Mar 2015 05:15:17 +0000 (05:15 +0000)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Thu, 26 Mar 2015 05:16:28 +0000 (05:16 +0000)
Move common variable initializations from raise.sh and unraise.sh to
common_init in common_functions.sh.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
common-functions.sh
raise.sh
unraise.sh

index c68a373c0a5301963cc10c537728d4f93e3e1945..706d332b3be8404c05bf577c789715e049a2e623 100644 (file)
@@ -1,5 +1,35 @@
 #!/usr/bin/env bash
 
+function common_init() {
+    export BASEDIR=`pwd`
+    export GIT=${GIT-git}
+    export SUDO=${SUDO-sudo}
+    export MAKE=${MAKE-make}
+    export PREFIX=${PREFIX-/usr}
+    export INST_DIR=${DESTDIR-dist}
+    
+    INST_DIR=`readlink -f $INST_DIR`
+    
+    # execution
+    if test $EUID -eq 0
+    then
+        export SUDO=""
+    elif test ! -f `which sudo 2>/dev/null`
+    then
+        echo "Raixen requires sudo to install build dependencies for you."
+        echo "Please install sudo, then run this script again."
+        exit 1
+    fi
+
+    get_distro
+    get_arch
+
+    for f in `cat "$BASEDIR"/components/series`
+    do
+        source "$BASEDIR"/components/"$f"
+    done
+}
+
 function get_distro() {
     if test -x "`which lsb_release 2>/dev/null`"
     then
index b96e0dffacfb313c822f672416c60da3a8d90435..887779ba4ef9ae3fe49c681d6301d5817c77befd 100755 (executable)
--- a/raise.sh
+++ b/raise.sh
@@ -5,16 +5,6 @@ set -e
 source config
 source common-functions.sh
 
-export BASEDIR=`pwd`
-export GIT=${GIT-git}
-export SUDO=${SUDO-sudo}
-export MAKE=${MAKE-make}
-export PREFIX=${PREFIX-/usr}
-export INST_DIR=${DESTDIR-dist}
-
-INST_DIR=`readlink -f $INST_DIR`
-mkdir -p "$INST_DIR" &>/dev/null
-
 help() {
     echo "Usage: ./build.sh <options>"
     echo "where options are:"
@@ -23,16 +13,7 @@ help() {
     echo "    -i | --install       Install under / and configure the system"
 }
 
-# execution
-if test $EUID -eq 0
-then
-    export SUDO=""
-elif test ! -f `which sudo 2>/dev/null`
-then
-    echo "Raixen requires sudo to install build dependencies for you."
-    echo "Please install sudo, then run this script again."
-    exit 1
-fi
+common_init
 
 # parameters check
 INST=0
@@ -58,17 +39,9 @@ do
   fi
 done
 
-
-get_distro
-get_arch
-
+mkdir -p "$INST_DIR" &>/dev/null
 install_dependencies git
 
-for f in `cat "$BASEDIR"/components/series`
-do
-    source "$BASEDIR"/components/"$f"
-done
-
 # build and install under $DESTDIR ($BASEDIR/dist by default)
 for_each_component clean
 for_each_component build
@@ -86,5 +59,3 @@ $SUDO cp -ar * / || true
 
 # configure
 for_each_component configure
-
-rm -rf "$INST_DIR"
index 43b8d1e561f19ff4042693194f934f5759691536..f9738460adbb9d6445bddf98d904a6d32a3a5450 100644 (file)
@@ -5,32 +5,7 @@ set -e
 source config
 source common-functions.sh
 
-export BASEDIR=`pwd`
-export GIT=${GIT-git}
-export SUDO=${SUDO-sudo}
-export MAKE=${MAKE-make}
-export PREFIX=${PREFIX-/usr}
-export INST_DIR=${DESTDIR-dist}
-
-INST_DIR=`readlink -f $INST_DIR`
-
-if test $EUID -eq 0
-then
-    export SUDO=""
-elif test ! -f `which sudo 2>/dev/null`
-then
-    echo "Raixen requires sudo to install build dependencies for you."
-    echo "Please install sudo, then run this script again."
-    exit 1
-fi
-
-get_distro
-get_arch
-
-for f in `cat "$BASEDIR"/components/series`
-do
-    source "$BASEDIR"/components/"$f"
-done
+common_init
 
 for_each_component clean
 for_each_component unconfigure