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
63 mkdir -p $(DESTDIR)/usr/share/sfa/tests
64 install -m 755 tests/*.py $(DESTDIR)/usr/share/sfa/tests/
67 rm -rf $(DESTDIR)/usr/share/sfa/tests
69 .PHONY: tests-install tests-uninstall
71 ########## refreshing methods package metafile
72 # Metafiles - manage Legacy/ and Accessors by hand
73 init := sfa/methods/__init__.py
80 methods_now := $(sort $(shell fgrep -v '"' sfa/methods/__init__.py 2>/dev/null))
81 # what should be declared
82 methods_paths := $(filter-out %/__init__.py, $(wildcard sfa/methods/*.py))
83 methods_files := $(sort $(notdir $(methods_paths:.py=)))
85 ifneq ($(methods_now),$(methods_files))
86 sfa/methods/__init__.py: force
88 sfa/methods/__init__.py:
89 (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()') > $@
94 # a lot of stuff in the working dir is just noise
96 @find . -type f | egrep -v '^\./\.|/\.git/|/\.svn/|TAGS|AA-|~$$|egg-info|\.(py[co]|doc|html|pdf|png|svg|out|bak|dg|pickle)$$'
99 @git ls-files | egrep -v '\.(doc|html|pdf)$$'
102 $(MAKE) git-files | xargs etags
107 (cd sfa/methods; grep 'def.*call' *.py > SIGNATURES)
110 ########## for uploading onto pypi
111 # use pypitest instead for tests (both entries need to be defined in your .pypirc)
113 PYPI_TARBALL_HOST=root@build.onelab.eu
114 PYPI_TARBALL_TOPDIR=/build/sfa
116 # a quick attempt on pypitest did not quite work as expected
117 # I was hoping to register the project using "setup.py register"
118 # but somehow most of my meta data did not make it up there
119 # and I could not find out why
120 # so I went for the manual method instead
121 # there also was a web dialog prompting for a zip file that would
122 # be used to initialize the project's home dir but this too
123 # did not seem to work the way I was trying to use it, so ...
125 # this target is still helpful to produce the readme in html from README.md
126 index.zip index.html: README.md
129 # I need to run this on my mac as my pypi
130 # run git pull first as this often comes afet a module-tag
131 # we need to re-run make so the version is right
138 # run this only once the sources are in on the right tag
140 setup.py sdist upload -r $(PYPI_TARGET)
141 ssh $(PYPI_TARBALL_HOST) mkdir -p $(PYPI_TARBALL_TOPDIR)/$(VERSIONTAG)
142 rsync -av dist/sfa-$(VERSIONTAG).tar.gz $(PYPI_TARBALL_HOST):$(PYPI_TARBALL_TOPDIR)/$(VERSIONTAG)
148 rm -f index.html index.zip
151 # 2 forms are supported
152 # (*) if your plc root context has direct ssh access:
153 # make sync PLC=private.one-lab.org
154 # (*) otherwise, for test deployments, use on your testmaster
156 # and cut'n paste the export lines before you run make sync
159 SSHURL:=root@$(PLC):/
160 SSHCOMMAND:=ssh root@$(PLC)
163 SSHURL:=root@$(PLCHOSTLXC):/vservers/$(GUESTNAME)
164 SSHCOMMAND:=ssh root@$(PLCHOSTLXC) ssh -o StrictHostKeyChecking=no $(GUESTHOSTNAME)
167 SSHURL:=root@$(PLCHOSTVS):/vservers/$(GUESTNAME)
168 SSHCOMMAND:=ssh root@$(PLCHOSTVS) vserver $(GUESTNAME) exec
175 @echo "sync: I need more info from the command line, e.g."
176 @echo " make sync PLC=boot.planetlab.eu"
177 @echo " make sync PLCHOSTVS=.. GUESTNAME=.."
178 @echo " make sync PLCHOSTLXC=.. GUESTNAME=.. GUESTHOSTNAME=.."
182 LOCAL_RSYNC_EXCLUDES += --exclude '*.pyc'
183 LOCAL_RSYNC_EXCLUDES += --exclude '*.png' --exclude '*.svg' --exclude '*.out'
184 RSYNC_EXCLUDES := --exclude .svn --exclude .git --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
185 RSYNC_COND_DRY_RUN := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
186 RSYNC := rsync -a -v $(RSYNC_COND_DRY_RUN) --no-owner $(RSYNC_EXCLUDES)
188 CLIENTS = $(shell ls clientbin/*.py)
190 BINS = ./config/sfa-config-tty ./config/gen-sfa-cm-config.py \
191 ./sfa/server/sfa-start.py \
192 ./clientbin/sfaadmin.py \
196 +$(RSYNC) --relative ./sfa/ --exclude migrations $(SSHURL)/usr/lib\*/python2.\*/site-packages/
198 +$(RSYNC) --relative ./sfa/ --exclude migrations $(SSHURL)/usr/lib\*/python3.\*/site-packages/
199 synclibdeb: synccheck
200 +$(RSYNC) --relative ./sfa/ --exclude migrations $(SSHURL)/usr/share/pyshared/
202 +$(RSYNC) ./sfa/storage/migrations/versions/*.py $(SSHURL)/usr/share/sfa/migrations/versions/
204 +$(RSYNC) $(BINS) $(SSHURL)/usr/bin/
205 syncservices: synccheck
206 +$(RSYNC) ./systemd/*.service $(SSHURL)/usr/lib/systemd/system
207 +$(RSYNC) ./systemd/sfa-db-init.sh $(SSHURL)/usr/bin
209 +$(RSYNC) ./config/default_config.xml $(SSHURL)/etc/sfa/
211 +$(RSYNC) ./tests/ $(SSHURL)/root/tests-sfa
212 syncrestart: synccheck
213 -$(SSHCOMMAND) systemctl --system daemon-reload
214 $(SSHCOMMAND) service sfa restart
217 +$(RSYNC) ./sfa/storage/migrations $(SSHURL)/usr/share/sfa/
221 sync: synclib syncbin syncservices syncconfig syncrestart
222 syncdeb: synclibdeb syncbin syncservices syncconfig syncrestart
223 # 99% of the time this is enough
224 syncfast: synclib syncrestart
226 .PHONY: synccheck synclib syncbin syncconfig synctest syncrestart sync syncfast
230 sfa/examples/miniclient.py \
232 sfa/client/{sfaserverproxy,sfaclientlib,__init__}.py \
233 sfa/trust/{certificate,__init__}.py \
234 sfa/util/{sfalogging,faults,genicode,enumeration,__init__}.py
237 @[ -d "$(CLIENTLIBTARGET)" ] || { echo "You need to set the make variable CLIENTLIBTARGET"; exit 1; }
238 rsync -av --relative $(CLIENTLIBFILES) $(CLIENTLIBTARGET)
240 #################### convenience, for debugging only
241 # make +foo : prints the value of $(foo)
242 # make ++foo : idem but verbose, i.e. foo=$(foo)
243 ++%: varname=$(subst +,,$@)
245 @echo "$(varname)=$($(varname))"
246 +%: varname=$(subst +,,$@)
248 @echo "$($(varname))"