megacoffee.net Gentoo overlay - legacy mirror
We have moved to Git. This repository is only provided for compatibility with old installations. Learn how to migrate your installation here.
changeset 128:507516b40917
Kallithea: fixing paths, adding emerge --config support (WIP)
author | Daniel Neugebauer <dneuge@energiequant.de> |
---|---|
date | Sun, 03 Aug 2014 19:24:42 +0200 |
parents | 86d178602b1f |
children | 4a630613e8cd |
files | dev-vcs/kallithea/Manifest dev-vcs/kallithea/kallithea-9999.ebuild |
diffstat | 2 files changed, 132 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/dev-vcs/kallithea/Manifest Sat Jul 12 23:37:46 2014 +0200 +++ b/dev-vcs/kallithea/Manifest Sun Aug 03 19:24:42 2014 +0200 @@ -1,1 +1,2 @@ -EBUILD kallithea-9999.ebuild 1821 SHA256 a7388d7e4d880d5157bf28ef6931a7be9bfddc2b1e77836382bf3449de3a0124 SHA512 e9fb5518a5f2abf5e56d703e745e759ac74d786bcbad92fbbfa1f3e6574b0a533d374df0ac8ac3eca4d847cca3704d3e322c248f21fd0323805f2a51c6231e5b WHIRLPOOL 2f727ce306fc183dcc7b3b18b35ce9f12a62c26acf53b2b38ad981111214526d20693bd8abc454d17e37e31581a9fbe960e7718ef7623abf188353c643dc5e7e +EBUILD kallithea-9999.ebuild 5830 SHA256 324756e05fbea408589fbcd8c9f71bdfa0573567ec7bd16aeddae8001c05a938 SHA512 0df6ff4566ed81b93a71879638df8a8070ba6c13bc55e83a25449dc9337aaed508c3e759db8b773f405d0667ee364fb92c5024a20df70a62ecc3675e8a3f2305 WHIRLPOOL d092f9b1363cfcd2f8eefd4daacb5bb10b1736aac7f9ede8a9baf3128468a2763a720aa5bdbb0b1b44333b6ee4d281c3b40952d536c8336f84b3fea00aabe9df +MISC kallithea-test.sh 603 SHA256 4d0ab7e309ea72d79691c903ed66de0c68845244a04728d93d466ce3e243ce61 SHA512 350b5eee94f0ee5cafac0b7254c8e0b61620686694bb068d6072c85edf4f6724057294e9f95e2f00df0b0a96a1cfc1553cf0790f4a1e64342dcb574ced57783c WHIRLPOOL fa671b48d21f25367f8653a825c9bcb1b196369d0d8d1b6ba6d1d926b835e289be2554ef365954dfe2af04d4400db0a8c7bff6f5a5551c803c38fdf09357a4dc
--- a/dev-vcs/kallithea/kallithea-9999.ebuild Sat Jul 12 23:37:46 2014 +0200 +++ b/dev-vcs/kallithea/kallithea-9999.ebuild Sun Aug 03 19:24:42 2014 +0200 @@ -24,24 +24,42 @@ RESTRICT_PYTHON_ABIS="3.*" +installBasePath="/opt/kallithea" +virtualenvActivationPath="bin/activate" + src_compile() { # not really compiling anything + realWorkDir=$(pwd) + # create new virtual environment virtualenv --no-site-packages dist/v # activate environment - source dist/v/bin/activate + 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 # perform automatic installation, includes dependencies + echo + echo "===> output by Kallithea's setup.py" python setup.py install || die "Automatic installation failed, please check above output." + echo "<=== Kallithea's setup.py is done, resuming ebuild code" + echo # rewrite virtualenv directory to later installation directory - sed -e 's/^\(VIRTUAL_ENV\s*=\s*\).*/\1"\/opt\/kallithea\/"/' -i dist/v/bin/activate + 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}" } src_install() { @@ -50,14 +68,123 @@ # just copy the virtualenv directory to /opt/kallithea dodir /opt - cp -aR "${S}/dist/v" "${D}/opt/kallithea" + cp -aR "${S}/dist/v" "${D}${installBasePath}" } 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 "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 + + 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 + + # open editor + if [[ "${EDITOR}" != "" ]] && [ -e "${EDITOR}" ]; then + ${EDITOR} "${iniPath}" + else + nano -w "${iniPath}" + fi + + # we better reset again... + source /etc/profile + reset + ;; + + *) echo "invalid choice ${choice}" + ;; + esac + done +}