summaryrefslogtreecommitdiffstats
path: root/encap/src/bcfg2-site/Makefile
blob: 52b688a1331dc74dad044a415105a70fbc82e65d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# $Id$

# Variables

PATH = /usr/local/lib/bcfg2/bin:/usr/local/bin:/usr/bin:/bin
CHEETAH = /usr/local/lib/bcfg2/bin/cheetah

# Main

.PHONY : all clean distclean fill copy fix encap install test cheetah
.SUFFIXES : 

BD = /usr/local
ED = ${BD}/encap
export ED

all : encap

clean :
	for DIR in `find . -type d | grep -v "\.svn"`; do \
		for GLOB in \#\* \*\~ \*.out\*; do \
			(rm $${DIR}/$${GLOB} 2>/dev/null || true); \
		done; \
	done

distclean : clean
	-rm *-encap-*.tar.gz

fill : clean
	$(CHEETAH) fill -R --oext out

copy : fill
	EN=`cat bcfg2-site-RENAME/encapname.out` && \
	( test ! -d $(ED)/bcfg2-site-$${EN} || rm -rf $(ED)/bcfg2-site-$${EN} ) && \
	for SRC in `find bcfg2-site-RENAME | grep -v svn | grep -v tmpl`; do \
		DEST=$(ED)/`printf "%s\n" "$$SRC" | sed s/RENAME/$$EN/g | sed s/\.out//g`; \
		if [ -d $$SRC ]; then mkdir $$DEST; else cp $$SRC $$DEST; fi; \
	done		

fix : copy
	EN="$(ED)/bcfg2-site-`cat bcfg2-site-RENAME/encapname.out`" && \
	chown -R 0 $$EN && chgrp -R 0 $$EN && \
	find $$EN -type d | xargs -n1 chmod 0755 && \
	find $$EN -type f | xargs -n1 chmod 0644 && \
	chmod 0600 $$EN/etc/ostiary.cfg && \
	chmod 0600 $$EN/etc/bcfg2.conf && \
	chmod 0755 $$EN/sbin/ost-bcfg2.sh && \
	chmod 0755 $$EN/postinstall

encap : fix
	EN="bcfg2-site-`cat bcfg2-site-RENAME/encapname.out`" && \
	cd $(ED) && \
	( test ! -f $${EN}-encap-*.tar.gz || rm $${EN}-encap-*.tar.gz ) && \
	mkencap -c $$EN
	EN="bcfg2-site-`cat bcfg2-site-RENAME/encapname.out`" && \
	mv $(ED)/$${EN}-encap-*.tar.gz ./
    
install : fix
	-(EN="bcfg2-site-`cat bcfg2-site-RENAME/encapname.out`" && \
	epkg -q -r $(ED)/$$EN)
	EN="bcfg2-site-`cat bcfg2-site-RENAME/encapname.out`" && \
	cd $(ED) && \
	epkg -q -i $(ED)/$$EN && \
	test -h $(BD)/var/encap/$$EN

test :
	: $(PATH)
	$(CHEETAH) test
	
cheetah :
	$(CHEETAH) $(ARGS)