2 ## (Re)builds Python metafile (__init__.py)
4 # overwritten by the specfile
10 install: python-install wsdl-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 # this used to be 'should-be-redefined-by-specfile' and it indeed should be
24 SCMURL=git://git.onelab.eu/sfa.git
28 version: sfa/util/version.py
29 sfa/util/version.py: sfa/util/version.py.in force
30 sed -e "s,@VERSIONTAG@,$(VERSIONTAG),g" -e "s,@SCMURL@,$(SCMURL),g" sfa/util/version.py.in > $@
32 # postinstall steps - various cleanups and tweaks for a nicer rpm
34 python setup.py install --prefix=$(PREFIX) --root=$(DESTDIR)
35 chmod 444 $(DESTDIR)/etc/sfa/default_config.xml
36 rm -rf $(DESTDIR)/usr/lib*/python*/site-packages/*egg-info
37 rm -rf $(DESTDIR)/usr/lib*/python*/site-packages/sfa/storage/migrations
38 (cd $(DESTDIR)/usr/bin ; ln -s sfi.py sfi; ln -s sfascan.py sfascan; ln -s sfaadmin.py sfaadmin)
40 python-clean: version-clean
45 rm -f sfa/util/version.py
47 .PHONY: python version python-install python-clean version-clean
52 # propagate DESTDIR from the specfile
54 $(MAKE) -C wsdl install
59 .PHONY: wsdl wsdl-install wsdl-clean
61 ######################################## debian packaging
62 # The 'debian' target is called from the build with the following variables set
63 # (see build/Makefile and target_debian)
70 DEBVERSION=$(RPMVERSION).$(RPMRELEASE)
71 DEBTARBALL=../$(PROJECT)_$(DEBVERSION).orig.tar.bz2
73 DATE=$(shell date -u +"%a, %d %b %Y %T")
75 debian: debian/changelog debian.source debian.package
77 debian/changelog: debian/changelog.in
78 sed -e "s|@VERSION@|$(DEBVERSION)|" -e "s|@DATE@|$(DATE)|" debian/changelog.in > debian/changelog
81 rsync -a $(RPMTARBALL) $(DEBTARBALL)
87 $(MAKE) -f debian/rules clean
88 rm -rf build/ MANIFEST ../*.tar.gz ../*.dsc ../*.build
89 find . -name '*.pyc' -delete
93 mkdir -p $(DESTDIR)/usr/share/sfa/tests
94 install -m 755 tests/*.py $(DESTDIR)/usr/share/sfa/tests/
97 rm -rf $(DESTDIR)/usr/share/sfa/tests
99 .PHONY: tests-install tests-uninstall
101 ########## refreshing methods package metafile
102 # Metafiles - manage Legacy/ and Accessors by hand
103 init := sfa/methods/__init__.py
110 methods_now := $(sort $(shell fgrep -v '"' sfa/methods/__init__.py 2>/dev/null))
111 # what should be declared
112 methods_paths := $(filter-out %/__init__.py, $(wildcard sfa/methods/*.py))
113 methods_files := $(sort $(notdir $(methods_paths:.py=)))
115 ifneq ($(methods_now),$(methods_files))
116 sfa/methods/__init__.py: force
118 sfa/methods/__init__.py:
119 (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()') > $@
124 # a lot of stuff in the working dir is just noise
126 @find . -type f | egrep -v '^\./\.|/\.git/|/\.svn/|TAGS|AA-|~$$|egg-info|\.(py[co]|doc|html|pdf|png|svg|out|bak|dg|pickle)$$'
129 @git ls-files | grep -v '\.doc$$'
132 $(MAKE) git-files | xargs etags
137 (cd sfa/methods; grep 'def.*call' *.py > SIGNATURES)
140 ########## for uploading onto pypi
141 # use pypitest instead for tests (both entries need to be defined in your .pypirc)
143 PYPI_TARBALL_HOST=root@build.onelab.eu
144 PYPI_TARBALL_TOPDIR=/build/sfa
146 # a quick attempt on pypitest did not quite work as expected
147 # I was hoping to register the project using "setup.py register"
148 # but somehow most of my meta data did not make it up there
149 # and I could not find out why
150 # so I went for the manual method instead
151 # there also was a web dialog prompting for a zip file that would
152 # be used to initialize the project's home dir but this too
153 # did not seem to work the way I was trying to use it, so ...
155 # this target is still helpful to produce the readme in html from README.md
156 index.zip index.html: README.md
159 # I need to run this on my mac as my pypi
160 # run git pull first as this often comes afet a module-tag
161 # we need to re-run make so the version is right
168 # run this only once the sources are in on the right tag
170 setup.py sdist upload -r $(PYPI_TARGET)
171 ssh $(PYPI_TARBALL_HOST) mkdir -p $(PYPI_TARBALL_TOPDIR)/$(VERSIONTAG)
172 rsync -av dist/sfa-$(VERSIONTAG).tar.gz $(PYPI_TARBALL_HOST):$(PYPI_TARBALL_TOPDIR)/$(VERSIONTAG)
178 rm -f index.html index.zip
181 # 2 forms are supported
182 # (*) if your plc root context has direct ssh access:
183 # make sync PLC=private.one-lab.org
184 # (*) otherwise, for test deployments, use on your testmaster
186 # and cut'n paste the export lines before you run make sync
189 SSHURL:=root@$(PLC):/
190 SSHCOMMAND:=ssh root@$(PLC)
193 SSHURL:=root@$(PLCHOSTLXC):/vservers/$(GUESTNAME)
194 SSHCOMMAND:=ssh root@$(PLCHOSTLXC) ssh -o StrictHostKeyChecking=no $(GUESTHOSTNAME)
197 SSHURL:=root@$(PLCHOSTVS):/vservers/$(GUESTNAME)
198 SSHCOMMAND:=ssh root@$(PLCHOSTVS) vserver $(GUESTNAME) exec
205 @echo "sync: I need more info from the command line, e.g."
206 @echo " make sync PLC=boot.planetlab.eu"
207 @echo " make sync PLCHOSTVS=.. GUESTNAME=.."
208 @echo " make sync PLCHOSTLXC=.. GUESTNAME=.. GUESTHOSTNAME=.."
212 LOCAL_RSYNC_EXCLUDES += --exclude '*.pyc'
213 LOCAL_RSYNC_EXCLUDES += --exclude '*.png' --exclude '*.svg' --exclude '*.out'
214 RSYNC_EXCLUDES := --exclude .svn --exclude .git --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
215 RSYNC_COND_DRY_RUN := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
216 RSYNC := rsync -a -v $(RSYNC_COND_DRY_RUN) --no-owner $(RSYNC_EXCLUDES)
218 CLIENTS = $(shell ls clientbin/*.py)
220 BINS = ./config/sfa-config-tty ./config/gen-sfa-cm-config.py \
221 ./sfa/server/sfa-start.py \
222 ./clientbin/sfaadmin.py \
226 +$(RSYNC) --relative ./sfa/ --exclude migrations $(SSHURL)/usr/lib\*/python2.\*/site-packages/
227 synclibdeb: synccheck
228 +$(RSYNC) --relative ./sfa/ --exclude migrations $(SSHURL)/usr/share/pyshared/
230 +$(RSYNC) ./sfa/storage/migrations/versions/*.py $(SSHURL)/usr/share/sfa/migrations/versions/
232 +$(RSYNC) $(BINS) $(SSHURL)/usr/bin/
234 +$(RSYNC) ./init.d/sfa $(SSHURL)/etc/init.d/
236 +$(RSYNC) ./config/default_config.xml $(SSHURL)/etc/sfa/
238 +$(RSYNC) ./tests/ $(SSHURL)/root/tests-sfa
239 syncrestart: synccheck
240 -$(SSHCOMMAND) systemctl --system daemon-reload
241 $(SSHCOMMAND) service sfa restart
244 +$(RSYNC) ./sfa/storage/migrations $(SSHURL)/usr/share/sfa/
248 sync: synclib syncbin syncinit syncconfig syncrestart
249 syncdeb: synclibdeb syncbin syncinit syncconfig syncrestart
250 # 99% of the time this is enough
251 syncfast: synclib syncrestart
253 .PHONY: synccheck synclib syncbin syncconfig synctest syncrestart sync syncfast
257 sfa/examples/miniclient.py \
259 sfa/client/{sfaserverproxy,sfaclientlib,__init__}.py \
260 sfa/trust/{certificate,__init__}.py \
261 sfa/util/{sfalogging,faults,genicode,enumeration,__init__}.py
264 @[ -d "$(CLIENTLIBTARGET)" ] || { echo "You need to set the make variable CLIENTLIBTARGET"; exit 1; }
265 rsync -av --relative $(CLIENTLIBFILES) $(CLIENTLIBTARGET)
267 #################### convenience, for debugging only
268 # make +foo : prints the value of $(foo)
269 # make ++foo : idem but verbose, i.e. foo=$(foo)
270 ++%: varname=$(subst +,,$@)
272 @echo "$(varname)=$($(varname))"
273 +%: varname=$(subst +,,$@)
275 @echo "$($(varname))"