#!/usr/bin/env bash
-function _grub_install_dependencies() {
+function grub_check_package() {
local DEP_Debian_common="build-essential tar autoconf bison flex"
local DEP_Debian_x86_32="$DEP_Debian_common"
local DEP_Debian_x86_64="$DEP_Debian_common libc6-dev-i386"
echo grub is only supported on x86_32 and x86_64
return
fi
- echo installing Grub dependencies
- eval install_dependencies \$DEP_"$DISTRO"_"$ARCH"
+ echo Checking Grub dependencies
+ eval check-package \$DEP_"$DISTRO"_"$ARCH"
}
function grub_build() {
- _grub_install_dependencies
-
cd "$BASEDIR"
rm -f memdisk.tar
tar cf memdisk.tar -C data grub.cfg
#!/usr/bin/env bash
-function _libvirt_install_dependencies() {
+function libvirt_check_package() {
local DEP_Debian_common="build-essential libtool autoconf autopoint \
xsltproc libxml2-utils pkg-config python-dev \
libxml-xpath-perl libyajl-dev libxml2-dev \
local DEP_Fedora_x86_32="$DEP_Fedora_common"
local DEP_Fedora_x86_64="$DEP_Fedora_common"
- echo installing Libvirt dependencies
- eval install_dependencies \$DEP_"$DISTRO"_"$ARCH"
+ echo Checking Libvirt dependencies
+ eval check-package \$DEP_"$DISTRO"_"$ARCH"
}
function libvirt_build() {
- _libvirt_install_dependencies
-
cd "$BASEDIR"
git-checkout $LIBVIRT_UPSTREAM_URL $LIBVIRT_UPSTREAM_REVISION libvirt-dir
cd libvirt-dir
#!/usr/bin/env bash
-function _xen_install_dependencies() {
+function xen_check_package() {
local DEP_Debian_common="build-essential python-dev gettext uuid-dev \
libncurses5-dev libyajl-dev libaio-dev pkg-config libglib2.0-dev \
libssl-dev libpixman-1-dev bridge-utils wget"
local DEP_Fedora_x86_32="$DEP_Fedora_common dev86 acpica-tools texinfo"
local DEP_Fedora_x86_64="$DEP_Fedora_x86_32 glibc-devel.i686"
- echo installing Xen dependencies
- eval install_dependencies \$DEP_"$DISTRO"_"$ARCH"
+ echo Checking Xen dependencies
+ eval check-package \$DEP_"$DISTRO"_"$ARCH"
}
function xen_build() {
- _xen_install_dependencies
-
cd "$BASEDIR"
git-checkout $XEN_UPSTREAM_URL $XEN_UPSTREAM_REVISION xen-dir
cd xen-dir
#!/usr/bin/env bash
-build() {
- if [[ $YES != "y" ]]
+function check-builddep() {
+ local -a missing
+
+ check-package git
+
+ if [[ $DISTRO = "Fedora" ]]
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
+ check-package rpm-build
fi
- mkdir -p "$INST_DIR" &>/dev/null
- install_dependencies git
- if [[ $DISTRO = "Fedora" ]]
+ for_each_component check_package
+
+ if [[ -n "${missing[@]}" ]]
then
- install_dependencies rpm-build
+ echo "Missing packages: ${missing[@]}"
+ if [[ $YES != "y" ]]
+ then
+ echo "Do you want Raisin to automatically install them for you? (y/n)"
+ while read answer
+ do
+ if [[ "$answer" = "n" ]]
+ then
+ echo "Please install, or run ./raise install-builddep"
+ exit 1
+ elif [[ "$answer" = "y" ]]
+ then
+ break
+ else
+ echo "Reply y or n"
+ fi
+ done
+ fi
+
+ echo "Installing..."
+ install-package "${missing[@]}"
fi
+}
+
+function install-builddep() {
+ YES=y check-builddep
+}
+
+function build() {
+ check-builddep
+
+ mkdir -p "$INST_DIR" &>/dev/null
+
# build and install under $DESTDIR
for_each_component clean
for_each_component build
build_package xen-system
}
-unraise() {
+function unraise() {
for_each_component clean
uninstall_package xen-system
rm -rf "$INST_DIR"
}
-install() {
+function install() {
# need single braces for filename matching expansion
if [ ! -f xen-sytem*rpm ] && [ ! -f xen-system*deb ]
then
install_package xen-system
}
-configure() {
+function configure() {
if [[ $YES != "y" ]]
then
echo "Proceeding we'll make changes to the running system,"
case "$os_VENDOR" in
"Debian"* | "Ubuntu"* | "LinuxMint"* )
DISTRO="Debian"
+ PKGTYPE="deb"
+ ;;
+ "Fedora" )
+ DISTRO="Fedora"
+ PKGTYPE="rpm"
;;
"SUSE"* )
DISTRO="SUSE"
+ PKGTYPE="rpm"
;;
"OpenSUSE"* | "openSUSE"* )
DISTRO="openSUSE"
+ PKGTYPE="rpm"
;;
"Red"* | "CentOS"* )
DISTRO="CentOS"
+ PKGTYPE="rpm"
;;
*)
DISTRO=$os_VENDOR
export os_VENDOR os_RELEASE os_UPDATE os_CODENAME
export DISTRO
+ export PKGTYPE
}
function get_arch() {
-e s/aarch64/arm64/`
}
-function install_dependencies() {
- if [[ "$NO_DEPS" && "$NO_DEPS" -eq 1 ]]
+function _check-package-deb() {
+ if [[ $VERBOSE -eq 1 ]]
+ then
+ echo "Checking for package ${args[0]}"
+ fi
+
+ if dpkg -s "$1" 2>/dev/null | grep -q "Status:.*installed"
then
- echo "Not installing any dependencies, as requested."
- echo "Depency list: $*"
return 0
+ else
+ return 1
fi
- case $DISTRO in
- "Debian" )
- $SUDO apt-get install -y $*
- ;;
- "Fedora" )
- $SUDO yum install -y $*
- ;;
- * )
- echo "I don't know how to install dependencies on $DISTRO"
- ;;
- esac
+}
+
+function _install-package-deb() {
+ $SUDO apt-get install -y $*
+}
+
+function _check-package-rpm() {
+ if [[ $VERBOSE -eq 1 ]]
+ then
+ echo "Checking for package $1"
+ fi
+
+ if rpm -q "$1" 2>&1 >/dev/null
+ then
+ return 0
+ else
+ return 1
+ fi
+}
+
+function _install-package-rpm() {
+ $SUDO yum install -y $*
+}
+
+# Modifies inherited variable "missing"
+function check-package() {
+ for p in $*
+ do
+ if ! _check-package-${PKGTYPE} $p
+ then
+ missing+=("$p")
+ fi
+ done
+
+}
+
+function install-package() {
+ _install-package-${PKGTYPE} $*
}
function start_initscripts() {
_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 " install-builddep Install build time dependencies (requires sudo)"
echo " build Build the components enabled in config"
echo " install Install binaries under / (requires sudo)"
echo " configure Configure the system (requires sudo)"
# parameters check
export VERBOSE=0
export YES="n"
-export NO_DEPS=0
while [[ $# -gt 1 ]]
do
if [[ "$1" = "-v" || "$1" = "--verbose" ]]
done
case "$1" in
- "build" | "install" | "configure" | "unraise" )
+ "install-builddep" | "build" | "install" | "configure" | "unraise" )
COMMAND=$1
;;
*)