Line # Revision Author
1 3 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 apache_start: check_conf_installed
754 @${call is_alive,${PROJ_VAR}/${PROJECT}/run/httpd.pid}; \
755 FLAGS=`perl -e 'print " -DDEVELOPMENT" if lc "${DEVELOPMENT}" eq "yes";'`; \
756 FLAGS=$$FLAGS`perl -e ' \
757 if (lc "${RSYSLOG_ENABLE}" eq "yes") { print " -DRSYSLOG"; } \
758 elsif (lc "${CRONOLOG_ENABLE}" eq "yes") { print " -DCRONOLOG"; } \
759 else { print " -DFILELOG"; }'`; \
760 if [ "${LIMIT_VMEMORY_HTTPD}" ]; then \
761 571 ahitrov if [ x`uname` = x"FreeBSD" ]; then \
762 LIMITS="${LIMIT_CMD} -v ${LIMIT_VMEMORY_HTTPD}"; \
763 else \
764 # echo "LIMIT_VMEMORY_HTTPD=${LIMIT_VMEMORY_HTTPD}"; \
765 _exp=`expr "${LIMIT_VMEMORY_HTTPD}" : '.*\(.\)'`; \
766 # echo _exp=$${_exp}; \
767 _value=`expr "${LIMIT_VMEMORY_HTTPD}" : '\(.*\).'`; \
768 # echo _value=$${_value}; \
769 if [ "$${_exp}" = "m" ]; then \
770 _value=`expr $$_value \* 1024 `; \
771 fi; \
772 # echo _value=$${_value}; \
773 LIMITS="ulimit -S -v $${_value}"; \
774 echo "DEBUG: running on Linux, LIMITS='$${LIMITS}'"; \
775 fi; \
776 fi; \
777 3 ahitrov@rambler.ru if [ "$${ALIVE}" = "YES" ]; then \
778 echo "WARNING: apache for project '${PROJECT}' already running"; \
779 else \
780 571 ahitrov [ x`uname` = x"Linux" ] && $${LIMITS} && LIMITS=""; \
781 3 ahitrov@rambler.ru if $${LIMITS} ${LOCAL}/apache/bin/httpd $${FLAGS} \
782 -d ${PROJ_USR}/${PROJECT}/ \
783 -f ${PROJ_USR}/${PROJECT}/conf/apache/httpd.conf; then \
784 echo -n "apache for project '${PROJECT}' started"; \
785 if [ "${LIMIT_VMEMORY_HTTPD}" ]; then \
786 echo " (with vmem limit: ${LIMIT_VMEMORY_HTTPD})"; \
787 else \
788 echo; \
789 fi; \
790 else \
791 echo "ERROR: can't start apache for project '${PROJECT}'"; \
792 exit 1; \
793 fi; \
794 fi;
795 @for M in `cd ${PROJ_VAR}/${PROJECT} && ls -d mason.*`; do \
796 echo "cleaning old mason files: $$M"; \
797 rm -Rf ${PROJ_VAR}/${PROJECT}/$$M; \
798 done;
799 @echo $@ done
800
801 apache_stop: check_conf_installed
802 @${call is_alive,${PROJ_VAR}/${PROJECT}/run/httpd.pid}; \
803 if [ "$${ALIVE}" = "YES" ]; then \
804 kill `head -n 1 ${PROJ_VAR}/${PROJECT}/run/httpd.pid`; \
805 ${call wait_stop,${PROJ_VAR}/${PROJECT}/run/httpd.pid,apache}; \
806 if [ $${STOPPED} != 'YES' ]; then \
807 echo "ERROR: can't stop apache for project '${PROJECT}'"; \
808 exit 1; \
809 else \
810 echo "apache for project '${PROJECT}' stopped"; \
811 fi; \
812 else \
813 echo "WARNING: apache for project '${PROJECT}' isn't running"; \
814 fi;
815 @echo $@ done
816
817 alog: apache_access_log ;
818 apache_access_log:
819 @test -e ${PROJECT_LOG}/access_log || touch ${PROJECT_LOG}/access_log
820 @tail -F ${PROJECT_LOG}/access_log
821
822 palog: apache_pager_access_log ;
823 apache_pager_access_log:
824 @test -e ${PROJECT_LOG}/access_log || touch ${PROJECT_LOG}/access_log
825 @${PAGER} ${PROJECT_LOG}/access_log
826
827 elog: apache_error_log ;
828 apache_error_log:
829 @test -e ${PROJECT_LOG}/error_log || touch ${PROJECT_LOG}/error_log
830 @tail -F ${PROJECT_LOG}/error_log
831
832 pelog: apache_pager_error_log ;
833 apache_pager_error_log:
834 @test -e ${PROJECT_LOG}/error_log || touch ${PROJECT_LOG}/error_log
835 @${PAGER} ${PROJECT_LOG}/error_log
836
837 #################
838 # pgsql_* targets
839 #################
840
841 ifeq (${DB_TYPE},SINGLE)
842
843 pgsql_init: check_user
844 @cd ${PORTSDIR}/all/postgresql \
845 && ${MAKE} -s initdb PREFIX=${LOCAL} PORTSWRK=${PORTSWRK}
846 @echo $@ done
847
848 pgsql_start: pgsql_init
849 @${call is_alive,${LOCAL}/pgsql/data/postmaster.pid}; \
850 if [ "$${ALIVE}" = "YES" ]; then \
851 echo "WARNING: postgresql already running"; \
852 else \
853 if ${LOCAL}/pgsql/bin/pg_ctl -w -D ${LOCAL}/pgsql/data start; then \
854 echo "postgresql started"; \
855 else \
856 echo "ERROR: can't start postgresql"; \
857 exit 1; \
858 fi; \
859 fi;
860 @echo $@ done
861
862 pgsql_stop: check_user
863 @${call is_alive,${LOCAL}/pgsql/data/postmaster.pid}; \
864 if [ "$${ALIVE}" = "YES" ]; then \
865 ${LOCAL}/pgsql/bin/pg_ctl -w -m fast -D ${LOCAL}/pgsql/data stop; \
866 ${call wait_stop,${LOCAL}/pgsql/data/postmaster.pid,postgresql}; \
867 if [ $${STOPPED} != 'YES' ]; then \
868 echo "ERROR: can't stop postgresql"; \
869 exit 1; \
870 else \
871 echo "postgresql stopped"; \
872 fi; \
873 else \
874 echo "WARNING: postgresql isn't running"; \
875 fi;
876 @echo $@ done
877
878 pgsql_create: pgsql_start
879 @if [ $$((`${PSQL} -p ${PGSQL_PORT} -l | \
880 perl -ne 'print $$_ if /^\s*${PGSQL_BASE}/' | wc -l`)) -eq 0 ]; then \
881 ${LOCAL}/pgsql/bin/createuser -SdR -p ${PGSQL_PORT} ${BASE_USER} \
882 || true; \
883 ${LOCAL}/pgsql/bin/createdb -p ${PGSQL_PORT} -O ${BASE_USER} \
884 ${PGSQL_BASE}; \
885 echo "ALTER USER ${BASE_USER} PASSWORD '${BASE_PASSWD}';" | \
886 ${PSQL} -p ${PGSQL_PORT} ${PGSQL_BASE}; \
887 ${PSQL} -p ${PGSQL_PORT} ${PGSQL_BASE} < ${LOCAL}/pgsql/share/contrib/_int.sql; \
888 else \
889 echo "WARNING: database ${PGSQL_BASE} already exists"; \
890 fi;
891 @echo $@ done
892
893
894 else
895
896 pgsql_init \
897 pgsql_start \
898 pgsql_stop \
899 pgsql_create:
900 @echo "ERROR: $@ not implemented for DB_TYPE: ${DB_TYPE}"; \
901 echo "HINT: use 'make cmd DB_TYPE=xxx' or edit ${ROOT_DIR}/config.mk"; \
902 exit 1
903
904 endif
905
906 ifeq (${DB_TYPE},SINGLE)
907 pgsql_template: pgsql_create
908 else
909 pgsql_template: check_project
910 endif
911 @if [ $$((`export PGPASSWORD=${BASE_PASSWD} && ${PSQL} -h '${BASE_HOST}' \
912 -p ${PGSQL_PORT} -U ${BASE_USER} -c '\d' ${PGSQL_BASE} | \
913 grep documents | wc -l`)) -lt 1 ]; then \
914 export PGPASSWORD=${BASE_PASSWD} && ${PSQL} -h '${BASE_HOST}' \
915 -p ${PGSQL_PORT} -U ${BASE_USER} ${PGSQL_BASE} < \
916 ${CORE_SRC}/sql/${STORE_METHOD}/contenido.sql; \
917 else \
918 echo "WARNING: template already loaded into database ${PGSQL_BASE}"; \
919 fi;
920
921 @echo $@ done
922
923 psql: pgsql_psql ;
924 ifeq (${DB_TYPE},SINGLE)
925 pgsql_psql: pgsql_create
926 else
927 pgsql_psql: check_project
928 endif
929 @(export PGPASSWORD=${BASE_PASSWD} && cd ../.. && ${PSQL} -h '${BASE_HOST}' -p ${PGSQL_PORT} \
930 -U ${BASE_USER} ${PGSQL_BASE})
931
932 # dump project database
933 dump: pgsql_dump ;
934 ifeq (${DB_TYPE},NONE)
935 pgsql_dump:
936 @echo "project ${PROJECT} hasn't database"; exit 1
937 else
938 ifeq (${DB_TYPE},SINGLE)
939 pgsql_dump: pgsql_create
940 else
941 pgsql_dump: check_project
942 endif
943 @echo "dumping ${BASE_HOST}:${PGSQL_PORT}/${PGSQL_BASE} => ${PROJ_VAR}/${PROJECT}/${PGSQL_BASE}.sql"
944 @export PGPASSWORD=${BASE_PASSWD} && ${PGDUMP} -Ox -h '${BASE_HOST}' -p ${PGSQL_PORT} \
945 -U ${BASE_USER} ${PGSQL_BASE} > ${PROJ_VAR}/${PROJECT}/${PGSQL_BASE}.sql
946 @echo $@ done
947 endif
948
949 # dump project database (gzip)
950 dumpz: pgsql_dumpz ;
951 ifeq (${DB_TYPE},NONE)
952 pgsql_dumpz:
953 @echo "project ${PROJECT} hasn't database"; exit 1
954 else
955 ifeq (${DB_TYPE},SINGLE)
956 pgsql_dumpz: pgsql_create
957 else
958 pgsql_dumpz: check_project
959 endif
960 @echo "dumping ${BASE_HOST}:${PGSQL_PORT}/${PGSQL_BASE} => ${PROJ_VAR}/${PROJECT}/${PGSQL_BASE}.sql.gz"
961 @export PGPASSWORD=${BASE_PASSWD} && ${PGDUMP} -Ox -h '${BASE_HOST}' -p ${PGSQL_PORT} \
962 -U ${BASE_USER} ${PGSQL_BASE} | gzip > ${PROJ_VAR}/${PROJECT}/${PGSQL_BASE}.sql.gz
963 @echo $@ done
964 endif
965
966
967 ########################
968 # internal targets
969 # (not for direct usage)
970 ########################
971
972 mason_clean:
973 @mv -f ${PROJ_VAR}/${PROJECT}/mason \
974 ${PROJ_VAR}/${PROJECT}/mason.`date +%Y-%m-%d.%H:%M:%S` \
975 && mkdir ${PROJ_VAR}/${PROJECT}/mason;
976 @echo $@ done
977
978
979 #################
980 # check_* targets
981 #################
982
983 # it's required
984 check_user: check_owner ;
985
986 # if user is installation owner?
987 check_owner:
988 @if [ `whoami` != ${OWNER} ]; then \
989 echo "ERROR: please run as OWNER: ${OWNER}"; \
990 echo "HINT: use 'sudo -u ${OWNER} -H bash' or 'sudo -i -u ${OWNER}'"; \
991 exit 1; \
992 fi;
993
994 # check if core installed
995 check_core_installed: check_user
996 @if [ $$((`ls -1A ${CORE_USR}/ | wc -l`)) -eq 0 ]; then \
997 echo "ERROR: core not installed"; \
998 echo "HINT: use 'make core_install' or 'make cin'"; \
999 exit 1; \
1000 fi;
1001
1002 # check for existing project (see include near line ~30)
1003 check_project: check_user
1004 @if [ -z "${PROJECT}" ]; then \
1005 echo "ERROR: project not defined"; \
1006 echo "HINT: use 'make cmd PROJECT=xxx' or edit ${ROOT_DIR}/config.mk"; \
1007 exit 1; \
1008 fi;
1009
1010 # check if project installed
1011 check_project_installed: check_project
1012 @if [ \! -d ${PROJ_USR}/${PROJECT} ]; then \
1013 echo "ERROR: project '${PROJECT}' not installed"; \
1014 echo "HINT: use 'make project_install' or 'make pin'"; \
1015 exit 1; \
1016 fi;
1017 @if [ $$((`ls -1A ${PROJ_USR}/${PROJECT} | wc -l`)) -eq 0 ]; then \
1018 echo "ERROR: project '${PROJECT}' not installed"; \
1019 echo "HINT: use 'make project_install' or 'make pin'"; \
1020 exit 1; \
1021 fi;
1022
1023 # check if plugins installed
1024 check_plugins_installed: check_project_installed
1025 @for P in ${PLUGINS}; do \
1026 if [ \! -d ${PLUG_USR}/$${P} ]; then \
1027 echo "ERROR: plugin '$${P}' not installed"; \
1028 echo "HINT: use 'make plugins_install' or 'make plin'"; \
1029 exit 1; \
1030 fi; \
1031 done;
1032
1033 # check if configs installed
1034 check_conf_installed: check_project_installed
1035 @if [ \! -d ${PROJ_USR}/${PROJECT}/conf ]; then \
1036 echo "ERROR: configs for project '${PROJECT}' not installed"; \
1037 echo "HINT: use 'make project_conf' or 'make conf'"; \
1038 exit 1; \
1039 fi;
1040
1041
1042 ##########################
1043 # port_* & ports_* targets
1044 ##########################
1045
1046 # single port sub-commands
1047 port_%: check_user
1048 ifdef PORT
1049 @cd ${PORTSDIR}/all/${PORT} \
1050 && ${MAKE} -s $* PREFIX=${LOCAL} PORTSWRK=${PORTSWRK}
1051 ifndef DRY_RUN
1052 @echo $@ done
1053 endif
1054 else
1055 @echo "ERROR: no PORT defined"; \
1056 echo "HINT: use 'make cmd PORT=name'"; \
1057 exit 1;
1058 endif
1059
1060 # multiple ports sub-commands
1061 ports_%: check_user
1062 @cd ${PORTSDIR} \
1063 && ${MAKE} -s $* PREFIX=${LOCAL} PORTSWRK=${PORTSWRK}
1064 @echo $@ done
1065
1066
1067 ########
1068 # macros
1069 ########
1070 define is_alive
1071 if [ \! -f ${1} ]; then \
1072 ALIVE='NO'; \
1073 else \
1074 if kill -0 `head -n 1 ${1}` 2>/dev/null; then \
1075 ALIVE='YES'; \
1076 else \
1077 rm -f ${1}; \
1078 ALIVE='NO'; \
1079 fi; \
1080 fi
1081 endef
1082
1083 define wait_stop
1084 TRYMAX=`test -z "${3}" && echo 10 || echo ${3}`; \
1085 TRYCUR=1; \
1086 STOPPED='NO'; \
1087 echo -n "Waiting for ${2} stopped, tries: $${TRYCUR}"; \
1088 ${call is_alive,${1}}; \
1089 while [ "$${ALIVE}" = "YES" -a $$(($${TRYCUR})) -lt $$(($${TRYMAX})) ]; do \
1090 sleep 1; \
1091 TRYCUR=$$(($${TRYCUR}+1)); \
1092 echo -n " $${TRYCUR}"; \
1093 ${call is_alive,${1}}; \
1094 done; \
1095 echo ""; \
1096 if [ "$${ALIVE}" = "NO" ]; then \
1097 STOPPED='YES'; \
1098 fi
1099 endef
1100
1101 ifeq (${USE_MTT},YES)
1102 define rewrite
1103 $(foreach R, ${REWRITE}, MTT_${R}="${${R}}") \
1104 ${CORE_SRC}/services/mttbfr > ${PROJ_TMP}/${PROJECT}/mtt.conf && \
1105 ${CORE_SRC}/services/mttcomp < ${1} | \
1106 ${LOCAL}/bin/mtt -b ${PROJ_TMP}/${PROJECT}/mtt.conf - ${2} \
1107 && echo "created ${2} (mtt)"
1108 endef
1109 else
1110 define rewrite
1111 $(foreach R, ${REWRITE}, ${R}="${${R}}") \
1112 perl -pe 's/@([A-Z_]+)@/$$ENV{$$1}/ge' < ${1} > ${2} \
1113 && echo "created ${2} (rewrite)"
1114 endef
1115 endif
1116
1117 define rewrite_skel
1118 NAME=${NAME} \
1119 LOCAL=@LOCAL@ \
1120 CORE_USR=@CORE_USR@ \
1121 PROJ_USR=@PROJ_USR@ \
1122 PROJECT_VAR=@PROJECT_VAR@ \
1123 perl -pe 's/@([A-Z_]+)@/$$ENV{$$1}/ge' < ${1} > ${2} \
1124 && echo "created ${2}"
1125 endef
1126
1127 # rewrites values
1128 PREFIX = ${LOCAL}
1129 ROOT_LOG = ${ROOT_DIR}/var/log
1130 PGSQL_REDIRECT = ${shell perl -e 'print lc("${PGSQL_LOGGING}") eq "yes" && "on" || "off"'}
1131 ifdef PROJECT
1132 PROJECT_USR = ${PROJ_USR}/${PROJECT}
1133 PROJECT_TMP = ${PROJ_TMP}/${PROJECT}
1134 PROJECT_VAR = ${PROJ_VAR}/${PROJECT}
1135 PROJECT_LOG = ${PROJ_VAR}/${PROJECT}/log
1136 PROJECT_RUN = ${PROJ_VAR}/${PROJECT}/run
1137 endif
1138
1139 # rewrites definitions
1140 REWRITE += \
1141 AUTH_COOKIE \
1142 AUTH_MEMCACHED_BUSY_LOCK \
1143 AUTH_MEMCACHED_ENABLE \
1144 AUTH_MEMCACHED_SERVERS \
1145 BASE_HOST \
1146 BASE_PASSWD \
1147 BASE_USER \
1148 BINARY \
1149 CASCADE \
1150 COMP_CACHE_ENABLED \
1151 COMP_TIMINGS_DISABLE \
1152 364 ahitrov COMPOSITE \
1153 3 ahitrov@rambler.ru CONF \
1154 CONTENIDO_VERSION \
1155 CONVERT \
1156 CORE_COMP \
1157 CORE_SRC \
1158 CORE_VERSION \
1159 CORE_USR \
1160 CRONOLOG_ENABLE \
1161 CRONOLOG_FORMAT \
1162 CROSSLINKS \
1163 DB_TYPE \
1164 DEBUG_FORMAT \
1165 DEBUG_MIN_LEVEL \
1166 DEBUG_MAX_LEVEL \
1167 DEBUG_STACK_TRACE \
1168 DEBUG \
1169 DEBUG_CORE \
1170 DEBUG_SQL \
1171 DEBUG_WORKTIME \
1172 DEFAULT_ESCAPE_FLAGS \
1173 DEFAULT_HANDLER \
1174 DEVELOPMENT \
1175 ERROR_MODE \
1176 FILES \
1177 204 ahitrov FILE_WEB_STORAGE \
1178 3 ahitrov@rambler.ru HOSTNAME \
1179 HTTPD_DOCS \
1180 HTTPD_ELOG_LEVEL \
1181 HTTPD_PORT \
1182 HTTPD_SERVER \
1183 IMAGES \
1184 LISTEN_BACK_LOG \
1185 LOCAL \
1186 LOCALE \
1187 LOGGER \
1188 MASON_CACHE_ENABLED \
1189 MASON_COMP \
1190 MASON_MEMCACHED_BACKEND \
1191 MASON_MEMCACHED_DEBUG \
1192 MASON_MEMCACHED_ENABLED \
1193 MASON_MEMCACHED_NAMESPACE \
1194 MASON_MEMCACHED_SERVERS \
1195 MASTER_BASE_HOST \
1196 MASTER_BASE_NAME \
1197 MASTER_BASE_PASSWD \
1198 MASTER_BASE_PORT \
1199 MASTER_BASE_USER \
1200 MAX_CLIENTS \
1201 MAX_PROCESS_SIZE \
1202 MAX_REQUESTS_PER_CHILD \
1203 MAX_SPARE_SERVERS \
1204 MEMCACHED_BACKEND \
1205 MEMCACHED_DELAYED \
1206 MEMCACHED_ENABLE \
1207 MEMCACHED_ENABLE_COMPRESS \
1208 MEMCACHED_SELECT_TIMEOUT \
1209 MEMCACHED_SERVERS \
1210 MEMCACHED_SET_MODE \
1211 MIN_SPARE_SERVERS \
1212 MODULES \
1213 MULTIDOMAIN \
1214 OPTIONS_EXPIRE \
1215 PERL_LEVEL \
1216 PERL_LIB \
1217 PERSISTENT_CONN \
1218 PGSQL_BASE \
1219 PGSQL_CLIENT_ENCODING \
1220 PGSQL_PORT \
1221 PGSQL_REAL_PREPARE \
1222 PGSQL_REDIRECT \
1223 PGSQL_CLIENT_ENCODING \
1224 PGSQL_ENCODE_DATA \
1225 PGSQL_DECODE_DATA \
1226 PGSQL_ENABLE_UTF \
1227 PLUG_SRC \
1228 PLUGINS \
1229 PLUGIN_COMP \
1230 PREAMBLE_HANDLER \
1231 PREAMBLE_HANDLER_PATH \
1232 PREFIX \
1233 PRELOADS \
1234 PREVIEW \
1235 PROFILING_DBI \
1236 PROJECT \
1237 PROJECT_HOME \
1238 PROJECT_LC \
1239 PROJECT_NAME \
1240 PROJECT_LOG \
1241 PROJECT_RUN \
1242 PROJECT_TMP \
1243 PROJECT_USR \
1244 PROJECT_VAR \
1245 PROJECT_VERSION \
1246 PROJ_SRC \
1247 PROJ_USR \
1248 ROOT_LOG \
1249 READONLY \
1250 RSYSLOG_ENABLE \
1251 RSYSLOG_HOST \
1252 SERVER_ADMIN \
1253 SESSIONS \
1254 SPARE_REAPER_DELAY \
1255 SPARE_REAPER_DELAY_FAKEMOD \
1256 START_SERVERS \
1257 STATIC_SOURCE_ENABLE \
1258 STATIC_SOURCE_TOUCH_FILE \
1259 STORE_METHOD \
1260
1261 #TODO: ElTexto compatibility only
1262 REWRITE += \
1263 COMMENTS_ON_PAGE \
1264 ELTEXTO_VERSION \
1265 MEMCACHED_EXPIRE \
1266 SYNC_WITH_GROUPS \
1267 TEXTS_ON_PAGE \
1268 TEXT_IDS_IN_CACHE \
1269
1270 #TODO: Rate compatibility only
1271 REWRITE += \
1272 RATE_CLASSES \
1273 RATE_COOKIE \
1274
1275 #TODO: Search plugin compatibility only
1276 REWRITE += \
1277 SEARCH_SERVER \
1278
1279 #TODO: Util Proxy image
1280 REWRITE += \
1281 PROXY_IMAGE_LOCATION \
1282 PROXY_IMAGE_SECRET \
1283