--- trunk/mage/usr/lib/mage/smage2.functions.sh 2013/02/01 09:45:47 2040 +++ branches/mage-next/src/smage2.functions.sh.in 2018/05/22 14:12:41 3082 @@ -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() @@ -394,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." @@ -491,7 +453,7 @@ [[ -z ${stripdir} ]] && stripdir="${BINDIR}" [[ -z ${STRIP_DYN_LIB} ]] && STRIP_DYN_LIB="--strip-debug" - find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_LIB} 2> /dev/null + find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep "[shared object|pie executable]" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_LIB} 2> /dev/null } mstripbins() @@ -500,7 +462,7 @@ [[ -z ${stripdir} ]] && stripdir="${BINDIR}" [[ -z ${STRIP_DYN_BIN} ]] && STRIP_DYN_BIN="--strip-debug" - find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep "executable" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_BIN} 2> /dev/null + find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep -v "pie executable" | grep "executable" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_BIN} 2> /dev/null } mstripstatic() @@ -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 } @@ -588,12 +550,12 @@ return "${retval}" } -marchsrcfile() +marchvariable() { local retval local var="$1" - [[ -z ${var} ]] && var="SRCFILE" + [[ -n ${var} ]] || die "marchvariable(): missing variable" if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]] then @@ -606,27 +568,43 @@ return "${retval}" } +marchsrcfile() +{ + local retval + local var="$1" + + [[ -z ${var} ]] && var="SRCFILE" + + marchvariable "${var}" || die +} + marchsrcdir() { local retval - if [[ ! -z $(eval echo \$SRCDIR_${ARCH/i*86/x86}) ]] - then - eval echo \$SRCDIR_${ARCH/i*86/x86} | tr ';' '\n' - retval=0 - else - retval=1 - fi + local var="$1" - return "${retval}" + [[ -z ${var} ]] && var="SRCDIR" + + marchvariable "${var}" || die } marchdepend() { local retval + local var="$1" - if [[ ! -z $(eval echo \$DEPEND_${ARCH/i*86/x86}) ]] + [[ -z ${var} ]] && var="DEPEND" + + 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 +616,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,69 +653,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 - - 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 + mqueryfeature "icecc" && export CCACHE_PREFIX=icecc - 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() @@ -762,7 +706,6 @@ { local magefile local dest - local target local split_pkg_base local sym local depname @@ -770,17 +713,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}" @@ -791,7 +731,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 @@ -804,9 +744,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} @@ -835,8 +772,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 @@ -847,8 +784,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 @@ -866,20 +801,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 @@ -919,16 +842,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 @@ -953,6 +867,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}" @@ -1027,6 +942,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}" @@ -1095,6 +1011,7 @@ unset SAVED_DESCRIPTION unset SAVED_HOMEPAGE unset SAVED_SPECIAL_VARS + unset SAVED_SPECIAL_FUNCTIONS unset SAVED_STATE unset SAVED_PKGTYPE unset SAVED_INHERITS @@ -1175,7 +1092,6 @@ local pver local pbuild local parch - local target local pkgname # very basic getops @@ -1187,7 +1103,6 @@ --pver|-v) shift; pver="$1" ;; --pbuild|-b) shift; pbuild="$1" ;; --parch|a) shift; parch="$1" ;; - --target|t) shift; target="$1" ;; esac shift done @@ -1203,11 +1118,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 @@ -1225,7 +1137,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 @@ -1237,16 +1149,9 @@ source_pkg_build() { - if [[ ${PKGTYPE} = virtual ]] - then - echo "Virtual package detected; src-pkg-tarball not necessary ..." - return 0 - fi - if [[ ! -d ${SOURCEDIR}/${PNAME} ]] then - echo "No SRC_URI defined; src-pkg-tarball not necessary ..." - return 0 + install -d ${SOURCEDIR}/${PNAME} fi [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly." @@ -1292,3 +1197,8 @@ return 1 fi } + +mqalint() +{ + return 0 +}