Line # Revision Author
1 8 ahitrov@rambler.ru ##############################################################################
2 # $HeadURL$
3 # $Id$
4 ###############################################################################
5
6 # installation settings
7 include ../../config.mk
8
9 # local defines
10 SOURCES = ${ROOT_DIR}/src
11 CORE_SRC = ${SOURCES}/core
12 PLUG_SRC = ${SOURCES}/plugins
13 PROJ_SRC = ${SOURCES}/projects
14
15 CORE_USR = ${ROOT_DIR}/usr/core
16 PLUG_USR = ${ROOT_DIR}/usr/plugins
17 PROJ_USR = ${ROOT_DIR}/usr/projects
18 PROJ_TMP = ${ROOT_DIR}/tmp/projects
19 PROJ_VAR = ${ROOT_DIR}/var/projects
20
21 PORTSDIR = ${CORE_SRC}/ports
22 LOCAL = ${ROOT_DIR}/usr/local
23 PORTSWRK = ${ROOT_DIR}/var/ports
24
25 CORE_VERSION = ${shell svnversion ${CORE_SRC}}
26
27 PAGER ?= ${shell which less || which more}
28 RSYNC_COMMAND = ${shell which rsync}
29
30 HOSTNAME = ${shell hostname}
31
32 PROJECT_LC = ${shell echo "${PROJECT}" | tr '[:upper:]' '[:lower:]'}
33
34 # core settings
35 include ${CORE_SRC}/config.mk
36
37 # perl settings
38 include ${CORE_SRC}/ports/etc/perl.mk
39
40 # project settings
41 ifdef PROJECT
42 ifneq (${shell test -f ${PROJ_SRC}/${PROJECT}/config.mk && echo 1},1)
43 ${error ERROR: no source ${PROJECT}/config.mk found, are you checked out project '${PROJECT}'?}
44 endif
45 -include /usr/local/etc/contenido.mk
46 RSYNC_SERVERS ?= ${addsuffix ::${PROJECT_LC}, ${FRONTENDS}}
47 include ${PROJ_SRC}/${PROJECT}/config.mk
48 include ${CORE_SRC}/project-default.mk
49
50 ifeq (${shell test -f ${PROJ_SRC}/${PROJECT}/GNUmakefile && echo 1},1)
51 include ${PROJ_SRC}/${PROJECT}/GNUmakefile
52 $(warning Use of GNUmakefile in project dir is deprecated, rename it to GNUmakefile.in)
53 endif
54 -include ${PROJ_SRC}/${PROJECT}/GNUmakefile.in
55
56 PROJECT_VERSION = ${shell svnversion ${PROJ_SRC}/${PROJECT}}
57 endif
58
59 .PHONY: \
60 local_clean realclean \
61 local_build build \
62 local_install install \
63 local_preview preview \
64 \
65 core_status cst \
66 core_update cup \
67 core_commit cci \
68 core_install cin \
69 core_info cinfo \
70 \
71 project_status pst \
72 project_update pup \
73 project_commit pci \
74 project_install pin \
75 project_conf conf \
76 project_rsync prs \
77 project_start start \
78 project_stop stop \
79 project_create create \
80 project_import import \
81 project_info pinfo \
82 project_reload reload \
83 project_fullreload full \
84 project_rewind rewind nano \
85 project_refresh refresh \
86 project_deinstall pdi \
87 project_user user \
88 project_switch switch swi \
89 project_backup backup \
90 \
91 plugin_create plc \
92 plugins_commit plci \
93 plugins_install plin \
94 plugins_status plst \
95 plugins_update plup \
96 plugins_deinstall pldi \
97 \
98 pgsql_init \
99 pgsql_start \
100 pgsql_stop \
101 pgsql_psql psql \
102 pgsql_dump dump \
103 pgsql_dumpz dumpz \
104 \
105 apache_access_log alog \
106 apache_pager_access_log palog \
107 apache_error_log elog \
108 apache_pager_error_log pelog \
109 apache_start \
110 apache_stop \
111 \
112 check_conf_installed \
113 check_core_installed \
114 check_owner \
115 check_project \
116 check_project_installed \
117 check_user \
118
119 #################
120 # local_* targets
121 #################
122
123 # build all required ports (core & project)
124 build: local_build ;
125 local_build: check_user
126 @for P in ${CORE_REQUIRED} ${PROJECT_REQUIRED}; do \
127 ${MAKE} -s port_build PORT=$${P} \
128 || exit 1; \
129 done;
130 @echo $@ done
131
132 # install all required ports (core & project)
133 install: local_install ;
134 local_install: check_user
135 @for P in ${CORE_REQUIRED} ${PROJECT_REQUIRED}; do \
136 ${MAKE} -s port_install PORT=$${P} \
137 || exit 1; \
138 done;
139 ifeq (${DB_TYPE},SINGLE)
140 @${MAKE} -s pgsql_init
141 endif
142 @echo $@ done
143
144 # preview of install all required ports (core & project)
145 preview: local_preview ;
146 @for P in ${CORE_REQUIRED} ${PROJECT_REQUIRED}; do \
147 ${MAKE} -s port_install PORT=$${P} DRY_RUN=yes \
148 || exit 1; \
149 done;
150
151
152
153 ################
154 # core_* targets
155 ################
156
157 # check core sources via repository
158 cst: core_status ;
159 core_status: check_user
160 @svn st -u ${CORE_SRC}
161 @echo $@ done
162
163 # update core sources from repository
164 cup: core_update ;
165 core_update: check_user
166 ifdef REV
167 @svn up -r ${REV} ${CORE_SRC}
168 else
169 @svn up ${CORE_SRC}
170 endif
171 @echo $@ done
172
173 # commit core changes to repository
174 cci: core_commit ;
175 core_commit: check_user
176 @svn ci ${CORE_SRC}
177 @echo $@ done
178 #
179 # pretty formatted core info
180 cinfo: core_info ;
181 core_info:
182 @REPOS=`svn info ${CORE_SRC} | grep -E '^URL' | sed -E 's/URL: //'`; \
183 RL=$$(($${#REPOS}+2)); \
184 DEVEL=`perl -e 'print "".(lc "${DEVELOPMENT}" eq "yes" ? "YES" : "NO");'`; \
185 DEBUG=`perl -e 'print "".(lc "${DEBUG}" eq "yes" ? "YES" : "NO");'`; \
186 printf "%-$${RL}s %-12s %-7s %-7s %-6s\n" REPOSITORY REVISION DEVEL DEBUG PORT; \
187 printf "%-$${RL}s %-12s %-7s %-7s %-6s\n" $${REPOS} ${CORE_VERSION} $${DEVEL} \
188 $${DEBUG} ${HTTPD_PORT}
189 @echo $@ done
190
191
192 # install core into work directory
193 cin: core_install ;
194 ifeq (${DB_TYPE},SINGLE)
195 core_install: check_user pgsql_init
196 else
197 core_install: check_user
198 endif
199 @if [ -d ${CORE_USR} ]; then \
200 chmod -R u+w ${CORE_USR} \
201 && rm -Rf ${CORE_USR}; \
202 fi;
203
204 @mkdir ${CORE_USR} \
205 && cp -Rp ${CORE_SRC}/comps ${CORE_SRC}/lib ${CORE_SRC}/services ${CORE_USR}/ \
206 && find ${CORE_USR}/ -depth -type d -name .svn -exec rm -Rf {} \; \
207 && find ${CORE_USR}/ -depth -type f -name '*.proto' -exec rm -f {} \;
208
209 @for PROJ in `ls -1A ${PROJ_USR}/`; do \
210 ln -s ${PROJ_USR}/$${PROJ}/lib/$${PROJ} ${CORE_USR}/lib/$${PROJ}; \
211 done;
212
213 @chmod -R a-w ${CORE_USR}
214
215 ifeq (${DB_TYPE},SINGLE)
216 @rm -f ${LOCAL}/pgsql/data/pg_hba.conf \
217 && rm -f ${LOCAL}/pgsql/data/pg_ident.conf \
218 && cp ${CORE_SRC}/conf/pgsql/pg_hba.conf ${LOCAL}/pgsql/data/ \
219 && touch ${LOCAL}/pgsql/data/pg_ident.conf
220
221 @${call rewrite,${CORE_SRC}/conf/pgsql/postgresql.conf.proto, \
222 ${LOCAL}/pgsql/data/postgresql.conf}
223 endif
224
225 @echo $@ done
226
227
228 ###################
229 # project_* targets
230 ###################
231
232 # check project sources via repository
233 pst: project_status ;
234 project_status:: check_project
235 @svn st -u ${PROJ_SRC}/${PROJECT}
236 @echo $@ done
237
238 # pretty formatted project info
239 pinfo: project_info ;
240 project_info:: check_project
241 @REPOS=`svn info ${PROJ_SRC}/${PROJECT} | grep -E '^URL' | sed -E 's/URL: //'`; \
242 PL=$$(($${#PROJECT}+2)); [ $${PL} -lt 9 ] && PL=9; RL=$$(($${#REPOS}+2)); \
243 printf "%-$${PL}s %-$${RL}s %-10s %s\n" PROJECT REPOSITORY REVISION PLUGINS; \
244 printf "%-$${PL}s %-$${RL}s %-10s ${PLUGINS}\n" ${PROJECT} $${REPOS} ${PROJECT_VERSION}
245 @echo $@ done
246
247 # update project sources from repository
248 pup: project_update ;
249 project_update:: check_project
250 ifdef REV
251 @svn up -r ${REV} ${PROJ_SRC}/${PROJECT}
252 else
253 @svn up ${PROJ_SRC}/${PROJECT}
254 endif
255 @echo $@ done
256
257 # commit project changes to repository
258 pci: project_commit ;
259 project_commit:: check_project
260 @svn ci ${PROJ_SRC}/${PROJECT}
261 @echo $@ done
262
263 # install project into work directory
264 pin: project_install ;
265 project_install:: check_core_installed check_project
266 @for PORT in ${PROJECT_REQUIRED}; do \
267 ${MAKE} -s port_install PORT=$${PORT} \
268 || exit 1; \
269 done;
270
271 @if [ -d ${PROJ_USR}/${PROJECT} ]; then \
272 chmod -R u+w ${PROJ_USR}/${PROJECT}; \
273 fi;
274
275 @if [ -n "${RSYNC_COMMAND}" ]; then \
276 ${RSYNC_COMMAND} -a --delete --delete-excluded --include='tags' --include '*.exe' --cvs-exclude --exclude '*.proto' ${PROJ_SRC}/${PROJECT}/* ${PROJ_USR}/${PROJECT}; \
277 else \
278 if [ -d ${PROJ_USR}/${PROJECT} ]; then \
279 rm -Rf ${PROJ_USR}/${PROJECT}; \
280 fi; \
281 cp -R ${PROJ_SRC}/${PROJECT} ${PROJ_USR}/${PROJECT} \
282 && find ${PROJ_USR}/${PROJECT}/ -depth -type d -name .svn -exec rm -Rf {} \; \
283 && find ${PROJ_USR}/${PROJECT}/ -depth -type f -name '*.proto' -exec rm -f {} \; ; \
284 fi
285
286 @if [ \! -e ${PROJ_USR}/${PROJECT}/lib/Contenido ]; then \
287 mkdir ${PROJ_USR}/${PROJECT}/lib/Contenido; \
288 fi;
289
290 @test -d ${PROJ_USR}/${PROJECT}/conf \
291 && rm -Rf ${PROJ_USR}/${PROJECT}/conf \
292 || true
293
294 @if [ \! -e ${CORE_USR}/lib/${PROJECT} ]; then \
295 chmod u+w ${CORE_USR}/lib \
296 && ln -s ${PROJ_USR}/${PROJECT}/lib/${PROJECT} \
297 ${CORE_USR}/lib/${PROJECT} \
298 && chmod u-w ${CORE_USR}/lib; \
299 fi;
300
301 @chmod -R a-w ${PROJ_USR}/${PROJECT}
302
303 @for D in ${PROJ_TMP}/${PROJECT} \
304 ${PROJ_VAR}/${PROJECT}/log \
305 ${PROJ_VAR}/${PROJECT}/mason \
306 ${PROJ_VAR}/${PROJECT}/run; do \
307 test -d $${D} || mkdir -p $${D}; \
308 done;
309
310 @echo $@ done
311
312 # deinstall project from work directory
313 pdi: project_deinstall ;
314 project_deinstall:: check_project_installed project_stop
315 @if [ -d ${PROJ_USR}/${PROJECT} ]; then \
316 chmod -R u+w ${PROJ_USR}/${PROJECT} \
317 && rm -Rf ${PROJ_USR}/${PROJECT}; \
318 fi;
319 @if [ -d ${PROJ_TMP}/${PROJECT} ]; then \
320 rm -Rf ${PROJ_TMP}/${PROJECT}; \
321 fi
322 @if [ -d ${PROJ_VAR}/${PROJECT} ]; then \
323 rm -Rf ${PROJ_VAR}/${PROJECT}; \
324 fi
325 @echo $@ done
326
327 # commit plugins changes
328 plci: plugins_commit ;
329 plugins_commit:
330 ifdef PLUGIN
331 @${MAKE} -s plugin_commit_${PLUGIN}
332 else
333 @for P in ${PLUGINS}; do \
334 ${MAKE} -s plugin_commit_$${P}; \
335 done;
336 endif
337 @echo $@ done
338
339 # commit plugin changes
340 plugin_commit_%:
341 @svn ci ${PLUG_SRC}/${*}
342 @echo $@ done
343
344 # status of plugins sources via repository
345 plst: plugins_status ;
346 plugins_status:
347 ifdef PLUGIN
348 @${MAKE} -s plugin_status_${PLUGIN}
349 else
350 @for P in ${PLUGINS}; do \
351 ${MAKE} -s plugin_status_$${P}; \
352 done;
353 endif
354 @echo $@ done
355
356 # status of plugin sources from repository
357 plugin_status_%:
358 @svn st -u ${PLUG_SRC}/${*}
359 @echo $@ done
360
361 # update plugins sources from repository
362 plup: plugins_update ;
363 plugins_update:
364 ifdef PLUGIN
365 @${MAKE} -s plugin_update_${PLUGIN}
366 else
367 @for P in ${PLUGINS}; do \
368 ${MAKE} -s plugin_update_$${P}; \
369 done;
370 endif
371 @echo $@ done
372
373 # update plugin sources from repository
374 plugin_update_%:
375 @svn up ${PLUG_SRC}/${*}
376 @echo $@ done
377
378 # install plugins into work directory
379 plin: plugins_install ;
380 plugins_install: check_project_installed
381 #XXX It's workaround only (for old instalaltions - without usr/plugins)
382 @test -d ${PLUG_USR} || mkdir ${PLUG_USR}
383 @for P in ${PLUGINS}; do \
384 ${MAKE} -s plugin_install_$${P}; \
385 done;
386 @echo $@ done
387
388 # install plugin
389 plugin_install_%:
390 @if [ -d ${PLUG_USR}/${*} ]; then \
391 chmod -R u+w ${PLUG_USR}/${*}; \
392 fi;
393 @if [ -n "${RSYNC_COMMAND}" ]; then \
394 ${RSYNC_COMMAND} -a --delete --delete-excluded \
395 --cvs-exclude --exclude '*.proto' \
396 ${PLUG_SRC}/${*}/ ${PLUG_USR}/${*}/; \
397 else \
398 if [ -d ${PLUG_USR}/${*} ]; then \
399 rm -Rf ${PLUG_USR}/${*}; \
400 fi; \
401 cp -R ${PLUG_SRC}/${*} ${PLUG_USR}/${*} \
402 && find ${PLUG_USR}/${*}/ -depth -type d -name .svn \
403 -exec rm -Rf {} \; \
404 && find ${PLUG_USR}/${*}/ -depth -type f -name '*.proto' \
405 -exec rm -f {} \; ; \
406 fi;
407 @chmod -R a-w ${PLUG_USR}/${*}
408 @echo $@ done
409
410 # deinstall plugins from work directory
411 pldi: plugins_deinstall ;
412 plugins_deinstall:
413 @for P in ${PLUGINS}; do \
414 ${MAKE} -s plugin_deinstall_$${P}; \
415 done;
416 @echo $@ done
417
418 # deinstall plugin
419 plugin_deinstall_%:
420 @if [ -d ${PLUG_USR}/${*} ]; then \
421 chmod -R u+w ${PLUG_USR}/${*} \
422 && rm -Rf ${PLUG_USR}/${*}; \
423 fi;
424 @echo $@ done
425
426 # create new plugin
427 plc: plugin_create ;
428 plugin_create: check_user
429 @if [ -z "${NAME}" ]; then \
430 echo "ERROR: NAME not defined"; \
431 echo "HINT: use 'make cmd NAME=xxx'"; \
432 exit 1; \
433 fi;
434 @if [ -e ${PLUG_SRC}/${NAME} ]; then \
435 echo "ERROR: plugin ${NAME} already exists in src/plugins"; \
436 echo "HINT: select other name for new plugin"; \
437 exit 1; \
438 fi;
439 @if [ -e ${PLUG_USR}/${NAME} ]; then \
440 echo "ERROR: plugin ${NAME} already exists in usr/plugins"; \
441 echo "HINT: select other name for new plugin"; \
442 exit 1; \
443 fi;
444
445 @mkdir -p ${PLUG_SRC} \
446 && cp -Rp ${CORE_SRC}/skel/plugin ${PLUG_SRC}/${NAME} \
447 && find ${PLUG_SRC}/${NAME}/ -depth -type d -name .svn -exec rm -Rf {} \; \
448 && find ${PLUG_SRC}/${NAME}/ -depth -type f -name '*.proto' -and \
449 \! -path '*/conf/*' -exec rm -f {} \;
450
451 @${call rewrite_skel,${CORE_SRC}/skel/plugin/lib/plugin/Apache.pm.proto, \
452 ${PLUG_SRC}/${NAME}/lib/plugin/Apache.pm}
453 @${call rewrite_skel,${CORE_SRC}/skel/plugin/lib/plugin/Init.pm.proto, \
454 ${PLUG_SRC}/${NAME}/lib/plugin/Init.pm}
455 @${call rewrite_skel,${CORE_SRC}/skel/plugin/lib/plugin/Keeper.pm.proto, \
456 ${PLUG_SRC}/${NAME}/lib/plugin/Keeper.pm}
457 @${call rewrite_skel,${CORE_SRC}/skel/plugin/lib/plugin/State.pm.proto, \
458 ${PLUG_SRC}/${NAME}/lib/plugin/State.pm.proto}
459 @${call rewrite_skel,${CORE_SRC}/skel/plugin/comps/contenido/plugin/dhandler, \
460 ${PLUG_SRC}/${NAME}/comps/contenido/plugin/dhandler}
461 @${call rewrite_skel,${CORE_SRC}/skel/plugin/comps/contenido/plugin/index.html, \
462 ${PLUG_SRC}/${NAME}/comps/contenido/plugin/index.html}
463
464 @mv ${PLUG_SRC}/${NAME}/lib/plugin ${PLUG_SRC}/${NAME}/lib/${NAME}
465 @mv ${PLUG_SRC}/${NAME}/comps/contenido/plugin ${PLUG_SRC}/${NAME}/comps/contenido/${NAME}
466
467 @echo $@ done
468
469
470 # install configs into work directory
471 conf: project_conf ;
472 project_conf:: check_plugins_installed
473 @chmod -R u+w ${PROJ_USR}/${PROJECT}
474
475 @if [ -d ${PROJ_USR}/${PROJECT}/conf ]; then \
476 rm -Rf ${PROJ_USR}/${PROJECT}/conf; \
477 fi
478 @mkdir -p ${PROJ_USR}/${PROJECT}/conf/apache \
479 && mkdir -p ${PROJ_USR}/${PROJECT}/conf/etc \
480 && mkdir -p ${PROJ_USR}/${PROJECT}/conf/mason \
481 && mkdir -p ${PROJ_USR}/${PROJECT}/conf/mod_perl
482
483 @cp ${CORE_SRC}/conf/apache/mime.conf \
484 ${CORE_SRC}/conf/apache/mime.types \
485 ${PROJ_USR}/${PROJECT}/conf/apache/
486
487 @${call rewrite,${CORE_SRC}/conf/apache/httpd.conf.proto, \
488 ${PROJ_USR}/${PROJECT}/conf/apache/httpd.conf}
489 @${call rewrite,${PROJ_SRC}/${PROJECT}/conf/apache/httpd.conf.proto, \
490 ${PROJ_USR}/${PROJECT}/conf/apache/httpd_project.conf}
491
492 ifeq (${CRON_ENABLE},YES)
493 @if [ -d ${PROJ_SRC}/${PROJECT}/conf/etc ]; then \
494 cd ${PROJ_SRC}/${PROJECT}/conf/etc && \
495 for CTPROTO in crontab.`hostname`.proto crontab.proto; do \
496 if [ -f $$CTPROTO ]; then \
497 ${call rewrite,$$CTPROTO, \
498 ${PROJ_USR}/${PROJECT}/conf/etc/crontab}; \
499 break; \
500 fi; \
501 done; \
502 fi
503 endif
504
505 @${call rewrite,${CORE_SRC}/conf/mason/handler.pl.proto, \
506 ${PROJ_USR}/${PROJECT}/conf/mason/handler.pl}
507 @${call rewrite,${PROJ_SRC}/${PROJECT}/conf/mason/handler.pl.proto, \
508 ${PROJ_USR}/${PROJECT}/conf/mason/handler_project.pl}
509
510 @${call rewrite,${CORE_SRC}/conf/mod_perl/startup.pl.proto, \
511 ${PROJ_USR}/${PROJECT}/conf/mod_perl/startup.pl}
512 @${call rewrite,${PROJ_SRC}/${PROJECT}/conf/mod_perl/startup.pl.proto, \
513 ${PROJ_USR}/${PROJECT}/conf/mod_perl/startup_project.pl}
514
515 @${call rewrite,${CORE_SRC}/conf/mason/Config.pm.proto, \
516 ${PROJ_USR}/${PROJECT}/conf/mason/Config.pm}
517 @${call rewrite,${CORE_SRC}/lib/Contenido/State.pm.proto, \
518 ${PROJ_USR}/${PROJECT}/lib/Contenido/State.pm}
519 @${call rewrite,${CORE_SRC}/lib/Modules.pm.proto, \
520 ${PROJ_USR}/${PROJECT}/lib/Modules.pm}
521
522 @${call rewrite,${PROJ_SRC}/${PROJECT}/lib/${PROJECT}/State.pm.proto, \
523 ${PROJ_USR}/${PROJECT}/lib/${PROJECT}/State.pm}
524
525 @chmod -R u+w ${CORE_USR}/lib ${CORE_USR}/services
526
527 @${call rewrite,${CORE_SRC}/services/inc.pl.proto, \
528 ${CORE_USR}/services/inc.pl}
529
530 @chmod -R a-w ${CORE_USR}/lib ${CORE_USR}/services
531
532 @for P in ${PLUGINS}; do \
533 chmod -R u+w ${PLUG_USR}/$${P}; \
534 ${call rewrite,${PLUG_SRC}/$${P}/lib/$${P}/State.pm.proto, \
535 ${PLUG_USR}/$${P}/lib/$${P}/State.pm}; \
536 chmod -R u-w ${PLUG_USR}/$${P}; \
537 done;
538
539 @if [ $$((`perl -e 'print "".(lc "${DEVELOPMENT}" eq "yes" ? 1 : 0);'`)) -ne 1 ]; then \
540 ${CORE_USR}/services/pregen \
541 ${PROJ_SRC} ${PROJ_USR} ${PROJECT} '${PREGEN_GLOB}' ${PREGEN_LIST}; \
542 fi
543
544 @chmod -R a-w ${PROJ_USR}/${PROJECT}
545
546
547 ifeq (${DISABLE},YES)
548 @crontab -l | sed 's/^#*/#/' | crontab -; \
549 echo "Disabled crontab"
550 else
551 @if [ -f ${PROJ_USR}/${PROJECT}/conf/etc/crontab ]; then \
552 crontab ${PROJ_USR}/${PROJECT}/conf/etc/crontab; \
553 echo "Installed crontab from: ${PROJ_USR}/${PROJECT}/conf/etc/crontab"; \
554 fi
555 endif
556
557 @echo $@ done
558
559 # rsync project static files directly to frontend
560 prs: project_rsync ;
561 project_rsync:: check_project
562 @for D in ${RSYNC_DIRS}; do \
563 if [ -d ${RSYNC_ROOT}/$${D} ]; then \
564 D=$${D}/; \
565 elif [ \! -f ${RSYNC_ROOT}/$${D} ]; then \
566 echo "ERROR: no such dir or file: ${RSYNC_ROOT}/$${D}"; \
567 exit 1; \
568 fi; \
569 for S in ${RSYNC_SERVERS}; do \
570 echo "#######################################"; \
571 echo "# rsync $${D} to $${S}"; \
572 echo "#######################################"; \
573 cd ${RSYNC_ROOT} && ${RSYNC} -rtRv \
574 --delete --delete-excluded --exclude .svn --chmod=u+w \
575 $${D} $${S}; \
576 echo -e "done\n"; \
577 done; \
578 done;
579 @echo $@ done
580
581 # start project
582 start: project_start ;
583 ifneq (${DISABLE},YES)
584 ifeq (${DB_TYPE},SINGLE)
585 project_start:: pgsql_start apache_start
586 @echo $@ done
587 else
588 project_start:: apache_start
589 @echo $@ done
590 endif
591 else
592 project_start::
593 @for M in `cd ${PROJ_VAR}/${PROJECT} && ls -d mason.* 2>/dev/null`; do \
594 echo "cleaning old mason files: $$M"; \
595 rm -Rf ${PROJ_VAR}/${PROJECT}/$$M; \
596 done;
597 @echo $@ disabled
598 endif
599
600 # stop project
601 stop: project_stop ;
602 project_stop:: apache_stop
603 @echo $@ done
604
605 # full reinstall & restart core & project
606 full: project_fullreload ;
607 project_fullreload:: project_stop mason_clean core_update core_install \
608 project_update project_install plugins_update plugins_install \
609 project_conf project_start
610 @echo $@ done
611
612 # full reinstall & restart project
613 reload: project_reload ;
614 project_reload:: project_stop mason_clean project_update project_install \
615 plugins_update plugins_install project_conf project_start
616 @echo $@ done
617
618 # restart project without svn update
619 nano: project_rewind ;
620 rewind: project_rewind ;
621 project_rewind:: project_stop mason_clean project_install plugins_install \
622 project_conf project_start
623 @echo $@ done
624
625 # clean all mason temporaries & restart project
626 refresh: project_refresh ;
627 project_refresh:: project_stop mason_clean project_start
628 @echo $@ done
629
630 # create new project
631 create: project_create ;
632 project_create: check_user
633 @if [ -z "${NAME}" ]; then \
634 echo "ERROR: NAME not defined"; \
635 echo "HINT: use 'make cmd NAME=xxx'"; \
636 exit 1; \
637 fi;
638 @if [ -e ${PROJ_SRC}/${NAME} ]; then \
639 echo "ERROR: project ${NAME} already exists in src/projects"; \
640 echo "HINT: select other name for new project"; \
641 exit 1; \
642 fi;
643 @if [ -e ${PROJ_USR}/${NAME} ]; then \
644 echo "ERROR: project ${NAME} already exists in usr/projects"; \
645 echo "HINT: select other name for new project"; \
646 exit 1; \
647 fi;
648
649 @cp -Rp ${CORE_SRC}/skel/project ${PROJ_SRC}/${NAME} \
650 && find ${PROJ_SRC}/${NAME}/ -depth -type d -name .svn -exec rm -Rf {} \; \
651 && find ${PROJ_SRC}/${NAME}/ -depth -type f -name '*.proto' -and \
652 \! -path '*/conf/*' -exec rm -f {} \;
653
654 @${call rewrite_skel,${CORE_SRC}/skel/project/lib/project/Apache.pm.proto, \
655 ${PROJ_SRC}/${NAME}/lib/project/Apache.pm}
656 @${call rewrite_skel,${CORE_SRC}/skel/project/lib/project/Init.pm.proto, \
657 ${PROJ_SRC}/${NAME}/lib/project/Init.pm}
658 @${call rewrite_skel,${CORE_SRC}/skel/project/lib/project/Keeper.pm.proto, \
659 ${PROJ_SRC}/${NAME}/lib/project/Keeper.pm}
660 @${call rewrite_skel,${CORE_SRC}/skel/project/lib/project/SampleCustomDocument.pm.proto, \
661 ${PROJ_SRC}/${NAME}/lib/project/SampleCustomDocument.pm}
662 @${call rewrite_skel,${CORE_SRC}/skel/project/lib/project/SampleDefaultDocument.pm.proto, \
663 ${PROJ_SRC}/${NAME}/lib/project/SampleDefaultDocument.pm}
664 @${call rewrite_skel,${CORE_SRC}/skel/project/lib/project/State.pm.proto, \
665 ${PROJ_SRC}/${NAME}/lib/project/State.pm.proto}
666 @${call rewrite_skel,${CORE_SRC}/skel/project/lib/project/SQL/SampleTable.pm.proto, \
667 ${PROJ_SRC}/${NAME}/lib/project/SQL/SampleTable.pm}
668 @${call rewrite_skel,${CORE_SRC}/skel/project/lib/project/SQL/SampleTable.pm.proto, \
669 ${PROJ_SRC}/${NAME}/lib/project/SQL/SampleTable.pm}
670 @${call rewrite_skel,${CORE_SRC}/skel/project/comps/www/index.html.proto, \
671 ${PROJ_SRC}/${NAME}/comps/www/index.html}
672 @${call rewrite_skel,${CORE_SRC}/skel/project/conf/etc/crontab.tmpl.proto, \
673 ${PROJ_SRC}/${NAME}/conf/etc/crontab.tmpl.proto}
674 @${call rewrite_skel,${CORE_SRC}/skel/project/config.mk.proto, \
675 ${PROJ_SRC}/${NAME}/config.mk}
676
677 @mv ${PROJ_SRC}/${NAME}/lib/project ${PROJ_SRC}/${NAME}/lib/${NAME}
678
679 @echo $@ done
680
681
682 # change active project
683 swi: project_switch ;
684 switch: project_switch ;
685 project_switch:
686 @if [ -z "${NAME}" ]; then \
687 echo "ERROR: NAME not defined"; \
688 echo "HINT: use 'make cmd NAME=xxx'"; \
689 exit 1; \
690 fi;
691 @if [ "${NAME}" = "${PROJECT}" ]; then \
692 echo "ERROR: project ${NAME} is already active"; \
693 exit 1; \
694 fi;
695 @if [ \! -d ${PROJ_SRC}/${NAME} ]; then \
696 echo "ERROR: project ${NAME} doesn't exists in src/projects"; \
697 echo "HINT: checkout sources for project ${NAME}"; \
698 exit 1; \
699 fi;
700 @${MAKE} -s project_stop
701 @perl -pi.orig -e 's|^([[:space:]]*PROJECT[[:space:]]*\?*\=[[:space:]]*)[^[:space:]]+([[:space:]]*)$$|$$1${NAME}$$2|' ${ROOT_DIR}/config.mk
702 @${MAKE} -s project_reload PROJECT=${NAME}
703
704 @echo $@ done
705
706 # backing-up project sources
707 backup: project_backup ;
708 project_backup:: check_project
709 @echo "compressing ${PROJECT} sources => ${PROJ_VAR}/${PROJECT}/${PROJECT}.src.tgz"
710 @tar -czf ${PROJ_VAR}/${PROJECT}/${PROJECT}.src.tgz -C ${PROJ_SRC} ${PROJECT}
711 @echo $@ done
712
713 # import project sources into repository
714 import: project_import ;
715 project_import: check_project
716 @if [ $$((`find ${PROJ_SRC}/${PROJECT} -type d -name .svn | wc -l`)) -ne 0 ]; then \
717 echo "ERROR: project '${PROJECT}' seems as already imported"; \
718 exit 1; \
719 fi
720 @if ! svn ls ${SVN_REPOSITORY}/${PROJECT}/trunk >&- 2>&-; then \
721 echo "ERROR: no repository for project '${PROJECT}' found"; \
722 echo "HINT: contact with respository administrators."; \
723 exit 1; \
724 fi
725 @if [ $$((`svn ls ${SVN_REPOSITORY}/${PROJECT}/trunk | wc -l`)) -ne 0 ]; then \
726 echo "ERROR: repository for project '${PROJECT}' isn't empty"; \
727 echo "Please contact with respository administrators."; \
728 exit 1; \
729 fi
730 @if svn import ${PROJ_SRC}/${PROJECT} ${SVN_REPOSITORY}/${PROJECT}/trunk \
731 && mv ${PROJ_SRC}/${PROJECT} ${PROJ_SRC}/${PROJECT}.before-import \
732 && svn checkout ${SVN_REPOSITORY}/${PROJECT}/trunk ${PROJ_SRC}/${PROJECT}; then \
733 echo "Your project directory moved to '${PROJ_SRC}/${PROJECT}.before-import'"; \
734 echo "Directory '${PROJ_SRC}/${PROJECT}' is now working copy"; \
735 else \
736 echo "ERROR: some errors occured during import/checkout project '${PROJECT}'"; \
737 echo "HINT: contact with respository administrators."; \
738 exit 1; \
739 fi
740 @echo $@ done
741
742 # create user (editors)
743 user: project_user ;
744 project_user: check_core_installed pgsql_template
745 @export PGPASSWORD=${BASE_PASSWD} && ${CORE_USR}/services/createuser | \
746 ${PSQL} -h '${BASE_HOST}' -p ${PGSQL_PORT} -U ${BASE_USER} ${PGSQL_BASE}
747 @echo $@ done
748
749 ##################
750 # apache_* targets
751 ##################
752
753 286 ahitrov # _exp=`perl -e 'print $1 if "${LIMIT_VMEMORY_HTTPD}" =~ /.*(.)$/;'`;
754 # _exp=`perl -e 'my $$e = ("${LIMIT_VMEMORY_HTTPD}"=~/.*(.)/)[0]; print $$e;'`; \
755 # echo _exp=$${_exp}; \
756
757 8 ahitrov@rambler.ru apache_start: check_conf_installed
758 @${call is_alive,${PROJ_VAR}/${PROJECT}/run/httpd.pid}; \
759 FLAGS=`perl -e 'print " -DDEVELOPMENT" if lc "${DEVELOPMENT}" eq "yes";'`; \
760 FLAGS=$$FLAGS`perl -e ' \
761 if (lc "${RSYSLOG_ENABLE}" eq "yes") { print " -DRSYSLOG"; } \
762 elsif (lc "${CRONOLOG_ENABLE}" eq "yes") { print " -DCRONOLOG"; } \
763 else { print " -DFILELOG"; }'`; \
764 if [ "${LIMIT_VMEMORY_HTTPD}" ]; then \
765 286 ahitrov if [ x`uname` = x"FreeBSD" ]; then \
766 LIMITS="${LIMIT_CMD} -v ${LIMIT_VMEMORY_HTTPD}"; \
767 else \
768 # echo "LIMIT_VMEMORY_HTTPD=${LIMIT_VMEMORY_HTTPD}"; \
769 _exp=`expr "${LIMIT_VMEMORY_HTTPD}" : '.*\(.\)'`; \
770 # echo _exp=$${_exp}; \
771 _value=`expr "${LIMIT_VMEMORY_HTTPD}" : '\(.*\).'`; \
772 # echo _value=$${_value}; \
773 if [ "$${_exp}" = "m" ]; then \
774 _value=`expr $$_value \* 1024 `; \
775 fi; \
776 # echo _value=$${_value}; \
777 LIMITS="ulimit -S -v $${_value}"; \
778 echo "DEBUG: running on Linux, LIMITS='$${LIMITS}'"; \
779 fi; \
780 8 ahitrov@rambler.ru fi; \
781 if [ "$${ALIVE}" = "YES" ]; then \
782 echo "WARNING: apache for project '${PROJECT}' already running"; \
783 else \
784 286 ahitrov [ x`uname` = x"Linux" ] && $${LIMITS} && LIMITS=""; \
785 8 ahitrov@rambler.ru if $${LIMITS} ${LOCAL}/apache/bin/httpd $${FLAGS} \
786 -d ${PROJ_USR}/${PROJECT}/ \
787 -f ${PROJ_USR}/${PROJECT}/conf/apache/httpd.conf; then \
788 echo -n "apache for project '${PROJECT}' started"; \
789 if [ "${LIMIT_VMEMORY_HTTPD}" ]; then \
790 echo " (with vmem limit: ${LIMIT_VMEMORY_HTTPD})"; \
791 else \
792 echo; \
793 fi; \
794 else \
795 echo "ERROR: can't start apache for project '${PROJECT}'"; \
796 exit 1; \
797 fi; \
798 fi;
799 @for M in `cd ${PROJ_VAR}/${PROJECT} && ls -d mason.*`; do \
800 echo "cleaning old mason files: $$M"; \
801 rm -Rf ${PROJ_VAR}/${PROJECT}/$$M; \
802 done;
803 @echo $@ done
804
805 apache_stop: check_conf_installed
806 @${call is_alive,${PROJ_VAR}/${PROJECT}/run/httpd.pid}; \
807 if [ "$${ALIVE}" = "YES" ]; then \
808 kill `head -n 1 ${PROJ_VAR}/${PROJECT}/run/httpd.pid`; \
809 ${call wait_stop,${PROJ_VAR}/${PROJECT}/run/httpd.pid,apache}; \
810 if [ $${STOPPED} != 'YES' ]; then \
811 echo "ERROR: can't stop apache for project '${PROJECT}'"; \
812 exit 1; \
813 else \
814 echo "apache for project '${PROJECT}' stopped"; \
815 fi; \
816 else \
817 echo "WARNING: apache for project '${PROJECT}' isn't running"; \
818 fi;
819 @echo $@ done
820
821 alog: apache_access_log ;
822 apache_access_log:
823 @test -e ${PROJECT_LOG}/access_log || touch ${PROJECT_LOG}/access_log
824 @tail -F ${PROJECT_LOG}/access_log
825
826 palog: apache_pager_access_log ;
827 apache_pager_access_log:
828 @test -e ${PROJECT_LOG}/access_log || touch ${PROJECT_LOG}/access_log
829 @${PAGER} ${PROJECT_LOG}/access_log
830
831 elog: apache_error_log ;
832 apache_error_log:
833 @test -e ${PROJECT_LOG}/error_log || touch ${PROJECT_LOG}/error_log
834 @tail -F ${PROJECT_LOG}/error_log
835
836 pelog: apache_pager_error_log ;
837 apache_pager_error_log:
838 @test -e ${PROJECT_LOG}/error_log || touch ${PROJECT_LOG}/error_log
839 @${PAGER} ${PROJECT_LOG}/error_log
840
841 #################
842 # pgsql_* targets
843 #################
844
845 ifeq (${DB_TYPE},SINGLE)
846
847 pgsql_init: check_user
848 @cd ${PORTSDIR}/all/postgresql \
849 && ${MAKE} -s initdb PREFIX=${LOCAL} PORTSWRK=${PORTSWRK}
850 @echo $@ done
851
852 pgsql_start: pgsql_init
853 @${call is_alive,${LOCAL}/pgsql/data/postmaster.pid}; \
854 if [ "$${ALIVE}" = "YES" ]; then \
855 echo "WARNING: postgresql already running"; \
856 else \
857 if ${LOCAL}/pgsql/bin/pg_ctl -w -D ${LOCAL}/pgsql/data start; then \
858 echo "postgresql started"; \
859 else \
860 echo "ERROR: can't start postgresql"; \
861 exit 1; \
862 fi; \
863 fi;
864 @echo $@ done
865
866 pgsql_stop: check_user
867 @${call is_alive,${LOCAL}/pgsql/data/postmaster.pid}; \
868 if [ "$${ALIVE}" = "YES" ]; then \
869 ${LOCAL}/pgsql/bin/pg_ctl -w -m fast -D ${LOCAL}/pgsql/data stop; \
870 ${call wait_stop,${LOCAL}/pgsql/data/postmaster.pid,postgresql}; \
871 if [ $${STOPPED} != 'YES' ]; then \
872 echo "ERROR: can't stop postgresql"; \
873 exit 1; \
874 else \
875 echo "postgresql stopped"; \
876 fi; \
877 else \
878 echo "WARNING: postgresql isn't running"; \
879 fi;
880 @echo $@ done
881
882 pgsql_create: pgsql_start
883 @if [ $$((`${PSQL} -p ${PGSQL_PORT} -l | \
884 perl -ne 'print $$_ if /^\s*${PGSQL_BASE}/' | wc -l`)) -eq 0 ]; then \
885 ${LOCAL}/pgsql/bin/createuser -SdR -p ${PGSQL_PORT} ${BASE_USER} \
886 || true; \
887 ${LOCAL}/pgsql/bin/createdb -p ${PGSQL_PORT} -O ${BASE_USER} \
888 ${PGSQL_BASE}; \
889 echo "ALTER USER ${BASE_USER} PASSWORD '${BASE_PASSWD}';" | \
890 ${PSQL} -p ${PGSQL_PORT} ${PGSQL_BASE}; \
891 ${PSQL} -p ${PGSQL_PORT} ${PGSQL_BASE} < ${LOCAL}/pgsql/share/contrib/_int.sql; \
892 else \
893 echo "WARNING: database ${PGSQL_BASE} already exists"; \
894 fi;
895 @echo $@ done
896
897
898 else
899
900 pgsql_init \
901 pgsql_start \
902 pgsql_stop \
903 pgsql_create:
904 @echo "ERROR: $@ not implemented for DB_TYPE: ${DB_TYPE}"; \
905 echo "HINT: use 'make cmd DB_TYPE=xxx' or edit ${ROOT_DIR}/config.mk"; \
906 exit 1
907
908 endif
909
910 ifeq (${DB_TYPE},SINGLE)
911 pgsql_template: pgsql_create
912 else
913 pgsql_template: check_project
914 endif
915 @if [ $$((`export PGPASSWORD=${BASE_PASSWD} && ${PSQL} -h '${BASE_HOST}' \
916 -p ${PGSQL_PORT} -U ${BASE_USER} -c '\d' ${PGSQL_BASE} | \
917 grep documents | wc -l`)) -lt 1 ]; then \
918 export PGPASSWORD=${BASE_PASSWD} && ${PSQL} -h '${BASE_HOST}' \
919 -p ${PGSQL_PORT} -U ${BASE_USER} ${PGSQL_BASE} < \
920 ${CORE_SRC}/sql/${STORE_METHOD}/contenido.sql; \
921 else \
922 echo "WARNING: template already loaded into database ${PGSQL_BASE}"; \
923 fi;
924
925 @echo $@ done
926
927 psql: pgsql_psql ;
928 ifeq (${DB_TYPE},SINGLE)
929 pgsql_psql: pgsql_create
930 else
931 pgsql_psql: check_project
932 endif
933 @(export PGPASSWORD=${BASE_PASSWD} && cd ../.. && ${PSQL} -h '${BASE_HOST}' -p ${PGSQL_PORT} \
934 -U ${BASE_USER} ${PGSQL_BASE})
935
936 # dump project database
937 dump: pgsql_dump ;
938 ifeq (${DB_TYPE},NONE)
939 pgsql_dump:
940 @echo "project ${PROJECT} hasn't database"; exit 1
941 else
942 ifeq (${DB_TYPE},SINGLE)
943 pgsql_dump: pgsql_create
944 else
945 pgsql_dump: check_project
946 endif
947 @echo "dumping ${BASE_HOST}:${PGSQL_PORT}/${PGSQL_BASE} => ${PROJ_VAR}/${PROJECT}/${PGSQL_BASE}.sql"
948 @export PGPASSWORD=${BASE_PASSWD} && ${PGDUMP} -Ox -h '${BASE_HOST}' -p ${PGSQL_PORT} \
949 -U ${BASE_USER} ${PGSQL_BASE} > ${PROJ_VAR}/${PROJECT}/${PGSQL_BASE}.sql
950 @echo $@ done
951 endif
952
953 # dump project database (gzip)
954 dumpz: pgsql_dumpz ;
955 ifeq (${DB_TYPE},NONE)
956 pgsql_dumpz:
957 @echo "project ${PROJECT} hasn't database"; exit 1
958 else
959 ifeq (${DB_TYPE},SINGLE)
960 pgsql_dumpz: pgsql_create
961 else
962 pgsql_dumpz: check_project
963 endif
964 @echo "dumping ${BASE_HOST}:${PGSQL_PORT}/${PGSQL_BASE} => ${PROJ_VAR}/${PROJECT}/${PGSQL_BASE}.sql.gz"
965 @export PGPASSWORD=${BASE_PASSWD} && ${PGDUMP} -Ox -h '${BASE_HOST}' -p ${PGSQL_PORT} \
966 -U ${BASE_USER} ${PGSQL_BASE} | gzip > ${PROJ_VAR}/${PROJECT}/${PGSQL_BASE}.sql.gz
967 @echo $@ done
968 endif
969
970
971 ########################
972 # internal targets
973 # (not for direct usage)
974 ########################
975
976 mason_clean:
977 @mv -f ${PROJ_VAR}/${PROJECT}/mason \
978 ${PROJ_VAR}/${PROJECT}/mason.`date +%Y-%m-%d.%H:%M:%S` \
979 && mkdir ${PROJ_VAR}/${PROJECT}/mason;
980 @echo $@ done
981
982
983 #################
984 # check_* targets
985 #################
986
987 # it's required
988 check_user: check_owner ;
989
990 # if user is installation owner?
991 check_owner:
992 @if [ `whoami` != ${OWNER} ]; then \
993 echo "ERROR: please run as OWNER: ${OWNER}"; \
994 echo "HINT: use 'sudo -u ${OWNER} -H bash' or 'sudo -i -u ${OWNER}'"; \
995 exit 1; \
996 fi;
997
998 # check if core installed
999 check_core_installed: check_user
1000 @if [ $$((`ls -1A ${CORE_USR}/ | wc -l`)) -eq 0 ]; then \
1001 echo "ERROR: core not installed"; \
1002 echo "HINT: use 'make core_install' or 'make cin'"; \
1003 exit 1; \
1004 fi;
1005
1006 # check for existing project (see include near line ~30)
1007 check_project: check_user
1008 @if [ -z "${PROJECT}" ]; then \
1009 echo "ERROR: project not defined"; \
1010 echo "HINT: use 'make cmd PROJECT=xxx' or edit ${ROOT_DIR}/config.mk"; \
1011 exit 1; \
1012 fi;
1013
1014 # check if project installed
1015 check_project_installed: check_project
1016 @if [ \! -d ${PROJ_USR}/${PROJECT} ]; then \
1017 echo "ERROR: project '${PROJECT}' not installed"; \
1018 echo "HINT: use 'make project_install' or 'make pin'"; \
1019 exit 1; \
1020 fi;
1021 @if [ $$((`ls -1A ${PROJ_USR}/${PROJECT} | wc -l`)) -eq 0 ]; then \
1022 echo "ERROR: project '${PROJECT}' not installed"; \
1023 echo "HINT: use 'make project_install' or 'make pin'"; \
1024 exit 1; \
1025 fi;
1026
1027 # check if plugins installed
1028 check_plugins_installed: check_project_installed
1029 @for P in ${PLUGINS}; do \
1030 if [ \! -d ${PLUG_USR}/$${P} ]; then \
1031 echo "ERROR: plugin '$${P}' not installed"; \
1032 echo "HINT: use 'make plugins_install' or 'make plin'"; \
1033 exit 1; \
1034 fi; \
1035 done;
1036
1037 # check if configs installed
1038 check_conf_installed: check_project_installed
1039 @if [ \! -d ${PROJ_USR}/${PROJECT}/conf ]; then \
1040 echo "ERROR: configs for project '${PROJECT}' not installed"; \
1041 echo "HINT: use 'make project_conf' or 'make conf'"; \
1042 exit 1; \
1043 fi;
1044
1045
1046 ##########################
1047 # port_* & ports_* targets
1048 ##########################
1049
1050 # single port sub-commands
1051 port_%: check_user
1052 ifdef PORT
1053 @cd ${PORTSDIR}/all/${PORT} \
1054 && ${MAKE} -s $* PREFIX=${LOCAL} PORTSWRK=${PORTSWRK}
1055 ifndef DRY_RUN
1056 @echo $@ done
1057 endif
1058 else
1059 @echo "ERROR: no PORT defined"; \
1060 echo "HINT: use 'make cmd PORT=name'"; \
1061 exit 1;
1062 endif
1063
1064 # multiple ports sub-commands
1065 ports_%: check_user
1066 @cd ${PORTSDIR} \
1067 && ${MAKE} -s $* PREFIX=${LOCAL} PORTSWRK=${PORTSWRK}
1068 @echo $@ done
1069
1070
1071 ########
1072 # macros
1073 ########
1074 define is_alive
1075 if [ \! -f ${1} ]; then \
1076 ALIVE='NO'; \
1077 else \
1078 if kill -0 `head -n 1 ${1}` 2>/dev/null; then \
1079 ALIVE='YES'; \
1080 else \
1081 rm -f ${1}; \
1082 ALIVE='NO'; \
1083 fi; \
1084 fi
1085 endef
1086
1087 define wait_stop
1088 TRYMAX=`test -z "${3}" && echo 10 || echo ${3}`; \
1089 TRYCUR=1; \
1090 STOPPED='NO'; \
1091 echo -n "Waiting for ${2} stopped, tries: $${TRYCUR}"; \
1092 ${call is_alive,${1}}; \
1093 while [ "$${ALIVE}" = "YES" -a $$(($${TRYCUR})) -lt $$(($${TRYMAX})) ]; do \
1094 sleep 1; \
1095 TRYCUR=$$(($${TRYCUR}+1)); \
1096 echo -n " $${TRYCUR}"; \
1097 ${call is_alive,${1}}; \
1098 done; \
1099 echo ""; \
1100 if [ "$${ALIVE}" = "NO" ]; then \
1101 STOPPED='YES'; \
1102 fi
1103 endef
1104
1105 ifeq (${USE_MTT},YES)
1106 define rewrite
1107 $(foreach R, ${REWRITE}, MTT_${R}="${${R}}") \
1108 ${CORE_SRC}/services/mttbfr > ${PROJ_TMP}/${PROJECT}/mtt.conf && \
1109 ${CORE_SRC}/services/mttcomp < ${1} | \
1110 ${LOCAL}/bin/mtt -b ${PROJ_TMP}/${PROJECT}/mtt.conf - ${2} \
1111 && echo "created ${2} (mtt)"
1112 endef
1113 else
1114 define rewrite
1115 $(foreach R, ${REWRITE}, ${R}="${${R}}") \
1116 perl -pe 's/@([A-Z_]+)@/$$ENV{$$1}/ge' < ${1} > ${2} \
1117 && echo "created ${2} (rewrite)"
1118 endef
1119 endif
1120
1121 define rewrite_skel
1122 NAME=${NAME} \
1123 LOCAL=@LOCAL@ \
1124 CORE_USR=@CORE_USR@ \
1125 PROJ_USR=@PROJ_USR@ \
1126 PROJECT_VAR=@PROJECT_VAR@ \
1127 perl -pe 's/@([A-Z_]+)@/$$ENV{$$1}/ge' < ${1} > ${2} \
1128 && echo "created ${2}"
1129 endef
1130
1131 # rewrites values
1132 PREFIX = ${LOCAL}
1133 ROOT_LOG = ${ROOT_DIR}/var/log
1134 PGSQL_REDIRECT = ${shell perl -e 'print lc("${PGSQL_LOGGING}") eq "yes" && "on" || "off"'}
1135 ifdef PROJECT
1136 PROJECT_USR = ${PROJ_USR}/${PROJECT}
1137 PROJECT_TMP = ${PROJ_TMP}/${PROJECT}
1138 PROJECT_VAR = ${PROJ_VAR}/${PROJECT}
1139 PROJECT_LOG = ${PROJ_VAR}/${PROJECT}/log
1140 PROJECT_RUN = ${PROJ_VAR}/${PROJECT}/run
1141 endif
1142
1143 # rewrites definitions
1144 REWRITE += \
1145 AUTH_COOKIE \
1146 AUTH_MEMCACHED_BUSY_LOCK \
1147 AUTH_MEMCACHED_ENABLE \
1148 AUTH_MEMCACHED_SERVERS \
1149 BASE_HOST \
1150 BASE_PASSWD \
1151 BASE_USER \
1152 BINARY \
1153 CASCADE \
1154 COMP_CACHE_ENABLED \
1155 COMP_TIMINGS_DISABLE \
1156 CONF \
1157 CONTENIDO_VERSION \
1158 CONVERT \
1159 CORE_COMP \
1160 CORE_SRC \
1161 CORE_VERSION \
1162 CORE_USR \
1163 CRONOLOG_ENABLE \
1164 CRONOLOG_FORMAT \
1165 CROSSLINKS \
1166 DB_TYPE \
1167 DEBUG_FORMAT \
1168 DEBUG_MIN_LEVEL \
1169 DEBUG_MAX_LEVEL \
1170 DEBUG_STACK_TRACE \
1171 DEBUG \
1172 DEBUG_CORE \
1173 DEBUG_SQL \
1174 DEBUG_WORKTIME \
1175 DEFAULT_ESCAPE_FLAGS \
1176 DEFAULT_HANDLER \
1177 DEVELOPMENT \
1178 ERROR_MODE \
1179 FILES \
1180 203 ahitrov FILE_WEB_STORAGE \
1181 8 ahitrov@rambler.ru HOSTNAME \
1182 HTTPD_DOCS \
1183 HTTPD_ELOG_LEVEL \
1184 HTTPD_PORT \
1185 HTTPD_SERVER \
1186 IMAGES \
1187 LISTEN_BACK_LOG \
1188 LOCAL \
1189 LOCALE \
1190 LOGGER \
1191 MASON_CACHE_ENABLED \
1192 MASON_COMP \
1193 MASON_MEMCACHED_BACKEND \
1194 MASON_MEMCACHED_DEBUG \
1195 MASON_MEMCACHED_ENABLED \
1196 MASON_MEMCACHED_NAMESPACE \
1197 MASON_MEMCACHED_SERVERS \
1198 MASTER_BASE_HOST \
1199 MASTER_BASE_NAME \
1200 MASTER_BASE_PASSWD \
1201 MASTER_BASE_PORT \
1202 MASTER_BASE_USER \
1203 MAX_CLIENTS \
1204 MAX_PROCESS_SIZE \
1205 MAX_REQUESTS_PER_CHILD \
1206 MAX_SPARE_SERVERS \
1207 MEMCACHED_BACKEND \
1208 MEMCACHED_DELAYED \
1209 MEMCACHED_ENABLE \
1210 MEMCACHED_ENABLE_COMPRESS \
1211 MEMCACHED_SELECT_TIMEOUT \
1212 MEMCACHED_SERVERS \
1213 MEMCACHED_SET_MODE \
1214 MIN_SPARE_SERVERS \
1215 MODULES \
1216 MULTIDOMAIN \
1217 OPTIONS_EXPIRE \
1218 PERL_LEVEL \
1219 PERL_LIB \
1220 PERSISTENT_CONN \
1221 PGSQL_BASE \
1222 PGSQL_CLIENT_ENCODING \
1223 PGSQL_PORT \
1224 PGSQL_REAL_PREPARE \
1225 PGSQL_REDIRECT \
1226 PGSQL_CLIENT_ENCODING \
1227 PGSQL_ENCODE_DATA \
1228 PGSQL_DECODE_DATA \
1229 PGSQL_ENABLE_UTF \
1230 217 ahitrov SERIALIZE_WITH \
1231 8 ahitrov@rambler.ru PLUG_SRC \
1232 PLUGINS \
1233 PLUGIN_COMP \
1234 PREAMBLE_HANDLER \
1235 PREAMBLE_HANDLER_PATH \
1236 PREFIX \
1237 PRELOADS \
1238 PREVIEW \
1239 PROFILING_DBI \
1240 PROJECT \
1241 PROJECT_HOME \
1242 PROJECT_LC \
1243 PROJECT_NAME \
1244 PROJECT_LOG \
1245 PROJECT_RUN \
1246 PROJECT_TMP \
1247 PROJECT_USR \
1248 PROJECT_VAR \
1249 PROJECT_VERSION \
1250 PROJ_SRC \
1251 PROJ_USR \
1252 ROOT_LOG \
1253 READONLY \
1254 RSYSLOG_ENABLE \
1255 RSYSLOG_HOST \
1256 SERVER_ADMIN \
1257 SESSIONS \
1258 SPARE_REAPER_DELAY \
1259 SPARE_REAPER_DELAY_FAKEMOD \
1260 START_SERVERS \
1261 STATIC_SOURCE_ENABLE \
1262 STATIC_SOURCE_TOUCH_FILE \
1263 STORE_METHOD \
1264
1265 #TODO: ElTexto compatibility only
1266 REWRITE += \
1267 COMMENTS_ON_PAGE \
1268 ELTEXTO_VERSION \
1269 MEMCACHED_EXPIRE \
1270 SYNC_WITH_GROUPS \
1271 TEXTS_ON_PAGE \
1272 TEXT_IDS_IN_CACHE \
1273
1274 #TODO: Rate compatibility only
1275 REWRITE += \
1276 RATE_CLASSES \
1277 RATE_COOKIE \
1278
1279 #TODO: Search plugin compatibility only
1280 REWRITE += \
1281 SEARCH_SERVER \
1282
1283 #TODO: Util Proxy image
1284 REWRITE += \
1285 PROXY_IMAGE_LOCATION \
1286 PROXY_IMAGE_SECRET \
1287