--- trunk/mage/usr/lib/mage/smage2.sh 2012/01/14 00:01:52 1659 +++ branches/mage-next/src/smage2.in 2014/02/14 09:02:18 2590 @@ -18,6 +18,9 @@ source ${MLIBDIR}/mage4.functions.sh source ${MLIBDIR}/smage2.functions.sh +# export default path +export PATH="${PATH}:${MLIBDIR}" + ## setup ## SMAGENAME="$1" SMAGEVERSION="$(< ${MLIBDIR}/version)" @@ -154,23 +157,8 @@ regen_mage_tree - # build several targets - if [[ -n ${MAGE_TARGETS} ]] - then - for target in ${MAGE_TARGETS} - do - # build md5sum for existing packages - generate_package_md5sum \ - --pcat "${PCAT}" \ - --pname "${PNAME}" \ - --pver "${PVER}" \ - --pbuild "${PBUILD}" \ - --parch "${ARCH}" \ - --target "${target}" - done - # build several subpackages - elif [[ -n ${SPLIT_PACKAGES} ]] + if [[ -n ${SPLIT_PACKAGES} ]] then split_save_variables for subpackage in ${SPLIT_PACKAGES} @@ -280,9 +268,6 @@ xtitle "Compiling ${PKGNAME}" echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}" -# auto regen mage tree if requested -regen_mage_tree - if mqueryfeature "srcpkgbuild" then if [[ -d ${SOURCEDIR}/${PNAME} ]] @@ -318,6 +303,10 @@ # setup for distcc goes *before* ccache, so ccache comes before distcc in path mqueryfeature "distcc" && setup_distcc_environment +# setup icecc +# setup for icecc goes *before* ccache, so ccache comes before icecc in path +mqueryfeature "icecc" && setup_icecc_environment + # setup ccache mqueryfeature "ccache" && setup_ccache_environment @@ -406,28 +395,42 @@ export SAVED_BINDIR="${BINDIR}" for subpackage in ${SPLIT_PACKAGES} do - if typeset -f src_install_${subpackage} > /dev/null + split_info_${subpackage} + if [[ ${PKGTYPE} = virtual ]] 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 "Virtual package detected" echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}" echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..." - ( run_resume src_install_${subpackage} || src_install_${subpackage} ) | ${SMAGE_LOG_CMD} - die_pipestatus 0 "src_install_${subpackage} failed" - resume_stamp src_install_${subpackage} - step_by_step src_install_${subpackage} + echo "virtual package detected; nothing will be build ..." + # automatically set !pkgbuild here too + msetfeature "!pkgbuild" + else + 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} ..." + + ( run_resume src_install_${subpackage} || src_install_${subpackage} ) | ${SMAGE_LOG_CMD} + die_pipestatus 0 "src_install_${subpackage} failed" + resume_stamp src_install_${subpackage} + step_by_step src_install_${subpackage} + fi fi + # restore smage environment + split_restore_variables done - # restore bindir & pname - split_restore_variables # unset all saved smage variables split_unset_variables else @@ -451,11 +454,33 @@ # compressing doc, info & man files if [[ -n ${SPLIT_PACKAGES} ]] then + # save smage environment + split_save_variables for subpackage in ${SPLIT_PACKAGES} do - run_resume post-mcompressdoc_${subpackage} || mcompressdocs ${BINDIR}_${subpackage} - resume_stamp post-mcompressdoc_${subpackage} + # honor split_info + split_info_${subpackage} + if [[ ${PKGTYPE} = virtual ]] + then + # automatically set !pkgbuild here too + msetfeature "!pkgbuild" + fi + + if mqueryfeature "!compressdoc" + then + echo -e "!compressdoc detected; documentation of '${subpackage}' will not be compressed ..." + elif mqueryfeature "!pkgbuild" + then + echo "!pkgbuild detected; skipping documentation compression for '${subpackage}' ..." + else + run_resume post-mcompressdoc_${subpackage} || mcompressdocs ${BINDIR}_${subpackage} + resume_stamp post-mcompressdoc_${subpackage} + fi + # restore smage environment + split_restore_variables done + # unset saved variables + split_unset_variables else run_resume post-mcompressdoc || mcompressdocs ${BINDIR} resume_stamp post-mcompressdoc @@ -470,12 +495,35 @@ else if [[ -n ${SPLIT_PACKAGES} ]] then + # save smage environment + split_save_variables for subpackage in ${SPLIT_PACKAGES} do - echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives for '${subpackage}' ...${COLDEFAULT}" - run_resume post-mstriplibtoolarchive_${subpackage} || mstriplibtoolarchive ${BINDIR}_${subpackage} - resume_stamp post-mstriplibtoolarchive_${subpackage} + # honor split_info + split_info_${subpackage} + if [[ ${PKGTYPE} = virtual ]] + then + # automatically set !pkgbuild here too + msetfeature "!pkgbuild" + fi + + if mqueryfeature "!libtool" + then + if mqueryfeature "!pkgbuild" + then + echo "!pkgbuild detected; skipping libtool archive stripping for '${subpackage}'..." + else + echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives for '${subpackage}' ...${COLDEFAULT}" + run_resume post-mstriplibtoolarchive_${subpackage} || mstriplibtoolarchive ${BINDIR}_${subpackage} + resume_stamp post-mstriplibtoolarchive_${subpackage} + fi + fi + + # restore smage environment + split_restore_variables done + # unset saved variables + split_unset_variables else echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives ...${COLDEFAULT}" run_resume post-mstriplibtoolarchive || mstriplibtoolarchive ${BINDIR} @@ -488,16 +536,39 @@ then if mqueryfeature "!pkgbuild" then - echo "!pkgbuild detected; skipping file purgation..." + echo "!pkgbuild detected; skipping file purgation ..." else if [[ -n ${SPLIT_PACKAGES} ]] then + # save smage environment + split_save_variables for subpackage in ${SPLIT_PACKAGES} do - echo -e "${COLBLUE}===${COLGREEN} purging all purge targets in '${subpackage}' ...${COLDEFAULT}" - run_resume post-mpurgetargets_${subpackage} || mpurgetargets ${BINDIR}_${subpackage} - resume_stamp post-mpurgetargets_${subpackage} + # honor split_info + split_info_${subpackage} + if [[ ${PKGTYPE} = virtual ]] + then + # automatically set !pkgbuild here too + msetfeature "!pkgbuild" + fi + + if mqueryfeature "purge" + then + if mqueryfeature "!pkgbuild" + then + echo "!pkgbuild detected; skipping file purgation for '${subpackage}' ..." + else + echo -e "${COLBLUE}===${COLGREEN} purging all purge targets in '${subpackage}' ...${COLDEFAULT}" + run_resume post-mpurgetargets_${subpackage} || mpurgetargets ${BINDIR}_${subpackage} + resume_stamp post-mpurgetargets_${subpackage} + fi + fi + + # restore smage environment + split_restore_variables done + # unset saved variables + split_unset_variables else echo -e "${COLBLUE}===${COLGREEN} purging all purge targets ...${COLDEFAULT}" run_resume post-mpurgetargets || mpurgetargets ${BINDIR} @@ -509,25 +580,48 @@ # stripping all bins and libs if mqueryfeature "!strip" then - echo -e "!strip detected; Package will not be stripped ..." + 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 + # save smage environment + split_save_variables for subpackage in ${SPLIT_PACKAGES} do - echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" - run_resume post-mstripbins_${subpackage} || mstripbins ${BINDIR}_${subpackage} - resume_stamp post-mstripbins_${subpackage} - echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}" - run_resume post-mstriplibs_${subpackage} || mstriplibs ${BINDIR}_${subpackage} - resume_stamp post-mstriplibs_${subpackage} - echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}" - run_resume post-mstripstatic_${subpackage} || mstripstatic ${BINDIR}_${subpackage} - resume_stamp post-mstripstatic_${subpackage} + # honor split_info + split_info_${subpackage} + if [[ ${PKGTYPE} = virtual ]] + then + # automatically set !pkgbuild here too + msetfeature "!pkgbuild" + fi + + if mqueryfeature "!strip" + then + echo -e "!strip detected; package '${subpackage}' will not be stripped ..." + elif mqueryfeature "!pkgbuild" + then + echo "!pkgbuild detected; skipping stripping of the package '${subpackage}' ..." + else + echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" + run_resume post-mstripbins_${subpackage} || mstripbins ${BINDIR}_${subpackage} + resume_stamp post-mstripbins_${subpackage} + echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}" + run_resume post-mstriplibs_${subpackage} || mstriplibs ${BINDIR}_${subpackage} + resume_stamp post-mstriplibs_${subpackage} + echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}" + run_resume post-mstripstatic_${subpackage} || mstripstatic ${BINDIR}_${subpackage} + resume_stamp post-mstripstatic_${subpackage} + fi + + # restore smage environment + split_restore_variables done + # unset saved variables + split_unset_variables else echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" run_resume post-mstripbins || mstripbins ${BINDIR} @@ -541,43 +635,55 @@ fi fi -if mqueryfeature "!pkgbuild" +if mqueryfeature "qalint" then - echo -e "!pkgbuild detected; Package will not be build ..." -else - # build several targets - if [[ -n ${MAGE_TARGETS} ]] + if mqueryfeature "!pkgbuild" + then + echo "!pkgbuild detected; skipping QA lint checks ..." + else + if [[ -n ${SPLIT_PACKAGES} ]] then - for target in ${MAGE_TARGETS} + # save smage environment + split_save_variables + for subpackage in ${SPLIT_PACKAGES} do - # check if a special target_pkgbuild exists - if typeset -f ${target}_pkgbuild > /dev/null + # honor split_info + split_info_${subpackage} + if [[ ${PKGTYPE} = virtual ]] then - # run it - run_resume post-${target}_pkgbuild || ${target}_pkgbuild - resume_stamp post-${target}_pkgbuild + # automatically set !pkgbuild here too + msetfeature "!pkgbuild" fi - # now create the target package - run_resume post-pkg_builddir_${target} || ${MLIBDIR}/pkgbuild_dir.sh \ - "${PNAME}-${target}-${PVER}-${ARCH}$(print_distrotag)-${PBUILD}" \ - ${BINDIR} || die "target: ${target} package-build failed" - resume_stamp post-pkg_builddir_${target} - # build pkg-md5-sum if requested - run_resume post-md5sum_${target} || generate_package_md5sum \ - --pcat "${PCAT}" \ - --pname "${PNAME}" \ - --pver "${PVER}" \ - --pbuild "${PBUILD}" \ - --parch "${ARCH}" \ - --target "${target}" - resume_stamp post-md5sum_${target} + if mqueryfeature "qalint" + then + if mqueryfeature "!pkgbuild" + then + echo "!pkgbuild detected; skipping QA lint checks for '${subpackage}' ..." + else + echo -e "${COLBLUE}===${COLGREEN} running QA lint checks for '${subpackage}' ...${COLDEFAULT}" + mqalint ${BINDIR}_${subpackage} + fi + fi - echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}$(print_distrotag)-${PBUILD} successfully builded.\n${COLDEFAULT}" + # restore smage environment + split_restore_variables done + # unset saved variables + split_unset_variables + else + echo -e "${COLBLUE}===${COLGREEN} running QA lint checks ...${COLDEFAULT}" + mqalint ${BINDIR} + fi + fi +fi +if mqueryfeature "!pkgbuild" +then + echo -e "!pkgbuild detected; Package will not be build ..." +else # build several subpackages - elif [[ -n ${SPLIT_PACKAGES} ]] + if [[ -n ${SPLIT_PACKAGES} ]] then split_save_variables for subpackage in ${SPLIT_PACKAGES} @@ -591,9 +697,19 @@ PCAT="${PCATEGORIE}" unset PCATEGORIE fi + if [[ ${PKGTYPE} = virtual ]] + then + # automatically set !pkgbuild here too + msetfeature "!pkgbuild" + fi # jump to next one if !pkgbuild is set in split_info - mqueryfeature "!pkgbuild" && continue + if mqueryfeature "!pkgbuild" + then + # restore smage environment + split_restore_variables + continue + fi # check if an special subpackage_pkgbuild exists if typeset -f ${PNAME}_pkgbuild > /dev/null @@ -649,6 +765,9 @@ fi fi +# auto regen mage tree if requested +regen_mage_tree + if mqueryfeature "buildlog" then bzip2 -9f /var/log/smage/${PKGNAME}.log