--- trunk/mage/usr/lib/mage/smage2.functions.sh 2013/08/14 07:38:37 2157 +++ branches/mage-next/src/smage2.functions.sh.in 2014/09/19 11:19:35 2832 @@ -79,51 +79,6 @@ fi } -showversion() -{ - echo -en "Magellan Source Install v${SMAGEVERSION} " - echo -e "-- Niels Rogalla (niro@magellan-linux.de)" -} - -die() -{ - xtitleclean - echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} - echo "SMAGE failed: $@" - exit 1 -} - -die_pipestatus() -{ - # the status change if we do any parameter declarations!! - # dont do this anymore, keep this in mind! - # - # local pos="$1" - # local comment="$2" - # - # [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}" - # - [ ${PIPESTATUS[$1]} -ne 0 ] && die "$2" -} - -xtitle() -{ - if [[ ${TERM} = xterm ]] - then - echo -ne "\033]0;[sMage: $@]\007" - fi - return 0 -} - -xtitleclean() -{ - if [[ ${TERM} = xterm ]] - then - echo -ne "\033]0;\007" - fi - return 0 -} - syncsmage2() { xtitle "Updating smage2-script tree ..." @@ -225,6 +180,13 @@ } # dummy function, used if that does not exist in smage file +pkg_setup() +{ + echo "no pkg_setup defined; doing nothing ..." + return 0 +} + +# dummy function, used if that does not exist in smage file src_prepare() { echo "no src_prepare defined; doing nothing ..." @@ -318,9 +280,9 @@ sysconfdir=${BINDIR}/etc \ libdir=${BINDIR}/usr/$(mlibdir) \ "$@" install || die "minstall failed" - else - die "no Makefile found" - fi + else + die "no Makefile found" + fi } mmake() @@ -566,10 +528,10 @@ then for i in $@ do - echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" + [[ ${SILENT} = 1 ]] || echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" source ${SMAGESCRIPTSDIR}/include/${i}.sminc done - echo + [[ ${SILENT} = 1 ]] || echo fi } @@ -609,9 +571,13 @@ marchsrcdir() { local retval - if [[ ! -z $(eval echo \$SRCDIR_${ARCH/i*86/x86}) ]] + local var="$1" + + [[ -z ${var} ]] && var="SRCDIR" + + if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]] then - eval echo \$SRCDIR_${ARCH/i*86/x86} | tr ';' '\n' + eval echo \$${var}_${ARCH/i*86/x86} | tr ';' '\n' retval=0 else retval=1 @@ -623,10 +589,20 @@ marchdepend() { local retval + local var="$1" + + [[ -z ${var} ]] && var="DEPEND" - if [[ ! -z $(eval echo \$DEPEND_${ARCH/i*86/x86}) ]] + if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]] then - echo "\$(eval echo \\\$DEPEND_\${ARCH/i*86/x86} | tr ';' '\n')" + # evaluate with escape strings for the magefile if called by smage + # but do not escape if the smagefile was called by depwalker directly + if [[ ${SMAGE_DEPEND} = 1 ]] + then + eval echo \$${var}_${ARCH/i*86/x86} | tr ';' '\n' + else + echo "\$(eval echo \\\$${var}_\${ARCH/i*86/x86} | tr ';' '\n')" + fi retval=0 else retval=1 @@ -638,9 +614,20 @@ marchsdepend() { local retval - if [[ ! -z $(eval echo \$SDEPEND_${ARCH/i*86/x86}) ]] + local var="$1" + + [[ -z ${var} ]] && var="SDEPEND" + + if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]] then - echo "\$(eval echo \\\$SDEPEND_\${ARCH/i*86/x86} | tr ';' '\n')" + # evaluate with escape strings for the magefile if called by smage + # but do not escape if the smagefile was called by depwalker directly + if [[ ${SMAGE_DEPEND} = 1 ]] + then + eval echo \$${var}_${ARCH/i*86/x86} | tr ';' '\n' + else + echo "\$(eval echo \\\$${var}_\${ARCH/i*86/x86} | tr ';' '\n')" + fi retval=0 else retval=1 @@ -664,75 +651,24 @@ fi } -setup_ccache_environment() +setup_icecc_environment() { - if [ -x /usr/bin/ccache ] + if [ -x /usr/bin/icecc ] then - echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}" - export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH" + echo -e "${COLBLUE}---${COLGREEN} Using IceCC for compilation ...${COLDEFAULT}" + export PATH=/usr/$(mlibdir)/icecc/bin:${PATH} || die "icecc: could not export new $PATH" fi } -# fixes given dependencies to match a MAGE_TARGET -# fix_mage_deps -target s/depend # <-- note -target ! -fix_mage_deps() +setup_ccache_environment() { - local target="$1" - local depend="$2" - local NDEPEND - local sym dep cat pver pname - - # first of all remove all tabs and duplicate lines - if [ -n "${depend}" ] - then - depend=$(echo "${depend}" | sed 's:\t::g' | sort -u) - fi - - # 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}" ] + if [ -x /usr/bin/ccache ] then - # fix DEPEND - while read sym dep - do - # ignore empty lines - [[ -z ${dep} ]] && continue - - cat="$(dirname ${dep})" - # change if not virtual - if [[ ${cat} = virtual ]] - then - pname="$(basename ${dep})" - else - # fix pver to target-pver - # to get pname-target-pver + mqueryfeature "icecc" && export CCACHE_PREFIX=icecc - # doing it backwards ! - pver="${dep##*-}" - # full pver - pname="$(basename ${dep/-${pver}/})${target}-${pver}" - fi - - # do not add empty lines - if [ -z "${NDEPEND}" ] - then - NDEPEND="${sym} ${cat}/${pname}" - else - NDEPEND="${NDEPEND} - ${sym} ${cat}/${pname}" - fi - - unset cat pname pver - done << EOF -${depend} -EOF - # set NDEPEND to DEPEND - depend="${NDEPEND}" + echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}" + export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH" fi - - echo "${depend}" } # build_mage_script(): helper functions for regen_mage_tree() @@ -768,7 +704,6 @@ { local magefile local dest - local target local split_pkg_base local sym local depname @@ -776,17 +711,14 @@ # if MAGE_TREE_DEST not set use BUILDDIR : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} - # determinate which suffix this mage file should get, if any - [[ $1 = --target ]] && shift && target="-$1" - # mark package as splitpackage [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1" # name of magefile - magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" + magefile="${PNAME}-${PVER}-${PBUILD}.mage" # destination to magefile - dest="${MAGE_TREE_DEST}/${PCAT}/${PNAME}${target}/${magefile}" + dest="${MAGE_TREE_DEST}/${PCAT}/${PNAME}/${magefile}" # show what we are doing echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}" @@ -797,7 +729,7 @@ > ${dest} # pgkname and state - echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}$(print_distrotag)-${PBUILD}\"" >> ${dest} + echo "PKGNAME=\"${PNAME}-${PVER}-\${ARCH}$(print_distrotag)-${PBUILD}\"" >> ${dest} echo "STATE=\"${STATE}\"" >> ${dest} # description and homepage @@ -810,9 +742,6 @@ # special tags and vars echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} - # echo MAGE_TARGETS ## note -target is needed ! - echo "MAGE_TARGETS=\"${target}\"" >> ${dest} - # split package base echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest} @@ -841,8 +770,8 @@ fi # deps and provides - echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} - echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} + echo "DEPEND=\"${DEPEND}\"" >> ${dest} + echo "SDEPEND=\"${SDEPEND}\"" >> ${dest} echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} # add special functions @@ -853,8 +782,6 @@ do # add to mage (quotes needed !) typeset -f "${i}" >> ${dest} - # unset to be safe (quotes needed !) - #unset "${i}" <-- later to get every target built done fi @@ -872,20 +799,8 @@ # build them only if requested if mqueryfeature regentree then - # run it without targets - if [[ -n ${MAGE_TARGETS} ]] - then - # build for each target a mage file - # run it with several targets - echo - for subpackage in ${MAGE_TARGETS} - do - build_mage_script --target "${subpackage}" - done - echo - # run it for splitpackages - elif [[ -n ${SPLIT_PACKAGES} ]] + if [[ -n ${SPLIT_PACKAGES} ]] then local split_pkg_base="${PNAME}" # save smage environment @@ -925,16 +840,7 @@ # now unset all uneeded vars to be safe # unset PKGNAME <-- don't do that; smage needs this var - # unset to be safe (quotes needed !) -# for i in ${SPECIAL_FUNCTIONS} -# do -# unset "${i}" -# done unset SPECIAL_FUNCTIONS -# for i in ${SPECIAL_VARS} -# do -# unset "${i}" -# done unset SPECIAL_VARS unset STATE unset DESCRIPTION @@ -959,6 +865,7 @@ export SAVED_DESCRIPTION="${DESCRIPTION}" export SAVED_HOMEPAGE="${HOMEPAGE}" export SAVED_SPECIAL_VARS="${SPECIAL_VARS}" + export SAVED_SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS}" export SAVED_STATE="${STATE}" export SAVED_INHERITS="${INHERITS}" export SAVED_DEPEND="${DEPEND}" @@ -1033,6 +940,7 @@ export DESCRIPTION="${SAVED_DESCRIPTION}" export HOMEPAGE="${SAVED_HOMEPAGE}" export SPECIAL_VARS="${SAVED_SPECIAL_VARS}" + export SPECIAL_FUNCTIONS="${SAVED_SPECIAL_FUNCTIONS}" export STATE="${SAVED_STATE}" export INHERITS="${SAVED_INHERITS}" export DEPEND="${SAVED_DEPEND}" @@ -1101,6 +1009,7 @@ unset SAVED_DESCRIPTION unset SAVED_HOMEPAGE unset SAVED_SPECIAL_VARS + unset SAVED_SPECIAL_FUNCTIONS unset SAVED_STATE unset SAVED_PKGTYPE unset SAVED_INHERITS @@ -1181,7 +1090,6 @@ local pver local pbuild local parch - local target local pkgname # very basic getops @@ -1193,7 +1101,6 @@ --pver|-v) shift; pver="$1" ;; --pbuild|-b) shift; pbuild="$1" ;; --parch|a) shift; parch="$1" ;; - --target|t) shift; target="$1" ;; esac shift done @@ -1209,11 +1116,8 @@ [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set." [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set." - # fix target as it may be empty ! - [ -n "${target}" ] && target="-${target}" - # build pkgname - pkgname="${pname}${target}-${pver}-${parch}$(print_distrotag)-${pbuild}" + pkgname="${pname}-${pver}-${parch}$(print_distrotag)-${pbuild}" # build pkg-md5-sum only if requested if mqueryfeature regentree @@ -1231,7 +1135,7 @@ : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} # setup md5 dir - dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5" + dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5" install -d ${dest} # gen md5sum