]> xenbits.xensource.com Git - people/sstabellini/raisin.git/commitdiff
Import raise.sh and unraise.sh into library
authorGeorge Dunlap <george.dunlap@eu.citrix.com>
Thu, 9 Apr 2015 14:45:37 +0000 (15:45 +0100)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Fri, 10 Apr 2015 13:55:43 +0000 (13:55 +0000)
Make as few changes as possible to begin with, just to separate code
motion from changes.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
lib/commands.sh [new file with mode: 0755]
raise [new file with mode: 0755]
raise.sh [deleted file]
scripts/mkdeb
scripts/mkrpm
unraise.sh [deleted file]

diff --git a/lib/commands.sh b/lib/commands.sh
new file mode 100755 (executable)
index 0000000..5827565
--- /dev/null
@@ -0,0 +1,75 @@
+#!/usr/bin/env bash
+
+build() {
+    if [[ $YES != "y" ]]
+    then
+        echo "Do you want Raisin to automatically install build time dependencies for you? (y/n)"
+        while read answer
+        do
+            if [[ "$answer" = "n" ]]
+            then
+                NO_DEPS=1
+                break
+            elif [[ "$answer" = "y" ]]
+            then
+                break
+            else
+                echo "Reply y or n"
+            fi
+        done
+    fi
+
+    mkdir -p "$INST_DIR" &>/dev/null
+    install_dependencies git
+    if [[ $DISTRO = "Fedora" ]]
+    then
+        install_dependencies rpm-build
+    fi
+    # build and install under $DESTDIR
+    for_each_component clean
+    for_each_component build
+    
+    build_package xen-system
+}
+
+unraise() {
+    for_each_component clean
+
+    uninstall_package xen-system
+    for_each_component unconfigure
+
+    rm -rf "$INST_DIR"
+}
+
+install() {
+    # need single braces for filename matching expansion
+    if [ ! -f xen-sytem*rpm ] && [ ! -f xen-system*deb ]
+    then
+        echo You need to raise build first.
+        exit 1
+    fi
+    install_package xen-system
+}
+
+configure() {
+    if [[ $YES != "y" ]]
+    then
+        echo "Proceeding we'll make changes to the running system,"
+        echo "are you sure that you want to continue? (y/n)"
+        while read answer
+        do
+            if [[ "$answer" = "n" ]]
+            then
+                exit 0
+            elif [[ "$answer" = "y" ]]
+            then
+                break
+            else
+                echo "Reply y or n"
+            fi
+        done
+    fi
+
+    for_each_component configure
+}
+
diff --git a/raise b/raise
new file mode 100755 (executable)
index 0000000..37d1898
--- /dev/null
+++ b/raise
@@ -0,0 +1,65 @@
+#!/usr/bin/env bash
+
+set -e
+
+_help() {
+    echo "Usage: ./build.sh <options> <command>"
+    echo "where options are:"
+    echo "    -n | --no-deps       Do no install build-time dependencies"
+    echo "    -v | --verbose       Verbose"
+    echo "    -y | --yes           Do not ask questions and continue"
+    echo "where commands are:"
+    echo "    build                Build the components enabled in config"
+    echo "    install              Install binaries under /  (requires sudo)"
+    echo "    configure            Configure the system  (requires sudo)"
+    echo "    unraise              Uninstall and unconfigure the system  (requires sudo)"
+}
+
+# Include your defaults
+if [[ -e "./config" ]] ; then
+    . ./config
+fi
+
+# To use this as a library, set RAISIN_PATH appropriately
+[[ -z "$RAISIN_PATH" ]] && RAISIN_PATH="$PWD/lib"
+
+# Then as many as the sub-libraries as you need
+source ${RAISIN_PATH}/common-functions.sh
+source ${RAISIN_PATH}/git-checkout.sh
+source ${RAISIN_PATH}/commands.sh
+
+# Set up basic functionality
+common_init
+
+# parameters check
+export VERBOSE=0
+export YES="n"
+export NO_DEPS=0
+while [[ $# -gt 1 ]]
+do
+  if [[ "$1" = "-v" || "$1" = "--verbose" ]]
+  then
+    VERBOSE=1
+    shift 1
+  elif [[ "$1" = "-y" || "$1" = "--yes" ]]
+  then
+    YES="y"
+    shift 1
+  else
+    _help
+    exit 1
+  fi
+done
+
+case "$1" in
+    "build" | "install" | "configure" | "unraise" )
+        COMMAND=$1
+        ;;
+    *)
+        _help
+        exit 1
+        ;;
+esac
+
+$COMMAND
+
diff --git a/raise.sh b/raise.sh
deleted file mode 100755 (executable)
index 422fbe4..0000000
--- a/raise.sh
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-
-source config
-source lib/common-functions.sh
-source lib/git-checkout.sh
-
-_help() {
-    echo "Usage: ./build.sh <options> <command>"
-    echo "where options are:"
-    echo "    -n | --no-deps       Do no install build-time dependencies"
-    echo "    -v | --verbose       Verbose"
-    echo "    -y | --yes           Do not ask questions and continue"
-    echo "where commands are:"
-    echo "    build                Build the components enabled in config"
-    echo "    install              Install binaries under /  (requires sudo)"
-    echo "    configure            Configure the system  (requires sudo)"
-}
-
-_build() {
-    if [[ $YES != "y" ]]
-    then
-        echo "Do you want Raisin to automatically install build time dependencies for you? (y/n)"
-        while read answer
-        do
-            if [[ "$answer" = "n" ]]
-            then
-                NO_DEPS=1
-                break
-            elif [[ "$answer" = "y" ]]
-            then
-                break
-            else
-                echo "Reply y or n"
-            fi
-        done
-    fi
-
-    mkdir -p "$INST_DIR" &>/dev/null
-    install_dependencies git
-    if [[ $DISTRO = "Fedora" ]]
-    then
-        install_dependencies rpm-build
-    fi
-    # build and install under $DESTDIR
-    for_each_component clean
-    for_each_component build
-    
-    build_package xen-system
-}
-
-_install() {
-    # need single braces for filename matching expansion
-    if [ ! -f xen-sytem*rpm ] && [ ! -f xen-system*deb ]
-    then
-        echo You need to raise.sh build first.
-        exit 1
-    fi
-    install_package xen-system
-}
-
-_configure() {
-    if [[ $YES != "y" ]]
-    then
-        echo "Proceeding we'll make changes to the running system,"
-        echo "are you sure that you want to continue? (y/n)"
-        while read answer
-        do
-            if [[ "$answer" = "n" ]]
-            then
-                exit 0
-            elif [[ "$answer" = "y" ]]
-            then
-                break
-            else
-                echo "Reply y or n"
-            fi
-        done
-    fi
-
-    for_each_component configure
-}
-
-# start execution
-common_init
-
-# parameters check
-export VERBOSE=0
-export YES="n"
-export NO_DEPS=0
-while [[ $# -gt 1 ]]
-do
-  if [[ "$1" = "-v" || "$1" = "--verbose" ]]
-  then
-    VERBOSE=1
-    shift 1
-  elif [[ "$1" = "-y" || "$1" = "--yes" ]]
-  then
-    YES="y"
-    shift 1
-  else
-    _help
-    exit 1
-  fi
-done
-
-case "$1" in
-    "build" | "install" | "configure" )
-        COMMAND=$1
-        ;;
-    *)
-        _help
-        exit 1
-        ;;
-esac
-
-_$COMMAND
-
index 46ade075f984447314da1641dead64c2fd770126..44a4f7d5143121747a6a8cc704b46e64e98979bc 100755 (executable)
@@ -35,7 +35,8 @@ mkdir -p deb/opt/raisin
 cp -r data deb/opt/raisin
 cp -r components deb/opt/raisin
 cp -r scripts deb/opt/raisin
