fix packaging for f37 (2/n)
[plcapi.git] / Makefile
index 885da21..87ce913 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,6 @@
 # starting with 5.0, support for these two modules is taken out
 
 # Other stuff - doc not implicit, it's redone by myplc-docs
-subdirs := php/xmlrpc
 
 # autoconf compatible variables
 DESTDIR := /
@@ -19,24 +18,35 @@ bindir := /usr/bin
 
 PWD := $(shell pwd)
 
-all: $(subdirs) 
-       python setup.py build
-
-install: 
-       python setup.py install \
-           --install-purelib=$(DESTDIR)/$(datadir)/plc_api \
-           --install-scripts=$(DESTDIR)/$(datadir)/plc_api \
-           --install-data=$(DESTDIR)/$(datadir)/plc_api
-       install -D -m 755 php/xmlrpc/xmlrpc.so $(DESTDIR)/$(shell php-config --extension-dir)/xmlrpc.so
-
-$(subdirs): %:
-       $(MAKE) -C $@
-
-clean: 
+all:
+       python3 setup.py build
+
+install: install-python install-phpxmlrpc
+
+install-python:
+       # we mention --upgrade because otherwise
+       # pip install complains the php/ target already exists
+       # and it refuses to put plc_api.php in there
+       pip install --upgrade --target $(DESTDIR)/$(datadir)/plc_api .
+       # it's important that plcsh sits in /usr/share/plc_api
+       # and not under bin/ so that python can find the PLC/ modules
+       mv $(DESTDIR)/$(datadir)/plc_api/bin/plcsh $(DESTDIR)/$(datadir)/plc_api
+       mv $(DESTDIR)/$(datadir)/plc_api/bin/Server.py $(DESTDIR)/$(datadir)/Server.py
+       # the old recipe used to read
+       # python3 setup.py install \
+       #     --install-purelib=$(DESTDIR)/$(datadir)/plc_api \
+       #     --install-scripts=$(DESTDIR)/$(datadir)/plc_api \
+       #     --install-data=$(DESTDIR)/$(datadir)/plc_api
+
+# phpxmlrpc is a git subtree; we just ship all its contents
+# under /usr/share/plc_api/php/phpxmlrpc
+install-phpxmlrpc:
+       mkdir -p $(DESTDIR)/$(datadir)/plc_api/php/phpxmlrpc/
+       rsync --exclude .git -ai php/phpxmlrpc/ $(DESTDIR)/$(datadir)/plc_api/php/phpxmlrpc/
+
+clean:
        find . -name '*.pyc' | xargs rm -f
-       rm -f $(INIT)
-       for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir clean ; done
-       python setup.py clean && rm -rf build
+       python3 setup.py clean && rm -rf build
 
 index:
        echo "This step is obsolete"
@@ -45,7 +55,7 @@ index:
 
 force:
 
-.PHONY: all install force clean index tags $(subdirs)
+.PHONY: all install force clean index tags
 
 #################### devel tools
 tags:
@@ -67,26 +77,27 @@ SSHCOMMAND:=ssh root@$(PLC)
 else
 ifdef PLCHOSTLXC
 SSHURL:=root@$(PLCHOSTLXC):/vservers/$(GUESTNAME)
-SSHCOMMAND:=ssh root@$(PLCHOSTLXC) virsh -c lxc:/// lxc-enter-namespace $(GUESTNAME) -- /usr/bin/env 
+SSHCOMMAND:=ssh root@$(PLCHOSTLXC) ssh -o StrictHostKeyChecking=no -o LogLevel=quiet $(GUESTHOSTNAME)
 endif
 endif
 
 LOCAL_RSYNC_EXCLUDES   := --exclude '*.pyc' --exclude Accessors_site.py
-RSYNC_EXCLUDES         := --exclude .svn --exclude .git --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
+RSYNC_EXCLUDES         := --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
 RSYNC_COND_DRY_RUN     := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
-RSYNC                  := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
+RSYNC                  := rsync -ai $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
 
 sync:
 ifeq (,$(SSHURL))
        @echo "sync: I need more info from the command line, e.g."
        @echo "  make sync PLC=boot.planetlab.eu"
-       @echo "  make sync PLCHOSTLXC=.. GUESTNAME=.."
+       @echo "  make sync PLCHOSTLXC=.. GUESTHOSTNAME=.. GUESTNAME=.."
        @exit 1
 else
-       +$(RSYNC) plcsh PLC planetlab5.sql migrations aspects $(SSHURL)/usr/share/plc_api/
+       +$(RSYNC) plcsh PLC planetlab5.sql migrations php $(SSHURL)/usr/share/plc_api/
        +$(RSYNC) db-config.d/ $(SSHURL)/etc/planetlab/db-config.d/
        +$(RSYNC) plc.d/ $(SSHURL)/etc/plc.d/
-       $(SSHCOMMAND) apachectl graceful
+       +$(RSYNC) apache/plc.wsgi $(SSHURL)/usr/share/plc_api/apache/
+       $(SSHCOMMAND) systemctl restart plc
 endif
 
 #################### convenience, for debugging only
@@ -98,4 +109,3 @@ endif
 +%: varname=$(subst +,,$@)
 +%:
        @echo "$($(varname))"
-