#!/bin/bash # get configuration BUILDSERVER_CONFIG_DIR="/etc/mage-buildserver" BUILDSERVER_CACHE_DIR="/var/cache/mage-buildserver" source ${BUILDSERVER_CONFIG_DIR}/buildserver.conf source ${BUILDSERVER_LIB_DIR}/buildserver-functions.sh if [ ! -f ${BUILDROOT}/.stamps/mage_svn-checkout-ok ] then die "svn checkout of mage required. run buildserver-svn first." fi # create buildroot layout install -d ${BUILDROOT}/.stamps install -d ${BUILDROOT}/ssh for arch in ${BUILD_ARCH[*]} src do install -d ${BUILDROOT}/${arch} install -d ${BUILDROOT}/mage-tree/${arch} install -d ${BUILDROOT}/packages/${arch} install -d ${BUILDROOT}/meta/${arch} install -d ${BUILDROOT}/build-info/${arch} done # # arch specific # for arch in src ${BUILD_ARCH[*]} do if [ ! -f ${BUILDROOT}/.stamps/${arch}_bootstrap-ok ] then mage-bootstrap \ --root ${BUILDROOT}/${arch} \ --magerc ${BUILDSERVER_CONFIG_DIR}/profiles/${BUILDROOT_PROFILE}/${arch}/mage.rc \ --profile "${BUILDROOT_PROFILE}" \ --basesystem "${BOOTSTRAP_BASESYSTEM}" \ || die "'${arch}' bootstrap" touch ${BUILDROOT}/.stamps/${arch}_bootstrap-ok else echo "Warning: bootstrap already done for arch '${arch}'" fi done # create initial mage-tree for all arches ${BUILDSERVER_LIB_DIR}/buildserver-setup-mage-tree.sh for arch in src ${BUILD_ARCH[*]} do echo "DEBUG: arch='${arch}' BUILD_ARCH[*]='${BUILD_ARCH[*]}'" # honor any proxy settings :> ${BUILDROOT}/${arch}/etc/env.d/01proxy [[ -n ${http_proxy} ]] && echo "http_proxy=\"${http_proxy}\"" >> ${BUILDROOT}/${arch}/etc/env.d/01proxy [[ -n ${https_proxy} ]] && echo "https_proxy=\"${https_proxy}\"" >> ${BUILDROOT}/${arch}/etc/env.d/01proxy [[ -n ${ftp_proxy} ]] && echo "ftp_proxy=\"${ftp_proxy}\"" >> ${BUILDROOT}/${arch}/etc/env.d/01proxy [[ -n ${ftps_proxy} ]] && echo "ftps_proxy=\"${ftps_proxy}\"" >> ${BUILDROOT}/${arch}/etc/env.d/01proxy [[ -n ${no_proxy} ]] && echo "no_proxy=\"${no_proxy}\"" >> ${BUILDROOT}/${arch}/etc/env.d/01proxy runarch ${arch} env-rebuild || die "${arch} environment rebuild for proxy setup" # always enable bootstrap mode to supress the startups of any services :> ${BUILDROOT}/${arch}/etc/env.d/00mage-buildserver echo "MAGE_BOOTSTRAP=\"true\"" >> ${BUILDROOT}/${arch}/etc/env.d/00mage-buildserver # install subversion if [ ! -f ${BUILDROOT}/.stamps/${arch}_subversion-ok ] then runarch "${arch}" mage install subversion || die "${arch} install subversion" touch ${BUILDROOT}/.stamps/${arch}_subversion-ok else echo "Warning: subversion already installed for arch '${arch}'" fi # install openssh if [ ! -f ${BUILDROOT}/.stamps/${arch}_openssh-ok ] then runarch "${arch}" mage install openssh || die "${arch} install openssh" touch ${BUILDROOT}/.stamps/${arch}_openssh-ok else echo "Warning: openssh already installed for arch '${arch}'" fi if [[ ${arch} != src ]] then if [ ! -f ${BUILDROOT}/.stamps/${arch}_common-devutils-ok ] then runarch "${arch}" mage install "${BOOTSTRAP_DEVUTILS}" || die "${arch} install '${BOOTSTRAP_DEVUTILS}'" touch ${BUILDROOT}/.stamps/${arch}_common-devutils-ok else echo "Warning: '${BOOTSTRAP_DEVUTILS}' already installed for arch '${arch}'" fi # install ccache if [ ! -f ${BUILDROOT}/.stamps/${arch}_ccache-ok ] then runarch "${arch}" mage install ccache || die "${arch} install ccache" touch ${BUILDROOT}/.stamps/${arch}_ccache-ok else echo "Warning: ccache already installed for arch '${arch}'" fi # setup ccache if [ ! -f ${BUILDROOT}/.stamps/${arch}_setup-ccache-ok ] then runarch "${arch}" ccache -M 4G || die "${arch} setup ccache" touch ${BUILDROOT}/.stamps/${arch}_setup-ccache-ok else echo "Warning: ccache already configured for arch '${arch}'" fi fi # update-ca-certificates runarch "${arch}" update-ca-certificates # no die here, cmd may missing # create list of protected packages echo "BUILDSERVER_CACHE_DIR=\"${BUILDSERVER_CACHE_DIR}\"" > ${BUILDROOT}/${arch}/.runrc cat >> ${BUILDROOT}/${arch}/.runrc << "EOF" 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 env-rebuild source /etc/profile echo "generate protected packages info data" install -d ${BUILDSERVER_CACHE_DIR}/protected for mage in $(find ${INSTALLDB} -name \*.${MAGESUFFIX}) do pkgname=$(basename ${mage} .${MAGESUFFIX}) pkgname="${pkgname%-*-*}" echo "${pkgname}" > ${BUILDSERVER_CACHE_DIR}/protected/"${pkgname}" done EOF runarch-script ${arch} .runrc || die "${arch} protect-gen failed" if [ -f ${BUILDROOT}/${arch}/.runrc ] then rm ${BUILDROOT}/${arch}/.runrc fi # cleanup runarch "${arch}" mage clean || die "${arch} mage clean" echo "Buildroot for arch '${arch}' sucessfully created."; echo done