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