die() { echo "ERROR: $@" exit 1 } runarch-script() { local arch="$1" local script="$2" local buildroot # only allow the right arches case ${arch} in i*86|x86_64) buildroot="${BUILDROOT}/${arch}" ;; src) arch="$(source ${BUILDSERVER_CONFIG_DIR}/profiles/${BUILDROOT_PROFILE}/src/mage.rc; echo ${ARCH})"; buildroot="${BUILDROOT}/src" ;; *) die "unknown architecture '${arch}'" ;; esac [ -f ${buildroot}/${script} ] || die "'${buildroot}/${script}' does not exist." setarch "${arch}" systemd-nspawn \ --directory="${buildroot}" \ --bind=${BUILDROOT}/tmp/mage-tree:/usr/mage \ --bind=${BUILDROOT}/svn/mage/include:/usr/mage/include \ --bind=${BUILDROOT}/svn/mage/profiles:/usr/mage/profiles \ --bind=${BUILDROOT}/svn/smage:/var/cache/mage/smage \ --bind=${BUILDROOT}/packages/${arch}:/var/cache/mage/packages \ --bind=${BUILDROOT}/packages/src:/var/cache/mage/src-packages \ --bind=${BUILDROOT}/meta/${arch}:/var/cache/mage/meta \ bash --login "${script}" \ || die "runarch-script '${script}' for '${arch}' failed." } runarch() { local arch="$1" shift local cmd="$@" local buildroot local runrc # only allow the right arches case ${arch} in i*86|x86_64|src) buildroot="${BUILDROOT}/${arch}"; runrc="${buildroot}/.runrc" ;; *) die "unknown architecture '${arch}'" ;; esac # create runrc echo "${cmd}" > "${runrc}" runarch-script "${arch}" .runrc || die "runarch script execition of '${runrc}' failed." if [ -f "${runrc}" ] then rm "${runrc}" fi }