new version of the eclass. Special thanks to nichoj and compnerd who contributed...
authorJohn N. Laliberte <allanonjl@gentoo.org>
Wed, 15 Mar 2006 00:38:40 +0000 (00:38 +0000)
committerJohn N. Laliberte <allanonjl@gentoo.org>
Wed, 15 Mar 2006 00:38:40 +0000 (00:38 +0000)
eclass/gnome2.eclass

index 616959f1e9070aeebdf7b94919a96967538f9eb0..1a91ed28ee85f0d50a8ab7b1c71b5cb0cd8961e2 100644 (file)
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/gnome2.eclass,v 1.62 2005/09/08 17:19:22 leonardop Exp $
-#
-# Authors:
-# Bruce A. Locke <blocke@shivan.org>
-# Spidler <spider@gentoo.org>
+# $Header: /var/cvsroot/gentoo-x86/eclass/gnome2.eclass,v 1.63 2006/03/15 00:38:40 allanonjl Exp $
 
-inherit libtool gnome.org debug fdo-mime
+# GNOME 2 ECLASS
+inherit libtool gnome.org debug fdo-mime eutils
 
-# Gnome 2 ECLASS
+# Extra configure opts passed to econf
+G2CONF=${G2CONF:=""}
 
-# extra configure opts passed to econf
-[ -z "$G2CONF" ] && G2CONF=""
+# Extra options passed to elibtoolize
+ELTCONF=${ELTCONF:=""}
 
-# extra options passed to elibtoolize
-[ -z "$ELTCONF" ] && ELTCONF=""
+# Should we use EINSTALL instead of DESTDIR
+USE_EINSTALL=${USE_EINSTALL:=""}
 
-# whether to run scrollkeeper for this package
-[ -z "$SCROLLKEEPER_UPDATE" ] && SCROLLKEEPER_UPDATE="1"
+# Run scrollkeeper for this package?
+SCROLLKEEPER_UPDATE=${SCROLLKEEPER_UPDATE:="1"}
 
-# use make DESTDIR=${D} install rather than einstall
-[ -z "$USE_DESTDIR" ] && USE_DESTDIR=""
+# Where to put scrollkeeper data lives
+SCROLLKEEPER_DIR=${SCROLLKEEPER_DIR:="/var/lib/scrollkeeper"}
 
+# Path to scrollkeeper-update
+SCROLLKEEPER_UPDATE_BIN=${SCROLLKEEPER_UPDATE_BIN:="${ROOT}/usr/bin/scrollkeeper-update"}
 
-IUSE="debug"
+# Path to gconftool-2
+GCONFTOOL_BIN=${GCONFTOOL_BIN:="${ROOT}/usr/bin/gconftool-2"}
 
+IUSE="debug doc"
 
-DEPEND=">=sys-apps/sed-4"
+DEPEND=">=sys-apps/sed-4
+                 sys-apps/findutils"
 
