# $Header: /alx-cvs/smage-eglibc/include/alx.sminc,v 1.4 2008/06/24 11:18:19 niro Exp $ # alx functions # some global includes sminclude cleanutils mtools # always include alx in mage files INHERITS="${INHERITS} alx" # to build a stripped down package version # you must call 'package_all_targets' in src_install(). # be sure you have the strip-target-alx() function defined, # get stuff stripped from the package. # # the dev version will be always build when including this file # # The only way to change the behavior is to set ALX_PKGTYPE # ALX_PKGTYPE=only-alx-dev -> means that *only* the alx-dev package gets build # ALX_PKGTYPE=only-alx -> means that *only* the stripped alx package gets build # # all targets for alx MAGE_TARGETS="alx_dev alx" # dummy functions, should be overrided in smage alx_dev_pkgbuild() { return 0; } alx_pkgbuild() { return 0; } # checks if compilation should be against alx target_alx_dev() { local i if [ -n "${MAGE_TARGETS}" ] then for i in ${MAGE_TARGETS} do [[ ${i} = alx_dev ]] && return 0 # alx-dev will always build when building target alx, # so target alx ist also allowed to be alx-dev [[ ${i} = alx ]] && return 0 # same for alx_livecd [[ ${i} = alx_livecd ]] && return 0 done fi # nothing match, we are *not* on alx linux return 1 } # check if compilation should be against stripped down alx target_alx() { if [ -n "${MAGE_TARGETS}" ] then for i in ${MAGE_TARGETS} do [[ ${i} = alx ]] && return 0 done fi # nothing match, we are *not* on alx linux return 1 } # # file injections: # # injects files to given path (defaults to /usr/bin) # alxinjectfile file {/path/to/dest} alxinjectfile() { local file local dest [[ -z $1 ]] && die "No etc file given" file="${SMAGENAME%/*}/alx/files/$1" dest="$2" if [[ -z $2 ]] then dest=/usr/bin install -d ${BINDIR}/${dest} || die fi # install our configfile install -m 0644 -o root -g root ${file} ${BINDIR}/${dest} || die } # injects executables to given path # alxinjectexec exec {/path/to/dest} alxinjectexec() { local file local dest [[ -z $1 ]] && die "No etc file given" file="${SMAGENAME%/*}/alx/files/$1" dest="$2" if [[ -z $2 ]] then dest=/usr/bin install -d ${BINDIR}/${dest} || die fi # install our configfile install -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die } # injects a patch to the sourcecode # - basically the same like mpatch() but uses patches from ${SMAGESCRIPTSDIR}/${PNAME}/alx/files # alxinjectpatch patch alxinjectpatch() { local PATCHOPTS local PATCHFILE local i PATCHOPTS=$1 PATCHFILE=$2 if [[ -z $2 ]] then PATCHFILE=$1 ## patch level auto-detection, get patch level for ((i=0; i < 10; i++)) do patch --dry-run -Np${i} -i ${SMAGENAME%/*}/alx/files/${PATCHFILE} > /dev/null if [[ $? = 0 ]] then PATCHOPTS="-Np${i}" break fi done fi echo -e "${COLBLUE}*** ${COLGREEN}Applying ALX patch '${PATCHFILE}'${COLDEFAULT}" patch "${PATCHOPTS}" -i ${SMAGENAME%/*}/alx/files/${PATCHFILE} } ############################# ##### compile functions #### ############################# # respect multilib! if [[ -z $(typeset -f oldconfigure) ]] then alx_old_mconfigure=alx_old$(typeset -f mconfigure) else alx_old_mconfigure=alx_old$(typeset -f oldmconfigure) fi eval ${alx_old_mconfigure} mconfigure() { local myconf local configurefile # get configure instructions from smage dir if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.cfg ]] then # version specific configure files configurefile=${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.cfg elif [[ -f ${SMAGENAME%/*}/alx/${PNAME}.cfg ]] then # generic configure files for a package configurefile=${SMAGENAME%/*}/alx/${PNAME}.cfg else configurefile="" fi # now read the content if [[ -f ${configurefile} ]] then echo -e "${COLBLUE}*** ${COLGREEN}Using configure info from ${configurefile}${COLDEFAULT}" local line while read line do # ignore empty and commeted lines case "${line}" in \#*|"") continue ;; esac echo -e " adding ${COLGREEN}${line}${COLDEFAULT} to ALX_CONFIGURE_OPTS" ALX_CONFIGURE_OPTS="${ALX_CONFIGURE_OPTS} ${line}" done < ${configurefile} fi alx_oldmconfigure --disable-nls ${myconf} $@ ${ALX_CONFIGURE_OPTS} || die } alx_pkgbuild() { local ALX_ZAPMOST local zapmostfile local ALX_REMOVE local removefile local i if [[ -d ${BINDIR}/usr/$(mlibdir) ]] then find ${BINDIR}/usr/$(mlibdir) -name '*'.a -exec rm '{}' ';' find ${BINDIR}/usr/$(mlibdir) -name '*'.la -exec rm '{}' ';' fi [[ -d ${BINDIR}/usr/include ]] && rm -rf ${BINDIR}/usr/include [[ -d ${BINDIR}/usr/$(mlibdir)/pkgconfig ]] && rm -rf ${BINDIR}/usr/$(mlibdir)/pkgconfig [[ -d ${BINDIR}/usr/share/aclocal ]] && rm -rf ${BINDIR}/usr/share/aclocal [[ -d ${BINDIR}/usr/share/doc ]] && rm -rf ${BINDIR}/usr/share/doc [[ -d ${BINDIR}/usr/share/info ]] && rm -rf ${BINDIR}/usr/share/info [[ -d ${BINDIR}/usr/share/man ]] && rm -rf ${BINDIR}/usr/share/man #[[ -d ${BINDIR}/usr/lib/X11/locale ]] && rm -rf ${BINDIR}/usr/lib/X11/locale # get zapmost instructions from smage dir if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.zap ]] then # version specific zap files zapmostfile=${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.zap elif [[ -f ${SMAGENAME%/*}/alx/${PNAME}.zap ]] then # generic zapmost files for a package zapmostfile=${SMAGENAME%/*}/${PNAME}/alx/${PNAME}.zap else zapmostfile="" fi # now read the content if [[ -f ${zapmostfile} ]] then echo -e "${COLBLUE}*** ${COLGREEN}Using zapmost info from ${zapmostfile}${COLDEFAULT}" local line while read line do # ignore empty and commeted lines case "${line}" in \#*|"") continue ;; esac ALX_ZAPMOST="${ALX_ZAPMOST} ${line}" done < ${zapmostfile} fi # finally run zapmost if [[ -n ${ALX_ZAPMOST} ]] then echo -e "${COLBLUE}*** ${COLGREEN}Running zapmost() ...${COLDEFAULT}" zapmost ${BINDIR} ${ALX_ZAPMOST} || die fi # same goes for the remove file # get remove instructions from smage dir if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.rm ]] then # version specific remove files removefile=${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.rm elif [[ -f ${SMAGENAME%/*}/alx/${PNAME}.rm ]] then # generic remove files for a package removefile=${SMAGENAME%/*}/alx/${PNAME}.rm else removefile="" fi # now read the content if [[ -f ${removefile} ]] then echo -e "${COLBLUE}*** ${COLGREEN}Using remove info from ${removefile}${COLDEFAULT}" local line while read line do # ignore empty and commeted lines case "${line}" in \#*|"") continue ;; esac ALX_REMOVE="${ALX_REMOVE} ${line}" done < ${removefile} fi # finally run zapmost if [[ -n ${ALX_REMOVE} ]] then echo -e "${COLBLUE}*** ${COLGREEN}Running remove() ...${COLDEFAULT}" for i in ${ALX_REMOVE} do if [[ -e ${BINDIR}/${i} ]] then echo -e " ${COLGREEN}<<<${COLDEFAULT} removing ${BINDIR}/${i}" rm -rf ${BINDIR}/${i} fi done fi # check if /usr/share is empty if [[ -d ${BINDIR}/usr/share ]] && ! rmdir ${BINDIR}/usr/share &> /dev/null then echo -e "${COLBLUE}*** ${COLRED}WARNING: ${BINDIR}/usr/share is *not* empty. Please check!${COLDEFAULT}" fi } alx_livecd_pkgbuild() { alx_pkgbuild || die } # get custom alx functions if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.custom ]] then echo -e "${COLBLUE}*** ${COLGREEN}Using custom build info from ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.custom${COLDEFAULT}" source ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.custom elif [[ -f ${SMAGENAME%/*}/alx/${PNAME}.custom ]] then echo -e "${COLBLUE}*** ${COLGREEN}Using custom build info from ${SMAGENAME%/*}/alx/${PNAME}.custom${COLDEFAULT}" source ${SMAGENAME%/*}/alx/${PNAME}.custom fi # overrides [[ ${ALX_PKGTYPE} = only-alx-dev ]] && MAGE_TARGETS="alx_dev" [[ ${ALX_PKGTYPE} = only-alx ]] && MAGE_TARGETS="alx"