#!/bin/bash BUILDSERVER_CACHE_DIR="/var/cache/mage-buildserver" SMAGEFILE="$1" LINT_CHECKS=1 if [ -f /etc/rc.d/init.d/functions ] then source /etc/rc.d/init.d/functions else die "/etc/rc.d/init.d/functions not found" fi if [ -f /etc/mage.rc.global ] then source /etc/mage.rc.global else die "/etc/mage.rc.global not found" fi if [ -f /etc/mage.rc ] then source /etc/mage.rc else die "/etc/mage.rc not found" fi if [ -f ${MLIBDIR}/mage4.functions.sh ] then source ${MLIBDIR}/mage4.functions.sh else die "${MLIBDIR}/mage4.functions.sh not found" fi if [ -f ${MLIBDIR}/smage2.functions.sh ] then source ${MLIBDIR}/smage2.functions.sh else die "${MLIBDIR}/smage2.functions.sh not found" fi # do this at least of all includes to prevent path overwrites env-rebuild source /etc/profile # export default path export PATH="${PATH}:${MLIBDIR}" die() { echo "ERROR: $@" exit 1 } is_split_target_magefile() { local mage="$1" for target_mage in ${MY_SPLIT_TARGET_MAGEFILES} do if [[ ${mage} = ${target_mage} ]] then return 0 fi done return 1 } load_mage_features mage_setup if [[ -z ${SMAGEFILE} ]] then die "no smage file given. call '$(basename $0) with/relative/path/from/buildroot/svn/smage/to/smagefile'" fi if [ -f ${SMAGESCRIPTSDIR}/${SMAGEFILE} ] then # be silent FVERBOSE=off \ SILENT=1 \ smagesource ${SMAGESCRIPTSDIR}/${SMAGEFILE} else die "smagefile '${SMAGESCRIPTSDIR}/${SMAGEFILE}' not found." fi # create build info dir install -d ${BUILDSERVER_CACHE_DIR}/build/${PNAME} if [ ! -f ${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/SRC_INSTALL_DEPS ] then die "${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/SRC_INSTALL_DEPS missing. run 'buildserver-build-depends first" fi SRC_INSTALL_DEPS="$(< ${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/SRC_INSTALL_DEPS)" if [[ -z ${SRC_INSTALL_DEPS} ]] then die "buildserver-build: SRC_INSTALL_DEPS are empty, aborting." fi # save STATE, gets deleted by regen_mage_tree BUILDSERVER_SAVED_STATE="${STATE}" #regen_mage_tree # do this after dep install TARGET_MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.${MAGESUFFIX}" TARGET_SRC_TARBALL="/var/cache/mage/src-packages/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX}" if [ ! -f ${TARGET_SRC_TARBALL} ] then die "${TARGET_SRC_TARBALL} is missing" fi if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} then echo -en "Package " echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" echo -e " already installed. try a revup." exit 3 fi if [ -f ${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/BUILD_OK ] then echo -en "Package " echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" echo -e " already build successfully. try a revup." exit 3 fi #if [ -f ${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/BUILD_FAILED ] #then # echo -en "Package " # echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" # echo -e " build has failed already. try to fix build and revup or enforce rebuild." # exit 3 #fi # create build info dir install -d ${BUILDSERVER_CACHE_DIR}/build/${PNAME} echo echo "---- environment -----" echo "MROOT: ${FAKE_MROOT}" echo "PKGDIR: ${PKGDIR}" echo "BUILDDIR: ${BUILDDIR}" echo "BINDIR: ${BINDIR}" echo "$(mprintfeatures)" echo "----------------------" echo #echo "DEBUG: paused"; read if [ ! -f ${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/INSTALLED_PREREQUISITES ] then die "${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/INSTALLED_PREREQUISITES missing. run 'buildserver-build-prerequisites first" fi #### building target package from src-pkg tarball#### if smage2 --src-tarball ${TARGET_SRC_TARBALL} then build_retval=0 echo 0 > ${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/BUILD_OK # remove maybe existing failed file if [ -f ${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/BUILD_FAILED ] then rm ${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/BUILD_FAILED fi echo "Build successfull!" regen_mage_tree # restore STATE STATE="${BUILDSERVER_SAVED_STATE}" if [[ ${LINT_CHECKS} = 1 ]] then /usr/lib/mage-buildserver/buildserver-lint.sh ${SMAGEFILE} fi if install_packages ${SRC_INSTALL_DEPS} || die "installing packages" then install_retval=0 echo 0 > ${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/INSTALL_OK echo "Install successfull!" else install_retval=1 echo 1 > ${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/INSTALL_FAILED echo "Installation *not* successfull!" fi else build_retval=1 echo 1 > ${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/BUILD_FAILED echo "Build failed" echo "DEBUG: read" read fi ## always run auto etc-update echo "running etc-update" echo "-5" | etc-update exit ${build_retval}