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 # in general overridden (set by the specfile); but can be called right away
20 RPMVERSION:=$(shell rpm -q --specfile sfa.spec --queryformat="%{version}\n" | head -1)
21 # somehow %{taglevel} is empty, turns out %{release} has what we want
22 RPMRELEASE:=$(shell rpm -q --specfile sfa.spec --queryformat="%{release}\n" 2> /dev/null | head -1)
23 VERSIONTAG=$(RPMVERSION)-$(RPMRELEASE)
24 SCMURL=should-be-redefined-by-specfile
28 version: sfa/util/version.py
29 sfa/util/version.py: sfa/util/version.py.in
30 sed -e "s,@VERSIONTAG@,$(VERSIONTAG),g" -e "s,@SCMURL@,$(SCMURL),g" sfa/util/version.py.in > $@
33 cd xmlbuilder-0.9 && python setup.py install --prefix=$(PREFIX) --root=$(DESTDIR) && cd -
34 rm -rf $(DESTDIR)/usr/lib*/python*/site-packages/*egg-info
36 # postinstall steps - various cleanups and tweaks for a nicer rpm
38 python setup.py install --prefix=$(PREFIX) --root=$(DESTDIR)
39 chmod 444 $(DESTDIR)/etc/sfa/default_config.xml
40 rm -rf $(DESTDIR)/usr/lib*/python*/site-packages/*egg-info
41 rm -rf $(DESTDIR)/usr/lib*/python*/site-packages/sfa/storage/migrations
42 (cd $(DESTDIR)/usr/bin ; ln -s sfi.py sfi; ln -s sfascan.py sfascan; ln -s sfaadmin.py sfaadmin)
44 python-clean: version-clean
49 rm -f sfa/util/version.py
51 .PHONY: python version python-install python-clean version-clean xmlbuilder-install
56 # propagate DESTDIR from the specfile
58 $(MAKE) -C wsdl install
63 .PHONY: wsdl wsdl-install wsdl-clean
65 ######################################## debian packaging
66 # The 'debian' target is called from the build with the following variables set
67 # (see build/Makefile and target_debian)
74 DEBVERSION=$(RPMVERSION).$(RPMRELEASE)
75 DEBTARBALL=../$(PROJECT)_$(DEBVERSION).orig.tar.bz2
77 DATE=$(shell date -u +"%a, %d %b %Y %T")
79 debian: debian/changelog debian.source debian.package
81 debian/changelog: debian/changelog.in
82 sed -e "s|@VERSION@|$(DEBVERSION)|" -e "s|@DATE@|$(DATE)|" debian/changelog.in > debian/changelog
85 rsync -a $(RPMTARBALL) $(DEBTARBALL)
91 $(MAKE) -f debian/rules clean
92 rm -rf build/ MANIFEST ../*.tar.gz ../*.dsc ../*.build
93 find . -name '*.pyc' -delete
97 mkdir -p $(DESTDIR)/usr/share/sfa/tests
98 install -m 755 tests/*.py $(DESTDIR)/usr/share/sfa/tests/
101 rm -rf $(DESTDIR)/usr/share/sfa/tests
103 .PHONY: tests-install tests-uninstall
105 ########## refreshing methods package metafile
106 # Metafiles - manage Legacy/ and Accessors by hand
107 init := sfa/methods/__init__.py
114 methods_now := $(sort $(shell fgrep -v '"' sfa/methods/__init__.py 2>/dev/null))
115 # what should be declared
116 methods_paths := $(filter-out %/__init__.py, $(wildcard sfa/methods/*.py))
117 methods_files := $(sort $(notdir $(methods_paths:.py=)))
119 ifneq ($(methods_now),$(methods_files))
120 sfa/methods/__init__.py: force
122 sfa/methods/__init__.py:
123 (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()') > $@
128 # a lot of stuff in the working dir is just noise
130 @find . -type f | egrep -v '^\./\.|/\.git/|/\.svn/|TAGS|AA-|~$$|egg-info|\.(py[co]|doc|html|pdf|png|svg|out|bak|dg|pickle)$$'
132 $(MAKE) scan | xargs etags
137 (cd sfa/methods; grep 'def.*call' *.py > SIGNATURES)
141 # 2 forms are supported
142 # (*) if your plc root context has direct ssh access:
143 # make sync PLC=private.one-lab.org
144 # (*) otherwise, for test deployments, use on your testmaster
146 # and cut'n paste the export lines before you run make sync
149 SSHURL:=root@$(PLC):/
150 SSHCOMMAND:=ssh root@$(PLC)
153 SSHURL:=root@$(PLCHOSTLXC):/var/lib/lxc/$(GUESTNAME)/rootfs
154 SSHCOMMAND:=ssh root@$(PLCHOSTLXC) ssh $(GUESTHOSTNAME)
157 SSHURL:=root@$(PLCHOSTVS):/vservers/$(GUESTNAME)
158 SSHCOMMAND:=ssh root@$(PLCHOSTVS) vserver $(GUESTNAME) exec
165 @echo "sync: I need more info from the command line, e.g."
166 @echo " make sync PLC=boot.planetlab.eu"
167 @echo " make sync PLCHOSTVS=.. GUESTNAME=.."
168 @echo " make sync PLCHOSTLXC=.. GUESTNAME=.. GUESTHOSTNAME=.."
172 LOCAL_RSYNC_EXCLUDES += --exclude '*.pyc'
173 LOCAL_RSYNC_EXCLUDES += --exclude '*.png' --exclude '*.svg' --exclude '*.out'
174 RSYNC_EXCLUDES := --exclude .svn --exclude .git --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
175 RSYNC_COND_DRY_RUN := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
176 RSYNC := rsync -a -v $(RSYNC_COND_DRY_RUN) --no-owner $(RSYNC_EXCLUDES)
178 CLIENTS = $(shell ls clientbin/*.py)
180 BINS = ./config/sfa-config-tty ./config/gen-sfa-cm-config.py \
181 ./sfa/server/sfa-start.py \
182 ./clientbin/sfaadmin.py \
186 +$(RSYNC) --relative ./sfa/ --exclude migrations $(SSHURL)/usr/lib\*/python2.\*/site-packages/
187 synclibdeb: synccheck
188 +$(RSYNC) --relative ./sfa/ --exclude migrations $(SSHURL)/usr/share/pyshared/
190 +$(RSYNC) $(BINS) $(SSHURL)/usr/bin/
192 +$(RSYNC) ./init.d/sfa $(SSHURL)/etc/init.d/
194 +$(RSYNC) ./config/default_config.xml $(SSHURL)/etc/sfa/
196 +$(RSYNC) ./tests/ $(SSHURL)/root/tests-sfa
197 syncrestart: synccheck
198 $(SSHCOMMAND) service sfa restart
201 +$(RSYNC) ./sfa/storage/migrations $(SSHURL)/usr/share/sfa/
205 sync: synclib syncbin syncinit syncconfig syncrestart
206 syncdeb: synclibdeb syncbin syncinit syncconfig syncrestart
207 # 99% of the time this is enough
208 syncfast: synclib syncrestart
210 .PHONY: synccheck synclib syncbin syncconfig synctest syncrestart sync syncfast
214 sfa/examples/miniclient.py \
216 sfa/client/{sfaserverproxy,sfaclientlib,__init__}.py \
217 sfa/trust/{certificate,__init__}.py \
218 sfa/util/{sfalogging,faults,genicode,enumeration,__init__}.py
221 @[ -d "$(CLIENTLIBTARGET)" ] || { echo "You need to set the make variable CLIENTLIBTARGET"; exit 1; }
222 rsync -av --relative $(CLIENTLIBFILES) $(CLIENTLIBTARGET)