--- trunk/mage/usr/lib/mage/smage2.sh 2005/08/19 03:43:56 192 +++ trunk/mage/usr/lib/mage/smage2.sh 2005/08/20 15:51:14 195 @@ -4,7 +4,7 @@ # needs pkgbuild_dir (mage) # SMAGE2 -# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.23 2005-08-19 03:43:56 niro Exp $ +# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.26 2005-08-20 15:51:14 niro Exp $ #01.10.2004 # added ccache support @@ -406,6 +406,55 @@ fi } + +# fixes given dependencies to match a MAGE_TARGET +# fix_mage_deps target s/depend +fix_mage_deps() { + local target="$1" + local depend="$2" + local NDEPEND + local sym dep cat pver pname + + # deps and provides are special + # they must be fixed to match the target + + # run this only if target and depend is not empty + if [ -n "${target}" ] && [ -n "${depend}" ] + then + # fix DEPEND + while read sym dep + do + cat="$(dirname ${dep})" + # abort on virtual + [[ ${cat} = virtual ]] && continue + + # fix pver to target-pver + # to get pname-target-pver + + # doing it backwards ! + pver="${dep##*-}" + pname=$(basename ${dep/-${pver}/}) + + # do not add empty lines + if [ -z "${NDEPEND}" ] + then + NDEPEND="${sym} ${cat}/${pname}-${target}-${pver}" + else + NDEPEND="${NDEPEND} + ${sym} ${cat}/${pname}-${target}-${pver}" + fi + + unset cat pname pver + done << EOF +${depend} +EOF + # set NDEPEND to DEPEND + depend="${NDEPEND}" + fi + + echo "${depend}" +} + # build_mage_script(): helper functions for regen_mage_tree() # generates an mage file with given information in smage file # needs at least: @@ -428,11 +477,13 @@ # # MAGE_TREE_DEST target destination of the generated tree # REGEN_MAGE_TREE set to 'true' to enable this +# +# gets called with build_mage_script target build_mage_script() { local magefile local dest - local suffix + local target local sym local depname @@ -440,13 +491,13 @@ : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} # determinate which suffix this mage file should get, if any - suffix="$1" + [ -n "$1" ] && target="-$1" # name of magefile - magefile="${PNAME}${suffix}-${PVER}-${PBUILD}.mage" + magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" # destination to magefile - dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${suffix}/${magefile}" + dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}" # show what we are doing echo "Generating Mage file:" @@ -457,11 +508,11 @@ > ${dest} # header - echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.23 2005-08-19 03:43:56 niro Exp $' >> ${dest} + echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.26 2005-08-20 15:51:14 niro Exp $' >> ${dest} echo >> ${dest} # pgkname and state - echo "PKGNAME=\"${PNAME}${suffix}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} + echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} echo "STATE=\"${STATE}\"" >> ${dest} echo >> ${dest} @@ -485,8 +536,8 @@ echo >> ${dest} # deps and provides - echo "DEPEND=\"${DEPEND}\"" >> ${dest} - echo "SDEPEND=\"${SDEPEND}\"" >> ${dest} + echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} + echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} echo >> ${dest} @@ -503,6 +554,17 @@ done fi + # add special vars + if [ -n "${SPECIAL_VARS}" ] + then + local i + for i in ${SPECIAL_VARS} + do + # being tricky here :) + echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} + done + fi + # pre|post-install|removes typeset -f preinstall >> ${dest} echo >> ${dest} @@ -521,13 +583,23 @@ # build them only if requested if [[ ${REGEN_MAGE_TREE} = true ]] then - # build for each target an mage file - for i in ${MAGE_TARGETS} - do + # run it without targets + if [ -z "${MAGE_TARGETS}" ] + then echo - build_mage_script "${i}" + build_mage_script echo - done + else + + # build for each target an mage file + # run it with several targets + for i in ${MAGE_TARGETS} + do + echo + build_mage_script "${i}" + echo + done + fi fi # now unset all uneeded vars to be safe @@ -538,6 +610,11 @@ unset "${i}" done unset SPECIAL_FUNCTIONS + for i in ${SPECIAL_VARS} + do + unset "${i}" + done + unset SPECIAL_VARS unset STATE unset DESCRIPTION unset HOMEPAGE