-gnome2_src_configure() {
+gnome2_src_unpack() {
+       unpack ${A}
+       cd ${S}
 
-       # [ -n "${ELTCONF}" ] && elibtoolize ${ELTCONF}
-       elibtoolize ${ELTCONF}
+       # Prevent scrollkeeper access violations
+       gnome2_omf_fix
+}
 
+gnome2_src_configure() {
+       # Update the GNOME configuration options
        use debug && G2CONF="${G2CONF} --enable-debug=yes"
-
-       # doc keyword for gtk-doc
        G2CONF="${G2CONF} $(use_enable doc gtk-doc)"
 
-       econf "$@" ${G2CONF} || die "./configure failure"
+       # Run libtoolize
+       elibtoolize ${ELTCONF}
 
+       # GST_REGISTRY is to work around gst-inspect trying to read/write /root
+       GST_REGISTRY="${S}/registry.xml" econf "$@" ${G2CONF} || die "configure failed"
 }
 
 gnome2_src_compile() {
-
        gnome2_src_configure "$@"
        emake || die "compile failure"
-
 }
 
 gnome2_src_install() {
-
        # if this is not present, scrollkeeper-update may segfault and
        # create bogus directories in /var/lib/
-       dodir /var/lib/scrollkeeper
+       dodir "${SCROLLKEEPER_DIR}"
 
        # we must delay gconf schema installation due to sandbox
        export GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL="1"
 
-       if [ -z "${USE_DESTDIR}" -o "${USE_DESTDIR}" = "0" ]; then
-               einstall "scrollkeeper_localstate_dir=${D}/var/lib/scrollkeeper/" "$@" || die "einstall failed"
+       debug-print "You are testing with DESTDIR by default - AllanonJL"
+       if [[ -z "${USE_EINSTALL}" || "${USE_EINSTALL}" = "0" ]]; then
+               make DESTDIR=${D} "$@" install || die "install failed"
        else
-               make DESTDIR=${D} \
-                       "$@" install || die "make DESTDIR install failed"
+               einstall "scrollkeeper_localstate_dir=${D}${SCROLLKEEPER_DIR} " "$@" || die "einstall failed"
        fi
 
        unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
 
-       # manual document installation
-       [ -n "${DOCS}" ] && dodoc ${DOCS}
+       # Manual document installation
+       [[ -n "${DOCS}" ]] && dodoc ${DOCS}
 
-       # do not keep /var/lib/scrollkeeper because:
+       # Do not keep /var/lib/scrollkeeper because:
        # 1. scrollkeeper will get regenerated at pkg_postinst()
        # 2. ${D}/var/lib/scrollkeeper contains only indexes for the current pkg
        #    thus it makes no sense if pkg_postinst ISN'T run for some reason.
 
-       if [ -z "`find ${D} -name '*.omf'`" ]; then
+       if [[ -z "$(find ${D} -name '*.omf')" ]]; then
                export SCROLLKEEPER_UPDATE="0"
        fi
 
-       # regenerate these in pkg_postinst()
-       rm -rf ${D}/var/lib/scrollkeeper
-       # make sure this one doesn't get in the portage db
-       rm -fr ${D}/usr/share/applications/mimeinfo.cache
+       # Regenerate these in pkg_postinst()
+       rm -rf "${D}${SCROLLKEEPER_DIR}"
 
+       # Make sure this one doesn't get in the portage db
+       rm -fr "${D}/usr/share/applications/mimeinfo.cache"
 }
 
 
 gnome2_gconf_install() {
-
-       if [ -x ${ROOT}/usr/bin/gconftool-2 ]
-       then
+       if [[ -x ${GCONFTOOL_BIN} ]]; then
+               # We are ready to install the GCONF Scheme now
                unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
-               export GCONF_CONFIG_SOURCE=`${ROOT}/usr/bin/gconftool-2 --get-default-source`
+               export GCONF_CONFIG_SOURCE=$(${GCONFTOOL_BIN} --get-default-source)
+
                einfo "Installing GNOME 2 GConf schemas"
-               grep "obj /etc/gconf/schemas" ${ROOT}/var/db/pkg/*/${PF}/CONTENTS | sed 's:obj \([^ ]*\) .*:\1:' | while read F; do
-                       if [ -e "${F}" ]; then
+
+               local contents="${ROOT}/var/db/pkg/*/${PN}-${PVR}/CONTENTS"
+
+               for F in $(grep "obj /etc/gconf/schemas" ${contents} | sed 's:obj \([^ ]*\) .*:\1:' ); do
+                       if [[ -e "${F}" ]]; then
                                # echo "DEBUG::gconf install  ${F}"
-                               ${ROOT}/usr/bin/gconftool-2  --makefile-install-rule ${F} 1>/dev/null
+                               ${GCONFTOOL_BIN} --makefile-install-rule ${F} 1>/dev/null
                        fi
                done
        fi
-
 }
 
 gnome2_gconf_uninstall() {
-
-       if [ -x ${ROOT}/usr/bin/gconftool-2 ]
-       then
+       if [[ -x ${GCONFTOOL_BIN} ]]; then
                unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
-               export GCONF_CONFIG_SOURCE=`${ROOT}/usr/bin/gconftool-2 --get-default-source`
+               export GCONF_CONFIG_SOURCE=$(${GCONFTOOL_BIN} --get-default-source)
+
                einfo "Uninstalling GNOME 2 GConf schemas"
-               cat ${ROOT}/var/db/pkg/*/${PN}-${PVR}/CONTENTS | grep "obj /etc/gconf/schemas" | sed 's:obj \([^ ]*\) .*:\1:' |while read F; do
+
+               local contents="${ROOT}/var/db/pkg/*/${PN}-${PVR}/CONTENTS"
+
+               for F in $(grep "obj /etc/gconf/schemas" ${contents} | sed 's:obj \([^ ]*\) .*:\1:' ); do
                        # echo "DEBUG::gconf install  ${F}"
-                       ${ROOT}/usr/bin/gconftool-2  --makefile-uninstall-rule ${F} 1>/dev/null
+                       ${GCONFTOOL_BIN} --makefile-uninstall-rule ${F} 1>/dev/null
                done
        fi
-
 }
 
 gnome2_icon_cache_update() {
-       local updater=`which gtk-update-icon-cache`
-       if ! grep -q "obj /usr/share/icons" ${ROOT}/var/db/pkg/*/${PF}/CONTENTS \
-       || [ ! -x "$updater" ]; then
-               # Nothing to update
+       local updater=$(type -p gtk-update-icon-cache 2> /dev/null)
+
+       ebegin "Updating icons cache"
+
+       if [[ ! -x ${updater} ]] ; then
+               debug-print "${updater} is not executable"
+
+               # We failed to run
+               eend 1
+
                return
        fi
 
-       ebegin "Updating icons cache"
+       if ! grep -q "obj /usr/share/icons" ${ROOT}/var/db/pkg/*/${PF}/CONTENTS
+       then
+               debug-print "No items to update"
+
+               # We are done successfully
+               eend 0
+
+               return
+       fi
 
        local retval=0
-       for dir in \
-       $(find ${ROOT}/usr/share/icons -maxdepth 1 -mindepth 1 -type d); do
-               if [ -f "${dir}/index.theme" ]; then
-                       $updater -qf $dir || retval=$?
+       local fails=( )
+
+       for dir in $(find ${ROOT}/usr/share/icons -maxdepth 1 -mindepth 1 -type d)
+       do
+               if [[ -f "${dir}/index.theme" ]] ; then
+                       local rv=0
+
+                       ${updater} -qf ${dir}
+                       rv=$?
+
+                       if [[ ! $rv -eq 0 ]] ; then
+                               debug-print "Updating cache failed on ${dir}"
+
+                               # Add to the list of failures
+                               fails[$(( ${#fails[@]} + 1 ))]=$dir
+
+                               retval=2
+                       fi
                fi
        done
 
-       eend $retval
+       eend ${retval}
+
+       for (( i = 0 ; i < ${#fails[@]} ; i++ )) ; do
+               eerror "Failed to update cache with icon ${fails[i]}"
+       done
 }
 
 gnome2_omf_fix() {
-
        # workaround/patch against omf.make or omf-install/Makefile.in
        # in order to remove redundant scrollkeeper-updates.
        # - <liquidx@gentoo.org>
 
-       local omf_makefiles
+       local omf_makefiles filename
 
        omf_makefiles="$@"
 
-       [ -f ${S}/omf-install/Makefile.in ] \
-               && omf_makefiles="${omf_makefiles} ${S}/omf-install/Makefile.in"
+       if [[ -f ${S}/omf-install/Makefile.in ]] ; then
+               omf_makefiles="${omf_makefiles} ${S}/omf-install/Makefile.in"
+       fi
 
        # FIXME: does this really work? because omf.make only gets included
        #        when autoconf/automake is run. You should directly patch
        #        the Makefile.in's
 
-       [ -f ${S}/omf.make ] \
-               && omf_makefiles="${omf_makefiles} ${S}/omf.make"
+       if [[ -f ${S}/omf.make ]] ; then
+               omf_makefiles="${omf_makefiles} ${S}/omf.make"
+       fi
 
+       # testing fixing of all makefiles found
+       for filename in $(find ./ -name "Makefile.in" -o -name "Makefile.am") ; do
+               omf_makefiles="${omf_makefiles} ${filename}"
+       done
+       
        ebegin "Fixing OMF Makefiles"
+
        local retval=0
-       for omf in ${omf_makefiles}; do
-               sed -i -e 's:scrollkeeper-update:true:' ${omf} || retval=$?
+       local fails=( )
+
+       for omf in ${omf_makefiles} ; do
+               local rv=0
+
+               sed -i -e 's:scrollkeeper-update:true:' ${omf}
+               retval=$?
+
+               if [[ ! $rv -eq 0 ]] ; then
+                       debug-print "updating of ${omf} failed"
+
+                       # Add to the list of failures
+                       fails[$(( ${#fails[@]} + 1 ))]=$omf
+
+                       retval=2
+               fi
        done
+
        eend $retval
 
+       for (( i = 0 ; i < ${#fails[@]} ; i++ )) ; do
+               eerror "Failed to update OMF Makefile ${fails[i]}"
+       done
 }
 
 gnome2_scrollkeeper_update() {
-
-       if [ -x ${ROOT}/usr/bin/scrollkeeper-update ] && [ "${SCROLLKEEPER_UPDATE}" = "1" ]
+       if [[ -x ${SCROLLKEEPER_UPDATE_BIN} && "${SCROLLKEEPER_UPDATE}" = "1" ]]
        then
                einfo "Updating scrollkeeper database ..."
-               scrollkeeper-update -q -p ${ROOT}/var/lib/scrollkeeper
+               ${SCROLLKEEPER_UPDATE_BIN} -q -p ${ROOT}${SCROLLKEEPER_DIR}
        fi
-
 }
 
 gnome2_pkg_postinst() {
-
        gnome2_gconf_install
        gnome2_scrollkeeper_update
        fdo-mime_desktop_database_update
        fdo-mime_mime_database_update
        gnome2_icon_cache_update
-
 }
 
 #gnome2_pkg_prerm() {
-
 #      gnome2_gconf_uninstall
-
 #}
 
 gnome2_pkg_postrm() {
-
        gnome2_scrollkeeper_update
        fdo-mime_desktop_database_update
        fdo-mime_mime_database_update
        gnome2_icon_cache_update
-
 }
 
-#EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_prerm  pkg_postrm
-EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm
+EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst pkg_postrm