Detect presence of sudo.
Many other cleanups.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
export PWD=`pwd`
export GIT=${GIT-git}
+export SUDO=${SUDO-sudo}
export MAKE=${MAKE-make -j}
export PREFIX=${PREFIX-/usr}
export INST_DIR=${DESTDIR-dist}
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'`
+ 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
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'`
+ 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
export DISTRO
}
+function get_arch() {
+ export ARCH=`uname -m | sed -e s/i.86/x86_32/ -e s/i86pc/x86_32/ -e \
+ s/amd64/x86_64/ -e s/armv7.*/arm32/ -e s/armv8.*/arm64/ \
+ -e s/aarch64/arm64/`
+}
+
# execution
+if test $EUID -eq 0
+then
+ export SUDO=""
+elif test ! -f `which sudo`
+then
+ echo "Raixen requires sudo to install build dependencies for you."
+ echo "Please install sudo, then run this script again."
+ exit 1
+fi
+
rm -rf "$INST_DIR"
mkdir -p "$INST_DIR"
get_distro
+get_arch
if test "$XEN_UPSTREAM_REVISION"
then
# Config variables for raixen
-# Build and git config
-#GIT=git
+# Build config
MAKE="make -j"
PREFIX="/usr"
DESTDIR=dist
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=
+# Software versions. Leave blank if you want to avoid the build, like
+# this: GRUB_UPSTREAM_REVISION=
+# Keep in mind that both Grub and Libvirt needs Xen to build and run.
XEN_UPSTREAM_REVISION="RELEASE-4.5.0"
GRUB_UPSTREAM_REVISION="master"
LIBVIRT_UPSTREAM_REVISION="v1.2.9.1"
}
function grub_build() {
- # install dependencies
+ if test $ARCH != "x86_64" && test $ARCH != "x86_32"
+ then
+ echo grub is only supported on x86_32 and x86_64
+ return
+ fi
+ echo installing Grub dependencies
case $DISTRO in
"Debian" | "Ubuntu" )
- apt-get install build-essential
+ # grub also requires xen
+ $SUDO apt-get install -y git build-essential tar autoconf bison flex
+ if test $ARCH = "x86_64"
+ then
+ $SUDO apt-get install -y libc6-dev-i386
+ fi
;;
* )
echo "I don't know how to install grub dependencies on $DISTRO"
## 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
+ ./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
+ if test $ARCH = "x86_64"
+ then
+ $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
+ fi
cd ..
}
}
function libvirt_build() {
- # install dependencies
+ echo installing Libvirt dependencies
case $DISTRO in
"Debian" | "Ubuntu" )
- apt-get install build-essential
+ # libvirt also requires xen
+ $SUDO apt-get install -y git build-essential libtool autoconf \
+ autopoint xsltproc libxml2-utils \
+ pkg-config python-dev libxml-xpath-perl \
+ libyajl-dev libxml2-dev
;;
* )
echo "I don't know how to install libvirt dependencies on $DISTRO"
./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
+ --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 ..
}
function xen_build() {
- # install dependencies
+ echo installing Xen dependencies
case $DISTRO in
"Debian" | "Ubuntu" )
- apt-get install build-essential
+ $SUDO apt-get install -y git build-essential python-dev gettext \
+ uuid-dev libncurses5-dev libyajl-dev libaio-dev
+ if test $ARCH = "x86_32" || test $ARCH = "x86_64"
+ then
+ $SUDO apt-get install -y bcc iasl bin86 libglib2.0-0 \
+ libpixman-1-dev
+ fi
+ if test $ARCH = "x86_64"
+ then
+ $SUDO apt-get install -y libc6-dev-i386
+ fi
;;
* )
echo "I don't know how to install xen dependencies on $DISTRO"