--- trunk/mage/usr/lib/mage/smage2.functions.sh 2012/01/13 18:29:52 1640 +++ branches/mage-next/src/smage2.functions.sh.in 2014/08/12 21:56:54 2743 @@ -7,71 +7,76 @@ smagesource() { local file="$1" - local mystate - local mycodename + local localstate + local distfilestate + local mytag source ${file} - [[ -n ${STATE} ]] && mystate="${STATE}" + # if PCAT was not set and PCATEGORIE was found + # inform the user and use PCATEGORIE as PCAT + if [[ -z ${PCAT} ]] + then + if [[ -n ${PCATEGORIE} ]] + then + PCAT="${PCATEGORIE}" + unset PCATEGORIE + # print a warning + echo -e "${COLYELLOW}Warning: 'PCATEGORIE' is deprecated and gets removed in the future.${COLDEFAULT}" + echo -e "${COLYELLOW} Please modify this smage2 script to use the 'PCAT' variable.${COLDEFAULT}" + echo + else + die "Neither PCAT nor PCATEGORIE are defined!" + fi + fi - # do not overide if local state was broken or disabled! - case ${STATE} in - broken) return ;; - disabled) return ;; - esac + [[ -n ${STATE} ]] && localstate="${STATE}" + [[ -n ${DISTROTAG} ]] && mytag="${DISTROTAG}" if [ -f ${SMAGESCRIPTSDIR}/distribution ] then source ${SMAGESCRIPTSDIR}/distribution - [[ -n ${STATE} ]] && mystate="${STATE}" + [[ -n ${STATE} ]] && distfilestate="${STATE}" + [[ -n ${DISTROTAG} ]] && mytag="${DISTROTAG}" + fi + # now switch state and export it but do not overide any local states + if [[ ! -z ${localstate} ]] + then + STATE="${localstate}" + else + STATE="${distfilestate}" fi - # now switch state and export it - STATE="${mystate}" -} - -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 ]] + if mqueryfeature "pkgdistrotag" then - echo -ne "\033]0;[sMage: $@]\007" + # if DISTROTAG was not defined globally + # or in distribution file then deactivate this feature! + # at this point $mytag must have the distrotag + if [[ -z ${mytag} ]] + then + FVERBOSE=off msetfeature "!pkgdistrotag" + unset DISTROTAG + echo -e "${COLRED}Requested 'pkgdistrotag' but no \$DISTROTAG found!${COLDEFAULT}" + echo -e "${COLRED}Disabled the feature for pkgbuild sanity!${COLDEFAULT}" + else + # now switch state and export it but do not overide any local states + export DISTROTAG="${mytag}" + fi + else + unset DISTROTAG fi - return 0 } -xtitleclean() +print_distrotag() { - if [[ ${TERM} = xterm ]] + if FVERBOSE=off mqueryfeature "pkgdistrotag" then - echo -ne "\033]0;\007" + if [[ ! -z ${DISTROTAG} ]] + then + # add a point as prefix + echo ".${DISTROTAG}" + fi fi - return 0 } syncsmage2() @@ -175,6 +180,13 @@ } # dummy function, used if that does not exist in smage file +src_setup() +{ + echo "no src_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 ..." @@ -231,8 +243,9 @@ fi fi - # always enable shared by default - if [[ ! -z $(./configure --help | grep -- '--.*able-shared') ]] + # always enable shared by default but not for waf configure + if [[ ! -z $(./configure --help | grep -- '--.*able-shared') ]] && + [[ -z $(./configure --version | grep waf) ]] then myopts+=" --enable-shared" fi @@ -267,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() @@ -292,6 +305,8 @@ DEST=$2 fi + echo -e "${COLBLUE}>>>${COLGREEN} Unpacking ${SOURCEDIR}/${PNAME}/${SRCFILE}${COLDEFAULT}" + [[ ! -d ${DEST} ]] && install -d ${DEST} case "${SRCFILE##*.}" in @@ -341,7 +356,7 @@ tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed." ;; rar) - unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed." + unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed." ;; zip|xpi|jar) unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed." @@ -513,11 +528,98 @@ 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 +} + +march() +{ + local retval + + if [[ ! -z ${ARCH} ]] + then + echo "${ARCH}" + retval=0 + else + retval=1 + fi + + return "${retval}" +} + +marchsrcfile() +{ + local retval + local var="$1" + + [[ -z ${var} ]] && var="SRCFILE" + + if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]] + then + eval echo \$${var}_${ARCH/i*86/x86} | tr ';' '\n' + retval=0 + else + retval=1 + fi + + return "${retval}" +} + +marchsrcdir() +{ + local retval + local var="$1" + + [[ -z ${var} ]] && var="SRCDIR" + + if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]] + then + eval echo \$${var}_${ARCH/i*86/x86} | tr ';' '\n' + retval=0 + else + retval=1 + fi + + return "${retval}" +} + +marchdepend() +{ + local retval + local var="$1" + + [[ -z ${var} ]] && var="DEPEND" + + if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]] + then + echo "\$(eval echo \\\$${var}_\${ARCH/i*86/x86} | tr ';' '\n')" + retval=0 + else + retval=1 fi + + return "${retval}" +} + +marchsdepend() +{ + local retval + local var="$1" + + [[ -z ${var} ]] && var="SDEPEND" + + if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]] + then + echo "\$(eval echo \\\$${var}_\${ARCH/i*86/x86} | tr ';' '\n')" + retval=0 + else + retval=1 + fi + + return "${retval}" } setup_distcc_environment() @@ -535,69 +637,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() -{ - local target="$1" - local depend="$2" - local NDEPEND - local sym dep cat pver pname - - # 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}" ] +setup_ccache_environment() +{ + if [ -x /usr/bin/ccache ] then - # fix DEPEND - while read sym dep - do - # ignore empty lines - [[ -z ${dep} ]] && continue + mqueryfeature "icecc" && export CCACHE_PREFIX=icecc - 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 - - # 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() @@ -606,10 +663,12 @@ # PNAME name of pkg # PVER version # PBUILD revision -# PCATEGORIE category of the pkg +# PCAT category of the pkg +# PCATEGORIE category of the pkg (deprecated, use PCAT!) # STATE state of pkg stable|unstable|old # DESCRIPTION a short description (opt) # HOMEPAGE homepage (opt) +# LICENSE license information of the pkg (opt) # DEPEND runtime dependencies (opt) # SDEPEND adds needed deps to build the pkg (opt) # PROVIDE provides a virtual (opt) @@ -631,7 +690,6 @@ { local magefile local dest - local target local split_pkg_base local sym local depname @@ -639,17 +697,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}/${PCATEGORIE}/${PNAME}${target}/${magefile}" + dest="${MAGE_TREE_DEST}/${PCAT}/${PNAME}/${magefile}" # show what we are doing echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}" @@ -660,19 +715,19 @@ > ${dest} # pgkname and state - echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} + echo "PKGNAME=\"${PNAME}-${PVER}-\${ARCH}$(print_distrotag)-${PBUILD}\"" >> ${dest} echo "STATE=\"${STATE}\"" >> ${dest} # description and homepage echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} + # license information + echo "LICENSE=\"${LICENSE}\"" >> ${dest} + # 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} @@ -701,8 +756,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 @@ -713,8 +768,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 @@ -732,20 +785,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 @@ -758,6 +799,12 @@ # get the right variables for the split export PNAME="${subpackage}" split_info_${subpackage} + # fix PCATEGORIE -> PCAT + if [[ ! -z ${PCATEGORIE} ]] + then + PCAT="${PCATEGORIE}" + unset PCATEGORIE + fi # get the preinstall etc split_export_inherits ${subpackage} build_mage_script --split-pkg-base "${split_pkg_base}" @@ -779,16 +826,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 @@ -809,12 +847,12 @@ export SAVED_PNAME="${PNAME}" export SAVED_PVER="${PVER}" export SAVED_PBUILD="${PBUILD}" - export SAVED_PCATEGORIE="${PCATEGORIE}" + export SAVED_PCAT="${PCAT}" 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_PKGTYPE="${PKGTYPE}" export SAVED_INHERITS="${INHERITS}" export SAVED_DEPEND="${DEPEND}" export SAVED_SDEPEND="${SDEPEND}" @@ -884,12 +922,12 @@ export PNAME="${SAVED_PNAME}" export PVER="${SAVED_PVER}" export PBUILD="${SAVED_PBUILD}" - export PCATEGORIE="${SAVED_PCATEGORIE}" + export PCAT="${SAVED_PCAT}" 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 PKGTYPE="${SAVED_PKGTYPE}" export INHERITS="${SAVED_INHERITS}" export DEPEND="${SAVED_DEPEND}" export SDEPEND="${SAVED_SDEPEND}" @@ -953,10 +991,11 @@ unset SAVED_PNAME unset SAVED_PVER unset SAVED_PBUILD - unset SAVED_PCATEGORIE + unset SAVED_PCAT unset SAVED_DESCRIPTION unset SAVED_HOMEPAGE unset SAVED_SPECIAL_VARS + unset SAVED_SPECIAL_FUNCTIONS unset SAVED_STATE unset SAVED_PKGTYPE unset SAVED_INHERITS @@ -1037,7 +1076,6 @@ local pver local pbuild local parch - local target local pkgname # very basic getops @@ -1049,7 +1087,6 @@ --pver|-v) shift; pver="$1" ;; --pbuild|-b) shift; pbuild="$1" ;; --parch|a) shift; parch="$1" ;; - --target|t) shift; target="$1" ;; esac shift done @@ -1065,11 +1102,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}-${pbuild}" + pkgname="${pname}-${pver}-${parch}$(print_distrotag)-${pbuild}" # build pkg-md5-sum only if requested if mqueryfeature regentree @@ -1087,7 +1121,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 @@ -1122,7 +1156,7 @@ [[ ! -d ${SRCPKGDIR} ]] && install -d ${SRCPKGDIR} mv ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${SRCPKGDIR}/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} - echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}" + echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}\n" } step_by_step() @@ -1154,3 +1188,8 @@ return 1 fi } + +mqalint() +{ + return 0 +}