# HG changeset patch # User Daniel Neugebauer # Date 1459192973 -7200 # Node ID b4ad250ded0204f6fc0d2d27ca9203b15cd432be # Parent fa6d2de366ace56aa48663205c8715d15aff9570# Parent bfe110645e2aad71cfdd1089fc851833129463a8 merge diff -r fa6d2de366ac -r b4ad250ded02 dev-vcs/kallithea/Manifest --- a/dev-vcs/kallithea/Manifest Mon Mar 28 21:19:27 2016 +0200 +++ b/dev-vcs/kallithea/Manifest Mon Mar 28 21:22:53 2016 +0200 @@ -1,4 +1,4 @@ AUX production.wsgi 448 SHA256 34aa607585b8526356d0a4e7103689a4c353e333bfd7dbd9316dea1601403af6 SHA512 f1d6310626ce5687317d856e4be2ea37d4d39dea5402846c64195d77cef1454ef96d3c6d23832a9a0c8ecdc6645582bc86b138cc7fbb7dc78226f45279d44f7a WHIRLPOOL cfee76d169facea538b00fdd9683a9ecefe58cd49f3c2f3f46e49025af459e5a8bdd236ea55252d5488ee52212f2f57423f3d8e21ddb2251e25851bffc93d243 AUX start-virtualenv.sh 463 SHA256 2f5def6c4840b94b78055fcc3f3e37aa42dd709e4e71dfa16d1fc63966274456 SHA512 0912644b3806b9c04d301f5f2f59c9b212549e73dec848a324fb0dd8bc9410e60750a571a3438ccc4b9dd940020986b67a9f3bb29a7fd27945daa2ae4c24139d WHIRLPOOL f4cbb8e583ec907baaa0801c6c2f73a9832689422654661079d420002a6c55ff872f8af1b4a2b78e50085f90e2c8d5876e93a436c443ac75f9d589510d8f615c -EBUILD kallithea-9999.ebuild 8413 SHA256 0455764589e04a214f885831587ab57a823994f9e57bda1b969f2ff746b59d03 SHA512 3e6b0a1ef1f2c1316f8690336a7d1516ac80cce301d8ac85f8b4adcb7b86780fd56328338c7c271dee0de505f54c324c1339b2b619ecc1a7169e67aac3cd4eae WHIRLPOOL 97827448c10e7ec8bd94ff129a5a9b3b2f94dde815d8a357c28b0e8e6f3c1a0768381133e730f0b0472750920cc55f9276aa0822bddc0581be0f3b2ec76eccfa -MISC kallithea-test.sh 603 SHA256 4d0ab7e309ea72d79691c903ed66de0c68845244a04728d93d466ce3e243ce61 SHA512 350b5eee94f0ee5cafac0b7254c8e0b61620686694bb068d6072c85edf4f6724057294e9f95e2f00df0b0a96a1cfc1553cf0790f4a1e64342dcb574ced57783c WHIRLPOOL fa671b48d21f25367f8653a825c9bcb1b196369d0d8d1b6ba6d1d926b835e289be2554ef365954dfe2af04d4400db0a8c7bff6f5a5551c803c38fdf09357a4dc +DIST Kallithea-0.3.1.tar.bz2 5320317 SHA256 9c6cac42d99da475af63012265f986c4d743a07e81c18f4744b3bf8be84aad7d SHA512 09bf8552d00176258dc2f00fc8a186bb95e0f12b535db836bf6a404bc41821805c144056af76f69eec66926ce3226ba0a6b3776abb8d717f5bbe5b33faa81beb WHIRLPOOL d05b0cbf7f9613571116efc10a0d99b1944c2c2ae4ede37dfde074120839bd40c2c0708f5028e2018f9d1fb4a24a7ef42b84f211c1fdef13200b2b7ee765f85f +EBUILD kallithea-0.3.1.ebuild 15526 SHA256 9c64b0c91c1631a61207f78aae7ba4c78f806b1c9127aa18d921655871cb7815 SHA512 8c3a0867552651f8e0257a685ddaa8c9dde02adb335a395a8daf282a35a11bd51f031ef7f7890756daa877a4cabcbc73c5f7157699d90f1c9ec27e3bb691a40c WHIRLPOOL d479eec505d49136e0f40f9678e23498ef37dbecc9359961bab7b45cb9c751aac55ddfde35fbb73e27e8a2139106d41cb0e18de7bb1a0b0373524c5c2ce475ad diff -r fa6d2de366ac -r b4ad250ded02 dev-vcs/kallithea/kallithea-0.3.1.ebuild --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev-vcs/kallithea/kallithea-0.3.1.ebuild Mon Mar 28 21:22:53 2016 +0200 @@ -0,0 +1,419 @@ +# Copyright 1999-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +### NOTES ########################################################################## +# +# When updating this ebuild, comment out all workarounds and try without them first. +# Only re-enable them if they are still required. +# +# Also check that documentation URLs are still correct. +# +#################################################################################### + +EAPI="5" +PYTHON_DEPEND="2" +SUPPORT_PYTHON_ABIS="1" + +inherit user + +DESCRIPTION="a web-based frontend and middleware to Mercurial and Git repositories" +HOMEPAGE="https://kallithea-scm.org/" +SRC_URI="https://pypi.python.org/packages/source/K/Kallithea/Kallithea-${PV}.tar.bz2" + +IUSE="+git mysql postgres sqlite" +REQUIRED_USE="|| ( mysql postgres sqlite )" + +RDEPEND=" + dev-python/virtualenv + git? ( dev-vcs/git ) + mysql? ( dev-db/mysql ) + postgres? ( dev-db/postgresql ) + sqlite? ( dev-lang/python:2.7[sqlite] ) +" + #mysql? ( virtual/libmysqlclient ) + +DEPEND="${RDEPEND} + app-arch/unzip + sys-apps/sed" + +LICENSE="GPL-3" +SLOT="0" +KEYWORDS="~amd64 ~x86" + +RESTRICT_PYTHON_ABIS="3.*" + +installDataPath="/var/lib/kallithea" +installBasePath="/opt/kallithea" +installConfigPath="/etc/kallithea" +virtualenvActivationPath="bin/activate" + +urlDocumentationSetup="http://kallithea.readthedocs.org/en/${PV}/setup.html" +urlDocumentationRhodeCode="http://kallithea.readthedocs.org/en/${PV}/readme.html#converting-from-rhodecode" +urlDocumentationMegacoffee="http://gentoo-overlay.megacoffee.net/s/docs-kallithea-apache-mod_wsgi" + +pkg_setup() { + # create user and group + enewgroup kallithea + enewuser kallithea -1 -1 "${installDataPath}" kallithea +} + +src_unpack() { + unpack ${A} + mv Kallithea-${PV} kallithea-${PV} || die "Unexpected directory structure, aborting..." +} + +src_compile() { + # not really compiling anything + + realWorkDir=$(pwd) + + # create new virtual environment + virtualenv --python=python2.7 --no-site-packages dist/v + + # activate environment + source "dist/v/${virtualenvActivationPath}" + + # WORKAROUND: + # we need to make sure we have a current version of setuptools to install Kallithea's dependencies + pip2.7 install 'setuptools>=17.1' || die "Failed to install setuptools, aborting!" + + # WORKAROUND: + # _after_ installation on --config we need a certain version of paster to create the initial config file... + pip2.7 install 'PasteScript==2.0.2' || die "Failed to install PasteScript, aborting!" + + # WORKAROUND: + # Kallithea's attempt to install Mercurial fails, so we do it first + pip2.7 install 'mercurial>=2.9,<3.8' || die "Failed to install Mercurial, aborting!" + + # WORKAROUND: + # Kallithea needs psycopg2 for PostgreSQL support which is not currently listed as a dependency?! + # at the time of writing 2.6.1 is current, so we limit the version to <2.7 + if use postgres ; then + pip2.7 install 'psycopg2>=2.6,<2.7' || die "Failed to install psycopg2 (required for PostgreSQL support), aborting!" + fi + + # WORKAROUND: + # Kallithea needs MySQLdb for MySQL support which is not currently listed as a dependency?! + # at the time of writing 1.2.5 is current, so we limit the version to <1.3 + if use mysql ; then + pip2.7 install 'MySQL-python>=1.2,<1.3' || die "Failed to install MySQL-python (required for MySQL support), aborting!" + fi + + # perform automatic installation, includes dependencies + echo + echo "===> output by Kallithea's setup.py" + python2.7 setup.py install + retval=$? + echo "<=== Kallithea's setup.py is done, resuming ebuild code" + echo + + # quit now if failed + if [ ${retval} -ne 0 ]; then + echo "Bad return value ${retval} from setup.py install" + exit 1 + fi + + # unzip all eggs + echo 'Unzipping all eggs...' + cd dist/v/lib/python2.7/site-packages/ || die "site-packages not found" + for eggname in *.egg; do + if [ -f "${eggname}" ]; then + mv "${eggname}" tmp.extract.zip + unzip -d "${eggname}" tmp.extract.zip + rm tmp.extract.zip + fi + done + + # disable Git support according to manual + # see: http://kallithea.readthedocs.org/en/0.3.1/usage/vcs_support.html + if ! use git ; then + sed -i -e "/^BACKENDS\s*=\s*{/,/}/ s/^\(\s*\)\('git'\)/\1#\2/" Kallithea-${PV}-py2.7.egg/kallithea/__init__.py || die 'Failed to disable git support, aborting...' + fi + + # create config + mkdir "${realWorkDir}/etc" + cd "${realWorkDir}/etc" + paster make-config Kallithea production.ini || die "unable to create configuration file" + + # rewrite config to refer to correct default paths + sed -i -e "s/%(here)s\(\/\(tarballcache\|data\)\)/${installDataPath//\//\\/}\1/" production.ini + sed -i -e "s/%(here)s\(\/kallithea.db\)/${installDataPath//\//\\/}\1/" production.ini + + # rewrite config to only log from WARN level to "console" + # By Kallithea defaults, handler_console logs everything from INFO level to "console". + # As mod_wsgi logs everything from "console" to error_log this results in a huge amount + # of unnecessary log entries which we would like to prevent. + # NOTE: As sed syntax is hard to read... this replacement rule is prefixed with an "address" which + # is being defined by two regexps, effectively restricting replacements just to the + # handler_console section of our ini file. + sed -i -e '/^\[handler_console\]/,/^\[/ s/level\s*=\s*INFO/level = WARN/' production.ini + + # rewrite config to disable debug mode + # By default, Kallithea uses debug = true which should *NOT* be used except during development. + # See: http://kallithea.readthedocs.org/en/0.3.1/usage/debugging.html + sed -i -e '/^\[DEFAULT\]/,/^\[/ s/\(debug\s*=\s*\)true/\1false/' production.ini + + ## (disabled, does not work from sandbox) + ## maintain system-unique variables from previous production.ini if available + #previousProductionConfig="${installConfigPath}/production.ini" + #if [ -e "${previousProductionConfig}" ]; then + # previousAppInstanceUUID="$(grep -oE '^\s*app_instance_uuid\s*=\s*[0-9a-f\-]+' /etc/kallithea/production.ini | cut -d'=' -f2 | tr -d ' ')" + # previousBeakerSessionSecret="$(grep -oE '^\s*beaker\.session\.secret\s*=\s*[0-9a-f\-]+' "${previousProductionConfig}" | cut -d'=' -f2 | tr -d ' ')" + # + # if [ ! -z "${previousAppInstanceUUID}" ]; then + # echo 'Transferring previous app instance UUID to new production.ini' + # sed -i -e "s/^\(\s*app_instance_uuid\s*=\s*\).*/\1${previousAppInstanceUUID}/" production.ini + # fi + # + # if [ ! -z "${previousBeakerSessionSecret}" ]; then + # echo 'Transferring previous Beaker session secret to new production.ini' + # sed -i -e "s/^\(\s*beaker\.session\.secret\s*=\s*\).*/\1${previousBeakerSessionSecret}/" production.ini + # fi + #fi + + # remove newly generated UUID and Beaker session secret from config + # as user should configure that instead and config diffs don't show + # unnecessary stuff + sed -i -e "s/^\(\s*app_instance_uuid\s*=\).*/#\1 (run uuidgen and insert the returned UUID here)/" production.ini + sed -i -e "s/^\(\s*beaker\.session\.secret\s*=\).*/#\1 (run uuidgen and insert the returned UUID here)/" production.ini + + # comment out sqlite DB as we don't want users to use it by accident + sed -i -e 's/^\(\s*\)\(sqlalchemy\.db1\.url\s*=\s*sqlite:.*\)/\1#\2/' production.ini + + # rename production.ini as it requires more configuration and is hard to read + mv production.ini production.ini.example + + # rewrite virtualenv directory to later installation directory + oldIFS="${IFS}" + IFS=" + " + echo "Searching files that need to have paths replaced when leaving portage sandbox..." + dirtyFiles=$(grep -Ri "${realWorkDir}/dist/v" ${realWorkDir}/dist/v | grep -vE '^Binary' | cut -d':' -f1 | sort | uniq) + for dirtyFile in ${dirtyFiles}; do + echo " patching ${dirtyFile}" + sed -e "s#${realWorkDir}/dist/v#${installBasePath}#" -i "${dirtyFile}" + done + IFS="${oldIFS}" + + # create WSGI file + cd "${realWorkDir}/etc" + cp "${FILESDIR}/production.wsgi" . + sed -e "s:###BASEDIR###:${installBasePath}:" -i production.wsgi + sed -e "s:###DATADIR###:${installDataPath}:" -i production.wsgi + sed -e "s:###CONFDIR###:${installConfigPath}:" -i production.wsgi +} + +src_install() { + # QA: no need to have anything world-writable... + chmod o-w -R dist/v/lib/python2.7/site-packages/ + + # just copy the virtualenv directory to /opt/kallithea + dodir /opt + cp -aR "${S}/dist/v" "${D}${installBasePath}" + + # install configuration files to /etc/kallithea + diropts -m750 -oroot -gkallithea + insopts -m640 -oroot -gkallithea + insinto "${installConfigPath}" + doins "${S}/etc/production.ini.example" + insopts -m644 -oroot -gkallithea + doins "${S}/etc/production.wsgi" + + # create data directory and subdirectories + diropts -m2770 -okallithea -gkallithea + keepdir "${installDataPath}" + keepdir "${installDataPath}/data" + keepdir "${installDataPath}/data/cache" + keepdir "${installDataPath}/data/cache/data" + keepdir "${installDataPath}/data/cache/lock" + keepdir "${installDataPath}/data/index" + keepdir "${installDataPath}/repositories" + keepdir "${installDataPath}/tarballcache" +} + +pkg_postinst() { + # 1 2 3 4 5 6 7 8 + # 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + elog "An example configuration file has already been created so you don't need to run" + elog "make-config again; please copy and edit carefully on first setup:" + elog " cp -a ${installConfigPath}/production.ini.example ${installConfigPath}/production.ini" + elog " \$EDITOR ${installConfigPath}/production.ini" + elog "" + elog "After updates, please compare what has changed and copy any necessary changes:" + elog " diff -u ${installConfigPath}/production.ini ${installConfigPath}/production.ini.example" + elog "" + elog "You still need to follow Kallithea's other setup steps according to the" + elog "instructions at:" + elog " ${urlDocumentationSetup}" + elog "" + elog "When doing so, please mind that Kallithea was installed into a Python virtual" + elog "environment that has to be \"activated\" before it can be used. To do so," + elog "you will have to run a dedicated shell and initialize the environment by running" + elog "" + elog " source ${installBasePath}/${virtualenvActivationPath}" + elog "" + elog "We altered the default config slightly. It may be best to have a look at our" + elog "short example on how to setup hosting with Apache and mod_wsgi, even if you" + elog "prefer another method of hosting Kallithea:" + elog " ${urlDocumentationMegacoffee}" + elog "" + #elog "We can wrap those commands for you if you run (no prior activation needed):" + #elog " emerge --config =${CATEGORY}/${PF}" + #elog "" + elog "Kallithea also provides a way to migrate your database if you are coming from" + elog "RhodeCode 2.2 or below. Instructions can be found at:" + elog "${urlDocumentationRhodeCode}" + elog "" + ewarn "Bear in mind that the whole purpose of a Python virtual environment is to" + ewarn "isolate complex dependency installations from other instances installed on the" + ewarn "same system so you will have to remember to re-emerge this ebuild when" + ewarn "Kallithea's dependencies received bug and in particular security fixes (assuming" + ewarn "it allows any more recent versions to be installed)." + + if use sqlite ; then + ewarn "" + ewarn "You chose to use SQLite for Kallithea. Please be advised that this is *ONLY* for" + ewarn "testing purposes, please avoid using SQLite in production and choose a different" + ewarn "database instead." + fi +} + + + + + +################################################################################################# +### EVERYTHING BELOW WAS AN ATTEMPT TO ASSIST USERS ON SETUP BUT CALLING EDITORS NEVER WORKED ### +### SHOULD STAY DEACTIVATED FOR NOW ### +################################################################################################# + + +my_read_line() { + # BASH function 'read' cannot write input back to variable in correct environment + # when run by emerge so we have to do *this* instead... great... :/ + # (at least this works...) + + python -c 'import sys; print(sys.stdin.readline().strip())' +} + +config_menu() { + choice="" + + oldIFS="${IFS}" + IFS=" + " + + # 1 2 3 4 5 6 7 8 + # 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + echo + echo "===============================================================================" + echo + echo "Your options:" + echo + echo " 1) create production config from template (paster make-config ...)" + echo " 2) edit production config" + echo " 3) initialize Kallithea (paster setup-db)" + echo " This will also ask for repository location and create an admin account." + echo " 0) quit" + echo " Kallithea should be able to run now, check documentation for more options" + echo " such as setting up a task queue or full text search if you need it." + echo + + echo "TERM is ${TERM}" + + while [[ ! "${choice}" =~ ^[0-3]$ ]]; do + echo -n "Your choice? " + choice=$(my_read_line) + done + + IFS="${oldIFS}" + + return ${choice} +} + +pkg_config() { + echo "Erm... You are not supposed to call --config as it has not been completed." + echo "Sorry, you will have to follow the docs yourself for now, see:" + echo " ${urlDocumentationSetup}" + echo + echo + exit 1 + + # 1 2 3 4 5 6 7 8 + # 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + + echo "Kallithea setup requires following multiple steps, some of which need to be run" + echo "in the correct virtual Python environment. This script helps you running those" + echo "commands by wrapping the commands to be run inside the correct virtualenv." + echo "You may still want to read the setup instructions while running this script:" + echo + echo " ${urlDocumentationSetup}" + + # activate virtualenv + cd ${installBasePath} || die "installation is gone? (${installBasePath})" + source "${virtualenvActivationPath}" || die "failed to activate virtualenv (${installBasePath}/${virtualenvActivationPath})" + + configFileName='production.ini' + + while true; do + config_menu + choice=$? + echo + + case "${choice}" in + 0) break + ;; + + 1) mkdir -p "${installBasePath}/etc" + cd "${installBasePath}/etc" + + shouldCreate="y" + if [ -e "${configFileName}" ]; then + shouldCreate="" + while true; do + echo "${configFileName} already exists, overwrite?" + while [[ ! "${shouldCreate}" =~ ^[yn]$ ]]; do + echo -n "Enter y to overwrite, n to abort: " + shouldCreate=$(my_read_line) + done + done + fi + + if [ "${shouldCreate}" == 'y' ]; then + echo 'Creating configuration file...' + paster make-config Kallithea ${configFileName} + else + echo 'Aborted, configuration file has not been overwritten.' + fi + ;; + + 2) iniPath="${installBasePath}/etc/${configFileName}" + + if [ ! -e "${iniPath}" ]; then + echo "config not found at ${iniPath}; did you follow step 1?" + continue + fi + + # terminal and shell need a reset or editor will be screwed up + source /etc/profile + reset + stty sane + + # open editor + if [[ "${EDITOR}" != "" ]] && [ -e "${EDITOR}" ]; then + TERM="xterm" ${EDITOR} "${iniPath}" + else + TERM="xterm" nano -w "${iniPath}" + fi + + # we better reset again... + source /etc/profile + reset + stty sane + ;; + + *) echo "invalid choice ${choice}" + ;; + esac + done +} diff -r fa6d2de366ac -r b4ad250ded02 dev-vcs/kallithea/kallithea-9999.ebuild --- a/dev-vcs/kallithea/kallithea-9999.ebuild Mon Mar 28 21:19:27 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,262 +0,0 @@ -# Copyright 1999-2014 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -EAPI="2" -PYTHON_DEPEND="2" -SUPPORT_PYTHON_ABIS="1" - -inherit mercurial -inherit user - -DESCRIPTION="a web-based frontend and middleware to Mercurial and Git repositories" -HOMEPAGE="https://kallithea-scm.org/" - -#EHG_REPO_URI="https://kallithea-scm.org/repos/kallithea" -EHG_REPO_URI="https://bitbucket.org/conservancy/kallithea" - -RDEPEND="dev-python/virtualenv" - -DEPEND="${RDEPEND}" - -LICENSE="GPL-3" -SLOT="0" -KEYWORDS="~amd64 ~x86" -IUSE="" - -RESTRICT_PYTHON_ABIS="3.*" - -installDataPath="/var/lib/kallithea" -installBasePath="/opt/kallithea" -installConfigPath="/etc/kallithea" -virtualenvActivationPath="bin/activate" - -pkg_setup() { - # create user and group - enewgroup kallithea - enewuser kallithea -1 -1 "${installDataPath}" kallithea -} - -src_compile() { - # not really compiling anything - - realWorkDir=$(pwd) - - # create new virtual environment - virtualenv --no-site-packages dist/v - - # activate environment - source "dist/v/${virtualenvActivationPath}" - - # WORKAROUND: - # pylonshq.com is dead, remove from config - sed -e 's/\(find_links\s*=\s*http:\/\/www.pylonshq.com\/\)/;\1/' -i setup.cfg - - # WORKAROUND: - # if we don't install anyjson via PIP we will get a sandbox violation on second run - # (after fixing pylonshq.com for Pylons EGG-INFO) - # see: https://groups.google.com/forum/#!msg/rhodecode/agjXi2JeDZQ/LzFJ6EAsk9AJ - pip install 'anyjson>=0.3.1' - - # perform automatic installation, includes dependencies - echo - echo "===> output by Kallithea's setup.py" - python setup.py install - retval=$? - echo "<=== Kallithea's setup.py is done, resuming ebuild code" - echo - - # WORKAROUND: - # pylonshq.com may still have been tried to be accessed and failed - # check if that's the case and retry with a patched egg info file - if [ ${retval} -ne 0 ]; then - pylonsPath="${realWorkDir}/dist/v/lib/python2.7/site-packages/Pylons-1.0-py2.7.egg" - #if [ ! -e "${pylonsPath}/pylons" ] && [ -e "${pylonsPath}/EGG-INFO" ]; then - if [ ! -e "${realWorkDir}/dist/v/lib/python2.7/site-packages/pylons" ] && [ -e "${realWorkDir}/dist/v/lib/python2.7/site-packages/Pylons-1.0-py2.7.egg/EGG-INFO" ]; then - # gnoar... it really smells like pylonshq.com... - sed -e 's#^http://www.pylonshq.com/.*##' -i "${pylonsPath}/EGG-INFO/dependency_links.txt" - - # prepare to try again (sandbox violation if not done) - # TODO: check if still required - source /etc/profile - cd "${realWorkDir}" - source "dist/v/${virtualenvActivationPath}" - - echo "Retrying installation with removed pylonshq.com URL..." - echo - echo "===> output by Kallithea's setup.py" - python setup.py install || die "Automatic installation failed, please check above output. (failed after fixing Pylons dependency URL)" - echo "<=== Kallithea's setup.py is done, resuming ebuild code" - else - # some other error on first run - die "Automatic installation failed, please check above output. (failed on first try)" - fi - fi - echo - - # create config - mkdir "${realWorkDir}/etc" - cd "${realWorkDir}/etc" - paster make-config Kallithea production.ini || die "unable to create configuration file" - - # rewrite virtualenv directory to later installation directory - oldIFS="${IFS}" - IFS=" - " - echo "Searching files that need to have paths replaced when leaving portage sandbox..." - dirtyFiles=$(grep -Ri "${realWorkDir}/dist/v" ${realWorkDir}/dist/v | grep -vE '^Binary' | cut -d':' -f1 | sort | uniq) - for dirtyFile in ${dirtyFiles}; do - echo " patching ${dirtyFile}" - sed -e "s#${realWorkDir}/dist/v#${installBasePath}#" -i "${dirtyFile}" - done - IFS="${oldIFS}" - - # create WSGI file - cd "${realWorkDir}/etc" - cp "${FILESDIR}/production.wsgi" . - sed -e "s:###BASEDIR###:${installBasePath}:" -i production.wsgi - sed -e "s:###DATADIR###:${installDataPath}:" -i production.wsgi - sed -e "s:###CONFDIR###:${installConfigPath}:" -i production.wsgi -} - -src_install() { - # QA: no need to have anything world-writable... - chmod o-w -R dist/v/lib/python2.7/site-packages/setuptools-0.9.8-py2.7.egg-info - - # just copy the virtualenv directory to /opt/kallithea - dodir /opt - cp -aR "${S}/dist/v" "${D}${installBasePath}" - - # install configuration files to /etc/kallithea - diropts -m750 -oroot -gkallithea - insopts -m640 -oroot -gkallithea - insinto "${installConfigPath}" - doins "${S}/etc/production.ini" - doins "${S}/etc/production.wsgi" - - # create data directory - diropts -m2770 -okallithea -gkallithea - keepdir "${installDataPath}" -} - -pkg_postinst() { - # 1 2 3 4 5 6 7 8 - # 12345678901234567890123456789012345678901234567890123456789012345678901234567890 - einfo "You need to setup Kallithea according to the instructions at:" - einfo " https://pythonhosted.org/Kallithea/setup.html" - einfo "" - einfo "When doing so, please mind that Kallithea was installed into a Python virtual" - einfo "environment that has to be \"activated\" before it can be used. To do so," - einfo "you will have to run a dedicated shell and initialize the environment by running" - einfo "" - einfo " source ${D}/dist/v/bin/activate" - einfo "" - einfo "We can wrap those commands for you if you run:" - einfo " emerge --config =${CATEGORY}/${PF}" - einfo "" - einfo "Kallithea also provides a way to migrate your database if you" - einfo "are coming from RhodeCode. Instructions can be found at:" - einfo "https://pythonhosted.org/Kallithea/index.html#converting-from-rhodecode" -} - -my_read_line() { - # BASH function 'read' cannot write input back to variable in correct environment - # when run by emerge so we have to do *this* instead... great... :/ - # (at least this works...) - - python -c 'import sys; print(sys.stdin.readline().strip())' -} - -config_menu() { - choice="" - - oldIFS="${IFS}" - IFS=" - " - - # 1 2 3 4 5 6 7 8 - # 12345678901234567890123456789012345678901234567890123456789012345678901234567890 - echo - echo "===============================================================================" - echo - echo "Your options:" - echo - echo " 1) create production config from template (paster make-config ...)" - echo " 2) edit production config" - echo " 3) initialize Kallithea (paster setup-db)" - echo " This will also ask for repository location and create an admin account." - echo " 0) quit" - echo " Kallithea should be able to run now, check documentation for more options" - echo " such as setting up a task queue or full text search if you need it." - echo - - echo "TERM is ${TERM}" - - while [[ ! "${choice}" =~ ^[0-3]$ ]]; do - echo -n "Your choice? " - choice=$(my_read_line) - done - - IFS="${oldIFS}" - - return ${choice} -} - -pkg_config() { - # 1 2 3 4 5 6 7 8 - # 12345678901234567890123456789012345678901234567890123456789012345678901234567890 - - echo "Kallithea setup requires following multiple steps, some of which need to be run" - echo "in the correct virtual Python environment. This script helps you running those" - echo "commands by wrapping the commands to be run inside the correct virtualenv." - echo "You may still want to read the setup instructions while running this script:" - echo - echo " https://pythonhosted.org/Kallithea/setup.html" - - # activate virtualenv - cd ${installBasePath} || die "installation is gone? (${installBasePath})" - source "${virtualenvActivationPath}" || die "failed to activate virtualenv (${installBasePath}/${virtualenvActivationPath})" - - while true; do - config_menu - choice=$? - echo - - case "${choice}" in - 0) break - ;; - - 1) mkdir -p "${installBasePath}/etc" - cd "${installBasePath}/etc" - paster make-config Kallithea production.ini - ;; - - 2) iniPath="${installBasePath}/etc/production.ini" - - if [ ! -e "${iniPath}" ]; then - echo "config not found at ${iniPath}; did you follow step 1?" - continue - fi - - # terminal and shell need a reset or editor will be screwed up - source /etc/profile - reset - stty sane - - # open editor - if [[ "${EDITOR}" != "" ]] && [ -e "${EDITOR}" ]; then - TERM="xterm" ${EDITOR} "${iniPath}" - else - TERM="xterm" nano -w "${iniPath}" - fi - - # we better reset again... - source /etc/profile - reset - stty sane - ;; - - *) echo "invalid choice ${choice}" - ;; - esac - done -}