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

Небольшая справка по веткам

cnddist – контейнер, в котором хранятся все дистрибутивы всех библиотек и программных пакетов, которые использовались при построении различных версий Contenido. Если какой-то библиотеки в данном хранилище нет, инсталлятор сделает попытку "подтянуть" ее с веба (например, с CPAN). Если библиотека слишком старая, есть очень большая вероятность, что ее там уже нет. Поэтому мы храним весь хлам от всех сборок. Если какой-то дистрибутив вдруг отсутствует в cnddist - напишите нам, мы положим его туда.

koi8 – отмирающая ветка, чей код, выдача и все внутренние библиотеки заточены на кодировку KOI8-R. Вносятся только те дополнения, которые касаются внешнего вида и функционала админки, баги ядра, обязательные обновления портов и мелочи, которые легко скопипастить. В дальнейшем планируется полная остановка поддержки по данной ветке.

utf8 – актуальная ветка, заточенная под UTF-8.

Внутри каждой ветки: core – исходники ядра; install – скрипт установки инсталляции; plugins – плагины; samples – "готовые к употреблению" проекты, которые можно поставить, запустить и посмотреть, как они работают.