--- trunk/mage/usr/lib/mage/smage2.sh 2005/06/28 20:39:35 90 +++ trunk/mage/usr/lib/mage/smage2.sh 2005/08/19 02:24:12 191 @@ -4,14 +4,13 @@ # needs pkgbuild_dir (mage) # SMAGE2 -# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.13 2005-06-28 20:39:35 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 # added distcc support ## setup ## -SMAGEVERSION=0.3.6-r17 PKGSUFFIX="mpk" SMAGENAME="$1" SMAGESUFFIX="smage2" @@ -19,6 +18,10 @@ #SMAGESCRIPTSDIR="/bootstrap/smage2-install-scripts" #SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts" MLIBDIR=/usr/lib/mage +SMAGEVERSION="$( < ${MLIBDIR}/version)" + +# export default C locale +export LC_ALL=C source /etc/mage.rc @@ -354,6 +357,20 @@ find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null } +sminclude() { + local i + + if [[ -n "$@" ]] + then + for i in $@ + do + echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" + source ${SMAGESCRIPTSDIR}/include/${i}.sminc + done + echo + fi +} + setup_distcc_environment(){ if [ -x /usr/bin/distcc ] then @@ -394,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 @@ -489,7 +647,6 @@ #download sources if [ "$1" == "download" -a -n "$2" ] then - showversion if [ ! -d ${SMAGESCRIPTSDIR} ] then install -d ${SMAGESCRIPTSDIR} @@ -558,6 +715,9 @@ xtitle "Compiling ${PKGNAME}" echo "Compiling ${PKGNAME}" +# auto regen mage tree if requested +regen_mage_tree + #download sources download_sources