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.
comparison dev-vcs/kallithea/kallithea-9999.ebuild @ 132:af030a9d6541
adding old dev-vcs/kallithea ebuild (lay around since late 2014, do not use!)
author | Daniel Neugebauer <dneuge@energiequant.de> |
---|---|
date | Sat, 26 Mar 2016 17:53:07 +0100 |
parents | |
children | fa6d2de366ac |
comparison
equal
deleted
inserted
replaced
120:56f8a6108f7d | 132:af030a9d6541 |
---|---|
1 # Copyright 1999-2014 Gentoo Foundation | |
2 # Distributed under the terms of the GNU General Public License v2 | |
3 | |
4 EAPI="2" | |
5 PYTHON_DEPEND="2" | |
6 SUPPORT_PYTHON_ABIS="1" | |
7 | |
8 inherit mercurial | |
9 inherit user | |
10 | |
11 DESCRIPTION="a web-based frontend and middleware to Mercurial and Git repositories" | |
12 HOMEPAGE="https://kallithea-scm.org/" | |
13 | |
14 #EHG_REPO_URI="https://kallithea-scm.org/repos/kallithea" | |
15 EHG_REPO_URI="https://bitbucket.org/conservancy/kallithea" | |
16 | |
17 RDEPEND="dev-python/virtualenv" | |
18 | |
19 DEPEND="${RDEPEND}" | |
20 | |
21 LICENSE="GPL-3" | |
22 SLOT="0" | |
23 KEYWORDS="~amd64 ~x86" | |
24 IUSE="" | |
25 | |
26 RESTRICT_PYTHON_ABIS="3.*" | |
27 | |
28 installDataPath="/var/lib/kallithea" | |
29 installBasePath="/opt/kallithea" | |
30 installConfigPath="/etc/kallithea" | |
31 virtualenvActivationPath="bin/activate" | |
32 | |
33 pkg_setup() { | |
34 # create user and group | |
35 enewgroup kallithea | |
36 enewuser kallithea -1 -1 "${installDataPath}" kallithea | |
37 } | |
38 | |
39 src_compile() { | |
40 # not really compiling anything | |
41 | |
42 realWorkDir=$(pwd) | |
43 | |
44 # create new virtual environment | |
45 virtualenv --no-site-packages dist/v | |
46 | |
47 # activate environment | |
48 source "dist/v/${virtualenvActivationPath}" | |
49 | |
50 # WORKAROUND: | |
51 # pylonshq.com is dead, remove from config | |
52 sed -e 's/\(find_links\s*=\s*http:\/\/www.pylonshq.com\/\)/;\1/' -i setup.cfg | |
53 | |
54 # WORKAROUND: | |
55 # if we don't install anyjson via PIP we will get a sandbox violation on second run | |
56 # (after fixing pylonshq.com for Pylons EGG-INFO) | |
57 # see: https://groups.google.com/forum/#!msg/rhodecode/agjXi2JeDZQ/LzFJ6EAsk9AJ | |
58 pip install 'anyjson>=0.3.1' | |
59 | |
60 # perform automatic installation, includes dependencies | |
61 echo | |
62 echo "===> output by Kallithea's setup.py" | |
63 python setup.py install | |
64 retval=$? | |
65 echo "<=== Kallithea's setup.py is done, resuming ebuild code" | |
66 echo | |
67 | |
68 # WORKAROUND: | |
69 # pylonshq.com may still have been tried to be accessed and failed | |
70 # check if that's the case and retry with a patched egg info file | |
71 if [ ${retval} -ne 0 ]; then | |
72 pylonsPath="${realWorkDir}/dist/v/lib/python2.7/site-packages/Pylons-1.0-py2.7.egg" | |
73 #if [ ! -e "${pylonsPath}/pylons" ] && [ -e "${pylonsPath}/EGG-INFO" ]; then | |
74 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 | |
75 # gnoar... it really smells like pylonshq.com... | |
76 sed -e 's#^http://www.pylonshq.com/.*##' -i "${pylonsPath}/EGG-INFO/dependency_links.txt" | |
77 | |
78 # prepare to try again (sandbox violation if not done) | |
79 # TODO: check if still required | |
80 source /etc/profile | |
81 cd "${realWorkDir}" | |
82 source "dist/v/${virtualenvActivationPath}" | |
83 | |
84 echo "Retrying installation with removed pylonshq.com URL..." | |
85 echo | |
86 echo "===> output by Kallithea's setup.py" | |
87 python setup.py install || die "Automatic installation failed, please check above output. (failed after fixing Pylons dependency URL)" | |
88 echo "<=== Kallithea's setup.py is done, resuming ebuild code" | |
89 else | |
90 # some other error on first run | |
91 die "Automatic installation failed, please check above output. (failed on first try)" | |
92 fi | |
93 fi | |
94 echo | |
95 | |
96 # create config | |
97 mkdir "${realWorkDir}/etc" | |
98 cd "${realWorkDir}/etc" | |
99 paster make-config Kallithea production.ini || die "unable to create configuration file" | |
100 | |
101 # rewrite virtualenv directory to later installation directory | |
102 oldIFS="${IFS}" | |
103 IFS=" | |
104 " | |
105 echo "Searching files that need to have paths replaced when leaving portage sandbox..." | |
106 dirtyFiles=$(grep -Ri "${realWorkDir}/dist/v" ${realWorkDir}/dist/v | grep -vE '^Binary' | cut -d':' -f1 | sort | uniq) | |
107 for dirtyFile in ${dirtyFiles}; do | |
108 echo " patching ${dirtyFile}" | |
109 sed -e "s#${realWorkDir}/dist/v#${installBasePath}#" -i "${dirtyFile}" | |
110 done | |
111 IFS="${oldIFS}" | |
112 | |
113 # create WSGI file | |
114 cd "${realWorkDir}/etc" | |
115 cp "${FILESDIR}/production.wsgi" . | |
116 sed -e "s:###BASEDIR###:${installBasePath}:" -i production.wsgi | |
117 sed -e "s:###DATADIR###:${installDataPath}:" -i production.wsgi | |
118 sed -e "s:###CONFDIR###:${installConfigPath}:" -i production.wsgi | |
119 } | |
120 | |
121 src_install() { | |
122 # QA: no need to have anything world-writable... | |
123 chmod o-w -R dist/v/lib/python2.7/site-packages/setuptools-0.9.8-py2.7.egg-info | |
124 | |
125 # just copy the virtualenv directory to /opt/kallithea | |
126 dodir /opt | |
127 cp -aR "${S}/dist/v" "${D}${installBasePath}" | |
128 | |
129 # install configuration files to /etc/kallithea | |
130 diropts -m750 -oroot -gkallithea | |
131 insopts -m640 -oroot -gkallithea | |
132 insinto "${installConfigPath}" | |
133 doins "${S}/etc/production.ini" | |
134 doins "${S}/etc/production.wsgi" | |
135 | |
136 # create data directory | |
137 diropts -m2770 -okallithea -gkallithea | |
138 keepdir "${installDataPath}" | |
139 } | |
140 | |
141 pkg_postinst() { | |
142 # 1 2 3 4 5 6 7 8 | |
143 # 12345678901234567890123456789012345678901234567890123456789012345678901234567890 | |
144 einfo "You need to setup Kallithea according to the instructions at:" | |
145 einfo " https://pythonhosted.org/Kallithea/setup.html" | |
146 einfo "" | |
147 einfo "When doing so, please mind that Kallithea was installed into a Python virtual" | |
148 einfo "environment that has to be \"activated\" before it can be used. To do so," | |
149 einfo "you will have to run a dedicated shell and initialize the environment by running" | |
150 einfo "" | |
151 einfo " source ${D}/dist/v/bin/activate" | |
152 einfo "" | |
153 einfo "We can wrap those commands for you if you run:" | |
154 einfo " emerge --config =${CATEGORY}/${PF}" | |
155 einfo "" | |
156 einfo "Kallithea also provides a way to migrate your database if you" | |
157 einfo "are coming from RhodeCode. Instructions can be found at:" | |
158 einfo "https://pythonhosted.org/Kallithea/index.html#converting-from-rhodecode" | |
159 } | |
160 | |
161 my_read_line() { | |
162 # BASH function 'read' cannot write input back to variable in correct environment | |
163 # when run by emerge so we have to do *this* instead... great... :/ | |
164 # (at least this works...) | |
165 | |
166 python -c 'import sys; print(sys.stdin.readline().strip())' | |
167 } | |
168 | |
169 config_menu() { | |
170 choice="" | |
171 | |
172 oldIFS="${IFS}" | |
173 IFS=" | |
174 " | |
175 | |
176 # 1 2 3 4 5 6 7 8 | |
177 # 12345678901234567890123456789012345678901234567890123456789012345678901234567890 | |
178 echo | |
179 echo "===============================================================================" | |
180 echo | |
181 echo "Your options:" | |
182 echo | |
183 echo " 1) create production config from template (paster make-config ...)" | |
184 echo " 2) edit production config" | |
185 echo " 3) initialize Kallithea (paster setup-db)" | |
186 echo " This will also ask for repository location and create an admin account." | |
187 echo " 0) quit" | |
188 echo " Kallithea should be able to run now, check documentation for more options" | |
189 echo " such as setting up a task queue or full text search if you need it." | |
190 echo | |
191 | |
192 echo "TERM is ${TERM}" | |
193 | |
194 while [[ ! "${choice}" =~ ^[0-3]$ ]]; do | |
195 echo -n "Your choice? " | |
196 choice=$(my_read_line) | |
197 done | |
198 | |
199 IFS="${oldIFS}" | |
200 | |
201 return ${choice} | |
202 } | |
203 | |
204 pkg_config() { | |
205 # 1 2 3 4 5 6 7 8 | |
206 # 12345678901234567890123456789012345678901234567890123456789012345678901234567890 | |
207 | |
208 echo "Kallithea setup requires following multiple steps, some of which need to be run" | |
209 echo "in the correct virtual Python environment. This script helps you running those" | |
210 echo "commands by wrapping the commands to be run inside the correct virtualenv." | |
211 echo "You may still want to read the setup instructions while running this script:" | |
212 echo | |
213 echo " https://pythonhosted.org/Kallithea/setup.html" | |
214 | |
215 # activate virtualenv | |
216 cd ${installBasePath} || die "installation is gone? (${installBasePath})" | |
217 source "${virtualenvActivationPath}" || die "failed to activate virtualenv (${installBasePath}/${virtualenvActivationPath})" | |
218 | |
219 while true; do | |
220 config_menu | |
221 choice=$? | |
222 echo | |
223 | |
224 case "${choice}" in | |
225 0) break | |
226 ;; | |
227 | |
228 1) mkdir -p "${installBasePath}/etc" | |
229 cd "${installBasePath}/etc" | |
230 paster make-config Kallithea production.ini | |
231 ;; | |
232 | |
233 2) iniPath="${installBasePath}/etc/production.ini" | |
234 | |
235 if [ ! -e "${iniPath}" ]; then | |
236 echo "config not found at ${iniPath}; did you follow step 1?" | |
237 continue | |
238 fi | |
239 | |
240 # terminal and shell need a reset or editor will be screwed up | |
241 source /etc/profile | |
242 reset | |
243 stty sane | |
244 | |
245 # open editor | |
246 if [[ "${EDITOR}" != "" ]] && [ -e "${EDITOR}" ]; then | |
247 TERM="xterm" ${EDITOR} "${iniPath}" | |
248 else | |
249 TERM="xterm" nano -w "${iniPath}" | |
250 fi | |
251 | |
252 # we better reset again... | |
253 source /etc/profile | |
254 reset | |
255 stty sane | |
256 ;; | |
257 | |
258 *) echo "invalid choice ${choice}" | |
259 ;; | |
260 esac | |
261 done | |
262 } |