[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 3/8] Move common-functions.sh and git-checkout.sh into lib



"script" implies something which is designed to be run standalone.

"lib" implies that this is going to be sourced from another bash script.

Also change "git-checkout" to be a function rather than a script

Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
---
CC: Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>
---
 components/grub                      |  2 +-
 components/libvirt                   |  2 +-
 components/xen                       |  2 +-
 {scripts => lib}/common-functions.sh |  0
 lib/git-checkout.sh                  | 32 ++++++++++++++++++++++++++++++++
 raise.sh                             |  3 ++-
 scripts/git-checkout.sh              | 30 ------------------------------
 unraise.sh                           |  2 +-
 8 files changed, 38 insertions(+), 35 deletions(-)
 rename {scripts => lib}/common-functions.sh (100%)
 create mode 100755 lib/git-checkout.sh
 delete mode 100755 scripts/git-checkout.sh

diff --git a/components/grub b/components/grub
index 5a42000..a5aa27d 100644
--- a/components/grub
+++ b/components/grub
@@ -29,7 +29,7 @@ function grub_build() {
     cd "$BASEDIR"
     rm -f memdisk.tar
     tar cf memdisk.tar -C data grub.cfg
-    ./scripts/git-checkout.sh $GRUB_UPSTREAM_URL $GRUB_UPSTREAM_REVISION 
grub-dir
+    git-checkout $GRUB_UPSTREAM_URL $GRUB_UPSTREAM_REVISION grub-dir
     cd grub-dir
     ./autogen.sh
     ## GRUB32
diff --git a/components/libvirt b/components/libvirt
index e22996e..6602dcf 100644
--- a/components/libvirt
+++ b/components/libvirt
@@ -26,7 +26,7 @@ function libvirt_build() {
     _libvirt_install_dependencies
 
     cd "$BASEDIR"
-    ./scripts/git-checkout.sh $LIBVIRT_UPSTREAM_URL $LIBVIRT_UPSTREAM_REVISION 
libvirt-dir
+    git-checkout $LIBVIRT_UPSTREAM_URL $LIBVIRT_UPSTREAM_REVISION libvirt-dir
     cd libvirt-dir
     CFLAGS="-I$INST_DIR/$PREFIX/include" \
     LDFLAGS="-L$INST_DIR/$PREFIX/lib -Wl,-rpath-link=$INST_DIR/$PREFIX/lib" \
diff --git a/components/xen b/components/xen
index a49a1d1..70b72b0 100644
--- a/components/xen
+++ b/components/xen
@@ -23,7 +23,7 @@ function xen_build() {
     _xen_install_dependencies
 
     cd "$BASEDIR"
-    ./scripts/git-checkout.sh $XEN_UPSTREAM_URL $XEN_UPSTREAM_REVISION xen-dir
+    git-checkout $XEN_UPSTREAM_URL $XEN_UPSTREAM_REVISION xen-dir
     cd xen-dir
     ./configure --prefix=$PREFIX
     $MAKE
diff --git a/scripts/common-functions.sh b/lib/common-functions.sh
similarity index 100%
rename from scripts/common-functions.sh
rename to lib/common-functions.sh
diff --git a/lib/git-checkout.sh b/lib/git-checkout.sh
new file mode 100755
index 0000000..2ca8f25
--- /dev/null
+++ b/lib/git-checkout.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+
+function git-checkout() {
+    if [[ $# -lt 3 ]]
+    then
+       echo "Usage: $0 <tree> <tag> <dir>"
+       exit 1
+    fi
+
+    TREE=$1
+    TAG=$2
+    DIR=$3
+
+    set -e
+
+    if [[ ! -d $DIR-remote ]]
+    then
+       rm -rf $DIR-remote $DIR-remote.tmp
+       mkdir -p $DIR-remote.tmp; rmdir $DIR-remote.tmp
+       $GIT clone $TREE $DIR-remote.tmp
+       if [[ "$TAG" ]]
+       then
+           cd $DIR-remote.tmp
+           $GIT branch -D dummy >/dev/null 2>&1 ||:
+           $GIT checkout -b dummy $TAG
+           cd ..
+       fi
+       mv $DIR-remote.tmp $DIR-remote
+    fi
+    rm -f $DIR
+    ln -sf $DIR-remote $DIR
+}
diff --git a/raise.sh b/raise.sh
index 3c8281e..422fbe4 100755
--- a/raise.sh
+++ b/raise.sh
@@ -3,7 +3,8 @@
 set -e
 
 source config
-source scripts/common-functions.sh
+source lib/common-functions.sh
+source lib/git-checkout.sh
 
 _help() {
     echo "Usage: ./build.sh <options> <command>"
diff --git a/scripts/git-checkout.sh b/scripts/git-checkout.sh
deleted file mode 100755
index 912bfae..0000000
--- a/scripts/git-checkout.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env bash
-
-if [[ $# -lt 3 ]]
-then
-       echo "Usage: $0 <tree> <tag> <dir>"
-       exit 1
-fi
-
-TREE=$1
-TAG=$2
-DIR=$3
-
-set -e
-
-if [[ ! -d $DIR-remote ]]
-then
-       rm -rf $DIR-remote $DIR-remote.tmp
-       mkdir -p $DIR-remote.tmp; rmdir $DIR-remote.tmp
-       $GIT clone $TREE $DIR-remote.tmp
-       if [[ "$TAG" ]]
-       then
-               cd $DIR-remote.tmp
-               $GIT branch -D dummy >/dev/null 2>&1 ||:
-               $GIT checkout -b dummy $TAG
-               cd ..
-       fi
-       mv $DIR-remote.tmp $DIR-remote
-fi
-rm -f $DIR
-ln -sf $DIR-remote $DIR
diff --git a/unraise.sh b/unraise.sh
index 2f08901..50ce310 100755
--- a/unraise.sh
+++ b/unraise.sh
@@ -3,7 +3,7 @@
 set -e
 
 source config
-source scripts/common-functions.sh
+source lib/common-functions.sh
 
 
 # start execution
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.