#!/bin/bash BUILDSERVER_CACHE_DIR="/var/cache/mage-buildserver" SMAGEFILE="$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}/INSTALL_DEPS ] then die "${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/INSTALL_DEPS missing. run 'buildserver-build-depends first" fi 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 INSTALL_DEPS="$(< ${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/INSTALL_DEPS)" SRC_INSTALL_DEPS="$(< ${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/SRC_INSTALL_DEPS)" if [[ -z ${SRC_INSTALL_DEPS} ]] then die "buildserver-build-uninstall-prerequisites: SRC_INSTALL_DEPS are empty, aborting." fi #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 [ -f ${BUILDSERVER_CACHE_DIR}/protected/${pname} ] then echo "'${pcat}/${pname}-${pver}-${pbuild}' is protected - ignoring" else 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 fi done # mark prerequisites as uninstalled touch ${BUILDSERVER_CACHE_DIR}/build/${PNAME}/${PNAME}-${PVER}-${PBUILD}/UNSTALLED_PREREQUISITES