2 ## (Re)builds Python metafile (__init__.py)
4 # overwritten by the specfile
10 install: python-install tests-install
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 python3 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
41 python3 setup.py clean
45 rm -f sfa/util/version.py
47 .PHONY: python version python-install python-clean version-clean
51 mkdir -p $(DESTDIR)/usr/share/sfa/tests
52 install -m 755 tests/*.py $(DESTDIR)/usr/share/sfa/tests/
55 rm -rf $(DESTDIR)/usr/share/sfa/tests
57 .PHONY: tests-install tests-uninstall
59 ########## refreshing methods package metafile
60 # Metafiles - manage Legacy/ and Accessors by hand
61 init := sfa/methods/__init__.py
68 methods_now := $(sort $(shell fgrep -v '"' sfa/methods/__init__.py 2>/dev/null))
69 # what should be declared
70 methods_paths := $(filter-out %/__init__.py, $(wildcard sfa/methods/*.py))
71 methods_files := $(sort $(notdir $(methods_paths:.py=)))
73 ifneq ($(methods_now),$(methods_files))
74 sfa/methods/__init__.py: force
76 sfa/methods/__init__.py:
77 (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()') > $@
82 # a lot of stuff in the working dir is just noise
84 @find . -type f | egrep -v '^\./\.|/\.git/|/\.svn/|TAGS|AA-|~$$|egg-info|\.(py[co]|doc|html|pdf|png|svg|out|bak|dg|pickle)$$'
87 @git ls-files | egrep -v '\.(doc|html|pdf)$$'
90 $(MAKE) git-files | xargs etags
95 (cd sfa/methods; grep 'def.*call' *.py > SIGNATURES)
98 ########## for uploading onto pypi
99 # use pypitest instead for tests (both entries need to be defined in your .pypirc)
101 PYPI_TARBALL_HOST=root@build.onelab.eu
102 PYPI_TARBALL_TOPDIR=/build/sfa
104 # a quick attempt on pypitest did not quite work as expected
105 # I was hoping to register the project using "setup.py register"
106 # but somehow most of my meta data did not make it up there
107 # and I could not find out why
108 # so I went for the manual method instead
109 # there also was a web dialog prompting for a zip file that would
110 # be used to initialize the project's home dir but this too
111 # did not seem to work the way I was trying to use it, so ...
113 # this target is still helpful to produce the readme in html from README.md
114 index.zip index.html: README.md
117 # I need to run this on my mac as my pypi
118 # run git pull first as this often comes afet a module-tag
119 # we need to re-run make so the version is right
126 # run this only once the sources are in on the right tag
128 setup.py sdist upload -r $(PYPI_TARGET)
129 ssh $(PYPI_TARBALL_HOST) mkdir -p $(PYPI_TARBALL_TOPDIR)/$(VERSIONTAG)
130 rsync -ai dist/sfa-$(VERSIONTAG).tar.gz $(PYPI_TARBALL_HOST):$(PYPI_TARBALL_TOPDIR)/$(VERSIONTAG)
136 rm -f index.html index.zip
139 # 2 forms are supported
140 # (*) if your plc root context has direct ssh access:
141 # make sync PLC=private.one-lab.org
142 # (*) otherwise, for test deployments, use on your testmaster
144 # and cut'n paste the export lines before you run make sync
147 SSHURL:=root@$(PLC):/
148 SSHCOMMAND:=ssh root@$(PLC)
151 SSHURL:=root@$(PLCHOSTLXC):/vservers/$(GUESTNAME)
152 SSHCOMMAND:=ssh root@$(PLCHOSTLXC) ssh -o StrictHostKeyChecking=no $(GUESTHOSTNAME)
155 SSHURL:=root@$(PLCHOSTVS):/vservers/$(GUESTNAME)
156 SSHCOMMAND:=ssh root@$(PLCHOSTVS) vserver $(GUESTNAME) exec
163 @echo "sync: I need more info from the command line, e.g."
164 @echo " make sync PLC=boot.planetlab.eu"
165 @echo " make sync PLCHOSTVS=.. GUESTNAME=.."
166 @echo " make sync PLCHOSTLXC=.. GUESTNAME=.. GUESTHOSTNAME=.."
170 LOCAL_RSYNC_EXCLUDES += --exclude '*.pyc'
171 LOCAL_RSYNC_EXCLUDES += --exclude '*.png' --exclude '*.svg' --exclude '*.out'
172 RSYNC_EXCLUDES := --exclude .svn --exclude .git --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
173 RSYNC_COND_DRY_RUN := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
174 RSYNC := rsync -ai $(RSYNC_COND_DRY_RUN) --no-owner $(RSYNC_EXCLUDES)
176 CLIENTS = $(shell ls clientbin/*.py)
178 BINS = ./config/sfa-config-tty ./systemd/sfa-setup.sh \
179 ./sfa/server/sfa-start.py ./clientbin/sfaadmin.py keyconvert/keyconvert.py \
183 +$(RSYNC) --relative ./sfa/ --exclude migrations $(SSHURL)/usr/lib\*/python3.\*/site-packages/
185 +$(RSYNC) ./sfa/storage/migrations/versions/*.py $(SSHURL)/usr/share/sfa/migrations/versions/
187 +$(RSYNC) $(BINS) $(SSHURL)/usr/bin/
188 syncservices: synccheck
189 +$(RSYNC) ./systemd/*.service $(SSHURL)/lib/systemd/system
190 +$(RSYNC) ./systemd/sfa-setup.sh $(SSHURL)/usr/bin
192 +$(RSYNC) ./config/default_config.xml $(SSHURL)/etc/sfa/
194 +$(RSYNC) ./tests/ $(SSHURL)/root/tests-sfa
195 syncrestart: synccheck
196 -$(SSHCOMMAND) systemctl --system daemon-reload
197 $(SSHCOMMAND) systemctl restart sfa-db
198 $(SSHCOMMAND) systemctl restart sfa-aggregate
201 +$(RSYNC) ./sfa/storage/migrations $(SSHURL)/usr/share/sfa/
205 sync: synclib syncbin syncservices syncconfig syncrestart
206 syncdeb: synclibdeb syncbin syncservices 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 -ai --relative $(CLIENTLIBFILES) $(CLIENTLIBTARGET)
224 #################### convenience, for debugging only
225 # make +foo : prints the value of $(foo)
226 # make ++foo : idem but verbose, i.e. foo=$(foo)
227 ++%: varname=$(subst +,,$@)
229 @echo "$(varname)=$($(varname))"
230 +%: varname=$(subst +,,$@)
232 @echo "$($(varname))"