#!/usr/bin/env bash
+function common_init() {
+ export BASEDIR=`pwd`
+ export GIT=${GIT-git}
+ export SUDO=${SUDO-sudo}
+ export MAKE=${MAKE-make}
+ export PREFIX=${PREFIX-/usr}
+ export INST_DIR=${DESTDIR-dist}
+
+ INST_DIR=`readlink -f $INST_DIR`
+
+ # execution
+ if test $EUID -eq 0
+ then
+ export SUDO=""
+ elif test ! -f `which sudo 2>/dev/null`
+ then
+ echo "Raixen requires sudo to install build dependencies for you."
+ echo "Please install sudo, then run this script again."
+ exit 1
+ fi
+
+ get_distro
+ get_arch
+
+ for f in `cat "$BASEDIR"/components/series`
+ do
+ source "$BASEDIR"/components/"$f"
+ done
+}
+
function get_distro() {
if test -x "`which lsb_release 2>/dev/null`"
then
source config
source common-functions.sh
-export BASEDIR=`pwd`
-export GIT=${GIT-git}
-export SUDO=${SUDO-sudo}
-export MAKE=${MAKE-make}
-export PREFIX=${PREFIX-/usr}
-export INST_DIR=${DESTDIR-dist}
-
-INST_DIR=`readlink -f $INST_DIR`
-mkdir -p "$INST_DIR" &>/dev/null
-
help() {
echo "Usage: ./build.sh <options>"
echo "where options are:"
echo " -i | --install Install under / and configure the system"
}
-# execution
-if test $EUID -eq 0
-then
- export SUDO=""
-elif test ! -f `which sudo 2>/dev/null`
-then
- echo "Raixen requires sudo to install build dependencies for you."
- echo "Please install sudo, then run this script again."
- exit 1
-fi
+common_init
# parameters check
INST=0
fi
done
-
-get_distro
-get_arch
-
+mkdir -p "$INST_DIR" &>/dev/null
install_dependencies git
-for f in `cat "$BASEDIR"/components/series`
-do
- source "$BASEDIR"/components/"$f"
-done
-
# build and install under $DESTDIR ($BASEDIR/dist by default)
for_each_component clean
for_each_component build
# configure
for_each_component configure
-
-rm -rf "$INST_DIR"
source config
source common-functions.sh
-export BASEDIR=`pwd`
-export GIT=${GIT-git}
-export SUDO=${SUDO-sudo}
-export MAKE=${MAKE-make}
-export PREFIX=${PREFIX-/usr}
-export INST_DIR=${DESTDIR-dist}
-
-INST_DIR=`readlink -f $INST_DIR`
-
-if test $EUID -eq 0
-then
- export SUDO=""
-elif test ! -f `which sudo 2>/dev/null`
-then
- echo "Raixen requires sudo to install build dependencies for you."
- echo "Please install sudo, then run this script again."
- exit 1
-fi
-
-get_distro
-get_arch
-
-for f in `cat "$BASEDIR"/components/series`
-do
- source "$BASEDIR"/components/"$f"
-done
+common_init
for_each_component clean
for_each_component unconfigure