--- trunk/mage/usr/lib/mage/smage2.sh 2005/08/16 23:23:33 186 +++ trunk/mage/usr/lib/mage/smage2.sh 2005/08/19 02:24:12 191 @@ -4,7 +4,7 @@ # needs pkgbuild_dir (mage) # SMAGE2 -# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.21 2005-08-16 23:23:26 niro Exp $ +# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.22 2005-08-19 02:24:12 niro Exp $ #01.10.2004 # added ccache support @@ -411,6 +411,147 @@ fi } +# alx_create_mage_file: helper functions for regen_mage_tree() +# generates an mage file with given information in smage file +# needs at least: +# PNAME name of pkg +# PVER version +# PBUILD revision +# PCATEGORIE categorie of the pkg +# STATE state of pkg stable|unstable|old +# DESCRIPTION va short description (opt) +# HOMEPAGE homepage (opt) +# DEPEND runtime dependencies (opt) +# SDEPEND add. needed deps to build the pkg (opt) +# PROVIDE provides a virtual (opt) +# +# special tags: +# PKGTYPE type of pkg +# INHERITS which functions get included +# SPECIAL_FUNCTIONS special functions wich should also be added +# warning: they get killed before the build starts ! +# +# MAGE_TREE_DEST target destination of the generated tree +# REGEN_MAGE_TREE set to 'true' to enable this +alx_create_mage_file() +{ + local magefile + local dest + local suffix + local sym + local depname + + # if MAGE_TREE_DEST not set use BUILDDIR + : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} + + # determinate which suffix this mage file should get, if any + suffix="$1" + + # name of magefile + magefile="${PNAME}${suffix}-${PVER}-${PBUILD}.mage" + + # destination to magefile + dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${suffix}/${magefile}" + + # show what we are doing + echo "Generating Mage file:" + echo " ${dest}" + + install -d "$(dirname ${dest})" + # now build the mage file + > ${dest} + + # header + echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.22 2005-08-19 02:24:12 niro Exp $' >> ${dest} + echo >> ${dest} + + # pgkname and state + echo "PKGNAME=\"${PNAME}${suffix}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} + echo "STATE=\"${STATE}\"" >> ${dest} + echo >> ${dest} + + # description and homepage + echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} + echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} + echo >> ${dest} + + # special tags + echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} + if [ -n "${INHERITS}" ] + then + echo -n "minclude" >> ${dest} + local i + for i in ${INHERITS} + do + echo -n " ${i}" >> ${dest} + done + echo >> ${dest} + fi + echo >> ${dest} + + # deps and provides + echo "DEPEND=\"${DEPEND}\"" >> ${dest} + echo "SDEPEND=\"${SDEPEND}\"" >> ${dest} + echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} + echo >> ${dest} + + # add special functions + if [ -n "${SPECIAL_FUNCTIONS}" ] + then + local i + for i in ${SPECIAL_FUNCTIONS} + do + # add to mage (quotes needed !) + typeset -f "${i}" >> ${dest} + # unset to be safe (quotes needed !) + unset "${i}" + done + fi + + # pre|post-install|removes + typeset -f preinstall >> ${dest} + echo >> ${dest} + typeset -f postinstall >> ${dest} + echo >> ${dest} + typeset -f preremove >> ${dest} + echo >> ${dest} + typeset -f postremove >> ${dest} + echo >> ${dest} +} + +regen_mage_tree() +{ + local i + + # build them only if requested + if [[ ${REGEN_MAGE_TREE} = true ]] + then + # build for each target an mage file + for i in ${MAGE_TARGETS} + do + echo + alx_create_mage_file "${i}" + echo + done + fi + + # now unset all uneeded vars to be safe + unset PKGNAME + unset STATE + unset DESCRIPTION + unset HOMEPAGE + unset PKGTYPE + unset INHERITS + unset DEPEND + unset SDEPEND + unset PROVIDE + unset SPECIAL_FUNCTIONS + unset preinstall + unset postinstall + unset preremove + unset postremove +} + # print out our version showversion echo @@ -574,6 +715,9 @@ xtitle "Compiling ${PKGNAME}" echo "Compiling ${PKGNAME}" +# auto regen mage tree if requested +regen_mage_tree + #download sources download_sources