#!/bin/bash # get configuration BUILDSERVER_CONFIG_DIR="/etc/mage-buildserver" source ${BUILDSERVER_CONFIG_DIR}/buildserver.conf source ${BUILDSERVER_LIB_DIR}/buildserver-functions.sh # override #BUILDROOT="/mnt/test-buildroot" #BUILD_ARCH=( x86_64 i686 ) #BUILDROOT_PROFILE="R11" #SMAGE_SVN_REPO="svn://cvs.magellan-linux.de/smage/trunk" #MAGE_SVN_REPO="svn://cvs.magellan-linux.de/mage/trunk" SMAGEFILE="$1" if [[ -z ${SMAGEFILE} ]] then die "no smage file given. call '$(basename $0) with/relative/path/from/buildroot/svn/smage/to/smagefile'" fi if [[ ! -f ${BUILDROOT}/svn/smage/${SMAGEFILE} ]] then die "given smage file does not exist" fi if [ ! -f ${BUILDROOT}/.stamps/mage_svn-checkout-ok ] then die "svn checkout of mage required. run buildserver-svn first." fi if [ ! -f ${BUILDROOT}/.stamps/smage_svn-checkout-ok ] then die "svn checkout of smage required. run buildserver-svn first." fi for arch in ${BUILD_ARCH[*]} src do if [ ! -f ${BUILDROOT}/.stamps/${arch}_bootstrap-ok ] then die "bootstrap of buildsystem required for arch '${arch}'. run buildserver-prepare first." fi if [ ! -f ${BUILDROOT}/.stamps/${arch}_initial-mage-tree-ok ] then die "initial regen of mage-tree required for '${arch}'. run buildserver-setup-mage-tree first." fi done for arch in ${BUILD_ARCH[*]} do if [ ! -f ${BUILDROOT}/.stamps/${arch}_common-devutils-ok ] then die "common-devutils package for '${arch}' not installed. run buildserver-prepare first." fi done # create src package tarball runarch src smage2 --create-src-tarball /var/cache/mage/smage/${SMAGEFILE} || die "src creating src-tarball" for arch in ${BUILD_ARCH[*]} do echo "SMAGEFILE=\"${SMAGEFILE}\"" > ${BUILDROOT}/${arch}/.runrc cat >> ${BUILDROOT}/${arch}/.runrc << "EOF" env-rebuild source /etc/profile 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 # override die function die() { echo "ERROR: $@" return 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 [ -f /var/cache/mage/smage/${SMAGEFILE} ] then smagesource /var/cache/mage/smage/${SMAGEFILE} else die "smagefile '/var/cache/mage/smage/${SMAGEFILE}' not found." 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 # get all dependencies of this package echo echo -n "Calculating dependencies ... " INSTALL_DEPS="$(${MLIBDIR}/depwalker.sh \ --method install-build-prerequisites \ --smage /var/cache/mage/smage/${SMAGEFILE})" # honor split packages if [[ -n ${SPLIT_PACKAGES} ]] then split_save_variables for subpackage in ${SPLIT_PACKAGES} do # get the right variables for the split export PNAME="${subpackage}" split_info_${PNAME} if [[ -z ${SRC_INSTALL_DEPS} ]] then SRC_INSTALL_DEPS="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.${MAGESUFFIX}" else SRC_INSTALL_DEPS+=" ${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.${MAGESUFFIX}" fi # restore smage environment split_restore_variables done # unset all saved smage variables split_unset_variables else SRC_INSTALL_DEPS="${TARGET_MAGEFILE}" fi echo "done" echo echo "---- environment -----" echo "MROOT: ${FAKE_MROOT}" echo "PKGDIR: ${PKGDIR}" echo "BUILDDIR: ${BUILDDIR}" echo "BINDIR: ${BINDIR}" echo "$(mprintfeatures)" echo "----------------------" echo echo "---- dependencies ----" echo "INSTALL_DEPS:" for i in ${INSTALL_DEPS} do echo " * ${i}" done echo "SRC_INSTALL_DEPS:" for i in ${SRC_INSTALL_DEPS} do echo " * ${i}" done echo "----------------------" echo "DEBUG: paused"; read # override packages path SAVED_PKGDIR="${PKGDIR}" PKGDIR="/var/cache/mage/tmp-packages" install -d "${PKGDIR}" # now install the packages (no srcinstall, when the user not explcitly want this) fetch_packages ${INSTALL_DEPS} || die "fetching packages" md5sum_packages ${INSTALL_DEPS} || die "md5 sum packages" unpack_packages ${INSTALL_DEPS} || die "unpacking packages" install_packages ${INSTALL_DEPS} || die "installing packages" cleanpkg # restore packages path PKGDIR="${SAVED_PKGDIR}" ## always run auto etc-update echo "running etc-update" echo "-5" | etc-update #### building target package from src-pkg tarball#### if smage2 --src-tarball ${TARGET_SRC_TARBALL} then build_retval=0 echo "Build successfull!" regen_mage_tree if install_packages ${SRC_INSTALL_DEPS} || die "installing packages" then install_retval=0 echo "Install successfull!" else install_retval=1 echo "Installation *not* successfull!" fi else build_retval=1 echo "Build failed" fi ## always run auto etc-update echo "running etc-update" echo "-5" | etc-update #reverse dep order unset REV_INSTALL_DEPS for dep in ${INSTALL_DEPS} do if [[ -z ${REV_INSTALL_DEPS} ]] then REV_INSTALL_DEPS="${dep}" else REV_INSTALL_DEPS="${dep} ${REV_INSTALL_DEPS}" fi done # remove all previously installed packages echo echo "Cleaning buildroot - removing previously installed packages in reversed order:" echo "---- dependencies ----" echo "SRC_INSTALL_DEPS:" for i in ${SRC_INSTALL_DEPS} do echo " * ${i}" done echo "INSTALL_DEPS:" for i in ${REV_INSTALL_DEPS} do echo " * ${i}" done echo "----------------------" for pkg in ${SRC_INSTALL_DEPS} ${REV_INSTALL_DEPS} do uninstall_list="" pname="$(magename2pname ${pkg})" pcat="$(magename2pcat ${pkg})" pver="$(magename2pver ${pkg})" pbuild="$(magename2pbuild ${pkg})" if is_installed ${pcat}/${pname}-${pver}-${pbuild} then if [[ -z ${uninstall_list} ]] then uninstall_list="${pcat}/${pname}-${pver}-${pbuild}" else uninstall_list="${uninstall_list} ${pcat}/${pname}-${pver}-${pbuild}" fi else echo "'${pcat}/${pname}-${pver}-${pbuild}' not installed - ignoring" fi if [[ -n ${uninstall_list} ]] then uninstall_packages "${uninstall_list}" || die "cleaning buildroot: ${pkg}" else echo "uninstall_list is empty for pkg '${pcat}/${pname}-${pver}-${pbuild}' - doing nothing" fi done exit ${build_retval} EOF runarch-script ${arch} .runrc || die "${arch} package build failed" if [ -f ${BUILDROOT}/${arch}/.runrc ] then rm ${BUILDROOT}/${arch}/.runrc fi done echo echo "smage '${SMAGEFILE}' sucessfully build on all arches."