die() { echo "ERROR: $@" exit 1 } os-arch() { local arch="$1" local os_arch case ${arch} in i*86|x86_64) os_arch="${arch}" ;; src|playground*) os_arch="$(source ${BUILDSERVER_CONFIG_DIR}/profiles/${BUILDROOT_PROFILE}/${arch}/mage.rc; echo ${ARCH})";; esac echo "${os_arch}" } runarch-script() { local arch="$1" local script="$2" local buildroot local os_arch # only allow the right arches case ${arch} in i*86|x86_64) buildroot="${BUILDROOT}/${arch}"; os_arch="${arch}" ;; src) os_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 "${os_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 \ --bind=/usr/lib/mage-buildserver/helper:/usr/lib/mage-buildserver \ --bind=${BUILDROOT}/build-info/${arch}:/var/cache/mage-buildserver \ --bind=${BUILDROOT}/ssh:/root/.ssh \ bash --login "${script}" \ || die "runarch-script '${script}' for '${arch}' failed." # wait for container to exit sleep 1 } 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 } runarch-pkg-install() { local arch="$1" local pkg="$2" if [ ! -f ${BUILDROOT}/.stamps/"${arch}"_"${pkg}"-ok ] then runarch "${arch}" mage install "${pkg}" || die "${arch} install 'python'" touch ${BUILDROOT}/.stamps/"${arch}"_"${pkg}"-ok else echo "Warning: '${pkg}' already installed for arch '${arch}'" fi # never fail return 0 } enum-build-arch-types() { echo "${BUILD_ARCH[*]}" } enum-all-arch-types() { local arch local build_arch_types for arch in src ${BUILD_ARCH[*]} do if [ ! -e ${BUILDSERVER_CONFIG_DIR}/profiles/${BUILDROOT_PROFILE}/${arch}/mage.rc ] then echo "Warning: mage.rc of '${arch}' not found. Arch '${arch}' ignored." >&2 else build_arch_types+=( "${arch}" ) fi done if [[ ${BUILD_PLAYGROUND} -eq 1 ]] then for arch in ${BUILD_ARCH[*]} do if [ ! -e ${BUILDSERVER_CONFIG_DIR}/profiles/${BUILDROOT_PROFILE}/playground-${arch}/mage.rc ] then echo "Warning: mage.rc of 'playground-${arch}' not found. Arch 'playground-${arch}' ignored." >&2 else build_arch_types+=( "playground-${arch}" ) fi done fi echo "${build_arch_types[*]}" }