2 ## (Re)builds Python metafile (__init__.py)
4 # overwritten by the specfile
10 install: python-install wsdl-install xmlbuilder-install tests-install
12 clean: python-clean wsdl-clean
14 uninstall: python-uninstall tests-uninstall
16 .PHONY: all install clean uninstall
19 rpmversion:=$(shell rpm -q --specfile sfa.spec --queryformat="%{version}\n" | head -1)
20 # somehow %{taglevel} is empty, turns out %{release} has what we want
21 rpmtaglevel:=$(shell rpm -q --specfile sfa.spec --queryformat="%{release}\n" 2> /dev/null | head -1)
22 VERSIONTAG=$(rpmversion)-$(rpmtaglevel)
23 SCMURL=should-be-redefined-by-specfile
27 version: sfa/util/version.py
28 sfa/util/version.py: sfa/util/version.py.in
29 sed -e "s,@VERSIONTAG@,$(VERSIONTAG),g" -e "s,@SCMURL@,$(SCMURL),g" sfa/util/version.py.in > $@
32 cd xmlbuilder-0.9 && python setup.py install --root=$(DESTDIR) && cd -
33 rm -rf $(DESTDIR)/usr/lib*/python*/site-packages/*egg-info
35 # postinstall steps - various cleanups and tweaks for a nicer rpm
37 python setup.py install --root=$(DESTDIR)
38 chmod 444 $(DESTDIR)/etc/sfa/default_config.xml
39 rm -rf $(DESTDIR)/usr/lib*/python*/site-packages/*egg-info
40 rm -rf $(DESTDIR)/usr/lib*/python*/site-packages/sfa/storage/migrations
41 (cd $(DESTDIR)/usr/bin ; ln -s sfi.py sfi; ln -s sfascan.py sfascan; ln -s sfaadmin.py sfaadmin)
43 python-clean: version-clean
48 rm -f sfa/util/version.py
50 .PHONY: python version python-install python-clean version-clean xmlbuilder-install
55 # propagate DESTDIR from the specfile
57 $(MAKE) -C wsdl install
62 .PHONY: wsdl wsdl-install wsdl-clean
66 mkdir -p $(DESTDIR)/usr/share/sfa/tests
67 install -m 755 tests/*.py $(DESTDIR)/usr/share/sfa/tests/
70 rm -rf $(DESTDIR)/usr/share/sfa/tests
72 .PHONY: tests-install tests-uninstall
74 ########## refreshing methods package metafile
75 # Metafiles - manage Legacy/ and Accessors by hand
76 init := sfa/methods/__init__.py
83 methods_now := $(sort $(shell fgrep -v '"' sfa/methods/__init__.py 2>/dev/null))
84 # what should be declared
85 methods_paths := $(filter-out %/__init__.py, $(wildcard sfa/methods/*.py))
86 methods_files := $(sort $(notdir $(methods_paths:.py=)))
88 ifneq ($(methods_now),$(methods_files))
89 sfa/methods/__init__.py: force
91 sfa/methods/__init__.py:
92 (echo '## Please use make index to update this file' ; echo 'all = """' ; cd sfa/methods; ls -1 *.py | grep -v __init__ | sed -e 's,.py$$,,' ; echo '""".split()') > $@
97 # a lot of stuff in the working dir is just noise
99 @find . -type f | egrep -v '^\./\.|/\.git/|/\.svn/|TAGS|AA-|~$$|egg-info|\.(py[co]|doc|html|pdf|png|svg|out|bak|dg|pickle)$$'
101 $(MAKE) scan | xargs etags
106 (cd sfa/methods; grep 'def.*call' *.py > SIGNATURES)
110 # 2 forms are supported
111 # (*) if your plc root context has direct ssh access:
112 # make sync PLC=private.one-lab.org
113 # (*) otherwise, for test deployments, use on your testmaster
115 # and cut'n paste the export lines before you run make sync
118 SSHURL:=root@$(PLC):/
119 SSHCOMMAND:=ssh root@$(PLC)
122 SSHURL:=root@$(PLCHOSTLXC):/var/lib/lxc/$(GUESTNAME)/rootfs
123 SSHCOMMAND:=ssh root@$(PLCHOSTLXC) ssh $(GUESTHOSTNAME)
126 SSHURL:=root@$(PLCHOSTVS):/vservers/$(GUESTNAME)
127 SSHCOMMAND:=ssh root@$(PLCHOSTVS) vserver $(GUESTNAME) exec
134 @echo "sync: I need more info from the command line, e.g."
135 @echo " make sync PLC=boot.planetlab.eu"
136 @echo " make sync PLCHOSTVS=.. GUESTNAME=.."
137 @echo " make sync PLCHOSTLXC=.. GUESTNAME=.. GUESTHOSTNAME=.."
141 LOCAL_RSYNC_EXCLUDES += --exclude '*.pyc'
142 LOCAL_RSYNC_EXCLUDES += --exclude '*.png' --exclude '*.svg' --exclude '*.out'
143 RSYNC_EXCLUDES := --exclude .svn --exclude .git --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
144 RSYNC_COND_DRY_RUN := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
145 RSYNC := rsync -a -v $(RSYNC_COND_DRY_RUN) --no-owner $(RSYNC_EXCLUDES)
147 CLIENTS = $(shell ls clientbin/*.py)
149 BINS = ./config/sfa-config-tty ./config/gen-sfa-cm-config.py \
150 ./sfa/server/sfa-start.py \
151 ./clientbin/sfaadmin.py \
155 +$(RSYNC) --relative ./sfa/ --exclude migrations $(SSHURL)/usr/lib\*/python2.\*/site-packages/
157 +$(RSYNC) $(BINS) $(SSHURL)/usr/bin/
159 +$(RSYNC) ./init.d/sfa $(SSHURL)/etc/init.d/
161 +$(RSYNC) ./config/default_config.xml $(SSHURL)/etc/sfa/
163 +$(RSYNC) ./tests/ $(SSHURL)/root/tests-sfa
164 syncrestart: synccheck
165 $(SSHCOMMAND) service sfa restart
168 +$(RSYNC) ./sfa/storage/migrations $(SSHURL)/usr/share/sfa/
172 sync: synclib syncbin syncinit syncconfig syncrestart
173 # 99% of the time this is enough
174 syncfast: synclib syncrestart
176 .PHONY: synccheck synclib syncbin syncconfig synctest syncrestart sync syncfast
180 sfa/examples/miniclient.py \
182 sfa/client/{sfaserverproxy,sfaclientlib,__init__}.py \
183 sfa/trust/{certificate,__init__}.py \
184 sfa/util/{sfalogging,faults,genicode,enumeration,__init__}.py
187 @[ -d "$(CLIENTLIBTARGET)" ] || { echo "You need to set the make variable CLIENTLIBTARGET"; exit 1; }
188 rsync -av --relative $(CLIENTLIBFILES) $(CLIENTLIBTARGET)