--- trunk/mage-buildroot/mage-buildroot.sh 2006/06/13 16:47:54 383 +++ trunk/mage-buildroot/mage-buildroot.sh 2008/04/23 16:07:00 720 @@ -1,5 +1,5 @@ #!/bin/bash -# $Header: /home/cvsd/magellan-cvs/magellan-src/mage-buildroot/mage-buildroot.sh,v 1.3 2006-06-13 16:47:54 niro Exp $ +# $Header: /home/cvsd/magellan-cvs/magellan-src/mage-buildroot/mage-buildroot.sh,v 1.4 2008-04-23 16:07:00 niro Exp $ # # mage buildroot # creates a buildroot to compile programms @@ -11,28 +11,11 @@ # default die function die() { + echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} echo -e ${COLRED}"$@"${COLDEFAULT} exit 1 } -[[ $(id -u ) != 0 ]] && die "you must be root" - -# i need some settings and functions from mage -[ -f /etc/rc.d/init.d/functions ] && \ - source /etc/rc.d/init.d/functions || \ - die "Your /etc/mage.rc is missing. Aborting." - -[ -f /etc/mage.rc.global ] && \ - source /etc/mage.rc.global || \ - die "/etc/mage.rc.global missing" - -[ -f /etc/mage.rc ] && source /etc/mage.rc || \ - die "Your /etc/mage.rc is missing. Aborting." - -[ -f ${MLIBDIR}/mage4.functions.sh ] && \ - source ${MLIBDIR}/mage4.functions.sh || \ - die "mage functions missing" - installrc() { local var="$1" @@ -49,39 +32,65 @@ [ ! -d ${MROOT}/sys ] && install -d ${MROOT}/sys mount -t proc proc ${MROOT}/proc - mount -t sysfs sysfs ${MROOT}/sys + mount -t sysfs sysfs ${MROOT}/sys mount -o bind /dev ${MROOT}/dev -# chroot ${MROOT} /bin/bash -i /.installrc - chroot ${MROOT} /usr/bin/env -i \ - HOME=/root \ - TERM="${TERM}" \ - PS1='\u:\w\$ ' \ + if [[ ${SMAGE_USE_CCACHE} = true ]] || [[ -f ${MROOT}/.ccache_enabled ]] + then + [ ! -d ${MROOT}/root/.ccache ] && install -d ${MROOT}/root/.ccache + mount -o bind /root/.ccache ${MROOT}/root/.ccache + fi + + chroot ${MROOT} /usr/bin/env -i \ + HOME=/root \ + TERM="${TERM}" \ + PS1='\u:\w\$ ' \ PATH=/bin:/usr/bin:/sbin:/usr/sbin \ - /bin/bash -i /.installrc #|| die "chr00ting" + /bin/bash /.installrc #|| die "chr00ting" umount ${MROOT}/dev umount ${MROOT}/proc umount ${MROOT}/sys - #[ -f ${MROOT}/.installrc ] && rm ${MROOT}/.installrc + [ -f ${MROOT}/.installrc ] && rm ${MROOT}/.installrc } # some sane defaults MROOT="$1" TARGET_PKG="$2" -#MAGERC="/etc/mage.rc" -MAGERC="/home/tjoke/mage.rc-buildroot" +MAGERC="/etc/mage.rc" +#MAGERC="/home/tjoke/mage.rc-buildroot" MAGE_PROFILE="$(basename $(readlink /etc/mage-profile))" TOOLCHAIN=toolchain BASESYSTEM=common-devutils +[[ $(id -u ) != 0 ]] && die "you must be root" + +# i need some settings and functions from mage +[ -f /etc/rc.d/init.d/functions ] && \ + source /etc/rc.d/init.d/functions || \ + die "Your /etc/mage.rc is missing. Aborting." + +[ -f /etc/mage.rc.global ] && \ + source /etc/mage.rc.global || \ + die "/etc/mage.rc.global missing" + +[ -f ${MAGERC} ] && source ${MAGERC} || \ + die "Your /etc/mage.rc is missing. Aborting." + +[ -f ${MLIBDIR}/mage4.functions.sh ] && \ + source ${MLIBDIR}/mage4.functions.sh || \ + die "mage functions missing" + +# sanity checks +[[ -z ${MROOT} ]] && die "\$MROOT not given." +[[ -z ${TARGET_PKG} ]] && die "\$TARGET_PKG not given." + # first install a toolchain and some common dev-utils using bootstrap2 # only if not already builded if [ ! -f ${MROOT}/.buildroot_build_ok-${TOOLCHAIN}-${BASESYSTEM} ] then - #mage-bootstrap \ - /home/tjoke/alx-cvs/magellan-src/bootstrap/scripts/mage-bootstrap.sh \ + mage-bootstrap \ --root "${MROOT}" \ --magerc "${MAGERC}" \ --profile "${MAGE_PROFILE}" \ @@ -91,18 +100,21 @@ # mark this as builded touch ${MROOT}/.buildroot_build_ok-${TOOLCHAIN}-${BASESYSTEM} || die "touch ok" + + # enable ccache + [[ ${SMAGE_USE_CCACHE} = true ]] && touch ${MROOT}/.ccache_enabled fi ##################################################### # setup a chroot environment # ##################################################### -echo > ${MROOT}/.installrc || die +:> ${MROOT}/.installrc || die # some needed env-vars and functions installrc 'unset MROOT' installrc 'env-rebuild' installrc 'source /etc/profile' -installrc 'die() { echo -e ${COLRED}"$@"${COLDEFAULT}; exit 1; }' +installrc 'die() { echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT};echo -e ${COLRED}"$@"${COLDEFAULT}; exit 1; }' installrc '[ -f /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions' # || die "Your /etc/mage.rc is missing. Aborting."' installrc '[ -f /etc/mage.rc.global ] && . /etc/mage.rc.global' # || die "/etc/mage.rc.global missing"' installrc '[ -f /etc/mage.rc ] && . /etc/mage.rc' # || die "Your /etc/mage.rc is missing. Aborting."'