--- trunk/mage/usr/lib/mage/smage2.sh 2011/12/28 12:23:50 1584 +++ trunk/mage/usr/lib/mage/smage2.sh 2012/01/03 19:11:57 1604 @@ -10,10 +10,6 @@ # set default user mage.rc : ${MAGERC="/etc/mage.rc"} -## setup ## -SMAGENAME="$1" -SMAGEVERSION="$( < ${MLIBDIR}/version)" - # export default C locale export LC_ALL=C @@ -21,6 +17,10 @@ source ${MAGERC} source ${MLIBDIR}/mage4.functions.sh +## setup ## +SMAGENAME="$1" +SMAGEVERSION="$(< ${MLIBDIR}/version)" + # set PKGDIR and BUILDDIR and BINDIR to MROOT if [[ -n ${MROOT} ]] then @@ -177,7 +177,8 @@ fi echo -e "${COLBLUE}==>${COLGREEN} fetching ${uri}${COLDEFAULT}" - mdownload --uri "${uri}" --dir "${outputdir}" || die "Could not download '${uri}'" + # do not die here, mchecksum catches download errors + mdownload --uri "${uri}" --dir "${outputdir}" # unset them to be sure unset uri @@ -201,28 +202,28 @@ # dummy function, used if that does not exist in smage file src_prepare() { - echo "no src_prepare defined" + echo "no src_prepare defined; doing nothing ..." return 0 } # dummy function, used if that does not exist in smage file src_compile() { - echo "no src_compile defined" + echo "no src_compile defined; doing nothing ..." return 0 } # dummy function, used if that does not exist in smage file src_check() { - echo "no src_check defined" + echo "no src_check defined; doing nothing ..." return 0 } # dummy function, used if that does not exist in smage file src_install() { - echo "no src_install defined" + echo "no src_install defined; doing nothing ..." return 0 } @@ -343,7 +344,7 @@ rar) unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed." ;; - zip|xpi) + zip|xpi|jar) unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed." ;; rpm) @@ -464,7 +465,7 @@ local stripdir="$@" [[ -z ${stripdir} ]] && stripdir="${BINDIR}" - find ${stripdir} ! -type d -name \*.la | xargs file | grep "libtool library" | cut -f 1 -d : | xargs --no-run-if-empty rm -f -- 2> /dev/null + find ${stripdir} ! -type d -name \*.la | xargs | grep "libtool library" | cut -f 1 -d : | xargs --no-run-if-empty rm -f -- 2> /dev/null } mpurgetargets() @@ -793,7 +794,7 @@ unset STATE unset DESCRIPTION unset HOMEPAGE - unset PKGTYPE + # unset PKGTYPE <-- don't do that either; smage needs this var unset INHERITS unset DEPEND unset SDEPEND @@ -1440,65 +1441,78 @@ [[ ! -d /var/log/smage ]] && install -d /var/log/smage echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log -src_prepare | ${SMAGE_LOG_CMD} -die_pipestatus 0 "src_prepare failed" -step_by_step $_ - -src_compile | ${SMAGE_LOG_CMD} -die_pipestatus 0 "src_compile failed" -step_by_step $_ - -# only run checks if requested -if mqueryfeature "!check" +if [[ ${PKGTYPE} = virtual ]] then - echo "!check detected; src_check() will not be run!" | ${SMAGE_LOG_CMD} - step_by_step src_check + echo "virtual package detected; nothing will be build ..." + # automatically set !pkgbuild here too + msetfeature "!pkgbuild" else - src_check | ${SMAGE_LOG_CMD} - die_pipestatus 0 "src_check failed" + src_prepare | ${SMAGE_LOG_CMD} + die_pipestatus 0 "src_prepare failed" step_by_step $_ -fi -# build several subpackages -if [[ -n ${SPLIT_PACKAGES} ]] -then - # save bindir & pname - split_save_variables - export SAVED_BINDIR="${BINDIR}" - for subpackage in ${SPLIT_PACKAGES} - do - if typeset -f src_install_${subpackage} > /dev/null - then - # export subpackage bindir - export BINDIR="${SAVED_BINDIR}_${subpackage}" - # export PNAME, several internal function and include - # rely on this variable - export PNAME="${subpackage}" - - echo - echo -en "${COLBLUE}*** ${COLDEFAULT}" - echo -en " Running ${COLGREEN}split src_install()${COLDEFAULT}" - echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}" - echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..." - - src_install_${subpackage} | ${SMAGE_LOG_CMD} - die_pipestatus 0 "src_install_${subpackage} failed" - step_by_step $_ - fi - done - # restore bindir & pname - split_restore_variables - # unset all saved smage variables - split_unset_variables -else - src_install | ${SMAGE_LOG_CMD} - die_pipestatus 0 "src_install failed" + src_compile | ${SMAGE_LOG_CMD} + die_pipestatus 0 "src_compile failed" step_by_step $_ + + # only run checks if requested + if mqueryfeature "!check" + then + echo "!check detected; src_check() will not be run!" | ${SMAGE_LOG_CMD} + step_by_step src_check + else + src_check | ${SMAGE_LOG_CMD} + die_pipestatus 0 "src_check failed" + step_by_step $_ + fi + + # build several subpackages + if [[ -n ${SPLIT_PACKAGES} ]] + then + # save bindir & pname + split_save_variables + export SAVED_BINDIR="${BINDIR}" + for subpackage in ${SPLIT_PACKAGES} + do + if typeset -f src_install_${subpackage} > /dev/null + then + # export subpackage bindir + export BINDIR="${SAVED_BINDIR}_${subpackage}" + # export PNAME, several internal function and include + # rely on this variable + export PNAME="${subpackage}" + + echo + echo -en "${COLBLUE}*** ${COLDEFAULT}" + echo -en " Running ${COLGREEN}split src_install()${COLDEFAULT}" + echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}" + echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..." + + src_install_${subpackage} | ${SMAGE_LOG_CMD} + die_pipestatus 0 "src_install_${subpackage} failed" + step_by_step $_ + fi + done + # restore bindir & pname + split_restore_variables + # unset all saved smage variables + split_unset_variables + else + src_install | ${SMAGE_LOG_CMD} + die_pipestatus 0 "src_install failed" + step_by_step $_ + fi fi +# echo for sake of good-looking +echo + if mqueryfeature "!compressdoc" then echo -e "!compressdoc detected; documentation will not be compressed ..." +elif mqueryfeature "!pkgbuild" +then + echo "!pkgbuild detected; skipping documentation compression..." else # compressing doc, info & man files if [[ -n ${SPLIT_PACKAGES} ]] @@ -1514,6 +1528,10 @@ if mqueryfeature "!libtool" then + if mqueryfeature "!pkgbuild" + then + echo "!pkgbuild detected; skipping libtool archive stripping ..." + else if [[ -n ${SPLIT_PACKAGES} ]] then for subpackage in ${SPLIT_PACKAGES} @@ -1525,10 +1543,15 @@ echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives ...${COLDEFAULT}" mstriplibtoolarchive ${BINDIR} fi + fi fi if mqueryfeature "purge" then + if mqueryfeature "!pkgbuild" + then + echo "!pkgbuild detected; skipping file purgation..." + else if [[ -n ${SPLIT_PACKAGES} ]] then for subpackage in ${SPLIT_PACKAGES} @@ -1540,37 +1563,41 @@ echo -e "${COLBLUE}===${COLGREEN} purging all purge targets ...${COLDEFAULT}" mpurgetargets ${BINDIR} fi + fi fi # stripping all bins and libs if mqueryfeature "!strip" then echo -e "!strip detected; Package will not be stripped ..." +elif mqueryfeature "!pkgbuild" +then + echo "!pkgbuild detected; skipping stripping of the package ..." else - if [[ -n ${SPLIT_PACKAGES} ]] - then - for subpackage in ${SPLIT_PACKAGES} - do - echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" - mstripbins ${BINDIR}_${subpackage} - echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}" - mstriplibs ${BINDIR}_${subpackage} - echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}" - mstripstatic ${BINDIR}_${subpackage} - done - else - echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" - mstripbins ${BINDIR} - echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}" - mstriplibs ${BINDIR} - echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}" - mstripstatic ${BINDIR} - fi + if [[ -n ${SPLIT_PACKAGES} ]] + then + for subpackage in ${SPLIT_PACKAGES} + do + echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" + mstripbins ${BINDIR}_${subpackage} + echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}" + mstriplibs ${BINDIR}_${subpackage} + echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}" + mstripstatic ${BINDIR}_${subpackage} + done + else + echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" + mstripbins ${BINDIR} + echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}" + mstriplibs ${BINDIR} + echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}" + mstripstatic ${BINDIR} + fi fi -if mqueryfeature "!buildpkg" +if mqueryfeature "!pkgbuild" then - echo -e "!buildpkg detected; Package will not be build ..." + echo -e "!pkgbuild detected; Package will not be build ..." else # build several targets if [[ -n ${MAGE_TARGETS} ]] @@ -1610,8 +1637,8 @@ export PNAME="${subpackage}" split_info_${PNAME} - # jump to next one if !buildpkg is set in split_info - mqueryfeature "!buildpkg" && continue + # jump to next one if !pkgbuild is set in split_info + mqueryfeature "!pkgbuild" && continue # check if an special subpackage_pkgbuild exists if typeset -f ${PNAME}_pkgbuild > /dev/null