-cp config raise.sh unraise.sh deb/opt/raisin
+cp -r lib deb/opt/raisin
+cp config raise deb/opt/raisin
 
 
 # Debian doesn't use /usr/lib64 for 64-bit libraries
index c530466353979c3dee37e802c25bac7bf287d015..8de4508338ecdac98f3e284c22c8255a2708fcbb 100755 (executable)
@@ -47,9 +47,9 @@ mkdir -p \$RPM_BUILD_ROOT/opt/raisin
 cp -r "$BASEDIR"/data \$RPM_BUILD_ROOT/opt/raisin
 cp -r "$BASEDIR"/components \$RPM_BUILD_ROOT/opt/raisin
 cp -r "$BASEDIR"/scripts \$RPM_BUILD_ROOT/opt/raisin
+cp -r "$BASEDIR"/lib \$RPM_BUILD_ROOT/opt/raisin
 cp "$BASEDIR"/config \$RPM_BUILD_ROOT/opt/raisin
-cp "$BASEDIR"/raise.sh \$RPM_BUILD_ROOT/opt/raisin
-cp "$BASEDIR"/unraise.sh \$RPM_BUILD_ROOT/opt/raisin
+cp "$BASEDIR"/raise \$RPM_BUILD_ROOT/opt/raisin
 
 %clean
 
diff --git a/unraise.sh b/unraise.sh
deleted file mode 100755 (executable)
index 50ce310..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-
-source config
-source lib/common-functions.sh
-
-
-# start execution
-common_init
-
-for_each_component clean
-
-uninstall_package xen-system
-for_each_component unconfigure
-
-rm -rf "$INST_DIR"