# Copyright 1999-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ EAPI="5" inherit subversion eutils ESVN_REPO_URI="http://svn.xmpp.ru/repos/tkabber/trunk/tkabber" ESVN_PROJECT="tkabber" ESVN_RESTRICT="export" DESCRIPTION="GUI client for XMPP (Jabber) instant messaging protocol, written in Tcl/Tk." HOMEPAGE="http://tkabber.jabber.ru/" IUSE="contrib doc examples gpg +plugins +3rd-party-plugins ssl sound +tkimg +trayicon" DEPEND="dev-lang/tcl dev-lang/tk dev-tcltk/tcllib dev-tcltk/bwidget >=dev-tcltk/tkXwin-1.0 gpg? ( dev-tcltk/tclgpg ) ssl? ( dev-tcltk/tls ) sound? ( dev-tcltk/snack ) trayicon? ( >=dev-tcltk/tktray-1.1 ) tkimg? ( dev-tcltk/tkimg )" RDEPEND="${DEPEND}" LICENSE="GPL-2" KEYWORDS="" SLOT="0" DOCS="AUTHORS ChangeLog INSTALL README" MY_D="/usr/share/${PN}" TKABBER_PLUGINS="${TKABBER_PLUGINS:-}" OFFICIAL_TKABBER_PLUGINS_DIR="${S}/plugins/official/tkabber-plugins" THIRD_PARTY_TKABBER_PLUGINS_DIR="${S}/plugins/3rd-party/plugins" TKABBER_SITE_PLUGINS="${TKABBER_SITE_PLUGINS:-${MY_D}/site-plugins}" INCOMPATIBLE_PLUGINS="pluginmanager" TKIMG_DEPENDENT_PLUGINS="alarm vimage" src_unpack() { subversion_fetch if use plugins; then ESVN_REPO_URI="http://svn.xmpp.ru/repos/tkabber/trunk/tkabber-plugins" \ ESVN_PROJECT="tkabber/plugins/official/" \ subversion_fetch fi if use 3rd-party-plugins; then ESVN_REPO_URI="http://svn.xmpp.ru/repos/tkabber-3rd-party/trunk/plugins" \ ESVN_PROJECT="tkabber/plugins/3rd-party" \ subversion_fetch fi ESVN_PROJECT="tkabber" subversion_export } src_prepare() { epatch_user } src_compile() { if use 3rd-party-plugins && has vimage ${TKABBER_PLUGINS}; then cd "${THIRD_PARTY_TKABBER_PLUGINS_DIR}/vimage/lib/tkImageTools" \ || die "Cannot cd to tkImageTools" # Replace hardcoded tcl version if has_version ">=dev-lang/tcl-8.6"; then sed -i -e 's/MINOR_VERSION = 5/MINOR_VERSION = 6/' Makefile \ || die "Cannot patch tkImageTools Makefile" fi emake fi } src_install() { insinto "${MY_D}" cd "${S}/${PN}" || die "Can't chdir to ${S}/${PN}/" local x local DOCSDIRS="doc examples contrib" for x in *; do if [[ -d "${x}" ]] ; then if ! has ${x} ${DOCSDIRS} ; then doins -r "${x}" fi fi done sed -e "s:svn\[get_snapshot \[fullpath ChangeLog\]\]:svn-$(get_commit_date):" \ -i tkabber.tcl \ || die "Failed to fixate date of commit in tkabber.tcl" doins *.tcl emake DESTDIR="${D}" PREFIX="/usr" install-bin dodoc ${DOCS} if use doc ; then dohtml doc/tkabber.html fi if use examples ; then insinto "/usr/share/doc/${PF}" doins -r examples fi if use contrib ; then insinto "/usr/share/doc/${PF}" doins -r contrib fi doicon "${FILESDIR}/${PN}.png" make_desktop_entry ${PN} Tkabber ${PN} if use plugins || use 3rd-party-plugins; then use plugins && \ local EXISTING_OFFICIAL_TKABBER_PLUGINS="$(dirlist "${OFFICIAL_TKABBER_PLUGINS_DIR}")" use 3rd-party-plugins && \ local EXISTING_THIRD_PARTY_TKABBER_PLUGINS="$(dirlist "${THIRD_PARTY_TKABBER_PLUGINS_DIR}")" if use plugins; then cd "${OFFICIAL_TKABBER_PLUGINS_DIR}" \ || die "Can't chdir to ${OFFICIAL_TKABBER_PLUGINS_DIR}" newdoc README README.plugins newdoc ChangeLog ChangeLog.plugins fi cd "${S}" || die "Can't chdir to ${S}" plugins_verify if use plugins; then plugins_install official \ || die "Failed to install official plugins" fi if use 3rd-party-plugins; then plugins_install 3rd-party \ || die "Failed to install 3rd-party plugins" fi cat <<-EOF > 99tkabber TKABBER_SITE_PLUGINS="${TKABBER_SITE_PLUGINS}" EOF doenvd 99tkabber fi } pkg_postinst() { echo einfo "There's no UI option to disable emoticons yet, however" einfo "you can put the following into your ~/.tkabber/config.tcl" einfo einfo "hook::add finload_hook {" einfo " array unset emoteicons::emoteicons" einfo "}" einfo einfo "By default tkabber uses an internal XML parser. You may want" einfo "to use an external one for (dubious) performance reasons," einfo "in which case you may like to emerge dev-tcltk/tdom (and put" einfo "\"package require tdom\" in your ~/.tkabber/config.tcl)." einfo einfo "You may also optionally emerge dev-tcltk/tclx to theoretically" einfo "speed some other of tkabber's pure-Tcl operations up," einfo "as you'd get them written in C. Real performance gains are" einfo "subject to further tests." if ! use tkimg; then einfo ewarn "dev-tcltk/tkimg adds support for PNG and JPG images, such as avatars," ewarn "photos, non-default emoticons, etc. Some plugins, for example the" ewarn "\"alarm\" plugin may not function correctly without dev-tcltk/tkimg" einfo fi plugins_inform } subversion_export() { cd "${ESVN_STORE_DIR}/${ESVN_PROJECT}" \ || die "Can't chdir to ${ESVN_STORE_DIR}/${ESVN_PROJECT}" mkdir -p "${S}" rsync -rlpgo --exclude=".svn/" . "${S}" \ || die "Can't export to ${S}." } # Getting list of directories in current or specified by argument directory. dirlist() { local i local OUTPUT local TARGET_DIR if [[ -n "${1}" ]]; then [[ -d ${1} ]] || die "${1} directory not found" TARGET_DIR="${1}" fi for i in ${TARGET_DIR}/*; do [[ -d "${i}" ]] && OUTPUT="${OUTPUT} $(basename ${i})" done echo ${OUTPUT} } plugins_verify() { local PLUGINS local ABSENT_PLUGINS local DEPENDENT_PLUGINS local i AVAILABLE_PLUGINS="" use plugins && \ AVAILABLE_PLUGINS="${AVAILABLE_PLUGINS} ${EXISTING_OFFICIAL_TKABBER_PLUGINS}" if use 3rd-party-plugins; then fix_existing_third_party_tkabber_plugins AVAILABLE_PLUGINS="${AVAILABLE_PLUGINS} ${EXISTING_THIRD_PARTY_TKABBER_PLUGINS}" fi # Verifying plugins existence. if [[ -n "$TKABBER_PLUGINS" ]]; then PLUGINS=( ${TKABBER_PLUGINS} ) TKABBER_PLUGINS="" for i in ${PLUGINS[@]}; do if has ${i} ${AVAILABLE_PLUGINS}; then TKABBER_PLUGINS="${TKABBER_PLUGINS} ${i}" else ABSENT_PLUGINS="${ABSENT_PLUGINS} ${i}" fi done if [[ -n "${ABSENT_PLUGINS}" ]]; then ewarn ewarn "Following plugins specified in the TKABBER_PLUGINS environment variable" ewarn "are not present in the svn repositories:" ewarn ewarn "${ABSENT_PLUGINS}" ewarn ewarn "You may want to cancel the installation by pressing ^C now and verify" ewarn "your settings. Waiting 5 seconds before continuing..." ewarn ebeep 5 epause 5 fi fi if ! use tkimg; then PLUGINS=( ${TKABBER_PLUGINS:-${AVAILABLE_PLUGINS}} ) for i in ${PLUGINS[@]}; do if has ${i} ${TKIMG_DEPENDENT_PLUGINS}; then DEPENDENT_PLUGINS="${DEPENDENT_PLUGINS} ${i}" fi done if [[ -n "${DEPENDENT_PLUGINS}" ]]; then eerror eerror "The \"tkimg\" USE-flag is not enabled, but the following plugins depend on dev-tcltk/tkimg:" eerror eerror "${DEPENDENT_PLUGINS}" eerror eerror "Please activate the \"tkimg\" USE-flag before installing these plugins" eerror die "\"tkimg\" USE-flag required, but not enabled." fi fi } plugins_inform() { if use plugins || use 3rd-party-plugins; then ewarn "You may need to refresh your profile (eg. login again)" ewarn "for the plugins to work." ewarn if [[ -z "${TKABBER_PLUGINS}" ]]; then einfo "You selected to install plugins via the plugins and/or 3rd-party-plugins" einfo "USE variables. Please note, that if you wish to install only particular" einfo "plugins from all available ones, you need to specify them in the" einfo "TKABBER_PLUGINS variable in make.conf." einfo einfo "Currently the following plugins are available:" einfo einfo "${AVAILABLE_PLUGINS}" einfo fi fi } plugins_install() { insinto "${TKABBER_SITE_PLUGINS}" local PLUGINS local EXISTING_PLUGINS local PLUGINS_DIR case "${1}" in official) EXISTING_PLUGINS="${EXISTING_OFFICIAL_TKABBER_PLUGINS}" PLUGINS_DIR="${OFFICIAL_TKABBER_PLUGINS_DIR}" ;; 3rd-party) EXISTING_PLUGINS="${EXISTING_THIRD_PARTY_TKABBER_PLUGINS}" PLUGINS_DIR="${THIRD_PARTY_TKABBER_PLUGINS_DIR}" ;; *) die "$0: wrong argument" ;; esac PLUGINS=( ${TKABBER_PLUGINS:-${EXISTING_PLUGINS}} ) for i in ${PLUGINS[@]}; do if has ${i} ${EXISTING_PLUGINS}; then doins -r "${PLUGINS_DIR}/${i}" fi done } # Fixing EXISTING_THIRD_PARTY_TKABBER_PLUGINS for avoiding collision of same plugins # from different svn repositories and installation unix-incompatible plugins. fix_existing_third_party_tkabber_plugins() { local PLUGINS=( ${EXISTING_THIRD_PARTY_TKABBER_PLUGINS} ) local CONFLICTING_PLUGINS EXISTING_THIRD_PARTY_TKABBER_PLUGINS="" for i in ${PLUGINS[@]}; do if ! has ${i} ${EXISTING_OFFICIAL_TKABBER_PLUGINS}; then if ! has ${i} ${INCOMPATIBLE_PLUGINS}; then EXISTING_THIRD_PARTY_TKABBER_PLUGINS="${EXISTING_THIRD_PARTY_TKABBER_PLUGINS} ${i}" fi else CONFLICTING_PLUGINS="${CONFLICTING_PLUGINS} ${i}" fi done if [[ -n "${CONFLICTING_PLUGINS}" ]]; then ewarn ewarn "Repositories have the following plugins duplicated," ewarn "official versions of this plugins will be prefered:" ewarn "${CONFLICTING_PLUGINS}" ewarn fi } get_commit_date() { grep -m 1 -o -P "\d{4}-\d\d-\d\d" "${S}/tkabber/ChangeLog" \ | sed s/'-'//g }