# Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils distutils MY_P=Pootle-1.2.1 S="${WORKDIR}/${MY_P}" DESCRIPTION="Web tool for software translation and translation management" HOMEPAGE="http://translate.sourceforge.net" SRC_URI="mirror://sourceforge/translate/${MY_P}.tar.bz2" LICENSE="GPL-2" SLOT="0" KEYWORDS="~x86" IUSE="cvs minimal subversion noregister" # pylucene is an optional but desirable run-time dependency. # Currently it lives in liquidx's overlay, and requires gcj. # 2008-06-22: you can also find a pylucene ebuild at http://gpo.zugaina.org # # pootle usually depends on a translate-toolkit with the same version number. # # If there is no zip, Pootle will use Python's implementation, which is slower. RDEPEND="=app-i18n/translate-toolkit-1.2* >=dev-python/jToolkit-0.7.8 !minimal? ( app-arch/zip )" PYTHON_MODNAME=Pootle USER_PREFS="${ROOT}etc/pootle/users.prefs" # Looks at the accounts configuration file for a previous administrator login. # Should be useful only for first-time installation, not for maintenance. # Known issue: returns TRUE for an inactive administrator login. pootle_previous() { grep --quiet --no-messages "^[^#]*rights.siteadmin" "$USER_PREFS" } src_unpack() { unpack ${A} # Hack to use distutils_src_install mv "${S}/pootlesetup.py" "${S}/setup.py" || die } pkg_setup() { enewgroup pootle enewuser pootle -1 -1 /dev/null pootle distutils_python_version TARGET="usr/$(get_libdir)/python${PYVER}/site-packages/${PYTHON_MODNAME}" } src_install() { # Leave the html files with Pootle's source code. This way, they are visible # for remote users when they are actually using Pootle through the WWW. DOCS="${DOCS} Pootle/ChangeLog Pootle/TODO" keepdir /var/run/pootle fowners pootle:pootle /var/run/pootle newinitd "${FILESDIR}/${PVR}/init" pootle newconfd "${FILESDIR}/${PVR}/conf" pootle insinto /var/lib/pootle doins -r Pootle/po/* fowners -R pootle:pootle /var/lib/pootle insinto /etc/pootle doins Pootle/*.prefs fperms 660 /etc/pootle/*.prefs fowners pootle:pootle /etc/pootle/*.prefs dosed "s:podirectory = \"po\":podirectory = \"${ROOT}var/lib/pootle\":g" /etc/pootle/pootle.prefs distutils_src_install rm "${D}/${TARGET}/po" -Rf rm "${D}/${TARGET}/"*.prefs } pkg_postinst() { distutils_pkg_postinst echo if ! pootle_previous; then einfo einfo "Before running your Pootle server, you must create an administrator login" einfo "for it. You can do that running \"emerge --config pootle\" or editing" einfo "$USER_PREFS" fi einfo einfo "Start your Pootle server with /etc/init.d/pootle, and configure it" einfo "with /etc/conf.d/pootle and ${ROOT}etc/pootle/*.prefs" einfo einfo "Local users in the \"pootle\" group will be able to edit Pootle " einfo "file locally, i. e., not using Pootle web interface. Typically, " einfo "you'll want to add only one user, the site administrator." einfo einfo "Your translations will be stored in /var/lib/pootle. Pootle's " einfo "interface translation is stored there too, as the \"pootle\" " einfo "project. Don't translate Pootle itself in your computer! Use " einfo "http://pootle.wordforge.org instead." einfo } # Pootle provides an "startup" login with password set to "startup". Normally # the user activates (uncomment) this login, create another, then inactivate # the first one. With this pkg_config, it should be easy to create an admin # login without ever using the "startup" one. pkg_config() { [ -r "$USER_PREFS" ] || die "Can't read $USER_PREFS" [ -w "$USER_PREFS" ] || die "Can't write to $USER_PREFS" if pootle_previous; then ewarn "This script creates an administrator login for Pootle, in the file" ewarn "$USER_PREFS" ewarn "It is okay to create another admin login for Pootle, but should do that" ewarn "using Pootle's administration interface. Continue only if your current" ewarn "administrator login is broken (e.g. you can't remember the password)." ewarn "If you want to quit, press Control+C." ewarn else einfo "This script will create an administrator login for your Pootle server." einfo "After that, you should manage Pootle users through the web interface or" einfo "editing $USER_PREFS." einfo fi einfo "Please provide information for the administrator login:" read -er -p "User name: " username [ -z $username ] && die "You must provide a user name for the administrator login" read -ers -p " Password: " password [ -z $password ] && die "You must provide a password for the administrator login" hashed_password=$(echo -n "$password" | md5sum | cut -f 1 -d " ") echo "${username}:" >> "$USER_PREFS" echo " activated = 1" >> "$USER_PREFS" echo " passwdhash = '${hashed_password}'" >> "$USER_PREFS" echo " rights.siteadmin = True" >> "$USER_PREFS" echo " name = ''" >> "$USER_PREFS" echo " email = ''" >> "$USER_PREFS" echo; echo einfo "Your information was written to $USER_PREFS." einfo "You may now start or restart your Pootle server, and login to it." }