# Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils distutils MY_P=Pootle-${PV} 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" # pylucene is an optional but desirable run-time dependency. # Currently it lives in liquidx's overlay, and requires gcj. # translate-toolkit is released with Pootle, versions must match. # If there is no zip, Pootle will use Python's implementation, which is slower. RDEPEND="=app-i18n/translate-toolkit-0.10* >=dev-python/jToolkit-0.7.8 !minimal ( app-arch/zip ) cvs? ( dev-util/cvs ) subversion? ( dev-util/subversion )" 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 mantainance. # Known issue: returns TRUE for an innactive 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() { # Pootle user should administrate the app, but not the host. enewgroup pootle enewuser pootle -1 -1 /dev/null pootle distutils_python_version TARGET="usr/$(get_libdir)/python${PYVER}/site-packages/Pootle" } src_install() { # Everything but the installation script is located under # ${WORKDIR}/Pootle-${PV}/Pootle DOCS="Pootle/ChangeLog Pootle/COPYING Pootle/LICENSE Pootle/README Pootle/TODO" distutils_src_install ebegin "Moving PO files to ${ROOT}var/lib/pootle" dodir -p /var/lib/pootle mv "${D}/${TARGET}"/po/* "${D}"/var/lib/pootle rmdir "${D}/${TARGET}"/po fowners -R pootle:pootle /var/lib/pootle eend $? ebegin "Moving configuration files to ${ROOT}etc/pootle" dodir -p /etc/pootle/ mv "${D}/${TARGET}"/*.prefs "${D}/etc/pootle" fowners root:pootle /etc/pootle/*.prefs fperms 660 /etc/pootle/*.prefs dosed "s:podirectory = \"po\":podirectory = \"${ROOT}var/lib/pootle\":g" /etc/pootle/pootle.prefs eend $? newinitd "${FILESDIR}/${PVR}/init" pootle newconfd "${FILESDIR}/${PVR}/conf" pootle keepdir /var/run/pootle fowners pootle:pootle /var/run/pootle } pkg_postinst() { distutils_pkg_postinst "${ROOT}/${TARGET}" 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 "Your translations will be stored in /var/lib/pootle. Pootle's interface" einfo "translation is stored there too, as the \"pootle\" project. Don't" einfo "translate Pootle itself in your computer! Use http://pootle.wordforge.org" einfo "instead." einfo } # Pootle provides an "startup" login with passoword 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 "admin 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 username 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 -c -32) echo "${username}:" >> "$USER_PREFS" echo " activated = 1" >> "$USER_PREFS" echo " passwdhash = '${hashed_password}'" >> "$USER_PREFS" echo " rights.siteadmin = True" >> "$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." }