From 6d4a3f09e6fd0beddaa567ffa9aef8d10d236f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Nizio?= Date: Mon, 26 Nov 2018 20:15:36 +0100 Subject: [PATCH] makefiles: establish a layout for sitedir installs The idea is that: - entropy.* imports will work as before (so any 3rd party clients will work as always) - installed in "entropy" package, - new "_entropy" package to hold a namespace for private modules (like ones that required adding special directories to sys.path). (Underscored name for a top level Python module is not very common... anyway, it was inspired by "_emerge.") Layout: site-packages/ entropy (backwards compatible) const.py ... kswitch (also toplevel to keep compatibility) ... _entropy eit magneto matter rigo RigoDaemon solo (Note that site-packages does not need to be actually Python's site-packages directory but anything as it is controlled by an argument to make. It is however intended to be the sitedir.) Another idea for a layout would be one that mimics sources checkout, but the layout there is somewhat scattered. (And some ugliness would be needed to make them modules before implicit namespaces from Python 3.3. Anyway, imports would be long and ugly.) Now, the layout of installed Entropy is lean; installation to virtualenv is also possible (though there would be a need to call scripts like "python equo.py" as shebangs are not converted). Follow up changes are needed to make it work. --- client/Makefile | 6 +++--- lib/Makefile | 12 +++++++----- lib/kswitch/Makefile | 4 ++-- magneto/Makefile | 18 +++++++++--------- matter/Makefile | 2 +- rigo/Makefile | 2 +- rigo/RigoDaemon/Makefile | 4 ++-- server/Makefile | 4 ++-- 8 files changed, 27 insertions(+), 25 deletions(-) diff --git a/client/Makefile b/client/Makefile index 638833e7c..37670f918 100644 --- a/client/Makefile +++ b/client/Makefile @@ -11,7 +11,7 @@ all: install: install -d $(DESTDIR)/$(LIBDIR)/entropy/client - install -d $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/client/solo/commands + install -d $(DESTDIR)/$(PYTHON_SITEDIR)/_entropy/solo/commands install -d -m 775 $(DESTDIR)/etc/entropy install -d $(DESTDIR)$(BINDIR) install -d $(DESTDIR)$(PREFIX)/share/man/man1 @@ -19,8 +19,8 @@ install: # copying portage bashrc install -m 644 ../conf/client.conf $(DESTDIR)/etc/entropy/ - install -m 644 solo/*.py $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/client/solo/ - install -m 644 solo/commands/*.py $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/client/solo/commands/ + install -m 644 solo/*.py $(DESTDIR)/$(PYTHON_SITEDIR)/_entropy/solo/ + install -m 644 solo/commands/*.py $(DESTDIR)/$(PYTHON_SITEDIR)/_entropy/solo/commands/ install -m 644 revision $(DESTDIR)/$(LIBDIR)/entropy/client/ install -m 755 equo.py $(DESTDIR)/$(BINDIR)/equo install -m 755 kernel-switcher $(DESTDIR)/$(BINDIR)/ diff --git a/lib/Makefile b/lib/Makefile index 59d9891d3..41659afb8 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -13,16 +13,19 @@ all: install: install -d $(DESTDIR)/$(LIBDIR)/entropy/lib/entropy - install -d $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/lib + install -d $(DESTDIR)/$(PYTHON_SITEDIR) + install -d $(DESTDIR)/$(PYTHON_SITEDIR)/_entropy install -d $(DESTDIR)$(PREFIX)/sbin install -d $(DESTDIR)$(BINDIR) install -d -m 775 $(DESTDIR)/etc/entropy install -d $(DESTDIR)/etc/env.d install -d $(DESTDIR)/etc/init.d install -d $(DESTDIR)/etc/logrotate.d - install -d $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/services install -d $(DESTDIR)/$(TMPFILESDIR) + # Make it a package + touch $(DESTDIR)/$(PYTHON_SITEDIR)/_entropy/__init__.py + # Empty directories that should be created and kept install -d -m 775 $(DESTDIR)$(VARDIR)/tmp/entropy touch $(DESTDIR)$(VARDIR)/tmp/entropy/.keep @@ -37,11 +40,10 @@ install: touch $(DESTDIR)/$(VARDIR)/log/entropy/.keep chmod +x entropy/spm/plugins/interfaces/portage_plugin/env_sourcer.sh - cp -Ra entropy $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/lib/ - rm $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/lib/entropy/revision + cp -Ra entropy $(DESTDIR)/$(PYTHON_SITEDIR) + rm $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/revision install -m 644 entropy/revision $(DESTDIR)/$(LIBDIR)/entropy/lib/entropy/ - ln -sf lib $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/libraries install -m 755 ../misc/entropy.sh $(DESTDIR)$(PREFIX)/sbin/ install -m 755 ../misc/entropy_hwgen.sh $(DESTDIR)$(BINDIR)/ install -m 644 ../misc/entropy.logrotate $(DESTDIR)/etc/logrotate.d/entropy diff --git a/lib/kswitch/Makefile b/lib/kswitch/Makefile index 00475e992..4a13166ab 100644 --- a/lib/kswitch/Makefile +++ b/lib/kswitch/Makefile @@ -8,7 +8,7 @@ all: install: - install -d $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/lib/kswitch - install -m 644 *.py $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/lib/kswitch/ + install -d $(DESTDIR)/$(PYTHON_SITEDIR)/kswitch + install -m 644 *.py $(DESTDIR)/$(PYTHON_SITEDIR)/kswitch/ clean: diff --git a/magneto/Makefile b/magneto/Makefile index ffc56068b..e004470ba 100644 --- a/magneto/Makefile +++ b/magneto/Makefile @@ -14,11 +14,11 @@ all: magneto-core-install: mkdir -p $(DESTDIR)$(PREFIX)/share/pixmaps/magneto mkdir -p $(DESTDIR)$(PREFIX)/share/magneto/icons - mkdir -p $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/magneto/magneto/core + mkdir -p $(DESTDIR)/$(PYTHON_SITEDIR)/_entropy/magneto/core install -m644 src/magneto/*.py \ - $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/magneto/magneto/. + $(DESTDIR)/$(PYTHON_SITEDIR)/_entropy/magneto/. install -m644 src/magneto/core/*.py \ - $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/magneto/magneto/core/. + $(DESTDIR)/$(PYTHON_SITEDIR)/_entropy/magneto/core/. install -m644 $(PIXDIR)/* $(DESTDIR)$(PREFIX)/share/pixmaps/magneto/. install -m644 $(ICONDIR)/* $(DESTDIR)$(PREFIX)/share/magneto/icons/. @@ -34,26 +34,26 @@ magneto-loader-install: magneto-gtk-install: mkdir -p $(DESTDIR)/$(LIBDIR)/entropy/magneto/magneto/gtk - mkdir -p $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/magneto/magneto/gtk + mkdir -p $(DESTDIR)/$(PYTHON_SITEDIR)/_entropy/magneto/gtk install -m644 src/magneto/gtk/*.py \ - $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/magneto/magneto/gtk/. + $(DESTDIR)/$(PYTHON_SITEDIR)/_entropy/magneto/gtk/. install -m644 src/magneto/gtk/*.glade \ $(DESTDIR)/$(LIBDIR)/entropy/magneto/magneto/gtk/. magneto-gtk3-install: mkdir -p $(DESTDIR)/$(LIBDIR)/entropy/magneto/magneto/gtk3 - mkdir -p $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/magneto/magneto/gtk3 + mkdir -p $(DESTDIR)/$(PYTHON_SITEDIR)/_entropy/magneto/gtk3 install -m644 src/magneto/gtk3/*.py \ - $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/magneto/magneto/gtk3/. + $(DESTDIR)/$(PYTHON_SITEDIR)/_entropy/magneto/gtk3/. install -m644 src/magneto/gtk3/*.ui \ $(DESTDIR)/$(LIBDIR)/entropy/magneto/magneto/gtk3/. magneto-kde-install: - mkdir -p $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/magneto/magneto/qt5 + mkdir -p $(DESTDIR)/$(PYTHON_SITEDIR)/_entropy/magneto/qt5 mkdir -p $(DESTDIR)$(PREFIX)/share/apps/magneto install -m644 src/magneto/qt5/*.py \ - $(DESTDIR)/$(PYTHON_SITEDIR)/entropy/magneto/magneto/qt5/. + $(DESTDIR)/$(PYTHON_SITEDIR)/_entropy/magneto/qt5/. # install Magneto notification service install -m644 $(MISCDIR)/magneto.notifyrc \ $(DESTDIR)$(PREFIX)/share/apps/magneto/. diff --git a/matter/Makefile b/matter/Makefile index 4ae21aeb5..a50b88772 100644 --- a/matter/Makefile +++ b/matter/Makefile @@ -4,7 +4,7 @@ LIBDIR = $(PREFIX)/lib PYTHON_SITEDIR = $(LIBDIR) SBINDIR = $(PREFIX)/sbin DESTDIR = -MATTER_PYDIR = $(DESTDIR)$(PYTHON_SITEDIR)/matter +MATTER_PYDIR = $(DESTDIR)$(PYTHON_SITEDIR)/_entropy all: for d in $(SUBDIRS); do $(MAKE) -C $$d; done diff --git a/rigo/Makefile b/rigo/Makefile index 0f84f3491..ded5bd54f 100644 --- a/rigo/Makefile +++ b/rigo/Makefile @@ -3,7 +3,7 @@ PREFIX = /usr BINDIR = $(PREFIX)/bin LIBDIR = $(PREFIX)/lib PYTHON_SITEDIR = $(LIBDIR) -RIGO_PYDIR = $(PYTHON_SITEDIR)/rigo +RIGO_PYDIR = $(PYTHON_SITEDIR)/_entropy DESTDIR = all: diff --git a/rigo/RigoDaemon/Makefile b/rigo/RigoDaemon/Makefile index 155cabcc8..179a43a6f 100644 --- a/rigo/RigoDaemon/Makefile +++ b/rigo/RigoDaemon/Makefile @@ -11,8 +11,8 @@ all: install: install -d $(DESTDIR)$(LIBEXECDIR) - install -d $(DESTDIR)$(PYTHON_SITEDIR)/rigo/RigoDaemon - install -m 644 $(wildcard *.py) $(DESTDIR)$(PYTHON_SITEDIR)/rigo/RigoDaemon/ + install -d $(DESTDIR)$(PYTHON_SITEDIR)/_entropy/RigoDaemon + install -m 644 $(wildcard *.py) $(DESTDIR)$(PYTHON_SITEDIR)/_entropy/RigoDaemon/ install -m 755 app/RigoDaemon_app.py $(DESTDIR)$(LIBEXECDIR)/ for d in $(SUBDIRS); do $(MAKE) -C $$d install; done diff --git a/server/Makefile b/server/Makefile index 6eb92bde5..1d65875e1 100644 --- a/server/Makefile +++ b/server/Makefile @@ -9,13 +9,13 @@ all: for d in $(SUBDIRS); do $(MAKE) -C $$d; done install: - mkdir -p $(DESTDIR)$(PYTHON_SITEDIR)/entropy/server + mkdir -p $(DESTDIR)$(PYTHON_SITEDIR)/_entropy mkdir -p $(DESTDIR)/etc/entropy mkdir -p $(DESTDIR)$(BINDIR) install -m 644 ../conf/server.conf.example $(DESTDIR)/etc/entropy/ - cp -R eit $(DESTDIR)$(PYTHON_SITEDIR)/entropy/server/ + cp -R eit $(DESTDIR)$(PYTHON_SITEDIR)/_entropy/ install -m 755 eit.py $(DESTDIR)$(BINDIR)/eit for d in $(SUBDIRS); do $(MAKE) -C $$d install; done