]> xenbits.xensource.com Git - people/gdunlap/raisin.git/.git/commitdiff
A script to build Xen, Grub and Libvirt
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>
Fri, 13 Mar 2015 18:23:41 +0000 (18:23 +0000)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Fri, 13 Mar 2015 19:18:11 +0000 (19:18 +0000)
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
build.sh [new file with mode: 0755]
git-checkout.sh [new file with mode: 0755]
grub-bootstrap.cfg [new file with mode: 0644]
grub.cfg [new file with mode: 0644]

diff --git a/build.sh b/build.sh
new file mode 100755 (executable)
index 0000000..59a175e
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,104 @@
+#!/usr/bin/env bash
+
+test -f config && . config
+
+PWD=`pwd`
+GIT=${GIT-git}
+MAKE=${MAKE-make -j}
+PREFIX=${PREFIX-/usr}
+if test "$DESTDIR"
+then
+    INST_DIR="$DESTDIR"
+else
+    INST_DIR=$PWD/dist
+fi
+
+if test "$GIT_HTTP" = y
+then
+    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"}
+else
+    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"}
+fi
+
+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"}
+
+
+
+# two functions per component
+clean_xen() {
+    rm -rf xen-dir
+}
+
+build_xen() {
+    ./git-checkout.sh $XEN_UPSTREAM_URL $XEN_UPSTREAM_REVISION xen-dir
+    cd xen-dir
+    ./configure --prefix=$PREFIX
+    $MAKE
+    $MAKE install DESTDIR="$INST_DIR"
+    cd ..
+}
+
+clean_grub() {
+    rm -rf memdisk.tar
+    rm -rf grub-dir
+}
+
+build_grub() {
+    tar cf memdisk.tar grub.cfg
+    ./git-checkout.sh $GRUB_UPSTREAM_URL $GRUB_UPSTREAM_REVISION grub-dir
+    cd grub-dir
+    ./autogen.sh
+    ## GRUB32
+    ./configure --target=i386 --with-platform=xen
+    $MAKE
+    ./grub-mkimage -d grub-core -O i386-xen -c ../grub-bootstrap.cfg -m ../memdisk.tar -o grub-i386-xen grub-core/*mod
+    cp grub-i386-xen "$INST_DIR"/$PREFIX/lib/xen/boot
+    ## GRUB64
+    $MAKE clean
+    ./configure --target=amd64 --with-platform=xen
+    $MAKE
+    ./grub-mkimage -d grub-core -O x86_64-xen -c ../grub-bootstrap.cfg -m ../memdisk.tar -o grub-x86_64-xen grub-core/*mod
+    cp grub-x86_64-xen "$INST_DIR"/$PREFIX/lib/xen/boot
+    cd ..
+}
+
+clean_libvirt() {
+    rm -rf libvirt-dir
+}
+
+build_libvirt() {
+    ./git-checkout.sh $LIBVIRT_UPSTREAM_URL $LIBVIRT_UPSTREAM_REVISION libvirt-dir
+    cd libvirt-dir
+    ./autogen.sh --disable-threads --with-xen --without-qemu --without-uml     \
+       --without-outopenvz --without-vmware --without-libssh2 --without-phyp  \
+       --without-xenapi --with-libxl --without-vbox --without-lxc             \
+       --without-esx --without-hyperv --without-parallels --without-test      \
+       --without-remote --with-libvirtd --without-sasl --with-yajl            \
+       --without-dbus --without-selinux --without-python --without-apparmor   \
+       --without-macvtap --without-avahi --without-openvz --without-dbus      \
+       --prefix=$PREFIX
+    $MAKE
+    $MAKE --ignore-errors install DESTDIR=$INST_DIR
+    cd ..
+}
+
+
+
+# execution
+export GIT
+rm -rf "$INST_DIR"
+mkdir -p "$INST_DIR"
+
+clean_xen
+clean_grub
+clean_libvirt
+
+build_xen
+build_grub
+build_libvirt
diff --git a/git-checkout.sh b/git-checkout.sh
new file mode 100755 (executable)
index 0000000..20ae31f
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+if test $# -lt 3; then
+       echo "Usage: $0 <tree> <tag> <dir>"
+       exit 1
+fi
+
+TREE=$1
+TAG=$2
+DIR=$3
+
+set -e
+
+if test \! -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 test "$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/grub-bootstrap.cfg b/grub-bootstrap.cfg
new file mode 100644 (file)
index 0000000..e988314
--- /dev/null
@@ -0,0 +1 @@
+normal (memdisk)/grub.cfg
diff --git a/grub.cfg b/grub.cfg
new file mode 100644 (file)
index 0000000..1600b1e
--- /dev/null
+++ b/grub.cfg
@@ -0,0 +1,21 @@
+if search -s -f /boot/xen/pvboot-x86_64.elf ; then
+        echo "Chainloading (${root})/boot/xen/pvboot-x86_64.elf"
+        multiboot "/boot/xen/pvboot-x86_64.elf"
+        boot
+fi
+
+if search -s -f /xen/pvboot-x86_64.elf ; then
+        echo "Chainloading (${root})/xen/pvboot-x86_64.elf"
+        multiboot "/xen/pvboot-x86_64.elf"
+        boot
+fi
+
+if search -s -f /boot/grub/grub.cfg ; then
+        echo "Reading (${root})/boot/grub/grub.cfg"
+        configfile /boot/grub/grub.cfg
+fi
+
+if search -s -f /grub/grub.cfg ; then
+        echo "Reading (${root})/grub/grub.cfg"
+        configfile /grub/grub.cfg
+fi