We have moved to Git. This repository is only provided for compatibility with old installations. Learn how to migrate your installation here.

comparison dev-vcs/kallithea/kallithea-9999.ebuild @ 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
comparison
equal deleted inserted replaced
127:86d178602b1f 128:507516b40917
22 KEYWORDS="~amd64 ~x86" 22 KEYWORDS="~amd64 ~x86"
23 IUSE="" 23 IUSE=""
24 24
25 RESTRICT_PYTHON_ABIS="3.*" 25 RESTRICT_PYTHON_ABIS="3.*"
26 26
27 installBasePath="/opt/kallithea"
28 virtualenvActivationPath="bin/activate"
29
27 src_compile() { 30 src_compile() {
28 # not really compiling anything 31 # not really compiling anything
32
33 realWorkDir=$(pwd)
29 34
30 # create new virtual environment 35 # create new virtual environment
31 virtualenv --no-site-packages dist/v 36 virtualenv --no-site-packages dist/v
32 37
33 # activate environment 38 # activate environment
34 source dist/v/bin/activate 39 source "dist/v/${virtualenvActivationPath}"
35 40
36 # WORKAROUND: 41 # WORKAROUND:
37 # pylonshq.com is dead, remove from config 42 # pylonshq.com is dead, remove from config
38 sed -e 's/\(find_links\s*=\s*http:\/\/www.pylonshq.com\/\)/;\1/' -i setup.cfg 43 sed -e 's/\(find_links\s*=\s*http:\/\/www.pylonshq.com\/\)/;\1/' -i setup.cfg
39 44
40 # perform automatic installation, includes dependencies 45 # perform automatic installation, includes dependencies
46 echo
47 echo "===> output by Kallithea's setup.py"
41 python setup.py install || die "Automatic installation failed, please check above output." 48 python setup.py install || die "Automatic installation failed, please check above output."
49 echo "<=== Kallithea's setup.py is done, resuming ebuild code"
50 echo
42 51
43 # rewrite virtualenv directory to later installation directory 52 # rewrite virtualenv directory to later installation directory
44 sed -e 's/^\(VIRTUAL_ENV\s*=\s*\).*/\1"\/opt\/kallithea\/"/' -i dist/v/bin/activate 53 oldIFS="${IFS}"
54 IFS="
55 "
56 echo "Searching files that need to have paths replaced when leaving portage sandbox..."
57 dirtyFiles=$(grep -Ri "${realWorkDir}/dist/v" ${realWorkDir}/dist/v | grep -vE '^Binary' | cut -d':' -f1 | sort | uniq)
58 for dirtyFile in ${dirtyFiles}; do
59 echo " patching ${dirtyFile}"
60 sed -e "s#${realWorkDir}/dist/v#${installBasePath}#" -i "${dirtyFile}"
61 done
62 IFS="${oldIFS}"
45 } 63 }
46 64
47 src_install() { 65 src_install() {
48 # QA: no need to have anything world-writable... 66 # QA: no need to have anything world-writable...
49 chmod o-w -R dist/v/lib/python2.7/site-packages/setuptools-0.9.8-py2.7.egg-info 67 chmod o-w -R dist/v/lib/python2.7/site-packages/setuptools-0.9.8-py2.7.egg-info
50 68
51 # just copy the virtualenv directory to /opt/kallithea 69 # just copy the virtualenv directory to /opt/kallithea
52 dodir /opt 70 dodir /opt
53 cp -aR "${S}/dist/v" "${D}/opt/kallithea" 71 cp -aR "${S}/dist/v" "${D}${installBasePath}"
54 } 72 }
55 73
56 pkg_postinst() { 74 pkg_postinst() {
75 # 1 2 3 4 5 6 7 8
76 # 12345678901234567890123456789012345678901234567890123456789012345678901234567890
57 einfo "You need to setup Kallithea according to the instructions at:" 77 einfo "You need to setup Kallithea according to the instructions at:"
58 einfo " https://pythonhosted.org/Kallithea/setup.html" 78 einfo " https://pythonhosted.org/Kallithea/setup.html"
79 einfo ""
80 einfo "When doing so, please mind that Kallithea was installed into a Python virtual"
81 einfo "environment that has to be \"activated\" before it can be used. To do so,"
82 einfo "you will have to run a dedicated shell and initialize the environment by running"
83 einfo ""
84 einfo " source ${D}/dist/v/bin/activate"
85 einfo ""
86 einfo "We can wrap those commands for you if you run:"
87 einfo " emerge --config =${CATEGORY}/${PF}"
59 einfo "" 88 einfo ""
60 einfo "Kallithea also provides a way to migrate your database if you" 89 einfo "Kallithea also provides a way to migrate your database if you"
61 einfo "are coming from RhodeCode. Instructions can be found at:" 90 einfo "are coming from RhodeCode. Instructions can be found at:"
62 einfo "https://pythonhosted.org/Kallithea/index.html#converting-from-rhodecode" 91 einfo "https://pythonhosted.org/Kallithea/index.html#converting-from-rhodecode"
63 } 92 }
93
94 my_read_line() {
95 # BASH function 'read' cannot write input back to variable in correct environment
96 # when run by emerge so we have to do *this* instead... great... :/
97 # (at least this works...)
98
99 python -c 'import sys; print(sys.stdin.readline().strip())'
100 }
101
102 config_menu() {
103 choice=""
104
105 oldIFS="${IFS}"
106 IFS="
107 "
108
109 # 1 2 3 4 5 6 7 8
110 # 12345678901234567890123456789012345678901234567890123456789012345678901234567890
111 echo "==============================================================================="
112 echo
113 echo "Your options:"
114 echo
115 echo " 1) create production config from template (paster make-config ...)"
116 echo " 2) edit production config"
117 echo " 3) initialize Kallithea (paster setup-db)"
118 echo " This will also ask for repository location and create an admin account."
119 echo " 0) quit"
120 echo " Kallithea should be able to run now, check documentation for more options"
121 echo " such as setting up a task queue or full text search if you need it."
122 echo
123
124 while [[ ! "${choice}" =~ ^[0-3]$ ]]; do
125 echo -n "Your choice? "
126 choice=$(my_read_line)
127 done
128
129 IFS="${oldIFS}"
130
131 return ${choice}
132 }
133
134 pkg_config() {
135 # 1 2 3 4 5 6 7 8
136 # 12345678901234567890123456789012345678901234567890123456789012345678901234567890
137
138 echo "Kallithea setup requires following multiple steps, some of which need to be run"
139 echo "in the correct virtual Python environment. This script helps you running those"
140 echo "commands by wrapping the commands to be run inside the correct virtualenv."
141 echo "You may still want to read the setup instructions while running this script:"
142 echo
143 echo " https://pythonhosted.org/Kallithea/setup.html"
144
145 # activate virtualenv
146 cd ${installBasePath} || die "installation is gone? (${installBasePath})"
147 source "${virtualenvActivationPath}" || die "failed to activate virtualenv (${installBasePath}/${virtualenvActivationPath})"
148
149 while true; do
150 config_menu
151 choice=$?
152 echo
153
154 case "${choice}" in
155 0) break
156 ;;
157
158 1) mkdir -p "${installBasePath}/etc"
159 cd "${installBasePath}/etc"
160 paster make-config Kallithea production.ini
161 ;;
162
163 2) iniPath="${installBasePath}/etc/production.ini"
164
165 if [ ! -e "${iniPath}" ]; then
166 echo "config not found at ${iniPath}; did you follow step 1?"
167 continue
168 fi
169
170 # terminal and shell need a reset or editor will be screwed up
171 source /etc/profile
172 reset
173
174 # open editor
175 if [[ "${EDITOR}" != "" ]] && [ -e "${EDITOR}" ]; then
176 ${EDITOR} "${iniPath}"
177 else
178 nano -w "${iniPath}"
179 fi
180
181 # we better reset again...
182 source /etc/profile
183 reset
184 ;;
185
186 *) echo "invalid choice ${choice}"
187 ;;
188 esac
189 done
190 }