1 |
commit: 15dec77039ea7416bbb647be05a24fde0b0b03fc |
2 |
Author: Julian Ospald <hasufell <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Oct 21 15:08:12 2015 +0000 |
4 |
Commit: James Le Cuirot <chewi <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Oct 21 15:08:12 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=15dec770 |
7 |
|
8 |
www-servers/tomcat: revbump on tomcat-instance-manager script |
9 |
|
10 |
This bump tweaks the behavior of test_can_deploy(), so that |
11 |
it does not fail if a target directory exists AND is empty. |
12 |
|
13 |
This can be extremely useful if the target directories are |
14 |
mount points, which is very common for e.g. docker setups. |
15 |
|
16 |
.../tomcat/files/tomcat-instance-manager-r2.bash | 270 +++++++++++++++++++++ |
17 |
www-servers/tomcat/tomcat-8.0.28-r1.ebuild | 147 +++++++++++ |
18 |
2 files changed, 417 insertions(+) |
19 |
|
20 |
diff --git a/www-servers/tomcat/files/tomcat-instance-manager-r2.bash b/www-servers/tomcat/files/tomcat-instance-manager-r2.bash |
21 |
new file mode 100644 |
22 |
index 0000000..b3b1a02 |
23 |
--- /dev/null |
24 |
+++ b/www-servers/tomcat/files/tomcat-instance-manager-r2.bash |
25 |
@@ -0,0 +1,270 @@ |
26 |
+#!/bin/bash |
27 |
+# Copyright 1999-2015 Gentoo Foundation |
28 |
+# Distributed under the terms of the GNU General Public License v2 |
29 |
+# Author: Ralph Sennhauser <sera@g.o> |
30 |
+ |
31 |
+die() { |
32 |
+ echo "${@}" |
33 |
+ exit 1 |
34 |
+} |
35 |
+ |
36 |
+dir_is_empty() { |
37 |
+ # usage: |
38 |
+ # dir_is_empty <some-dir> |
39 |
+ # |
40 |
+ # returns 2 if the dir does not even exist |
41 |
+ # returns 1 if the dir is not empty |
42 |
+ # returns 0 (success) if the dir exists and is empty |
43 |
+ |
44 |
+ local dir=$1 |
45 |
+ local files |
46 |
+ |
47 |
+ if [[ ! -e ${dir} ]] ; then |
48 |
+ return 2 |
49 |
+ fi |
50 |
+ |
51 |
+ shopt -s nullglob dotglob # To include hidden files |
52 |
+ files=( "${dir}"/* ) |
53 |
+ shopt -u nullglob dotglob |
54 |
+ |
55 |
+ if [[ ${#files[@]} -eq 0 ]]; then |
56 |
+ return 0 |
57 |
+ else |
58 |
+ return 1 |
59 |
+ fi |
60 |
+ |
61 |
+} |
62 |
+ |
63 |
+usage() { |
64 |
+ cat <<EOL |
65 |
+Usage: ${BASH_SOURCE} <--create|--remove|--help> [--suffix s][--user u][--group g] |
66 |
+ |
67 |
+ Options: |
68 |
+ --help: |
69 |
+ show this text. |
70 |
+ --create: |
71 |
+ create a new instance |
72 |
+ --remove: |
73 |
+ remove an existing instance. |
74 |
+ --suffix SUFFIX: |
75 |
+ a suffix for this instance. the suffix may not collide with an already |
76 |
+ existing instance, defaults to empty. |
77 |
+ --user USER: |
78 |
+ the user for which to configure this instance for. The user needs to |
79 |
+ exist already. defaults to tomcat. |
80 |
+ --group GROUP: |
81 |
+ the group for which to configure this instance for. The group needs to |
82 |
+ exist already. defaults to tomcat. |
83 |
+ |
84 |
+ Examples: |
85 |
+ ${BASH_SOURCE} --create --suffix testing --user tacmot --group tacmot |
86 |
+ ${BASH_SOURCE} --remove --suffix testing |
87 |
+EOL |
88 |
+} |
89 |
+ |
90 |
+parse_argv() { |
91 |
+ action="not specified" |
92 |
+ instance_name="tomcat-@SLOT@" |
93 |
+ instance_user="tomcat" |
94 |
+ instance_group="tomcat" |
95 |
+ |
96 |
+ while [[ -n $1 ]]; do |
97 |
+ case $1 in |
98 |
+ --help) |
99 |
+ usage |
100 |
+ exit 0;; |
101 |
+ --suffix) |
102 |
+ instance_name+="-$2" |
103 |
+ shift; shift;; |
104 |
+ --user) |
105 |
+ instance_user="$2" |
106 |
+ shift; shift;; |
107 |
+ --group) |
108 |
+ instance_group="$2" |
109 |
+ shift; shift;; |
110 |
+ --create) |
111 |
+ action=create |
112 |
+ shift;; |
113 |
+ --remove) |
114 |
+ action=remove |
115 |
+ shift;; |
116 |
+ --backup) |
117 |
+ action=backup |
118 |
+ shift;; |
119 |
+ --restore) |
120 |
+ action=restore |
121 |
+ shift;; |
122 |
+ --update) |
123 |
+ action=update |
124 |
+ shift;; |
125 |
+ *) |
126 |
+ echo "Invalid option '$1'" |
127 |
+ usage |
128 |
+ exit 2;; |
129 |
+ esac |
130 |
+ done |
131 |
+ |
132 |
+ tomcat_home="/@GENTOO_PORTAGE_EPREFIX@usr/share/tomcat-@SLOT@" |
133 |
+ instance_base="/@GENTOO_PORTAGE_EPREFIX@var/lib/${instance_name}" |
134 |
+ instance_conf="/@GENTOO_PORTAGE_EPREFIX@etc/${instance_name}" |
135 |
+ instance_logs="/@GENTOO_PORTAGE_EPREFIX@var/log/${instance_name}" |
136 |
+ instance_temp="/@GENTOO_PORTAGE_EPREFIX@var/tmp/${instance_name}" |
137 |
+ |
138 |
+ all_targets=( |
139 |
+ "${instance_base}" |
140 |
+ "${instance_logs}" |
141 |
+ "${instance_temp}" |
142 |
+ "/@GENTOO_PORTAGE_EPREFIX@etc/${instance_name}" |
143 |
+ "/@GENTOO_PORTAGE_EPREFIX@etc/init.d/${instance_name}" |
144 |
+ "/@GENTOO_PORTAGE_EPREFIX@etc/conf.d/${instance_name}" |
145 |
+ ) |
146 |
+} |
147 |
+ |
148 |
+test_can_deploy() { |
149 |
+ local no_deploy target |
150 |
+ for target in "${all_targets[@]}"; do |
151 |
+ if [[ -e "${target}" ]]; then |
152 |
+ if ! dir_is_empty "${target}" ; then |
153 |
+ echo "Error: '${target}' already exists and is not empty." |
154 |
+ no_deploy=yes |
155 |
+ fi |
156 |
+ fi |
157 |
+ done |
158 |
+ if [[ -n "${no_deploy}" ]]; then |
159 |
+ cat <<-EOL |
160 |
+ |
161 |
+ To protect an existing installation no new instance was deployed. You can use |
162 |
+ '${BASH_SOURCE} --remove' |
163 |
+ to remove an existing instance first or run |
164 |
+ '${BASH_SOURCE} --create --sufix <instance_suffix>' |
165 |
+ to deploy an instance under a different name |
166 |
+ |
167 |
+ EOL |
168 |
+ usage |
169 |
+ exit 1 |
170 |
+ fi |
171 |
+ |
172 |
+ if ! getent passwd | cut -d: -f1 | grep -Fx "${instance_user}" > /dev/null; then |
173 |
+ echo "Error: user '${instance_user}' doesn't exist." |
174 |
+ exit 1 |
175 |
+ fi |
176 |
+ |
177 |
+ if ! getent group | cut -d: -f1 | grep -Fx "${instance_group}" > /dev/null; then |
178 |
+ echo "Error: group '${instance_group}' doesn't exist." |
179 |
+ exit 1 |
180 |
+ fi |
181 |
+} |
182 |
+ |
183 |
+deploy_instance() { |
184 |
+ test_can_deploy |
185 |
+ |
186 |
+ mkdir -p "${instance_base}"/{work,webapps} || die |
187 |
+ mkdir -p "${instance_logs}" || die |
188 |
+ mkdir -p "${instance_temp}" || die |
189 |
+ mkdir -p "${instance_conf}" || die |
190 |
+ |
191 |
+ cp -r "${tomcat_home}"/webapps/ROOT "${instance_base}"/webapps || die |
192 |
+ |
193 |
+ chown -R "${instance_user}":"${instance_group}" \ |
194 |
+ "${instance_base}" "${instance_logs}" "${instance_temp}" || die |
195 |
+ |
196 |
+ find "${instance_base}"/webapps -type d -exec chmod 750 {} + || die |
197 |
+ find "${instance_base}"/webapps -type f -exec chmod 640 {} + || die |
198 |
+ |
199 |
+ # initial config # |
200 |
+ |
201 |
+ cp -r "${tomcat_home}"/conf/* "${instance_conf}"/ || die |
202 |
+ |
203 |
+ sed -i -e "s|\${catalina.base}/logs|${instance_logs}|" \ |
204 |
+ "${instance_conf}"/logging.properties || die |
205 |
+ sed -i -e "s|directory=\"logs\"|directory=\"${instance_logs}\"|" \ |
206 |
+ "${instance_conf}"/server.xml || die |
207 |
+ |
208 |
+ mkdir -p "${instance_conf}"/Catalina/localhost || die |
209 |
+ cat > "${instance_conf}"/Catalina/localhost/host-manager.xml <<-'EOF' |
210 |
+ <?xml version="1.0" encoding="UTF-8"?> |
211 |
+ <Context docBase="${catalina.home}/webapps/host-manager" |
212 |
+ antiResourceLocking="false" privileged="true" /> |
213 |
+ EOF |
214 |
+ |
215 |
+ cat > "${instance_conf}"/Catalina/localhost/manager.xml <<-'EOF' |
216 |
+ <?xml version="1.0" encoding="UTF-8"?> |
217 |
+ <Context docBase="${catalina.home}/webapps/manager" |
218 |
+ antiResourceLocking="false" privileged="true" /> |
219 |
+ EOF |
220 |
+ |
221 |
+ if [[ -d "${tomcat_home}"/webapps/docs ]]; then |
222 |
+ cat > "${instance_conf}"/Catalina/localhost/docs.xml <<-'EOF' |
223 |
+ <?xml version="1.0" encoding="UTF-8"?> |
224 |
+ <Context docBase="${catalina.home}/webapps/docs" /> |
225 |
+ EOF |
226 |
+ fi |
227 |
+ |
228 |
+ if [[ -d "${tomcat_home}"/webapps/examples ]]; then |
229 |
+ cat > "${instance_conf}"/Catalina/localhost/examples.xml <<-'EOF' |
230 |
+ <?xml version="1.0" encoding="UTF-8"?> |
231 |
+ <Context docBase="${catalina.home}/webapps/examples" /> |
232 |
+ EOF |
233 |
+ fi |
234 |
+ |
235 |
+ chown -R "${instance_user}":"${instance_group}" "${instance_conf}" || die |
236 |
+ find "${instance_conf}" -type d -exec chmod 750 {} + || die |
237 |
+ find "${instance_conf}" -type f -exec chmod 640 {} + || die |
238 |
+ |
239 |
+ # rc script # |
240 |
+ |
241 |
+ cp "${tomcat_home}"/gentoo/tomcat.init \ |
242 |
+ "/@GENTOO_PORTAGE_EPREFIX@etc/init.d/${instance_name}" || die |
243 |
+ |
244 |
+ sed -e "s|@INSTANCE_NAME@|${instance_name}|g" \ |
245 |
+ -e "s|@INSTANCE_USER@|${instance_user}|g" \ |
246 |
+ -e "s|@INSTANCE_GROUP@|${instance_group}|g" \ |
247 |
+ "${tomcat_home}"/gentoo/tomcat.conf \ |
248 |
+ > "/@GENTOO_PORTAGE_EPREFIX@etc/conf.d/${instance_name}" || die |
249 |
+ |
250 |
+ # some symlinks for tomcat and netbeans # |
251 |
+ |
252 |
+ ln -s "${instance_conf}" "${instance_base}"/conf || die |
253 |
+ ln -s "${instance_temp}" "${instance_base}"/temp || die |
254 |
+ |
255 |
+ # a note to update the default configuration # |
256 |
+ |
257 |
+ cat <<-EOL |
258 |
+ Successfully created instance '${instance_name}' |
259 |
+ It's strongly recommended for production systems to go carefully through the |
260 |
+ configuration files at '${instance_conf}'. |
261 |
+ The generated initial configuration is close to upstreams default which |
262 |
+ favours the demo aspect over hardening. |
263 |
+ EOL |
264 |
+} |
265 |
+ |
266 |
+remove_instance() { |
267 |
+ echo "The following files will be removed permanently:" |
268 |
+ local target; for target in "${all_targets[@]}"; do |
269 |
+ find ${target} |
270 |
+ done |
271 |
+ |
272 |
+ echo "Type 'yes' to continue" |
273 |
+ read |
274 |
+ if [[ ${REPLY} == yes ]]; then |
275 |
+ rm -rv "${all_targets[@]}" |
276 |
+ else |
277 |
+ echo "Aborting as requested ..." |
278 |
+ fi |
279 |
+} |
280 |
+ |
281 |
+parse_argv "$@" |
282 |
+ |
283 |
+if [[ ${action} == create ]]; then |
284 |
+ deploy_instance |
285 |
+elif [[ ${action} == remove ]]; then |
286 |
+ remove_instance |
287 |
+elif [[ ${action} == "not specified" ]]; then |
288 |
+ echo "No action specified!" |
289 |
+ usage |
290 |
+ exit 1 |
291 |
+else |
292 |
+ echo "${action} not yet implemented!" |
293 |
+ usage |
294 |
+ exit 1 |
295 |
+fi |
296 |
|
297 |
diff --git a/www-servers/tomcat/tomcat-8.0.28-r1.ebuild b/www-servers/tomcat/tomcat-8.0.28-r1.ebuild |
298 |
new file mode 100644 |
299 |
index 0000000..a06fb32 |
300 |
--- /dev/null |
301 |
+++ b/www-servers/tomcat/tomcat-8.0.28-r1.ebuild |
302 |
@@ -0,0 +1,147 @@ |
303 |
+# Copyright 1999-2015 Gentoo Foundation |
304 |
+# Distributed under the terms of the GNU General Public License v2 |
305 |
+# $Id$ |
306 |
+ |
307 |
+EAPI=5 |
308 |
+ |
309 |
+JAVA_PKG_IUSE="doc source test" |
310 |
+ |
311 |
+inherit eutils java-pkg-2 java-ant-2 prefix user |
312 |
+ |
313 |
+MY_P="apache-${P}-src" |
314 |
+ |
315 |
+DESCRIPTION="Tomcat Servlet-3.1/JSP-2.3 Container" |
316 |
+HOMEPAGE="http://tomcat.apache.org/" |
317 |
+SRC_URI="mirror://apache/${PN}/tomcat-8/v${PV}/src/${MY_P}.tar.gz" |
318 |
+ |
319 |
+LICENSE="Apache-2.0" |
320 |
+SLOT="8" |
321 |
+KEYWORDS="~amd64 ~x86 ~x86-fbsd ~x86-freebsd ~amd64-linux ~x86-linux ~x86-solaris" |
322 |
+IUSE="extra-webapps" |
323 |
+ |
324 |
+RESTRICT="test" # can we run them on a production system? |
325 |
+ |
326 |
+ECJ_SLOT="4.4" |
327 |
+SAPI_SLOT="3.1" |
328 |
+ |
329 |
+COMMON_DEP="dev-java/eclipse-ecj:${ECJ_SLOT} |
330 |
+ dev-java/oracle-javamail:0 |
331 |
+ dev-java/tomcat-servlet-api:${SAPI_SLOT}" |
332 |
+RDEPEND="${COMMON_DEP} |
333 |
+ !<dev-java/tomcat-native-1.1.24 |
334 |
+ >=virtual/jre-1.7" |
335 |
+DEPEND="${COMMON_DEP} |
336 |
+ >=virtual/jdk-1.7 |
337 |
+ test? ( |
338 |
+ >=dev-java/ant-junit-1.9:0 |
339 |
+ dev-java/easymock:3.2 |
340 |
+ )" |
341 |
+ |
342 |
+S=${WORKDIR}/${MY_P} |
343 |
+ |
344 |
+pkg_setup() { |
345 |
+ java-pkg-2_pkg_setup |
346 |
+ enewgroup tomcat 265 |
347 |
+ enewuser tomcat 265 -1 /dev/null tomcat |
348 |
+} |
349 |
+ |
350 |
+java_prepare() { |
351 |
+ find -name '*.jar' -type f -delete -print || die |
352 |
+ |
353 |
+ # Remove bundled javamail, servlet-api |
354 |
+ rm -rv java/javax/{el,mail,servlet} || die |
355 |
+ |
356 |
+ epatch "${FILESDIR}/${P}-build.xml.patch" |
357 |
+ |
358 |
+ # For use of catalina.sh in netbeans |
359 |
+ sed -i -e "/^# ----- Execute The Requested Command/ a\ |
360 |
+ CLASSPATH=\`java-config --classpath ${PN}-${SLOT}\`" \ |
361 |
+ bin/catalina.sh || die |
362 |
+} |
363 |
+ |
364 |
+JAVA_ANT_REWRITE_CLASSPATH="true" |
365 |
+ |
366 |
+EANT_BUILD_TARGET="deploy" |
367 |
+EANT_GENTOO_CLASSPATH="eclipse-ecj-${ECJ_SLOT},oracle-javamail,tomcat-servlet-api-${SAPI_SLOT}" |
368 |
+EANT_TEST_GENTOO_CLASSPATH="easymock-3.2" |
369 |
+EANT_GENTOO_CLASSPATH_EXTRA="${S}/output/classes" |
370 |
+EANT_NEEDS_TOOLS="true" |
371 |
+EANT_EXTRA_ARGS="-Dversion=${PV}-gentoo -Dversion.number=${PV} -Dcompile.debug=false" |
372 |
+ |
373 |
+# revisions of the scripts |
374 |
+IM_REV="-r2" |
375 |
+INIT_REV="-r1" |
376 |
+ |
377 |
+src_compile() { |
378 |
+ EANT_GENTOO_CLASSPATH_EXTRA+=":$(java-pkg_getjar --build-only ant-core ant.jar)" |
379 |
+ java-pkg-2_src_compile |
380 |
+} |
381 |
+ |
382 |
+src_test() { |
383 |
+ java-pkg-2_src_test |
384 |
+} |
385 |
+ |
386 |
+src_install() { |
387 |
+ local dest="/usr/share/${PN}-${SLOT}" |
388 |
+ |
389 |
+ java-pkg_jarinto "${dest}"/bin |
390 |
+ java-pkg_dojar output/build/bin/*.jar |
391 |
+ exeinto "${dest}"/bin |
392 |
+ doexe output/build/bin/*.sh |
393 |
+ |
394 |
+ java-pkg_jarinto "${dest}"/lib |
395 |
+ java-pkg_dojar output/build/lib/*.jar |
396 |
+ |
397 |
+ dodoc RELEASE-NOTES RUNNING.txt |
398 |
+ use doc && java-pkg_dojavadoc output/dist/webapps/docs/api |
399 |
+ use source && java-pkg_dosrc java/* |
400 |
+ |
401 |
+ ### Webapps ### |
402 |
+ |
403 |
+ insinto "${dest}"/webapps |
404 |
+ doins -r output/build/webapps/{host-manager,manager,ROOT} |
405 |
+ use extra-webapps && doins -r output/build/webapps/{docs,examples} |
406 |
+ |
407 |
+ ### Config ### |
408 |
+ |
409 |
+ # create "logs" directory in $CATALINA_BASE |
410 |
+ # and set correct perms, see #458890 |
411 |
+ dodir "${dest}"/logs |
412 |
+ fperms 0750 "${dest}"/logs |
413 |
+ |
414 |
+ # replace the default pw with a random one, see #92281 |
415 |
+ local randpw=$(echo ${RANDOM}|md5sum|cut -c 1-15) |
416 |
+ sed -i -e "s|SHUTDOWN|${randpw}|" output/build/conf/server.xml || die |
417 |
+ |
418 |
+ # prepend gentoo.classpath to common.loader, see #453212 |
419 |
+ sed -i -e 's/^common\.loader=/\0${gentoo.classpath},/' output/build/conf/catalina.properties || die |
420 |
+ |
421 |
+ insinto "${dest}" |
422 |
+ doins -r output/build/conf |
423 |
+ |
424 |
+ ### rc ### |
425 |
+ |
426 |
+ cp "${FILESDIR}"/tomcat{.conf,${INIT_REV}.init,-instance-manager${IM_REV}.bash} "${T}" || die |
427 |
+ eprefixify "${T}"/tomcat{.conf,${INIT_REV}.init,-instance-manager${IM_REV}.bash} |
428 |
+ sed -i -e "s|@SLOT@|${SLOT}|g" "${T}"/tomcat{.conf,${INIT_REV}.init,-instance-manager${IM_REV}.bash} || die |
429 |
+ |
430 |
+ insinto "${dest}"/gentoo |
431 |
+ doins "${T}"/tomcat.conf |
432 |
+ exeinto "${dest}"/gentoo |
433 |
+ newexe "${T}"/tomcat${INIT_REV}.init tomcat.init |
434 |
+ newexe "${T}"/tomcat-instance-manager${IM_REV}.bash tomcat-instance-manager.bash |
435 |
+} |
436 |
+ |
437 |
+pkg_postinst() { |
438 |
+ elog "New ebuilds of Tomcat support running multiple instances. If you used prior version" |
439 |
+ elog "of Tomcat (<7.0.32), you have to migrate your existing instance to work with new Tomcat." |
440 |
+ elog "You can find more information at https://wiki.gentoo.org/wiki/Apache_Tomcat" |
441 |
+ |
442 |
+ elog "To manage Tomcat instances, run:" |
443 |
+ elog " ${EPREFIX}/usr/share/${PN}-${SLOT}/gentoo/tomcat-instance-manager.bash --help" |
444 |
+ |
445 |
+ ewarn "tomcat-dbcp.jar is not built at this time. Please fetch jar" |
446 |
+ ewarn "from upstream binary if you need it. Gentoo Bug # 144276" |
447 |
+ |
448 |
+# einfo "Please read https://www.gentoo.org/proj/en/java/tomcat6-guide.xml for more information." |
449 |
+} |