From 0f26a3cec70c257ffc40618f1bd378fb7d363a1e Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Mon, 16 Mar 2015 18:54:13 +0000 Subject: [PATCH] Install missing dependencies for Debian and Ubuntu Detect presence of sudo. Many other cleanups. Signed-off-by: Stefano Stabellini --- build.sh | 33 ++++++++++++++++++++++++++++----- config | 8 ++++---- grub.sh | 31 +++++++++++++++++++++++-------- libvirt.sh | 22 +++++++++++++--------- xen.sh | 14 ++++++++++++-- 5 files changed, 80 insertions(+), 28 deletions(-) diff --git a/build.sh b/build.sh index 7dafda7..26240f0 100755 --- a/build.sh +++ b/build.sh @@ -4,6 +4,7 @@ source config 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} @@ -51,9 +52,12 @@ function get_distro() { 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 @@ -61,8 +65,10 @@ function get_distro() { 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 @@ -88,12 +94,29 @@ function get_distro() { 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 diff --git a/config b/config index a69aa65..cc9bc86 100644 --- a/config +++ b/config @@ -1,7 +1,6 @@ # Config variables for raixen -# Build and git config -#GIT=git +# Build config MAKE="make -j" PREFIX="/usr" DESTDIR=dist @@ -14,8 +13,9 @@ XEN_UPSTREAM_URL="git://xenbits.xen.org/xen.git" 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" diff --git a/grub.sh b/grub.sh index cd75003..e5d7e66 100644 --- a/grub.sh +++ b/grub.sh @@ -8,10 +8,20 @@ function grub_clean() { } 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" @@ -26,13 +36,18 @@ function grub_build() { ## 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 .. } diff --git a/libvirt.sh b/libvirt.sh index da390f7..9f8a676 100644 --- a/libvirt.sh +++ b/libvirt.sh @@ -7,10 +7,14 @@ function libvirt_clean() { } 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" @@ -21,13 +25,13 @@ function libvirt_build() { ./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 .. diff --git a/xen.sh b/xen.sh index 34ab869..54cd9aa 100644 --- a/xen.sh +++ b/xen.sh @@ -7,10 +7,20 @@ function xen_clean() { } 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" -- 2.39.5